AFNI
h'p://afni.nimh.nih.gov/afni
–1–
AAFFNNI I && FMRIFMRIIntroduction, Concepts, Principles
http://afni.nimh.nih.gov/afni
AFNI Fundamentals –26–
• Basic unit of data in AFNI is the dataset
★ A collection of 1 or more 3D arrays of numberso Each entry in the array is in a particular spatial location in a 3D grid
(a voxel = 3D pixel)
o Image datasets: each array holds a collection of slices from thescanner
➥ Each number is the signal intensity for that particular voxel
o Derived datasets: each number is computed from other dataset(s)
➥ e.g., each voxel value is a t-statistic reporting “activation”significance from an FMRI time series dataset, for that voxel
★ Each 3D array in a dataset is called a sub-bricko There is one number in each voxel in each sub-brick
Fundamental AFNI Concepts
3x3x3DatasetWith 4
Sub-bricks
AFNI Dataset Files • AFNI forma'ed datasets are stored in 2 file types – .HEAD holds auxiliary informaBon – .BRIK hold all the numbers in the sub-‐briks
• 3 coordinate systems – Original (+orig) – AC-‐PC aligned (+acpc) – Talairach (+tlrc)
• AFNI can read many kinds of datasets: analyze (.hdr/.img), .mnc, .mri, .1D – .nii is the new standard (when giving a prefix, must end in .nii to be saved in that format)
–36–
Markers controltransformation to+acpc and +tlrccoordinates
Controls colorfunctional overlay
Miscellaneous menus
Switch betweendirectories, underlay(anatomical) datasets,and overlay(functional) datasets
Switch to differentcoordinate systemfor viewing images
Controls display ofoverlaid surfaces
Coordinates ofcurrent focus point
Control crosshairsappearance
Time index
Open images andgraphs of datasets
Open new AFNIcontroller
Help Button
AFNI controller window at startupTitlebar shows current datasets: first one is [A], etc
Close this controllerPlace to show amusing logos
–37–
AFNI Image ViewerDisp and Mont
control panels
–38–
AFNI Time Series Graph Viewer
Data (black) and Reference
waveforms (red)Menus for controlling
graph displays
–39–
Define Overlay: Colorizing Panel (etc)
Color mapfor overlay
Hidden popupmenus here
Choose which datasetmakes the underlay image
Choose which sub-brickfrom Underlay datasetto display (usually ananatomical dataset)
Choose which sub-brick offunctional dataset iscolorized (after threshold)
Choose which sub-brickof functional dataset isthe Threshold
Shows ranges of data inUnderlay and Overlaydataset
Shows automatic rangefor color scaling
Rotates color map
Lets you choose rangefor color scaling (insteadof autoRange)
Threshold slider:voxels with Thr sub-brick above this getcolorized from Olay
sub-brick
p-value of currentthreshold value
Choose range ofthreshold slider, in
powers of 10
Positive-only or bothsigns of function?
Number of panes incolor map (2-20 or **)
Shows voxelvalues at focus
Cluster above-thresholdvoxels into contiguous“blobs” bigger thansome given size
–40–
Volume Rendering: an AFNI plugin
Range of values torender
Histogram of valuesin underlay dataset
Maximum voxel opacity
Menu to control scripting(control rendering from afile)
Render new imageimmediately when acontrol is changed
Accumulate a history ofrendered images (can latersave to an animation)
Open color overlay controlsSub-brick to displayName of underlay datasetPick new underlay dataset
Range of values inunderlay
Change mapping fromvalues in dataset tobrightness in image
Mapping from valuesto opacity
Cutout parts of 3Dvolume
Controlviewingangles
Detailed instructions Force a new image tobe rendered
Reload values fromthe dataset
Close all rendering windows
Show 2D crosshairs
Compute many imagesin a row
Command Line Programs
• Most parts of AFNI are only available through the command line – 3dDeconvolve – mulBple linear regression on 3D+Bme datasets, to fit each voxel’s Bme series to an acBvaBon model and test these fits for significance • 3dNLfim for nonlinear fiZng
– 3dANOVA – 1, 2, 3, and 4-‐way ANOVA layouts for combining and contrasBng datasets in standard space
– 3dcalc – general purpose voxel-‐wise calculator – 3dclust – find clusters of acBvated voxels – 3dresample – re-‐orient and/or resize dataset voxel grid
Single Subject Data Processing –51–
3D Individual Subject Analysis
Assemble images into AFNI-formatted datasets
Check images for quality (visual & automatic)
Register (realign) images
Smooth images spatially
Mask out non-brain parts of images
Normalize time series baseline to 100 (for %-izing)
Fit stimulus timing + hemodynamic model to time series• catenates imaging runs, removes residual movementeffects, computes response sizes & inter-stim contrasts
Segregate into differentially “activated” blobs
Look at results, and ponder
to3dOR
can do at NIH scanners
afni + 3dToutcount
3dvolregOR
3dWarpDrive
3dAutomask + 3dcalc (optional)
3dTstat + 3dcalc (optional: could be done post-fit)
3dDeconvolve3dDeconvolve
Alphasim + 3dmergeOR
Extraction from ROIs
afniAND
your personal brain
… to group analysis (next page)
3dmergeOR
3dBlurToFWHM
(optional)
Single Subject • Get the data from dicom into a format readable by AFNI – to3d
• Structural scan – to3d –prefix anat *.dcm – Can also use d2afni
• FuncBonal scan to3d –Bme:zt 34 67 2.5 alt+z –prefix EPI1 *.dcm – -‐Bme:zt – slices presented in the order of space then Bme – 34 – number of slices – 67 – number of volumes – 2.5 – TR – Alt+z – slices gathered in alternaBng order in the z direcBon – -‐prefix – name the output dataset; if you want a niei file format, use EPI1.nii
Single Subject • Get the data from dicom into a format readable by AFNI – to3d *.dcm
-25-
• Same to3d control panel (without negative voxel warning):
• Above the double line: must fill out 3 types of geometry information
★ Left column: orientation of the dataset axes
★ Middle column: size of the dataset images or voxels
★ Right column: offset of the first slice
Single Subject • Time shie to 0 – 3dTshie –tzero 0 –prefix Ts_Run1 EPI1.nii
• Register to one volume – 3dvolreg –base Ts_Run1+orig’[173]’ –prefix VrTs_Run1 Ts_Run1+orig
• Smoothing – 3dmerge -‐1blur_fwhm 4 –doall –prefix BlVeTs_Run1 VrTs_Run1
• Remove highpass and lowpass – 3dFourier –prefix FrBlVrTs_Run1 –lowpass .1 –highpass .01 –ignore 5 –retrend BlVrTs_Run1+orig
Single Subject • Create brain-‐only mask – 3dAutomask –dilate 1 –prefix mask_Run1 FrBlVrTs_Run1+orig
• Combine masks from mulBple runs – 3dcalc –a mask_Run1+orig –b mask_Run2+orig –c mask_Run3+orig –expr ‘or(a+b+c)’ –prefix fullmask
• Scale each run’s mean to 100 (% signal change) – 3dTstat –prefix mean_Run1 FrBlVrTs_Run1+orig – 3dcalc –a FrBlVrTs_Run1+orig –b mean_Run1+orig –c fullmask+orig –expr ‘(a/b * 100)*c’ –prefix ScFrBlVrTs_Run1
Single Subject • MoBon CorrecBon – movecensor.pl – creates one file for each run with six values of moBon for each Bme point
• Concatenate moBon files – cat moBon_1 moBon_2 moBon_3 > AllRuns_moBon
Single Subject • Signal DeconvoluBon 3dDeconvolve \ -‐input ScBlVrTs_EPI1+orig ScBlVrTs_EPI2+orig ScBlVrTs_EPI3+orig \ -‐polort 3 \ -‐num_sBmts 12 \ -‐sBm_Bmes 1 EPI_Studied_R.1D 'TENT(0,15,7)' \ -‐sBm_label 1 Studied_R \ -‐sBm_Bmes 2 EPI_Studied_K.1D 'TENT(0,15,7)' \ -‐sBm_label 2 Studied_K \ -‐sBm_Bmes 3 EPI_Studied_N.1D 'TENT(0,15,7)' \ -‐sBm_label 3 Studied_N \ -‐sBm_Bmes 4 EPI_Novel_R.1D 'TENT(0,15,7)' \ -‐sBm_label 4 Novel_R \ -‐sBm_Bmes 5 EPI_Novel_K.1D 'TENT(0,15,7)' \ -‐sBm_label 5 Novel_K \ -‐sBm_Bmes 6 EPI_Novel_N.1D 'TENT(0,15,7)' \ -‐sBm_label 6 Novel_N \ -‐sBm_file 7 AllRuns_moBon_EPI'[0]' -‐sBm_base 7 \ -‐sBm_file 8 AllRuns_moBon_EPI'[1]' -‐sBm_base 8 \ -‐sBm_file 9 AllRuns_moBon_EPI'[2]' -‐sBm_base 9 \ -‐sBm_file 10 AllRuns_moBon_EPI'[3]' -‐sBm_base 10 \ -‐sBm_file 11 AllRuns_moBon_EPI'[4]' -‐sBm_base 11 \ -‐sBm_file 12 AllRuns_moBon_EPI'[5]' -‐sBm_base 12 \ -‐iresp 1 iresp_EPI_studied_R \ -‐iresp 2 iresp_EPI_studied_K \ -‐iresp 3 iresp_EPI_studied_N \ -‐iresp 4 iresp_EPI_novel_R \ -‐iresp 5 iresp_EPI_novel_K \ -‐iresp 6 iresp_EPI_novel_N \ -‐fout -‐tout -‐nobout -‐xjpeg Xmat \ -‐bucket bucket_EPI_se1 \ -‐xsave \ -‐allzero_ok \ -‐num_glt 10 \ -‐gltsym 'SYM: +Studied_R' -‐glt_label 1 Studied-‐R \ -‐gltsym 'SYM: +Studied_K' -‐glt_label 2 Studied-‐K \ -‐gltsym 'SYM: +Studied_N' -‐glt_label 3 Studied-‐N \ -‐gltsym 'SYM: +Novel_R' -‐glt_label 4 Novel-‐R \ -‐gltsym 'SYM: +Novel_K' -‐glt_label 5 Novel-‐K \ -‐gltsym 'SYM: +Novel_N' -‐glt_label 6 Novel-‐N \ -‐gltsym 'SYM: +Novel_R +Novel_K' -‐glt_label 7 Novel-‐Inc \ -‐gltsym 'SYM: +Studied_R -‐Studied_K' -‐glt_label 8 Studied_R-‐K \ -‐gltsym 'SYM: +Studied_R -‐Studied_N' -‐glt_label 9 Studied_R-‐N \ -‐gltsym 'SYM: +Studied_K -‐Studied_N' -‐glt_label 10 Studied_K-‐N \ -‐censor censor_moBon_EPI.txt
Single Subject • ConverBng to Standard Space • Manual or automaBc ac-‐pc and talairaching • Adwarp – coverts funcBonals
adwarp -‐apar ANAT+tlrc -‐dpar bucket_RT+orig \ -‐prefix bucket_RT \ -‐dxyz 4.0 -‐thr NN -‐func Bk
Group Analysis 3d'est \ -‐session ../Analysis_ROI_HC+DN \ -‐prefix 'est_DN_12subj \ -‐base1 0.0 \ -‐set2 \ am041609_bucket_DN_ms_postDemons+tlrc'[3]' \ aw043009_bucket_DN_ms_postDemons+tlrc'[3]' \ ec041709_bucket_DN_ms_postDemons+tlrc'[3]' \ es041509_bucket_DN_ms_postDemons+tlrc'[3]' \ gg043009_bucket_DN_ms_postDemons+tlrc'[3]' \ jf042809_bucket_DN_ms_postDemons+tlrc'[3]' \ lk041509_bucket_DN_ms_postDemons+tlrc'[3]' \ mj043009_bucket_DN_ms_postDemons+tlrc'[3]' \ ng041609_bucket_DN_ms_postDemons+tlrc'[3]' \ rb041409_bucket_DN_ms_postDemons+tlrc'[3]' \ sk041709_bucket_DN_ms_postDemons+tlrc'[3]' \ sm042709_bucket_DN_ms_postDemons+tlrc'[3]' \
Group Analysis
• Clustering 3dmerge \ -‐1thresh 2.201 \ -‐1clust 4.0 200 \ -‐1dindex 0 \ -‐1Bndex 1 \ -‐prefix Clust_'est.05_DN_12subj \ 'est_DN_12subj
Group Analysis
• ExtracBng impulse response curves or beta values 3dROIstats -‐mask Clustorder_'est.05_DN_12subj+tlrc -‐nzmean \ Brewer_${subject}_bucket+tlrc'[3]' >>Analysis_HC/3dROIstats_HC_12subj.txt