Doing visual localizers in freesurfer/afni+suma
- sub-brick: each 3D array in a dataset
- .HEAD is the header file
- .BRIK is the file with all the sub-bricks
- Coordinate systems:
- +orig: scanner coordinates
- +acpc: ACPC aligned
- +tlrc: talairach
- Session: a directory with all the data from that session—assumed to have same view and same coordinates
- AVol: anatomy volume
- AVol@Epi: the anatomy volume registered to the EPI data
- SVol: surface volume
- SVol@Epi: the surface volume registered to the EPI data
- to3d: converts dicom or nifti data into AFNI bricks; called with only input file (to3d myfile) brings up a gui which can preview the data
- to3d –prefix outFileStub inputFile.ext
- to3d inputFile [launches gui]
- 3dvolreg: motion correction on functional data (within scan and between scans)
- 3dWarpDrive: warp??
- 3dcalc: average functional data
- Binary Mask: 3dcalc –prefix OutFile.type –a FileToMaskOn –expr ‘step(a)’
- Afni_proc.py: single subject FMRI preproc and TS analysis for functional activation
- Uber_subject.py: GUI for afni_proc.py
- Align_epi_anat.py: image alignment (registration): anatomical—EPI, anatomical—anatomical, EPI—EPI, and to atlas space (talairach/MNI)
- use this instead of 3dvolreg and 3dWarpDrive
- need to AlignCenters first!!!
- Partial_coverge flag
- 3dAFNItoNIFTI: converts brik/head files to nifti
- Afni –niml: run afni with comms port open
- Suma –spec ../path/to/specFile.spec –sv LocalFileSVol@Epi+orig
For each subject, process the anatomy (one time only) in freesurfer
- recon-all
- check the output, edit WM (etc) as necessary, rerun steps if needed
- cut patches and flatten them
- tksurfer to cut patches
- mris_flatten to flatten the patches
- port the various anatomy files to AFNI
- @SUMA_Make_Spec_FS
Process the functional data
- Traveling wave (rotating wedges and expanding/contracting rings) can be done with the @RetinoProc command; object and motion scans can be processed as traditional block design studies
- This step could also be done with custom code (e.g., python or matlab script to do the traveling wave analysis). In the end we need a nifti file with the parameters (e.g., phase and coherence threshold)
- Wedges and rings
- Setup a script to call @RetinoProc (which calls 3dRetinoPhase), which needs
- SUMA’d brain (from @SUMA_Make_Spec step)
- Lh and rh spec files (from @SUMA_Make_Spec)
- (original?) anatomy volume as a single .nii file (T1 intcorr???)
- Details on the functional data
- Tr—note that AFNI read Tr differently and often need a 3drefit command to tell it Tr is in s vs ms
- Period and # of blocks
- # and size of rings/wedges
- which scan was which
- time before stim starts
- # volumes to ignore (e.g., reference volumes)
- Run the script that calls @RetinoProc. My example is a modified @Proc.All
- Outputs are put into a new folder called ProcOut.All
- View them via:
- afni –niml & (launches afni with niml comms enabled and runs in the background)
- suma –spec ../SUMA/s1032_lh.spec –sv SVol@Epi+orig (spec file is the original freesurfered spec for one/both hemispheres—could copy over or leave in orig directory. Surface volume file is the aligned SVol, which is in the results directory, NOT the original s1032_SurfVol+orig file. SVol file MUST be in the same directory as results)
- in AFNI
- load the SVol@Epi+orig as underlay (must do this before enabling comms within suma)
- In SUMA
- View…surface controller…Load Dset then choose the lh.pol.field (or rh…)
- Also interesting to load ecc.field, then can switch between the two
- Use . and , to cycle between surfaces (inflated/patches/flats)
- Hit t to link to AFNI
- To be able to see the output in AFNI, the niml.dset files have to be converted to AFNI format using
- ConvertDset .,….. didn’t work don’t really need this.
- What’s inside the polar angle dataset. 3 columns (for each node)
- Polar angle (0 to 360)... relative to starting angle (wherever your stimulus was when you started, counting from the first non-ignored volume)
- Hemo. Offset (-180 to 178.9076)
- Max.PwR@0.042Hz (0 to 2606.652)—use this for thresholding which voxels to display!
- Load custom colormap to match Larsson and Heeger—near cmap click new.
- Format of colormap file—space delimited text file with r g b values, one set per row, # of rows = # colors, file name: MyColorMap.1D.cmap
- The polar angle that SUMA displays is (I think) the angle relative to the starting angle of the stimulus. It doesn’t know what angle I started my wedge at (or eccentricity I started the ring at), so it’s just giving relative place in the cycle.
- e. How do I perform distortion compensation? Fsl on the command line, but when (which stage) and on what file? Presumably right after moco, but how can I do that when it’s all wrapped up in RetinoProc?
- The script automatically does motion compensation (“registration”) in the AFNI way of aligning the anatomy TO the EPI reference and the remaining EPI volumes to that EPI reference. The surface (from freesurfer) is then aligned to the post-alignment anatomy volume.
- One can bypass this automatic alignment step by specifying a couple of flags in the call to RetinoProc—pass in the pre-aligned volumes
- Do the distCo and moCo beforehand then give those results to RetinoProc.
- Use align_epi_anat.py (or 3dAllineate)????
- Motion and object scans are processed as a block design
- Convert DCM to afni files with to3d, then move the output to the “session” dir
- Use uber_subject.py to setup the AFNI session (GUI for afni_proc.py which is the single subject preprocessing and timeseries analysis)
- Location of anatomy files
- Location of EPI files
- Location of text file with timing information (block design specs)
- Text file with time onset of each stim—one file for each stim type
- Within one file, one ROW for each SCAN—times are relative to start of TRIMMED scan
- E.g., throw away first 6 Trs (2 sec each). The stim literally starts 12 sec into the run, but the first time I’d specify in stimtiming is 0s, since it starts 0s after the start of the trimmed file
- When using uber_subject.py, the stim file is a bit tricky. If there is only ONE condition (as in motion or object, where it’s the one thing or “nothing”), uber_subject.py has an error—have to explicitly type in the label, and do this BEFORE clicking on the block(x,y) which resets the labels.
- Or……have to redo the label after the block thing, which overwrote the label
- Time in seconds, not Trs,
- stimName.1D as filename
- # of points to remove from each EPI
- “blur” size
- Prepare to view results on the surface by aligning the surfaces to the EPI data
- Change directory to the folder containing the results of the block analysis
- @SUMA_AlignToExperiment –exp_anat ExpVol+orig –surf_anat /path/to/surfaces/SurfVol+orig
- Copy the SVol@Epi+orig file over to the output directory
- Load up in AFNI alone (from output dir)
- afni &
- Choose anat_final for underlay
- Choose stats as overlay—Olay is coeff, Thr is Tstat, ** to 1, # to 12
- Load up AFNI and SUMA (from output dir)
- afni –niml &
- suma –spec ../SUMA/s1032_lh.spec –sv SVol@Epi+orig
- strip skull of field map magnitude (via bet, or afni, or manually)
- bet magFile magStripped -m
- (here, magFile was MR-ST001-SE013-0001.dcm)
- scale phase map to 0-2pi via fslmaths
- fslmaths phaseFile -sub 2048 -mul 3.14159 -div 2048 ph_rad -odt float
- (here phaseFile was MR-ST001-SE013-EC2-0001.dcm)
- unwrap the phasemap using stripped brain as mask, via prelude
- prelude -p ph_rad -a magStripped -m magStripped_mask -o ph_rad_unwrapped
- convert to freq map (rad/ms) via fslmaths
- fslmaths ph_rad_unwrapped -div 1.02 ph_rad_per_ms
- (here, 1.02 is the delta TE of the field map)
- apply field map to data via fugue
- fugue -i epiFile --loadfmap=ph_rad_per_ms --dwell=.105 --unwarpdir=y -u epi_unwarped
- (here dwell time is EPI echo spacing divided by acceleration factor, 0.42/4)
- (here unwarpdir was positive y, gained by trial and error!)