Processing task-based FMRI with AFNI and afni_proc.py#

Author: Paul A. Taylor (SSCC, NIMH, NIH, USA)

Date: 11 Nov 2025

Overview#

This tutorial goes through full single-subject processing of task-based FMRI data. It uses AFNI tools, in particular afni_proc.py to setup the full pipeline, which includes several built-in provenance and QC features. We discuss checking the data at several points, and how the user can stay close to their data to avoid bad surprises (as much as possible).

This workflow is based on the standard AFNI Bootcamp demo dataset and processing. It looks at task-based FMRI processing for a volumetric, voxelwise analysis in an adult human subject. We note that this pipeline can be tweaked to cover further cases of ROI-based processing, surface-based analysis, non-human subjects and other age groups.

In this workflow, you will see the following programs in action (and we keep using several of the acronyms, for brevity and hipness):

  • gtkyd_check.py : Get To Know Your Data (GTKYD) by tabularizing and summarizing properties of many datasets efficiently

  • gen_ss_review_table.py : (GSSRT) sift through textfile-stored properties of many datasets for desired/undesired properties or outliers

  • afni_proc.py : (AP) create your full, auto-commented FMRI processing pipeline, with built-in QC

  • 3dinfo : quickly check properties of one dataset, including the history of its processing (=provenance)

You will also hear about how the following programs can be run prior to AP, and their results helpfully incorporated. (These are run before because they can be long and computationally expensive, and if you re-run your processing in AP, there likely isn’t a need to re-run them.)

  • sswarper2 : (SSW) skullstrip your T1w anatomical and generate nonlinear warps to a template space

  • recon-all : (from FreeSurfer, FS) estimate parcellations and surface meshes from the T1w anatomical

  • @SUMA_Make_Spec_FS : an AFNI program run immediately after FS to convert volumes to NIFTI format, surfaces to GIFTI format, to standardize surface meshes, and to create useful *.spec files relating surface families.

Note that a very, very important part of processing data is visualizing it both before and after processing (and often looking at intermediate results). In this jupyter-notebook interface, it is difficult to open a GUI, so that part will have to be done separately outside of this (e.g., in a concurrent terminal). We will include snapshots as we discuss features, and we very much encourage users to also use the AFNI GUI to view data and a browser to view the APQC HTML.

Tools and citations relevant for this workflow#

  • AFNI the open source, publicly available toolbox for MRI-related processing:
    Cox RW (1996). AFNI: software for analysis and visualization of functional magnetic resonance neuroimages. Comput Biomed Res 29(3):162-173.

  • afni_proc.py, a program to make full, detailed processing pipelines for FMRI datasets:
    Reynolds RC, Glen DR, Chen G, Saad ZS, Cox RW, Taylor PA (2024). Processing, evaluating and understanding FMRI data with afni_proc.py. Imaging Neuroscience 2:1-52.

  • AFNI QC tools including the APQC HTML, tools for evaluating both raw and processed data properties for appropriateness:
    Taylor PA, Glen DR, Chen G, Cox RW, Hanayik T, Rorden C, Nielson DM, Rajendra JK, Reynolds RC (2024). A Set of FMRI Quality Control Tools in AFNI: Systematic, in-depth and interactive QC with afni_proc.py and more. Imaging Neuroscience 2: 1–39.

  • AFNI QC tutorial examples, part of the FMRI Open QC Project on demonstrating quality control in FMRI:
    Reynolds RC, Taylor PA, Glen DR (2023). Quality control practices in FMRI analysis: Philosophy, methods and examples using AFNI. Front. Neurosci. 16:1073800.

And some additional related reading:

  • An earlier discussion of processing choices and using afni_proc.py, with examples:
    Taylor PA, Chen G, Glen DR, Rajendra JK, Reynolds RC, Cox RW (2018). FMRI processing with AFNI: Some comments and corrections on ‘Exploring the Impact of Analysis Software on Task fMRI Results’. bioRxiv 308643

  • Why scaling FMRI time series is often a helpful and meaningful processing choice:
    Chen G, Taylor PA, Cox RW (2017). Is the statistic value all we should care about in neuroimaging? Neuroimage. 147:952-959.

  • Why do we use lpc and lpa cost functions for alignment?
    Saad ZS, Glen DR, Chen G, Beauchamp MS, Desai R, Cox RW (2009). A new method for improving functional-to-structural MRI alignment using local Pearson correlation. Neuroimage 44 839–848.

  • Why do we use 3dvolreg for motion correction?
    Oakes TR, Johnstone T, Ores Walsh KS, Greischar LL, Alexander AL, Fox AS, Davidson RJ (2005). Comparison of fMRI motion correction software tools. Neuroimage. 28(3):529-543.

  • Why it is important to transparently threshold data to really understand it (in addition to QC issues, noted in above papers):
    Taylor PA, Reynolds RC, Calhoun V, Gonzalez-Castillo J, Handwerker DA, Bandettini PA, Mejia AF, Chen G (2023). Highlight Results, Don’t Hide Them: Enhance interpretation, reduce biases and improve reproducibility. Neuroimage 274:120138.

  • … and in case you needed more convincing on why it is important to transparently threshold data:
    Taylor PA, Aggarwal H, Bandettini PA, Barilari M, Bright M, Caballeros-Gaudes C, Calhoun VD, Chakravarty M, Devenyi G, Evans J, Garza-Villarreal E, Rasgado-Toledo J, Gau R, Glen DR, Goebel R, Gonzalez-Castillo J, Gulban OF, Halchenko Y, Handwerker D, Hanayik T, Lauren PD, Leopold D, Lerch J, Mathys C, McCarthy P, McLeod A, Mejia A, Moia S, Nichols TE, Pernet C, Pessoa L, Pfleiderer B, Rajendra JK, Reyes L, Reynolds RC, Roopchansingh V, Rorden C, Russ BE, Sundermann B, Thirion B, Torrisi S, Chen G (2025). Go Figure: Transparency in neuroscience images preserves context and clarifies interpretation. arXiv:2504.07824

Additional educational resources#

Accompanying video tutorials for this processing example, as well as several other topics in MRI data visualization and processing, are available on the AFNI Academy channel: https://www.youtube.com/c/afnibootcamp.

The AFNI handouts directory for the Bootcamp can be downloaded from a terminal shell with:

curl -O https://afni.nimh.nih.gov/pub/dist/edu/data/CD/afni_handouts.tgz
tar -xvf afni_handouts.tgz

… or see this webpage.

Additional educational resources are available here.

Questions and comments can be posted on the AFNI Message Board.

Load and check AFNI installation#

Run the following to load the most recent version of AFNI available, and also run the system check to verify the components.

The AFNI system check (ASC) outputs a lot of useful diagnostic information about dependencies and programs. At the bottom is a “Please fix” section, which contains any particular items to address. Any questions can be posted on the AFNI Message Board.

# import some Python packages for this jupyter-notebook tour
import os            # to interact with files and paths
import IPython       # to visualize image files

# load the AFNI module for neurodesk
try:
    import module    # to load neurodesk modules

    # load most recent available AFNI
    await module.load('afni')
    await module.list()
except:
    print("++ Python library 'module' not available")
# run the system check
!afni_system_check.py -check_all
-------------------------------- general ---------------------------------
architecture:         64bit 
cpu type:             x86_64
system:               Linux
release:              5.15.0-151-generic
version:              #161-Ubuntu SMP Tue Jul 22 14:25:40 UTC 2025
distribution:         ubuntu 24.04 Noble Numbat
number of CPUs:       32
user:                 ubuntu
apparent login shell: bash
shell RC file:        .bashrc (exists)

--------------------- AFNI and related program tests ---------------------
which afni           : /usr/local/abin/afni
afni version         : Precompiled binary linux_ubuntu_24_64: Jul  4 2025 
                     : AFNI_25.2.03 'Gordian I'
AFNI_version.txt     : AFNI_25.2.03, linux_ubuntu_24_64, Jul 04 2025, official
which python         : /usr/bin/python
python version       : 3.12.3
which R              : /usr/bin/R
R version            : R version 4.3.3 (x86_64-pc-linux-gnu)

instances of various programs found in PATH:
    afni    : 1   (/usr/local/abin/afni)
                  (not owned by user)
    R       : 1   (/usr/bin/R)
    python  : 1   (/usr/bin/python3.12)
    python2 : 0 
    python3 : 1   (/usr/bin/python3.12)

testing ability to start various programs...
    afni                 : success
    suma                 : success
    3dSkullStrip         : success
    3dAllineate          : success
    3dRSFC               : success
    SurfMesh             : success
    3dClustSim           : success
    build_afni.py        : success
    uber_subject.py      : success
    3dMVM                : success
    rPkgsInstall         : success
------------------------ dependent program tests -------------------------
checking for dependent programs...
which tcsh           : /usr/bin/tcsh
tcsh version         : 6.24.10
which Xvfb           : /usr/bin/Xvfb

checking for R packages...
    rPkgsInstall -pkgs ALL -check : success
R RHOME : /usr/lib/R

------------------------------ python libs -------------------------------
++ module loaded: matplotlib.pyplot
   module file : /usr/lib/python3/dist-packages/matplotlib/pyplot.py
   matplotlib version : 3.6.3
++ module loaded: flask
   module file : /usr/lib/python3/dist-packages/flask/__init__.py
   flask version : 3.0.2
++ module loaded: flask_cors
   module file : /usr/lib/python3/dist-packages/flask_cors/__init__.py
   flask_cors version : 4.0.0

-------------------------------- env vars --------------------------------
PATH                       = /opt/freesurfer-7.4.1/bin:/opt/freesurfer-7.4.1/fsfast/bin:/opt/freesurfer-7.4.1/tktools:/opt/freesurfer-7.4.1/mni/bin:/usr/local/abin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:~/.local/bin

PYTHONPATH                 = 
R_LIBS                     = /usr/local/share/R-4.3
LD_LIBRARY_PATH            = /.singularity.d/libs
DYLD_LIBRARY_PATH          = 
DYLD_FALLBACK_LIBRARY_PATH = 
CONDA_SHLVL                = 
CONDA_DEFAULT_ENV          = 
CC                         = 
HOMEBREW_PREFIX            = 

----------------------------- eval dot files -----------------------------

----------- AFNI $HOME files -----------

    .afnirc                   : missing
    .sumarc                   : missing
    .afni/help/all_progs.COMP : missing

--------- shell startup files ----------

   -- no .tcshrc, will create one as a follower of .cshrc
   -- considered operations: path, apsearch
   
   -- note: followers should not need edits, so edit flags should be 0
      (have 1 follower(s), which can be ignored)
   
   dot file test : want 4 modifications across 3 files:
   
      file             path  flatdir  apsearch        follower
      ---------------  ----  -------  --------        --------
      .cshrc           1     0        1               0     
      .tcshrc          0     0        0               1     
      .bashrc          1     0        1               0     
   
------------------------------ data checks -------------------------------
data dir : missing AFNI_data6
data dir : missing AFNI_demos
data dir : missing suma_demo
data dir : missing afni_handouts
atlas    : found TT_N27+tlrc  under /usr/local/abin

------------------------------ OS specific -------------------------------
which apt-get        : /usr/bin/apt-get
apt-get version      : apt 2.8.3 (amd64)
which git            : /usr/bin/git
git version          : git version 2.43.0
which gcc            : /usr/bin/gcc
gcc version          : gcc (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0

have Ubuntu system: ubuntu 24.04 Noble Numbat
have Ubuntu afni  : Precompiled binary linux_ubuntu_24_64: Jul  4 2025 

=========================  summary, please fix:  =========================
*  just be aware: login shell 'bash', but our code examples use 'tcsh'
*  please run: cp /usr/local/abin/AFNI.afnirc ~/.afnirc
*  please run: "suma -update_env" for .sumarc
*  please run: apsearch -update_all_afni_help
*  dot file test : want 4 modifications across 3 files:
*  insufficient data for AFNI bootcamp
   (see "Prepare for Bootcamp" on install pages)

Reading the “Please fix” section#

There may be some useful things to do, based on the final “summary, please fix” output in the ASC output.

For example, some of the items that commonly occur, and which you should follow-up on, are (NB: some paths may be different on your system):

  • please run: apsearch -update_all_afni_help
    -> Sets up the TAB-autocompletion of the options for all the AFNI programs.
    You then don’t have to remember each option name in full (but go ahead and memorize them all instead, if you prefer!)

  • please run: cp /usr/local/abin/AFNI.afnirc ~/.afnirc
    -> Sets up default settings file to manage fine control of the AFNI GUI and programs.
    You then open ~/.afnirc in a text editor and adjust a lot of settings (such as default colors, left-right settings, directories of reference data to always load, and more).

  • please run: suma -update_env
    -> Sets up default settings file to manage fine control of the AFNI GUI and programs.
    You then open ~/.sumarc in a text editor and adjust a lot of settings (such as rotation angle per click, various colors, and more).

  • python library <something> is required
    -> Points out missing Python module dependency for some AFNI functionality. On Linux systems, you might be able to install these directly with the package manager. If not, or if using macOS, you might find it useful to add these packages using some form of Conda, like Miniconda, for which we have copy+paste instructions here.

Get the data#

The data used here is part of the standard AFNI Bootcamp teaching data. If you have already downloaded and unpacked the full tutorial data (CD.tgz), you can use those contents. If you don’t have that, and would like just the directory containing demo’s data (plus other examples) you can run the following to download+unpack it, as well as to move into the demo dir itself:

# download the compressed data directory "AFNI_data7" 
# (if it doesn't already exist and if we are't in the data dir)

have_datadir = os.path.isdir('AFNI_data7')          # demo already downloaded?
in_demodir   = os.getcwd().endswith('task_demo_ap') # alread in demo directory?

if not(have_datadir) and not(in_demodir) :
    # download the compressed data
    !curl -O https://afni.nimh.nih.gov/pub/dist/edu/data/AFNI_data7.tgz
    !echo "++ Done downloading the data"

    # unpack/open the directory
    !tar -xf AFNI_data7.tgz
    !echo "++ Done unpacking the data"
else :
    !echo "++ I appear to already have the data directory. Nice!"
    
# move to the directory with unprocessed data (if not already there)
if not(in_demodir) :
    os.chdir('AFNI_data7/task_demo_ap')
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
  0  487M    0 31886    0     0  19727      0  7:12:02  0:00:01  7:12:01 19719
  0  487M    0  960k    0     0   373k      0  0:22:17  0:00:02  0:22:15  373k
  0  487M    0 4835k    0     0  1350k      0  0:06:09  0:00:03  0:06:06 1350k
  1  487M    1 8421k    0     0  1827k      0  0:04:33  0:00:04  0:04:29 1826k
  2  487M    2 11.2M    0     0  2059k      0  0:04:02  0:00:05  0:03:57 2317k
  2  487M    2 13.6M    0     0  2127k      0  0:03:54  0:00:06  0:03:48 2814k
  3  487M    3 15.4M    0     0  2089k      0  0:03:58  0:00:07  0:03:51 2973k
  3  487M    3 16.9M    0     0  2026k      0  0:04:06  0:00:08  0:03:58 2509k
  3  487M    3 18.5M    0     0  1978k      0  0:04:12  0:00:09  0:04:03 2117k
  4  487M    4 20.3M    0     0  1974k      0  0:04:12  0:00:10  0:04:02 1879k
  4  487M    4 22.1M    0     0  1960k      0  0:04:14  0:00:11  0:04:03 1740k
  4  487M    4 23.5M    0     0  1892k      0  0:04:23  0:00:12  0:04:11 1603k
  5  487M    5 25.0M    0     0  1883k      0  0:04:25  0:00:13  0:04:12 1640k
  5  487M    5 26.0M    0     0  1831k      0  0:04:32  0:00:14  0:04:18 1547k
  5  487M    5 27.0M    0     0  1771k      0  0:04:41  0:00:15  0:04:26 1344k
  5  487M    5 27.7M    0     0  1710k      0  0:04:51  0:00:16  0:04:35 1137k
  5  487M    5 28.5M    0     0  1662k      0  0:05:00  0:00:17  0:04:43 1057k
  6  487M    6 29.5M    0     0  1626k      0  0:05:07  0:00:18  0:04:49  927k
  6  487M    6 30.3M    0     0  1587k      0  0:05:14  0:00:19  0:04:55  878k
  6  487M    6 31.2M    0     0  1550k      0  0:05:22  0:00:20  0:05:02  861k
  6  487M    6 32.0M    0     0  1522k      0  0:05:28  0:00:21  0:05:07  892k
  6  487M    6 33.0M    0     0  1500k      0  0:05:32  0:00:22  0:05:10  930k
  6  487M    6 34.0M    0     0  1477k      0  0:05:38  0:00:23  0:05:15  923k
  7  487M    7 35.0M    0     0  1459k      0  0:05:42  0:00:24  0:05:18  958k
  7  487M    7 36.4M    0     0  1458k      0  0:05:42  0:00:25  0:05:17 1077k
  7  487M    7 37.9M    0     0  1459k      0  0:05:42  0:00:26  0:05:16 1191k
  8  487M    8 39.3M    0     0  1462k      0  0:05:41  0:00:27  0:05:14 1290k
  8  487M    8 40.7M    0     0  1459k      0  0:05:42  0:00:28  0:05:14 1372k
  8  487M    8 42.4M    0     0  1469k      0  0:05:39  0:00:29  0:05:10 1523k
  9  487M    9 44.2M    0     0  1478k      0  0:05:37  0:00:30  0:05:07 1577k
  9  487M    9 45.8M    0     0  1487k      0  0:05:35  0:00:31  0:05:04 1641k
  9  487M    9 48.1M    0     0  1500k      0  0:05:32  0:00:32  0:05:00 1701k
 10  487M   10 49.2M    0     0  1494k      0  0:05:34  0:00:33  0:05:01 1695k
 10  487M   10 50.2M    0     0  1484k      0  0:05:36  0:00:34  0:05:02 1569k
 10  487M   10 51.2M    0     0  1474k      0  0:05:38  0:00:35  0:05:03 1451k
 10  487M   10 52.0M    0     0  1455k      0  0:05:43  0:00:36  0:05:07 1248k
 10  487M   10 52.9M    0     0  1443k      0  0:05:46  0:00:37  0:05:09 1047k
 11  487M   11 53.7M    0     0  1425k      0  0:05:50  0:00:38  0:05:12  939k
 11  487M   11 54.4M    0     0  1407k      0  0:05:54  0:00:39  0:05:15  870k
 11  487M   11 55.1M    0     0  1391k      0  0:05:58  0:00:40  0:05:18  803k
 11  487M   11 56.0M    0     0  1379k      0  0:06:02  0:00:41  0:05:21  824k
 11  487M   11 56.7M    0     0  1365k      0  0:06:05  0:00:42  0:05:23  779k
 11  487M   11 57.5M    0     0  1351k      0  0:06:09  0:00:43  0:05:26  785k
 11  487M   11 58.3M    0     0  1339k      0  0:06:12  0:00:44  0:05:28  799k
 12  487M   12 59.2M    0     0  1331k      0  0:06:15  0:00:45  0:05:30  840k
 12  487M   12 60.1M    0     0  1322k      0  0:06:17  0:00:46  0:05:31  849k
 12  487M   12 61.2M    0     0  1317k      0  0:06:19  0:00:47  0:05:32  904k
 12  487M   12 62.4M    0     0  1316k      0  0:06:19  0:00:48  0:05:31 1002k
 13  487M   13 64.0M    0     0  1323k      0  0:06:17  0:00:49  0:05:28 1178k
 13  487M   13 65.2M    0     0  1321k      0  0:06:17  0:00:50  0:05:27 1236k
 13  487M   13 66.6M    0     0  1323k      0  0:06:17  0:00:51  0:05:26 1330k
 13  487M   13 68.2M    0     0  1328k      0  0:06:15  0:00:52  0:05:23 1437k
 14  487M   14 69.7M    0     0  1331k      0  0:06:15  0:00:53  0:05:22 1476k
 14  487M   14 70.9M    0     0  1330k      0  0:06:15  0:00:54  0:05:21 1401k
 14  487M   14 72.1M    0     0  1329k      0  0:06:15  0:00:55  0:05:20 1407k
 15  487M   15 73.5M    0     0  1331k      0  0:06:15  0:00:56  0:05:19 1410k
 15  487M   15 74.7M    0     0  1324k      0  0:06:17  0:00:57  0:05:20 1280k
 15  487M   15 76.0M    0     0  1328k      0  0:06:15  0:00:58  0:05:17 1296k
 15  487M   15 77.1M    0     0  1325k      0  0:06:16  0:00:59  0:05:17 1267k
 16  487M   16 78.4M    0     0  1327k      0  0:06:16  0:01:00  0:05:16 1299k
 16  487M   16 79.7M    0     0  1326k      0  0:06:16  0:01:01  0:05:15 1270k
 16  487M   16 81.0M    0     0  1325k      0  0:06:16  0:01:02  0:05:14 1338k
 16  487M   16 82.0M    0     0  1321k      0  0:06:17  0:01:03  0:05:14 1237k
 17  487M   17 83.3M    0     0  1322k      0  0:06:17  0:01:04  0:05:13 1286k
 17  487M   17 84.6M    0     0  1320k      0  0:06:18  0:01:05  0:05:13 1244k
 17  487M   17 85.9M    0     0  1321k      0  0:06:17  0:01:06  0:05:11 1261k
 17  487M   17 87.2M    0     0  1322k      0  0:
06:17  0:01:07  0:05:10 1283k
 18  487M   18 88.7M    0     0  1324k      0  0:06:16  0:01:08  0:05:08 1372k
 18  487M   18 90.0M    0     0  1324k      0  0:06:16  0:01:09  0:05:07 1360k
 18  487M   18 91.4M    0     0  1326k      0  0:06:16  0:01:10  0:05:06 1398k
 19  487M   19 92.8M    0     0  1328k      0  0:06:15  0:01:11  0:05:04 1419k
 19  487M   19 94.4M    0     0  1331k      0  0:06:14  0:01:12  0:05:02 1462k
 19  487M   19 95.9M    0     0  1335k      0  0:06:13  0:01:13  0:05:00 1479k
 20  487M   20 97.7M    0     0  1341k      0  0:06:12  0:01:14  0:04:58 1574k
 20  487M   20 99.1M    0     0  1343k      0  0:06:11  0:01:15  0:04:56 1592k
 20  487M   20  100M    0     0  1348k      0  0:06:10  0:01:16  0:04:54 1635k
 20  487M   20  101M    0     0  1344k      0  0:06:11  0:01:17  0:04:54 1534k
 21  487M   21  102M    0     0  1338k      0  0:06:13  0:01:18  0:04:55 1384k
 21  487M   21  103M    0     0  1331k      0  0:06:14  0:01:19  0:04:55 1186k
 21  487M   21  104M    0     0  1324k      0  0:06:16  0:01:20  0:04:56 1037k
 21  487M   21  104M    0     0  1316k      0  0:06:19  0:01:21  0:04:58  828k
 21  487M   21  105M    0     0  1308k      0  0:06:21  0:01:22  0:04:59  744k
 21  487M   21  106M    0     0  1302k      0  0:06:23  0:01:23  0:05:00  733k
 21  487M   21  107M    0     0  1295k      0  0:06:25  0:01:24  0:05:01  725k
 22  487M   22  107M    0     0  1290k      0  0:06:27  0:01:25  0:05:02  736k
 22  487M   22  108M    0     0  1284k      0  0:06:28  0:01:26  0:05:02  765k
 22  487M   22  109M    0     0  1279k      0  0:06:30  0:01:27  0:05:03  803k
 22  487M   22  110M    0     0  1272k      0  0:06:32  0:01:28  0:05:04  780k
 22  487M   22  110M    0     0  1266k      0  0:06:34  0:01:29  0:05:05  765k
 22  487M   22  111M    0     0  1261k      0  0:06:35  0:01:30  0:05:05  764k
 23  487M   23  112M    0     0  1256k      0  0:06:37  0:01:31  0:05:06  765k
 23  487M   23  113M    0     0  1251k      0  0:06:39  0:01:32  0:05:07  755k
 23  487M   23  113M    0     0  1246k      0  0:06:40  0:01:33  0:05:07  781k
 23  487M   23  114M    0     0  1242k      0  0:06:41  0:01:34  0:05:07  818k
 23  487M   23  115M    0     0  1238k      0  0:06:43  0:01:35  0:05:08  829k
 23  487M   23  116M    0     0  1234k      0  0:06:44  0:01:36  0:05:08  840k
 24  487M   24  117M    0     0  1231k      0  0:06:45  0:01:37  0:05:08  869k
 24  487M   24  118M    0     0  1231k      0  0:06:45  0:01:38  0:05:07  946k
 24  487M   24  119M    0     0  1232k      0  0:06:45  0:01:39  0:05:06 1049k
 24  487M   24  121M    0     0  1236k      0  0:06:43  0:01:40  0:05:03 1190k
 25  487M   25  123M    0     0  1243k      0  0:06:41  0:01:41  0:05:00 1419k
 25  487M   25  125M    0     0  1257k      0  0:06:37  0:01:42  0:04:55 1763k
 26  487M   26  129M    0     0  1276k      0  0:06:31  0:01:43  0:04:48 2167k
 27  487M   27  132M    0     0  1299k      0  0:06:24  0:01:44  0:04:40 2597k
 27  487M   27  135M    0     0  1314k      0  0:06:19  0:01:45  0:04:34 2896k
 28  487M   28  138M    0     0  1325k      0  0:06:16  0:01:46  0:04:30 2981k
 28  487M   28  139M    0     0  1328k      0  0:06:15  0:01:47  0:04:28 2777k
 28  487M   28  141M    0     0  1333k      0  0:06:14  0:01:48  0:04:26 2519k
 29  487M   29  143M    0     0  1338k      0  0:06:13  0:01:49  0:04:24 2172k
 29  487M   29  145M    0     0  1345k      0  0:06:11  0:01:50  0:04:21 1996k
 30  487M   30  147M    0     0  1351k      0  0:06:09  0:01:51  0:04:18 1894k
 30  487M   30  149M    0     0  1357k      0  0:06:07  0:01:52  0:04:15 1977k
 31  487M   31  151M    0     0  1364k      0  0:06:05  0:01:53  0:04:12 2008k
 31  487M   31  152M    0     0  1365k      0  0:06:05  0:01:54  0:04:11 1960k
 31  487M   31  154M    0     0  1367k      0  0:06:05  0:01:55  0:04:10 1851k
 32  487M   32  156M    0     0  1371k      0  0:06:04  0:01:56  0:04:08 1829k
 32  487M   32  157M    0     0  1375k      0  0:06:02  0:01:57  0:04:05 1794k
 32  487M   32  160M    0     0  1382k      0  0:06:01  0:01:58  0:04:03 1802k
 33  487M   33  162M    0     0  1387k      0  0:06:00  0:01:59  0:04:01 1873k
 33  487M   33  163M    0     0  1387k      0  0:05:59  0:02:00  0:03:59 1846k
 33  487M   33  165M    0     0  1393k      0  0:05:58  0:02:01  0:03:57 1909k
 34  487M   34  167M    0     0  1397k      0  0:05:57  0:02:02  0:03:55 1895k
 34  487M   34  168M    0     0  1397k      0  0:05:57  0:02:03  0:03:54 1743k
 34  487M   34  169M    0     0  1393k      0  0:05:58  0:02:04  0:03:54 1552k
 34  487M   34  170M    0     0  1390k      0  0:05:59  0:02:05  0:03:54 1463k
 35  487M   35  171M    0     0  1387k      0  0:05:59  0:02:06  0:03:53 1251k
 35  487M   35  172M    0     0  1385k      0  0:06:00  0:02:07  0:03:53 1109k
 35  487M   35  173M    0     0  1383k      0  0:06:00  0:02:08  0:03:52 1046k
 35  487M   35  174M    0     0  1381k      0  0:06:01  0:02:09  0:03:52 1091k
 36  487M   36  175M    0     0  1379k      0  0:06:02  0:02:10  0:03:52 1092k
 36  487M   36  176M    0     0  1375k      0  0:06:03  0:02:11  0:03:52 1066k
 36  487M   36  177M    0     0  1374k      0  0:06:03  0:02:12  0:03:51 1078k
 36  487M   36  178M    0     0  1371k      0  0:06:03  0:02:13  0:03:50 1076k
 36  487M   36  180M    0     0  1369k      0  0:06:04  0:02:14  0:03:50 1051k
 37  487M   37  181M    0     0  1368k      0  0:06:04  0:02:15  0:03:49 1076k
 37  487M   37  182M    0     0  1366k      0  0:06:05  0:02:16  0:03:49 1130k
 37  487M   37  183M    0     0  1366k      0  0:06:05  0:02:17  0:03:48 1152k
 37  487M   37  184M    0     0  1365k      0  0:06:05  0:02:18  0:03:47 1185k
 38  487M   38  185M    0     0  1361k      0  0:06:06  0:02:19  0:03:47 1145k
 38  487M   38  186M    0     0  1359k      0  0:06:07  0:02:20  0:03:47 1130k
 38  487M   38  187M    0     0  1358k      0  0:06:07  0:02:21  0:03:46 1120k
 38  487M   38  188M    0     0  1356k      0  0:06:08  0:02:22  0:03:46 1085k
 38  487M   38  190M    0     0  1354k      0  0:06:08  0:02:23  0:03:45 1062k
 39  487M   39  191M    0     0  1354k      0  0:06:08  0:02:24  0:03:44 1158k
 39  487M   39  192M    0     0  1353k      0  0:06:08  0:02:25  0:03:43 1179k
 39  487M   39  193M    0     0  1352k      0  0:06:09  0:02:26  0:03:43 1183k
 39  487M   39  194M    0     0  1349k      0  0:06:09  0:02:27  0:03:42 1168k
 40  487M   40  195M    0     0  1348k      0  0:06:10  0:02:28  0:03:42 1165k
 40  487M   40  196M    0     0  1343k      0  0:06:11  0:02:29  0:03:42 1031k
 40  487M   40  196M    0     0  1338k      0  0:06:13  0:02:30  0:03:43  903k
 40  487M   40  197M    0     0  1333k      0  0:06:14  0:02:31  0:03:43  794k
 40  487M   40  198M    0     0  1329k      0  0:06:15  0:02:32  0:03:43  732k
 40  487M   40  198M    0     0  1325k      0  0:06:16  0:02:33  0:03:43  633k
 40  487M   40  199M    0     0  1320k      0  0:06:18  0:02:34  0:03:44  624k
 40  487M   40  199M    0     0  1315k      0  0:06:19  0:02:35  0:03:44  609k
 41  487M   41  200M    0     0  1309k      0  0:06:21  0:02:36  0:03:45  577k
 41  487M   41  200M    0     0  1304k      0  0:06:22  0:02:37  0:03:45  523k
 41  487M   41  201M    0     0  1298k      0  0:06:24  0:02:38  0:03:46  474k
 41  487M   41  201M    0     0  1293k      0  0:06:26  0:02:39  0:03:47  446k
 41  487M   41  202M    0     0  1288k      0  0:06:27  0:02:40  0:03:47  450k
 41  487M   41  202M    0     0  1283k      0  0:06:29  0:02:41  0:03:48  453k
 41  487M   41  202M    0     0  1277k      0  0:06:31  0:02:42  0:03:49  430k
 41  487M   41  203M    0     0  1271k      0  0:06:32  0:02:43  0:03:49  401k
 41  487M   41  203M    0     0  1265k      0  0:06:34  0:02:44  0:03:50  373k
 41  487M   41  203M    0     0  1259k      0  0:06:36  0:02:45  0:03:51  336k
 41  487M   41  203M    0     0  1253k      0  0:06:38  0:02:46  0:03:52  306k
 41  487M   41  204M    0     0  1248k      0  0:06:40  0:02:47  0:03:53  305k
 41  487M   41  204M    0     0  1242k      0  0:06:41  0:02:48  0:03:53  304k
 42  487M   42  204M    0     0  1236k      0  0:06:43  0:02:49  0:03:54  305k
 42  487M   42  205M    0     0  1231k      0  0:06:45  0:02:50  0:03:55  302k
 42  487M   42  205M    0     0  1226k      0  0:06:47  0:02:51  0:03:56  308k
 42  487M   42  205M    0     0  1221k      0  0:06:48  0:02:52  0:03:56  307k
 42  487M   42  206M    0     0  1215k      0  0:06:50  0:02:53  0:03:57  313k
 42  487M   42  206M    0     0  1210k      0  0:06:52  0:02:54  0:03:58  312k
 42  487M   42  206M    0     0  1205k      0  0:06:54  0:02:55  0:03:59  315k
 42  487M   42  207M    0     0  1200k      0  0:06:55  0:02:56  0:03:59  318k
 42  487M   42  207M    0     0  1195k      0  0:06:57  0:02:57  0:04:00  329k
 42  487M   42  207M    0     0  1190k      0  0:06:59  0:02:58  0:04:01  337k
 42  487M   42  208M    0     0  1186k      0  0:07:00  0:02:59  0:04:01  354k
 42  487M   42  208M    0     0  1182k      0  0:07:02  0:03:00  0:04:02  359k
 42  487M   42  208M    0     0  1176k      0  0:07:04  0:03:01  0:04:03  355k
 42  487M   42  209M    0     0  1172k      0  0:07:06  0:03:02  0:04:04  334k
 42  487M   42  209M    0     0  1167k      0  0:07:07  0:03:03  0:04:04  315k
 42  487M   42  209M    0     0  1162k      0  0:07:09  0:03:04  0:04:05  287k
 43  487M   43  209M    0     0  1156k      0  0:07:11  0:03:05  0:04:06  266k
 43  487M   43  210M    0     0  1152k      0  0:07:13  0:03:06
  0:04:07  248k
 43  487M   43  210M    0     0  1147k      0  0:07:15  0:03:07  0:04:08  261k
 43  487M   43  210M    0     0  1143k      0  0:07:16  0:03:08  0:04:08  283k
 43  487M   43  211M    0     0  1140k      0  0:07:17  0:03:09  0:04:08  326k
 43  487M   43  211M    0     0  1137k      0  0:07:19  0:03:10  0:04:09  397k
 43  487M   43  212M    0     0  1135k      0  0:07:19  0:03:11  0:04:08  511k
 43  487M   43  213M    0     0  1136k      0  0:07:19  0:03:12  0:04:07  703k
 44  487M   44  215M    0     0  1139k      0  0:07:18  0:03:13  0:04:05  961k
 44  487M   44  216M    0     0  1141k      0  0:07:17  0:03:14  0:04:03 1192k
 44  487M   44  218M    0     0  1142k      0  0:07:17  0:03:15  0:04:02 1332k
 44  487M   44  219M    0     0  1142k      0  0:07:16  0:03:16  0:04:00 1408k
 45  487M   45  220M    0     0  1143k      0  0:07:16  0:03:17  0:03:59 1427k
 45  487M   45  221M    0     0  1144k      0  0:07:16  0:03:18  0:03:58 1347k
 45  487M   45  223M    0     0  1145k      0  0:07:16  0:03:19  0:03:57 1289k
 46  487M   46  224M    0     0  1146k      0  0:07:15  0:03:20  0:03:55 1306k
 46  487M   46  225M    0     0  1146k      0  0:07:15  0:03:21  0:03:54 1304k
 46  487M   46  227M    0     0  1146k      0  0:07:15  0:03:22  0:03:53 1245k
 46  487M   46  227M    0     0  1144k      0  0:07:16  0:03:23  0:03:53 1168k
 46  487M   46  228M    0     0  1143k      0  0:07:16  0:03:24  0:03:52 1094k
 47  487M   47  229M    0     0  1143k      0  0:07:16  0:03:25  0:03:51 1008k
 47  487M   47  230M    0     0  1142k      0  0:07:17  0:03:26  0:03:51  949k
 47  487M   47  231M    0     0  1140k      0  0:07:17  0:03:27  0:03:50  901k
 47  487M   47  232M    0     0  1139k      0  0:07:18  0:03:28  0:03:50  898k
 47  487M   47  232M    0     0  1137k      0  0:07:18  0:03:29  0:03:49  890k
 47  487M   47  233M    0     0  1136k      0  0:07:19  0:03:30  0:03:49  859k
 48  487M   48  234M    0     0  1132k      0  0:07:20  0:03:31  0:03:49  772k
 48  487M   48  235M    0     0  1131k      0  0:07:21  0:03:32  0:03:49  771k
 48  487M   48  235M    0     0  1129k      0  0:07:22  0:03:33  0:03:49  736k
 48  487M   48  236M    0     0  1126k      0  0:07:23  0:03:34  0:03:49  667k
 48  487M   48  236M    0     0  1124k      0  0:07:24  0:03:35  0:03:49  606k
 48  487M   48  237M    0     0  1121k      0  0:07:25  0:03:36  0:03:49  605k
 48  487M   48  237M    0     0  1118k      0  0:07:26  0:03:37  0:03:49  552k
 48  487M   48  238M    0     0  1116k      0  0:07:27  0:03:38  0:03:49  538k
 48  487M   48  238M    0     0  1113k      0  0:07:28  0:03:39  0:03:49  535k
 49  487M   49  239M    0     0  1111k      0  0:07:29  0:03:40  0:03:49  553k
 49  487M   49  239M    0     0  1108k      0  0:07:30  0:03:41  0:03:49  568k
 49  487M   49  240M    0     0  1106k      0  0:07:31  0:03:42  0:03:49  562k
 49  487M   49  241M    0     0  1104k      0  0:07:32  0:03:43  0:03:49  615k
 49  487M   49  241M    0     0  1102k      0  0:07:33  0:03:44  0:03:49  605k
 49  487M   49  242M    0     0  1099k      0  0:07:34  0:03:45  0:03:49  592k
 49  487M   49  242M    0     0  1096k      0  0:07:35  0:03:46  0:03:49  565k
 49  487M   49  243M    0     0  1093k      0  0:07:36  0:03:47  0:03:49  553k
 49  487M   49  243M    0     0  1091k      0  0:07:37  0:03:48  0:03:49  487k
 50  487M   50  244M    0     0  1089k      0  0:07:38  0:03:49  0:03:49  502k
 50  487M   50  244M    0     0  1086k      0  0:07:39  0:03:50  0:03:49  504k
 50  487M   50  245M    0     0  1084k      0  0:07:40  0:03:51  0:03:49  519k
 50  487M   50  245M    0     0  1082k      0  0:07:41  0:03:52  0:03:49  537k
 50  487M   50  246M    0     0  1079k      0  0:07:42  0:03:53  0:03:49  554k
 50  487M   50  246M    0     0  1078k      0  0:07:43  0:03:54  0:03:49  574k
 50  487M   50  247M    0     0  1075k      0  0:07:44  0:03:55  0:03:49  577k
 50  487M   50  248M    0     0  1074k      0  0:07:44  0:03:56  0:03:48  632k
 51  487M   51  249M    0     0  1073k      0  0:07:45  0:03:57  0:03:48  670k
 51  487M   51  249M    0     0  1071k      0  0:07:45  0:03:58  0:03:47  685k
 51  487M   51  250M    0     0  1069k      0  0:07:46  0:03:59  0:03:47  680k
 51  487M   51  250M    0     0  1067k      0  0:07:47  0:04:00  0:03:47  698k
 51  487M   51  251M    0     0  1065k      0  0:07:48  0:04:01  0:03:47  627k
 51  487M   51  251M    0     0  1063k      0  0:07:49  0:04:02  0:03:47  583k
 51  487M   51  252M    0     0  1061k      0  0:07:50  0:04:03  0:03:47  563k
 51  487M   51  252M    0     0  1059k      0  0:07:51  0:04:04  0:03:47  547k
 51  487M   51  253M    0     0  1056k      0  0:07:52  0:04:05  0:03:47  531k
 52  487M   52  254M    0     0  1055k      0  0:07:53  0:04:06  0:03:47  544k
 52  487M   52  254M    0     0  1053k      0  0:07:54  0:04:07  0:03:47  559k
 52  487M   52  255M    0     0  1050k      0  0:07:55  0:04:08  0:03:47  539k
 52  487M   52  255M    0     0  1048k      0  0:07:56  0:04:09  0:03:47  543k
 52  487M   52  256M    0     0  1047k      0  0:07:56  0:04:10  0:03:46  557k
 52  487M   52  256M    0     0  1045k      0  0:07:57  0:04:11  0:03:46  563k
 52  487M   52  257M    0     0  1043k      0  0:07:58  0:04:12  0:03:46  569k
 52  487M   52  258M    0     0  1041k      0  0:07:59  0:04:13  0:03:46  595k
 53  487M   53  258M    0     0  1040k      0  0:08:00  0:04:14  0:03:46  615k
 53  487M   53  259M    0     0  1038k      0  0:08:00  0:04:15  0:03:45  607k
 53  487M   53  259M    0     0  1036k      0  0:08:01  0:04:16  0:03:45  603k
 53  487M   53  260M    0     0  1034k      0  0:08:02  0:04:17  0:03:45  595k
 53  487M   53  260M    0     0  1032k      0  0:08:03  0:04:18  0:03:45  580k
 53  487M   53  261M    0     0  1030k      0  0
:08:04  0:04:19  0:03:45  548k
 53  487M   53  261M    0     0  1029k      0  0:08:05  0:04:20  0:03:45  545k
 53  487M   53  262M    0     0  1027k      0  0:08:06  0:04:21  0:03:45  540k
 53  487M   53  262M    0     0  1025k      0  0:08:06  0:04:22  0:03:44  544k
 54  487M   54  263M    0     0  1023k      0  0:08:07  0:04:23  0:03:44  545k
 54  487M   54  264M    0     0  1021k      0  0:08:08  0:04:24  0:03:44  550k
 54  487M   54  264M    0     0  1019k      0  0:08:09  0:04:25  0:03:44  542k
 54  487M   54  265M    0     0  1018k      0  0:08:10  0:04:26  0:03:44  553k
 54  487M   54  265M    0     0  1016k      0  0:08:11  0:04:27  0:03:44  553k
 54  487M   54  266M    0     0  1015k      0  0:08:11  0:04:28  0:03:43  564k
 54  487M   54  266M    0     0  1013k      0  0:08:12  0:04:29  0:03:43  583k
 54  487M   54  267M    0     0  1012k      0  0:08:13  0:04:30  0:03:43  609k
 54  487M   54  268M    0     0  1010k      0  0:08:14  0:04:31  0:03:43  613k
 55  487M   55  268M    0     0  1009k      0  0:08:14  0:04:32  0:03:42  637k
 55  487M   55  269M    0     0  1009k      0  0:08:14  0:04:33  0:03:41  691k
 55  487M   55  270M    0     0  1009k      0  0:08:14  0:04:34  0:03:40  768k
 55  487M   55  271M    0     0  1009k      0  0:08:14  0:04:35  0:03:39  884k
 56  487M   56  273M    0     0  1012k      0  0:08:13  0:04:36  0:03:37 1086k
 56  487M   56  275M    0     0  1016k      0  0:08:11  0:04:37  0:03:34 1370k
 57  487M   57  278M    0     0  1022k      0  0:08:08  0:04:38  0:03:30 1729k
 57  487M   57  281M    0     0  1029k      0  0:08:04  0:04:39  0:03:25 2150k
 58  487M   58  285M    0     0  1041k      0  0:07:59  0:04:40  0:03:19 2766k
 59  487M   59  289M    0     0  1053k      0  0:07:53  0:04:41  0:03:12 3249k
 60  487M   60  294M    0     0  1068k      0  0:07:47  0:04:42  0:03:05 3978k
 61  487M   61  298M    0     0  1077k      0  0:07:43  0:04:43  0:03:00 4161k
 61  487M   61  301M    0     0  1085k      0  0:07:39  0:04:44  0:02:55 4245k
 62  487M   62  304M    0     0  1092k      0  0:07:36  0:04:45  0:02:51 4004k
 63  487M   63  307M    0     0  1098k      0  0:07:34  0:04:46  0:02:48 3694k
 63  487M   63  309M    0     0  1103k      0  0:07:32  0:04:47  0:02:45 3080k
 64  487M   64  312M    0     0  1109k      0  0:07:30  0:04:48  0:02:42 2900k
 64  487M   64  314M    0     0  1111k      0  0:07:29  0:04:49  0:02:40 2562k
 64  487M   64  315M    0     0  1113k      0  0:07:28  0:04:50  0:02:38 2274k
 65  487M   65  317M    0     0  1114k      0  0:07:28  0:04:51  0:02:37 2059k
 65  487M   65  318M    0     0  1114k      0  0:07:28  0:04:52  0:02:36 1682k
 65  487M   65  319M    0     0  1115k      0  0:07:27  0:04:53  0:02:34 1484k
 65  487M   65  320M    0     0  1114k      0  0:07:27  0:04:54  0:02:33 1313k
 65  487M   65  321M    0     0  1114k      0  0:07:27  0:04:55  0:02:32 1215k
 66  487M   66  322M    0     0  1114k      0  0:07:28  0:04:56  0:02:32 1129k
 66  487M   66  323M    0     0  1113k      0  0:07:28  0:04:57  0:02:31 1093k
 66  487M   66  324M    0     0  1113k      0  0:07:28  0:04:58  0:02:30  996k
 66  487M   66  325M    0     0  1112k      0  0:07:29  0:04:59  0:02:30  940k
 66  487M   66  326M    0     0  1109k      0  0:07:29  0:05:00  0:02:29  831k
 67  487M   67  326M    0     0  1109k      0  0:07:30  0:05:01  0:02:29  796k
 67  487M   67  327M    0     0  1107k      0  0:07:30  0:05:02  0:02:28  724k
 67  487M   67  327M    0     0  1105k      0  0:07:31  0:05:03  0:02:28  615k
 67  487M   67  328M    0     0  1103k      0  0:07:32  0:05:04  0:02:28  594k
 67  487M   67  328M    0     0  1101k      0  0:07:33  0:05:05  0:02:28  569k
 67  487M   67  329M    0     0  1099k      0  0:07:34  0:05:06  0:02:28  493k
 67  487M   67  329M    0     0  1097k      0  0:07:34  0:05:07  0:02:27  513k
 67  487M   67  330M    0     0  1096k      0  0:07:35  0:05:08  0:02:27  531k
 67  487M   67  330M    0     0  1094k      0  0:07:36  0:05:09  0:02:27  551k
 68  487M   68  331M    0     0  1093k      0  0:07:36  0:05:10  0:02:26  593k
 68  487M   68  332M    0     0  1093k      0  0:07:36  0:05:11  0:02:25  698k
 68  487M   68  333M    0     0  1093k      0  0:07:36  0:05:12  0:02:24  833k
 68  487M   68  335M    0     0  1094k      0  0:07:36  0:05:13  0:02:23 1016k
 69  487M   69  337M    0     0  1097k      0  0:07:34  0:05:14  0:02:20 1297k
 69  487M   69  339M    0     0  1103k      0  0:07:32  0:05:15  0:02:17 1704k
 70  487M   70  343M    0     0  1110k      0  0:07:29  0:05:16  0:02:13 2161k
 71  487M   71  346M    0     0  1117k      0  0:07:27  0:05:17  0:02:10 2592k
 71  487M   71  350M    0     0  1124k      0  0:07:23  0:05:18  0:02:05 2916k
 72  487M   72  352M    0     0  1128k      0  0:07:22  0:05:19  0:02:03 3057k
 72  487M   72  354M    0     0  1132k      0  0:07:20  0:05:20  0:02:00 2985k
 73  487M   73  356M    0     0  1134k      0  0:07:20  0:05:21  0:01:59 2678k
 73  487M   73  357M    0     0  1135k      0  0:07:19  0:05:22  0:01:57 2306k
 73  487M   73  359M    0     0  1136k      0  0:07:19  0:05:23  0:01:56 1907k
 73  487M   73  359M    0     0  1135k      0  0:07:19  0:05:24  0:01:55 1577k
 74  487M   74  361M    0     0  1135k      0  0:07:19  0:05:25  0:01:54 1326k
 74  487M   74  361M    0     0  1134k      0  0:07:20  0:05:26  0:01:54 1159k
 74  487M   74  362M    0     0  1134k      0  0:07:20  0:05:27  0:01:53 1072k
 74  487M   74  363M    0     0  1133k      0  0:07:20  0:05:28  0:01:52  939k
 74  487M   74  364M    0     0  1131k      0  0:07:21  0:05:29  0:01:52  900k
 74  487M   74  364M    0     0  1130k      0  0:07:21  0:05:30  0:01:51  798k
 74  487M   74  365M    0     0  1128k      0  0:07:22  0:05:31  0:01:51  746k
 75  487M   75  366M    0     0  1127k      0  0:07:22  0:05:32  0:01:50  683k
 75  487M   75  366M    0     0  1126k      0  0:07:23  0:05:33  0:01:50  673k
 75  487M   75  367M    0     0  1125k      0  0:07:23  0:05:34  0:01:49  680k
 75  487M   75  368M    0     0  1123k      0  0:07:24  0:05:35  0:01:49  668k
 75  487M   75  368M    0     0  1121k      0  0:07:25  0:05:36  0:01:49  651k
 75  487M   75  369M    0     0  1120k      0  0:07:25  0:05:37  0:01:48  646k
 75  487M   75  370M    0     0  1119k      0  0:07:26  0:05:38  0:01:48  657k
 76  487M   76  370M    0     0  1118k      0  0:07:26  0:05:39  0:01:47  655k
 76  487M   76  371M    0     0  1116k      0  0:07:27  0:05:40  0:01:47  678k
 76  487M   76  372M    0     0  1115k      0  0:07:27  0:05:41  0:01:46  699k
 76  487M   76  372M    0     0  1114k      0  0:07:28  0:05:42  0:01:46  703k
 76  487M   76  373M    0     0  1112k      0  0:07:28  0:05:43  0:01:45  679k
 76  487M   76  374M    0     0  1111k      0  0:07:29  0:05:44  0:01:45  677k
 76  487M   76  374M    0     0  1110k      0  0:07:29  0:05:45  0:01:44  678k
 76  487M   76  375M    0     0  1108k      0  0:07:30  0:05:46  0:01:44  643k
 77  487M   77  375M    0     0  1107k      0  0:07:30  0:05:47  0:01:43  625k
 77  487M   77  376M    0     0  1106k      0  0:07:31  0:05:48  0:01:43  625k
 77  487M   77  377M    0     0  1104k      0  0:07:32  0:05:49  0:01:43  618k
 77  487M   77  377M    0     0  1103k      0  0:07:32  0:05:50  0:01:42  599k
 77  487M   77  378M    0     0  1101k      0  0:07:33  0:05:51  0:01:42  615k
 77  487M   77  378M    0     0  1100k      0  0:07:33  0:05:52  0:01:41  634k
 77  487M   77  379M    0     0  1099k      0  0:07:34  0:05:53  0:01:41  663k
 78  487M   78  380M    0     0  1099k      0  0:07:34  0:05:54  0:01:40  709k
 78  487M   78  381M    0     0  1099k      0  0:07:34  0:05:55  0:01:39  808k
 78  487M   78  382M    0     0  1099k      0  0:07:34  0:05:56  0:01:38  942k
 78  487M   78  384M    0     0  1101k      0  0:07:33  0:05:57  0:01:36 1150k
 79  487M   79  386M    0     0  1104k      0  0:07:32  0:05:58  0:01:34 1428k
 79  487M   79  389M    0     0  1109k      0  0:07:30  0:05:59  0:01:31 1813k
 80  487M   80  392M    0     0  1115k      0  0:07:27  0:06:00  0:01:27 2304k
 81  487M   81  397M    0     0  1124k      0  0:07:23  0:06:01  0:01:22 2910k
 82  487M   82  402M    0     0  1136k      0  0:07:19  0:06:02  0:01:17 3635k
 83  487M   83  407M    0     0  1147k      0  0:07:15  0:06:03  0:01:12 4249k
 84  487M   84  410M    0     0  1153k      0  0:07:12  0:06:04  0:01:08 4370k
 85  487M   85  415M    0     0  1164k      0  0:07:08  0:06:05  0:01:03 4672k
 85  487M   85  419M    0     0  1170k      0  0:07:06  0:06:06  0:01:00 4360k
 86  487M   86  422M    0     0  1177k      0  0:07:04  0:06:07  0:00:57 4129k
 87  487M   87  425M    0     0  1182k      0  0:07:02  0:06:08  0:00:54 3736k
 87  487M   87  428M    0     0  1187k      0  0:07:00  0:06:09  0:00:51 3680k
 88  487M   88  431M    0     0  1191k      0  0:06:58  0:06:10  0:00:48 3185k
 88  487M   88  433M    0     0  1195k      0  0:06:57  0:06:11  0:00:46 3102k
 89  487M   89  436M    0     0  1198k      0  0:06:56  0:06:12  0:00:44 2766k
 89  487M   89  438M    0     0  1201k      0  0:06:55  0:06:13  0:00:42 2612k
 90  487M   90  440M    0     0  1203k      0  0:06:54  0:06:14  0:00:40 2381k
 90  487M   90  442M    0     0  1205k      0  0:06:54  0:06:15  0:00:39 2214k
 91  487M   91  443M    0     0  1206k      0  0:06:53  0:06:16  0:00:37 2046k
 91  487M   91  445M    0     0  1208k      0  0:06:53  0:06:17  0:00:36 1914k
 91  487M   91  447M    0     0  1209k      0  0:06:52  0:06:18  0:00:34 1822k
 92  487M   92  449M    0     0  1211k      0  0:06:52  0:06:19  0:00:33 1791k
 92  487M   92  450M    0     0  1213k      0  0:06:51  0:06:20  0:00:31 1788k
 92  487M   92  452M    0     0  1214k      0  0:06:51  0:06:21  0:00:30 1816k
 93  487M   93  454M    0     0  1216k      0  0:06:50  0:06:22  0:00:28 1848k
 93  487M   93  456M    0     0  1218k      0  0:06:49  0:06:23  0:00:26 1872k
 93  487M   93  458M    0     0  1220k      0  0:06:49  0:06:24  0:00:25 1875k
 94  487M   94  460M    0     0  1222k      0  0:06:48  0:06:25  0:00:23 1925k
 94  487M   94  462M    0     0  1225k      0  0:06:47  0:06:26  0:00:21 2015k
 95  487M   95  465M    0     0  1228k      0  0:06:46  0:06:27  0:00:19 2148k
 95  487M   95  467M    0     0  1232k      0  0:06:45  0:06:28  0:00:17 2325k
 96  487M   96  470M    0     0  1235k      0  0:06:44  0:06:29  0:00:15 2402k
 96  487M   96  472M    0     0  1238k      0  0:06:43  0:06:30  0:00:13 2505k
 97  487M   97  475M    0     0  1242k      0  0:06:41  0:06:31  0:00:10 2607k
 98  487M   98  477M    0     0  1246k      0  0:06:40  0:06:32  0:00:08 2654k
 98  487M   98  480M    0     0  1251k      0  0:06:39  0:06:33  0:00:06 2682k
 99  487M   99  483M    0     0  1255k      0  0:06:37  0:06:34  0:00:03 2842k
 99  487M   99  486M    0     0  1259k      0  0:06:36  0:06:35  0:00:01 2898k
100  487M  100  487M    0     0  1260k      0  0:06:36  0:06:36 --:--:-- 2863k
++ Done downloading the data
++ Done unpacking the data

Investigate the demo contents#

Let’s go check out the demo contents:

  • what data files are present

  • some of the properties and contents

  • what script examples there are

The starting data directories

  • sub-000 : the directory of basic/unprocessed FMRI and anatomical data for this participant

  • SSW : output directory from running AFNI’s sswarper2, which skullstrips the participant’s anatomical volume and calculates a nonlinear warp to a chosen template space (here, MNI)

  • SUMA : output directory from running FreeSurfer’s recon-all and AFNI’s @SUMA_Make_Spec_FS, which contains anatomical surface meshes and volumetric parcellations

The demo scripts

  • do_01_gtkyd.tcsh : before any processing takes place, run gtykd_check.py to Get To Know Your Data (GTKYD), checking for unwanted or inconsistent properties

  • do_12_fs.tcsh : (already run) run FS’s recon-all to perform cortical mesh estimation, tissue segmentation and region parcellation of the anatomical, stored in SUMA/

  • do_13_ssw.tcsh : (already run) run sswarper2 to skullstrip (ss) the anatomical and estimate nonlinear alignment (warping) of it to a template, stored in SSW/

  • do_14_timing.tcsh : (already run) run timing_tool.py to convert BIDS-format TSV files into AFNI-format timing files, producing sub-000/func/times*txt

  • do_20_ap_simple.tcsh : a wrapper command for AP which essentially no options besides input data; useful for simple, quick processing (treats data like rest) to generate the APQC HTML and other QC info

  • do_21_ap_affine.tcsh : a task-based analysis using the stimulus timing info and more control of options; the primary teaching example, it only uses affine alignment of anatomical->template space, for faster processing in class

  • do_22_ap_nonlinear.tcsh : the same as do_21*.tcsh but applying nonlinear warping to template space from sswarper2 (alrady run, via do_13_ssw.tcsh), making it a more real example.

  • do_23_ap_surf.tcsh : a surface-based processing example, using a mesh estimated with FreeSurfer’s recon-all (already run, via do_12_fs.tcsh)

… and other stuff, including what will be created as we run the scripts

  • README.txt : description of demo directory contents

  • example_snapshots : images to support the jupyter-notebook description

  • proc* : for provenance, verification and education, AP creates a fully commented script of the complete processing; this gets executed to do the work

  • run* : when running the “simple” AP processing, a copy of the command is saved for reference

  • out* : for provenance, verification and troubleshooting, we try to execute the proc* scripts in a way that logs all terminal text, to these files

  • sub-*.results : the results directory from running an AP proc* script; contains a lot of intermediate outputs and QC items, to assist verification checks

# display the files present
!ls -1 --color
README.txt
SSW
SUMA
do_01_gtkyd.tcsh
do_12_fs.tcsh
do_13_ssw.tcsh
do_14_timing.tcsh
do_20_ap_simple.tcsh
do_21_ap_affine.tcsh
do_22_ap_nonlinear.tcsh
do_23_ap_surf.tcsh
example_snapshots
save.proc.sub-000.affine
sub-000

The basic input data: brief overview

This example uses a BIDS-ish data structure and set of names for datasets. AP is flexible and happy to use these as inputs.

There is one T1-weighted (T1w) anatomical volume: anat/sub-000_T1w.nii.gz. This is a 3D volume, typically of higher spatial resolution than the FMRI data and providing clear anatomical information.

There are 3 EPI-based FMRI datasets, which contain a record of blood oxygen-level dependence (BOLD) signal changes throughout the brain: func/sub-000_task-av_run-0?_bold.nii.gz. These were acquired while the subject performed a task (described below), each has a BIDS-formatted record of event timing: func/*events.tsv. These are each “4D” datasets, because they have three dimensions of space and one dimension of time. These three runs were all acquired in the same session, so we will process them all together in a single AP command.

The final two text files that contain (most of) the necessary timing information for the task paradigm performed by the subject during the FMRI runs, in a simple format used by AFNI programs: func/times.*.txt. Each text file contains the event timing information for one of the two stimulus class types, during this audio-visual task used here:

  • “vis” class: “visual reliable” presentation of a clear image of a person speaking while hearing garbled sound;

  • “aud” class: “audial reliable” presentation of a blurred image of a person speaking while hearing clear sound.

# display the contents of the basic input data tree
# (one participant's datasets):
!tree sub-000
sub-000
├── anat
│   └── sub-000_T1w.nii.gz
└── func
    ├── sub-000_task-av_run-01_bold.nii.gz
    ├── sub-000_task-av_run-01_events.tsv
    ├── sub-000_task-av_run-02_bold.nii.gz
    ├── sub-000_task-av_run-02_events.tsv
    ├── sub-000_task-av_run-03_bold.nii.gz
    ├── sub-000_task-av_run-03_events.tsv
    ├── times.aud.txt
    └── times.vis.txt

3 directories, 9 files

Timing files

The two stimulus files are: sub-000/func/times.{aud,vis}.txt.

In this study, each stimulus event lasted for 20s, and the stimuli were all separated by 10s of “rest” (no sound, no image). The ordering of presented stimuli was random. This style of task presentation is called a “block design”, because the events are fairly long. While many modern task paradigms are in a different style with very short (less than a couple seconds) called “event-related”, this is useful for understanding BOLD responses—we can actually see the task-related changes in the BOLD signal. FMRI time series are very noisy, so for very short or more subtle tasks this is usually not possible. NB: mathematics makes that OK, and we can still get useful quantities to evaluate, but it is less helpful for a demo.

It is important to know the onset times of each event during the processing, and this information is stored in the func/times.*.txt files. It is also important to know the duration of each event. In this case, it is a constant 20s, and we just know that we need to remember and provide that number during the AP setup. If the event durations differed, that would be recorded in the timing files.

The format of these timing files is as follows:

  • there are N rows of text, corresponding to each of the N runs of data (here, N=3).

  • within a row, each number corresponds to the onset time of a given event

  • each onset value is the time (in seconds) from the start of the FMRI dataset that is being processed

    • the onset times here happen to be integers, but they don’t need to be; they don’t even need to fall on a TR

    • if part of processing includes removing initial volumes from the FMRI dataset (like to remove pre-steady state), the timing values need to count from the post-trimmed values—so be sure to account for that in your timing file creation?

    • if an FMRI run had no events, you could put just * * in that row to signify that it is empty

You can see the compact contents of the timing files as in the next cell (and similarly for the vis class).

# display the timing file for the "aud" stimulus class
!cat sub-000/func/times.aud.txt
0.0 30.0 150.0 210.0 270.0 
0.0 30.0 60.0 90.0 240.0 
30.0 90.0 180.0 210.0 270.0

Visualization note#

At this point, we reiterate that it is generally useful to visualize your datasets, particularly if they are recently scanned or downloaded. You can learn so much about a dataset’s properties, suitability for an analysis and potential pitfalls to look out for. This qualitative information gathering will be complemented by quantitative ones, too, described below.

Anatomical volume

This volume provides useful structural and anatomical information for the participant, since it is much less distorted than the EPI-based FMRI dataset(s) and has better tissue contrast.

This can best be appreciated by visualizing the anatomical in AFNI:

  • Open the AFNI GUI, loading all dsets recursively in the source data dir: afni -R -all_dsets sub-000

  • Anatomical may be default dset, or click “Underlay” -> “sub-000/anat/sub-000_T1w.nii.gz” -> “Set”

  • Navigate the crosshairs to the coordinate origin of the dset:

    • AFNI uses (x, y, z) coordinates (physical units of mm) for locations

    • Coordinates are shown in the upper left corner, in RAI sign convention (Right/Ant/Inf are negative)

    • In any image window, right-click -> “Jump to (xyz)” -> enter 0 0 0 -> Set

    • NB: actual location will be voxel centroid closest to coordinate origin.

A screenshot of the described GUI setup is shown, below.

NB: this dataset has not been defaced/refaced (and is shared with the scanner participant’s permission!), but that could be done in AFNI with @afni_refacer_run, which has been rated a top defacing/refacing tool in independent comparisons.

# Display a screenshot of the AFNI GUI with the T1w anatomical loaded
IPython.display.Image(filename='example_snapshots/img_00_afnigui_anat_000.png') 
../../_images/7eb05cde5e7fce5b5d1faf25480060f15311a7a9f394dfa17f6b7858d7ae8786.png

One would check the anatomical dataset for appropriate coverage, spatial resolution, tissue contrast, and other desired properties.

At some stages of processing, the following steps usually happen with this T1w dataset:

  1. It is skullstripped to identify just the brain part within the FOV.

  2. A single volume from the FMRI data is aligned to it, for structural and anatomical reference.

  3. In many volume-based studies, it may be aligned to a template volume, to have all data in the same reference space (typically done with nonlinear warping, in a real analysis).

  4. In surface-based studies, a surface mesh will be estimated from this volume, to project data onto (in AFNI, this mesh is standardized).

In standard AFNI processing, Items #2 and 3 are typically performed prior to running AP (simultaneously using AFNI’s sswarper2), and then relevant data are provided via options. Indeed, we have done that prior anatomical processing here, with the SSW directory (discussed above) containing the sswarper2 outputs.

Additionally, Item #4 would also typically be performed before running AP (using FS’s recon-all), and the relevant data are provided via options. We have done so here, with the SUMA directory (discussed above) containing the recon-all outputs.

FMRI volumes

FMRI volumes don’t have the high spatial resolution of anatomical datasets—they are typically 2-3mm per edge—but they are acquired in a way to provide a time series-view of what is happening every couple seconds (a typical TR is about 2s). The standard scan technique for acquiring FMRI is called echo planar imaging (EPI), and we use the terms interchangeably here.

Again, we can appreciate some properties of the EPI dataset best by visualizing it in AFNI (the first step repeats from above, so you can skip it if the GUI is still open):

  • Open the AFNI GUI, loading all dsets recursively in the source data dir: afni -R -all_dsets sub-000

  • To select the first run of EPI data, click “Underlay” -> “sub-000/func/sub-000_task-av_run-01_bold.nii.gz” -> “Set”

  • Open a Graph Viewer by clicking the “Graph” button in the GUI (left panel, next to a yellow Image button; we chose the graph in the Sagittal slice)

  • Navigate the crosshairs to the coordinate origin of the dset:

    • AFNI uses (x, y, z) coordinates (physical units of mm) for locations

    • Coordinates are shown in the upper left corner, in RAI sign convention (Right/Ant/Inf are negative)

    • In any image window, right-click -> “Jump to (xyz)” -> enter 0 0 0 -> Set

    • NB: actual location will be voxel centroid closest to coordinate origin.

A screenshot of the described GUI setup is shown, below.

In the Image panels, you see a fuzzy-looking brain, with some cortical patterns visible, but tissue boundaries and regions probably aren’t as obvious as in the anatomical dataset view, above.

In the Graph panel, you are seeing a montage of time series from a (default) 3x3 grid of voxels in the given sagittal slice. In this subcortical region, the time series have a lot of fluctuations and don’t have a recognizable pattern.

# Display a screenshot of the AFNI GUI with the first EPI run loaded, seen at coordinate origin
IPython.display.Image(filename='example_snapshots/img_01_afnigui_epi_r01_000.png') 
../../_images/230cc87850086d0cc51017fcc155a583ecb39e569916ab90b26550ade057de65.png

EPI feature: spikes

Click around and see how different parts of the brain appear. For example, if you end up at the location (x,y,z) ~ (8, 31, 60), you will see some spikes that are very big relative to the other fluctuations. These are due to a subject motion event about a quarter of the way through the run.

Some spikes are up, some are down, and some time series don’t appear to have any. This heterogeneity of motion-induced spikiness is one major reason why participant motion is so hard to navigate well in processing and analysis.

Up above, and here as well, you might also notice a subtle thing that appears in all time series at their very start—a different kind of spike. (It is hiding a bit, because of the y-axis there, but look closely.) This one is different because it is always upwards, uniformly. This has a different root cause. Each dataset looks normal there as a 3D volume, but in fact the recorded values are uniformly higher in the first few volumes than the rest—this is a “pre-steady state” phenomenon. It occurs generally in FMRI as the acquisition sequence settles into a steady state. Some scanners or initial data-streams clip out these time points, while others don’t. It is good to be aware that these can occur.

You can tell afni_proc.py to remove the first few EPI volumes, if the input data does include such pre-steady state volumes. And afni_proc.py will automatically check and warn you if it appears that the user did not account for some pre-steady state volumes that appear to be present. (And we note that participant motion can occur in the first few volumes, so sometimes it is hard to tell which affect might be happening, or if both are.) In any case, you need to make sure that your task-based timing files stay synchronous with the EPI datasets as processed!

# Display a screenshot of the AFNI GUI with the first EPI run loaded, checking out spikes
IPython.display.Image(filename='example_snapshots/img_02_afnigui_epi_r01_spikes.png') 
../../_images/46131ddfd698370db628152f22b5707ca1f78f9b0515788c32fe949500047e05.png

EPI feature: task response

The task performed during this FMRI scan was an audio-visual one. So, let’s check out how things look in the visual cortex. Well, see see some notable patterns, such as at the location (x,y,z) ~ (16, 78, 3.3), as below. While the earlier-noted motion and pre-steady state spikes apparent, we now see some very regular pattern of hills. And indeed, these are signatures of task-related BOLD response for this block design paradigm (we could load the idealized response time series into the graph viewer, too, to help verify this).

Specifically, this paradigm has the start of a block that contains either a blurred or clear visual component every 30s and a duration of 20s, so seeing regular response in the visual cortex is not unexpected. The fact that we see a few time series in this graph montage with the task signature reflects our spatial sampling: the voxel edges are roughly the same diameter as GM cortex. Notice also that the response shapes aren’t perfectly rectangular—the BOLD response is not on/off, but has a ramp up and ramp down—and that notable plus/minus noise bumps are still present.

Later, we will look at performing real processing to get a more detailed description of task responses: quantifying each stimulus class, perhaps comparing them (i.e., evaluating their “contrast”), trying to boost their signal-to-noise ratio while also reducing spikes and other noise features. That is the job of the real processing.

# Display a screenshot of the AFNI GUI with the first EPI run loaded
IPython.display.Image(filename='example_snapshots/img_03_afnigui_epi_r01_taskresp.png') 
../../_images/df242a56362284883d4e5b72322ff8de8574fb812b73727711a90463314798b7.png

FMRI comments

FMRI datasets are useful windows into the whole brain, at reasonable spatio- and temporal resolutions. As with any modality, it has pluses and minuses and trade-offs to consider.

First, these are some key pluses:

  • MR safety: MRI and FMRI are generally considered quite safe, because the electromagnetic frequencies involved are in the radio range. So, there are not concerns of ionizing radiation, and some people have literally had hundreds of scans performed on them without adverse consequences.

  • Noninvasive: Standard FMRI is noninvasive, in that no cutting or insertion of devices is needed, and no contrast agents or dyes need to be ingested.

  • Reasonable spatial resolution: We can acquire FMRI datasets with typical voxels edge lengths of 2-3mm. This allows researchers to resolve functional gray matter regions at a useful scale.

  • Reasonable temporal sampling: We can acquire repeated whole brain volumes at a typical rate of every 1-2s. This allows researchers to study functional changes at a useful time sampling.

  • Whole brain: While MEG and EEG have much higher temporal sampling (order of ms), FMRI provides better spatial resolution and localization, as well as the ability to view into to the interior depths of the brain.

  • Length of scan: Participants can stay in the scanner safely for a long time, so one can acquire a lot of functional data, either from a single or multiple runs. However, one must balance duration with participant comfort, ability to perform the task reasonably (e.g., not getting bored, falling asleep, failing to respond, learning task too well, etc.). There are also practical considerations of coil heating and baseline changes over time, that can make regression modeling more difficult.

  • Flexible task design: A large number of tasks can be performed by the participant in the scanner, allowing researchers to focus on different aspects of brain function. This includes reading, viewing images/movies, finger tapping/button pushing, imagining, neurofeedback, resting, and much more.

  • Reasonable signal strength: While the measured BOLD data have a lot of non-neuronal sources that contribute both structured and unstructured noise, we can still observe useful BOLD signals to work with.

… and also some challenging considerations:

  • Tight voxel sampling: Considering spatial scales, EPI voxel edges are generally about the same length as the human cortical ribbon. This means we are not deeply sampling the GM as we would want, leading to partial voluming (mixing GM, WM and CSF) of information within a voxel.

  • Sensitivity to motion: FMRI is highly, highly, highly susceptiple to motion by the participant, even at annoyingly small amounts like <0.5 mm. This makes it difficult to acquire reasonable data for many patient populations, or for certain tasks that might induce motion, or for very long runs. Limiting motion, esp. task-correlated motion, is one of the primary arts of study design and data acquisition; post-processing can only do so much to reduce its impact. There will be up and down spikes inserted into many time series, as well as the fact that a given time series will gather signals from different parts of the brain.

  • Geometric distortions: EPI is highly susceptible to geometric distortions. Along the “phase encoding” axis (which is generally along the anterior-posterior axis), one edge of the brain will get stretched out and signals attenuated and the other squashed with signals piled-up.

  • BOLD measures: FMRI measures an indirect quantity—blood oxygenation level dependent (BOLD) responses—that arises from the neuronal firing which we are actually most interested in. There are many other sources of BOLD fluctuations, such as breathing and heartrate, and other noise sources due to the physics of the acquisition and practical realities of scanning live participants (like motion). So, we need to take this into account for our processing, modeling and interpretations. Oh, and BOLD measures have no physical units, making interpretation more challenging (but we can navigate this a bit in processing).

  • Poor tissue contrast: In general, EPI datasets are a bit fuzzy and it can be hard to distinguish where tissue boundaries end/start. (This is one reason for acquiring a higher-resolution anatomical, to give a better map of what is what in the brain).

  • Brightness inhomogeneity: EPI signals are often not homogeneous across the brain or a given tissue type, meaning that the baseline measures might be higher in one patch than another. Typically, parts of the brain physically closer to MRI coils have higher signal, meaning the edges are very bright. Like the challenge with not having BOLD measures, this is something we don’t want to affect final analyses, and we try to account for this in processing.

  • FMRI signal strength: FMRI data are very noisy, in the sense that there are many non-BOLD sources with large magnitudes mixed into the data. This is often quantified via the temporal signal to noise ratio (TSNR). But more generally this means we often need many events of a task-based design, and generally acquire multiple partipants to be able to generalize robust results for more subtle questions of interest.

  • Signal loss: EPI signal will often get lost near boundaries with air, so the part of the brain near the sinuses will get very distorted and low-strength; this greatly affects the inferiofrontal regions and ventromedial prefrontral cortex (VMPFC).

  • Slicewise acquisition: The full EPI volume is not acquired in a single snapshot, but instead slice-by-slice over the full duration of the TR; even more interestingly, to reduce signal mixing across slices this is done every other slice, so a voxel’s “upstairs” and “downstairs” neighbors are often about TR/2 seconds out of sync.

  • Field of view considerations: Voxels at the very edge of the FOV are typically distorted, so some slices of “padding” should be included around areas of interest. Sometimes to have smaller voxels or shorter TR, researchers trim the coverage and don’t acquire some parts of the brain, like the cerebellum.

  • Time-space trade-offs: To get better time sampling (shorter TR), researchers could decrease spatial resolution (larger voxel sizes). Trimming the FOV (note above) can be used to improve either.

  • Multiband and slice acceleration: To increase spatial and/or temporal resolution, researchers can use acquisition tricks, like acquiring multiple (non-neighboring) slices simultaneously or subsampling within a slice. These can provide benefits, but they will also provide increasing distortions so that one has to make sure that the trade-off remains reasonable for data usage.

In the end, there are many considerations when designing an experiment. We will highlight subject motion as one that should be limited as much as possible from the beginning, with acclimating participants to MRI scanners and the FMRI task and careful study design. Geometric distortions will always be present, participant motion will be a problem, the asynchrony of FMRI slices can be an issue, and our data of interest are an indirect measure of neuronal activity, gathered in a noisy environment. These facts influence many aspects of our processing, which therefore may include:

  1. Cross-EPI alignment to a reference time point, which helps with a couple things:

    • try make it look more like the brain didn’t move during the scan, so that each voxel’s time series is from a consistent location

    • provides time series estimates of relative motion (3 translation and 3 rotation), which can be used as regressors in time series modeling as well as to censor out time points where “too much” motion occurred

    • … in general, these are referred to as “motion correction”, though we can never get rid of all of these affects.

  2. Because motion can put in somewhat arbitrary spikes into time series, one can perform de-spiking to try to reduce their impact and spread.

  3. In AFNI, we generally recommend scaling each time series by its mean value, transforming the unitless data into a meaningful “BOLD percent signal change”. This also helps reduce the effects of spatial brightness inhomogeneity.

  4. To synchonize the data within a volume, one can perform slice-timing correction (or time-shifting), if one has the information of the slice timing pattern.

  5. To reduce geometric distortions, one can acquire a short, supplemental dataset to unwarp the EPI:

    • A short reverse phase-encoded dataset, which is aligned to the main EPI and the “half-way” point of the matching is considered more fiducial to the actual brain

    • A phase map, which should encode the B0 field inhomogeneity that actually causes the distortion, and hence can be applied inversely to unwarp

  6. Blurring the data will reduce spatial resolution further, but it can provide a way to boost signal TSNR, with the idea that random noise cancels out a bit while neighboring signal reinforces. Doing this on a surface may provide the best boost.

  7. Regression modeling includes a lot of options for dealing with motion, task design, BOLD response and more. It is something to consider from the beginning in the study design.

Checking dataset properties

A lot of features have to be verified to help ensure that the data at hand are as appropriate as possible for the current study. Above we have looked at some important visualization aspects of how the data look. We want to be sure to partner that with some investigation of their “meta-data” or “header” features.

One simple way to do that is to check the header information directly, using 3dinfo. You can display the full header information directly by just providing a dataset name, as below.

In doing so, we see a lot of properties. Ignoring some of the ones at the top of the output for the moment, we focus on seeing things like:

  • the stored dataset orientation on disk ([-orient RAI]),

  • the size of the voxels (2.75 mm... 2.750 mm... 3.000 mmm),

  • the number of volumes (Number of time steps = 152),

  • the TR (Time step = 2.00000s),

  • the min-max range for each volume (0 to    3272, etc.),

… and more.

An important and unique feature in AFNI is seeing the stored history for the dataset. As AFNI commands are run, each is saved in an accumulating list in a file, so you can be sure of what steps have happened. The history also notes the version of AFNI used, the time stamp and the computer name. Having this kind of provenance during processing is extremely useful in general. (Here, this dataset was just copied twice, basically since the author of this was indecisive about the best name and also wanted to keep a long filename as short as possible.)

As a second example below, we show how you can output one or more specific pieces of the header info with one or more options. This can be very useful for scripting. You can also output information for more than one dataset at a time, which can be useful for checking consistency (more on another tool for comparing conveniently on a larger scale, below). When inputting multiple datasets, I like to include -prefix so I know which attributes go with with one.

# display full header information for a dataset
!3dinfo sub-000/func/sub-000_task-av_run-01_bold.nii.gz
++ 3dinfo: AFNI version=AFNI_25.2.03 (Jul  4 2025) [64-bit]

Dataset File:    /home/jovyan/workspace/books/examples/functional_imaging/AFNI_data7/task_demo_ap/sub-000/func/sub-000_task-av_run-01_bold.nii.gz
Identifier Code: AFN_KSEjKVq0xkBQoe5qpDpMrw  Creation Date: Wed Sep  3 17:17:28 2025
Template Space:  ORIG
Dataset Type:    Echo Planar (-epan)
Byte Order:      LSB_FIRST {assumed} [this CPU native = LSB_FIRST]
Storage Mode:    NIFTI
Storage Space:   64,204,800 (64 million) bytes
Geometry String: "MATRIX(2.75,0,0,-112.6622,0,2.75,0,-122.7787,0,0,3,-17.65058):80,80,33"
Data Axes Tilt:  Plumb
Data Axes Orientation:
  first  (x) = Right-to-Left
  second (y) = Anterior-to-Posterior
  third  (z) = Inferior-to-Superior   [-orient RAI]
R-to-L extent:  -112.662 [R] -to-   104.588 [L] -step-     2.750 mm [ 80 voxels]
A-to-P extent:  -122.779 [A] -to-    94.471 [P] -step-     2.750 mm [ 80 voxels]
I-to-S extent:   -17.651 [I] -to-    78.349 [S] -step-     3.000 mm [ 33 voxels]
Number of time steps = 152  Time step = 2.00000s  Origin = 0.00000s  Number time-offset slices = 33  Thickness = 3.000
  -- At sub-brick #0 '#0' datum type is short:            0 to          3272
  -- At sub-brick #1 '#1' datum type is short:            0 to          2924
  -- At sub-brick #2 '#2' datum type is short:            0 to          2841
** For info on all 152 sub-bricks, use '3dinfo -verb' **

----- HISTORY -----
[rickr@manwe.nimh.nih.gov: Thu Mar 18 11:19:14 2010] 3dcopy epi_r1.nii FT_epi_r1
[ptaylor@Valta-X3: Wed Sep  3 11:21:31 2025] {AFNI_25.2.09:linux_ubuntu_16_64_glw_local_shared} 3dcopy ../AFNI_data6/FT_analysis/FT/FT_epi_r1+orig. sub-000/func/sub-000_task-visaud_run-01_bold.nii.gz
[ptaylor@Valta-X3: Wed Sep  3 17:17:28 2025] {AFNI_25.2.09:linux_ubuntu_16_64_glw_local_shared} 3dcopy sub-000_task-visaud_run-01_bold.nii.gz sub-000_task-av_run-01_bold.nii.gz
# display specific pieces of info and for multiple datasets
!3dinfo -tr -orient -prefix sub-000/func/sub*bold.nii.gz
2.000000	RAI	sub-000_task-av_run-01_bold.nii.gz
2.000000	RAI	sub-000_task-av_run-02_bold.nii.gz
2.000000	RAI	sub-000_task-av_run-03_bold.nii.gz

Checking dataset properties on a large scale

Using 3dinfo is great for individual or a small number of datasets, but it is also nice to able to summarize and check properties across a large number of datasets—even across multiple subjects. That can be useful for checking consistency, as well as sifting through for potentially unwanted/odd properties in datasets.

Therefore, AFNI has the gtkyd_check.py program, for Getting To Know Your Data. This will gather together lots of pieces of header information: both those from AFNI’s BRIK/HEAD and, if the dataset type is NIFTI, then NIFTI; in modern code, it can even query the existence and values of JSON sidecar keys that may be present. In the example here, we look at applying it to the 3 EPI datasets for sub-000, but in general we would probably apply it across all sub-* in a study.

The basic usage is to provide a set of input datasets, and then an output prefix. It probably makes most sense to run this across a single kind of dataset, like all EPIs that might be considered in a group together, and then separately across all anatomicals for that group. That will make consistency checks for voxel size and other features more reasonable.

In the demo script do_01_gtkyd.tcsh, the following is the first gtkyd_check.py command, to make a summary table and a set of supplementary text files for the EPI datasets here:

gtkyd_check.py                                            \
    -infiles           sub-000/func/sub-*task-av*nii*     \
    -outdir            data_01_gtkyd/all_epi

This creates the following outputs in the data_1_gtkyd directory:

  • all_epi.xls : a spreadsheet where there is 1 row per file, and each column is one of the header properties of interest

  • all_epi : a directory of supplementary text files; we will use all_epi/dset*.txt for a follow-up command shortly

# run a script of gtkyd_check.py and follow-up gen_ss_review_table.py 
# commands on both EPI and anatomical datasets (if not run already)


# Run GTKYD only if output folder does not exist
if not os.path.exists('sub-000.gtkyd'):
    os.makedirs('sub-000.gtkyd')
    !tcsh do_01_gtkyd.tcsh
++ Generate: make table+supplements of properties from FMRI dsets
++ Have 3 dsets to check
++ Making new output directory: sub-000.gtkyd/all_epi
++ Now starting to Get To Know Your Data...
++ ---------------------------
++ DONE. See the outputs:
   group summary table       : sub-000.gtkyd/all_epi.xls
   group detailed values     : sub-000.gtkyd/all_epi/rep_gtkyd_detail_*.dat
   group unique values       : sub-000.gtkyd/all_epi/rep_gtkyd_unique_*.dat
   individual value lists    : sub-000.gtkyd/all_epi/dset_*.txt

++ Review: query for specific data properties that we want to avoid
== outlier test: tr VARY_PM 0.001
** invalid comparison, 'VARY_PM'   should be in: SHOW, VARY, EQ, NE, LT, LE, GT, GE, ZLT, ZLE, ZGT, ZGE

… and on the command line, one could open the created spreadsheet of EPI dataset properties created by gtkyd_check.py with, for example:

afni_open -s sub-000.gtkyd/all_epi.xls

This is shown below. The first set of properties are from 3dinfo (“n3” is the 3D matrix dimensions; “nv” is the number of volumes; and see the program help for further descriptions). Since the dataset format is NIFTI, further checks for NIFTI-specific header properties are checked (“datatype” is a code for being short/float/etc.; “sform_code” is a numeric coding of the space being original/template/etc.; and see the nifti_tool’s help for further descriptions).

# Display a screenshot of the spreadsheet of EPI properties created by gtkyd_check.py
IPython.display.Image(filename='example_snapshots/img_05_gtkyd_xls_epi.png') 
../../_images/78faf7bc75e042deb66bf3ae6f99136c179cc54efd7d18833ad87485b8b83b7c.png

It is possible to scan columns for consistency or unexpected values, but it is also nice to let the computer do that work for you. The AFNI program gen_ss_review_table.py can effectively query the values columnwise for

  • comparisons: does any dataset have a voxel dimension >=2.8 mm? are any TRs <= 1.5s? etc.

  • exact variations: is the matrix size of any dataset different than the rest?

  • variations with plus/minus tolerance: do voxel sizes vary, outside of floating point roundoff?

  • equality: is any participant’s raw data somehow labeled as being in a template space? and more. Please see the program’s help for further description.

This program queries text files in a simple dictionary format (colon-separated columns, or JSON). Fortunately, gtkyd_check.py is aware of this fact and has created a set of these for datasets it received as input—these were the all_epi/dset*.txt files alluded to, above. In the demo script do_01_gtkyd.tcsh, the following is the first gen_ss_review_table.py command, to make a small table of any datasets that have a particular property we were interested in, such as variable voxel dimension or a short TR, etc.:

gen_ss_review_table.py                                    \
    -outlier_sep space                                    \
    -infiles            sub-000.gtkyd/all_epi/dset*txt    \
    -report_outliers    'subject ID'     SHOW             \
    -report_outliers    'av_space'       EQ    "+tlrc"    \
    -report_outliers    'n3'             VARY             \
    -report_outliers    'nv'             VARY             \
    -report_outliers    'orient'         VARY             \
    -report_outliers    'datum'          VARY             \
    -report_outliers    'ad3'            VARY_PM 0.001    \
    -report_outliers    'tr'             VARY_PM 0.001    \
    -report_outliers    'ad3'            GE   2.8         \
    -report_outliers    'tr'             LE   1.5         \
    |& tee              sub-000.gtkyd/all_epi_gssrt.dat

NB: since this program outputs text to the terminal, the |& tee ... part at the end is to store a copy of the output terminal text into the given *.dat text file, for later readability.

If we display the contents of that text file (see below), we see that there are a lot of columns (because we checked a lot of properties) and in fact there were datasets that were a “hit” for at least one of the given criteria. If we can view the full *.dat file clearly, we see that one voxel dimension for each EPI dataset was >=2.8 mm, and so it would output in the table.

Note, in this case, we aren’t really worried about that property, but for example purposes we used that criterion to have something be output.

!cat sub-000.gtkyd/all_epi_gssrt.dat
== outlier test: tr VARY_PM 0.001
** invalid comparison, 'VARY_PM'   should be in: SHOW, VARY, EQ, NE, LT, LE, GT, GE, ZLT, ZLE, ZGT, ZGE

Dependencies in Jupyter/Python#

  • Using the package watermark to document system environment and software versions used in this notebook

%load_ext watermark

%watermark
%watermark --iversions
Last updated: 2026-01-18T06:10:15.568192+00:00

Python implementation: CPython
Python version       : 3.13.9
IPython version      : 9.7.0

Compiler    : GCC 14.3.0
OS          : Linux
Release     : 5.15.0-151-generic
Machine     : x86_64
Processor   : x86_64
CPU cores   : 32
Architecture: 64bit

IPython: 9.7.0