# MM Data Preproc [toc] --- ## Info **Project Directory: `121.48.165.31:/data/huze/Fs.subjects`** There **273 fMRI scans** but only **212 T1 scans** in the MRS dataset, subject missing T1 scan can't be preprocess by FS-FAST. Ignoring these subjects: ``` CRITICAL:CHECKING FMRI WITHOUT T1:FMRI WITHOUT T1 LIST: ['3056_1', '2003_3', '2043_1', '3026_1', '2074_1', '3067_3', '2066_3', '2038_1', '3007_3', '2039_3', '3056_3', '3067_1', '2034_3', '2030_3', '2055_1', '2119_3', '3026_3', '2039_1', '2042_1', '2100_1', '2038_3', '3005_3', '2043_3', '2074_3', '2105_1', '2081_3', '2060_3', '3007_1', '2034_1', '2030_1', '3004_3', '2003_1', '3063_1', '3004_1', '3053_3', '2055_3', '2042_3', '2060_1', '3053_1', '3005_1', '2072_3', '2100_3', '3034_3', '3061_3', '3060_1', '2084_3', '2084_1', '2081_1', '3061_1', '2119_1', '2073_1', '2114_1', '3063_3', '2105_3', '3034_1', '2114_3', '3060_3', '2073_3', '2072_1', '2066_1'] ``` --- ## recon-all on T1 **recon-all** : Performs all, or any part of, the FreeSurfer cortical reconstruction process. ### Documentations #### Part 1 **recon-all docs**: https://surfer.nmr.mgh.harvard.edu/fswiki/recon-all http://surfer.nmr.mgh.harvard.edu/fswiki/ReconAllTableStableV6.0 According to **Manual-Intervention Workflow Directives** at [recon-all doc](https://surfer.nmr.mgh.harvard.edu/fswiki/recon-all) as blow, the flag `-autorecon#` is good for managing the stages. <table><tbody><tr> <td><p class="line862">-all </p></td> <td><p class="line862">do everything, including subcortical segmentation </p></td> </tr> <tr> <td><span class="anchor" id="line-27"></span><p class="line862">-autorecon-all </p></td> <td><p class="line862">same as -all </p></td> </tr> </tbody></table> <table><tbody><tr> <td><p class="line862">-autorecon1 </p></td> <td><p class="line862">process steps 1-5 (see below) </p></td> </tr> <tr> <td><span class="anchor" id="line-32"></span><p class="line862">-autorecon2 </p></td> <td><p class="line862">process steps 6-23 </p></td> </tr> <tr> <td><span class="anchor" id="line-33"></span><p class="line862"> </p></td> <td><p class="line862">after autorecon2, check final surfaces: </p></td> </tr> <tr> <td><span class="anchor" id="line-34"></span><p class="line862"> </p></td> <td><p class="line862">a. if wm edit was required, then run -autorecon2-wm </p></td> </tr> <tr> <td><span class="anchor" id="line-35"></span><p class="line862"> </p></td> <td><p class="line862">b. if control points added, then run -autorecon2-cp </p></td> </tr> <tr> <td><span class="anchor" id="line-36"></span><p class="line862"> </p></td> <td><p class="line862">c. if edits made to correct pial, then run -autorecon2-pial </p></td> </tr> <tr> <td><span class="anchor" id="line-37"></span><p class="line862"> </p></td> <td><p class="line862">d. proceed to run -autorecon3 </p></td> </tr> <tr> <td><span class="anchor" id="line-38"></span><p class="line862">-autorecon2-cp </p></td> <td><p class="line862">process stages 12-23 (uses -f w/ mri_normalize, -keep w/ mri_seg) </p></td> </tr> <tr> <td><span class="anchor" id="line-39"></span><p class="line862">-autorecon2-wm </p></td> <td><p class="line862">process stages 15-23 </p></td> </tr> <tr> <td><span class="anchor" id="line-40"></span><p class="line862">-autorecon2-pial </p></td> <td><p class="line862">process stages 21-23 </p></td> </tr> <tr> <td><span class="anchor" id="line-41"></span><p class="line862">-autorecon3 </p></td> <td><p class="line862">process stages 24-31 </p></td> </tr> <tr> <td><span class="anchor" id="line-42"></span><p class="line862">-hemi ?h </p></td> <td><p class="line862">just do lh or rh (default is to do both) </p></td> </tr> </tbody></table> **Autorecon Processing Stages (see -autorecon# flags above):** <ol type="1"><li>Motion Correction and Conform <span class="anchor" id="line-47"></span></li><li>NU (Non-Uniform intensity normalization) <span class="anchor" id="line-48"></span></li><li>Talairach transform computation <span class="anchor" id="line-49"></span></li><li>Intensity Normalization 1 <span class="anchor" id="line-50"></span></li><li>Skull Strip <span class="anchor" id="line-51"></span><span class="anchor" id="line-52"></span></li><li class="gap">EM Register (linear volumetric registration) <span class="anchor" id="line-53"></span></li><li>CA Intensity Normalization <span class="anchor" id="line-54"></span></li><li>CA Non-linear Volumetric Registration <span class="anchor" id="line-55"></span></li><li>Remove Neck <span class="anchor" id="line-56"></span></li><li>LTA with Skull <span class="anchor" id="line-57"></span></li><li>CA Label (Volumetric Labeling, ie Aseg) and Statistics <span class="anchor" id="line-58"></span><span class="anchor" id="line-59"></span></li><li class="gap">Intensity Normalization 2 (start here for control points) <span class="anchor" id="line-60"></span></li><li>White matter segmentation <span class="anchor" id="line-61"></span></li><li>Edit WM With ASeg <span class="anchor" id="line-62"></span></li><li>Fill (start here for wm edits) <span class="anchor" id="line-63"></span></li><li>Tessellation (begins per-hemisphere operations) <span class="anchor" id="line-64"></span></li><li>Smooth1 <span class="anchor" id="line-65"></span></li><li>Inflate1 <span class="anchor" id="line-66"></span></li><li>QSphere <span class="anchor" id="line-67"></span></li><li>Automatic Topology Fixer <span class="anchor" id="line-68"></span></li><li>Final Surfs (start here for brain edits for pial surf) <span class="anchor" id="line-69"></span></li><li>Smooth2 <span class="anchor" id="line-70"></span></li><li>Inflate2 <span class="anchor" id="line-71"></span><span class="anchor" id="line-72"></span></li><li class="gap">Spherical Mapping <span class="anchor" id="line-73"></span></li><li>Spherical Registration <span class="anchor" id="line-74"></span></li><li>Spherical Registration, Contralateral hemisphere <span class="anchor" id="line-75"></span></li><li>Map average curvature to subject <span class="anchor" id="line-76"></span></li><li>Cortical Parcellation - Desikan_Killiany and Christophe (Labeling) <span class="anchor" id="line-77"></span></li><li>Cortical Parcellation Statistics <span class="anchor" id="line-78"></span></li><li>Cortical Ribbon Mask <span class="anchor" id="line-79"></span></li><li>Cortical Parcellation mapping to Aseg <span class="anchor" id="line-80"></span><span class="anchor" id="line-81"></span></li></ol> Where stages 1-23 (included in `-autorecon1` and `-autorecon2`) are the necessary stages. One should check the results manually after step 1-23, and then proceed to stages 24-31 to calculate the features. #### Part 2 Run recon-all in [parallel](http://manpages.ubuntu.com/manpages/cosmic/man1/parallel.1.html) on multiple CPU cores. ### Pre-steps Creat subject list file with `creat_subj_list.py` ```python import os from os import listdir from os.path import isfile, isdir, join, basename import sys import logging def main(working_dir): onlyniis = [join(working_dir, f) for f in \ listdir(working_dir) if f.endswith('.nii.gz')] subj_list = [basename(s).replace('_mdeft.nii.gz', '') for s in onlyniis] with open(join(working_dir, 'subject_list'), 'w+') as f: for s in subj_list: f.write(s+'\n') if __name__ == '__main__': main(*sys.argv[1:]) ``` Run it as: ```shell python3 creat_subj_list.py ./MM/T1 ``` This commands creates `subject_list` with all subject's id, which will be used later. ### Running recon-all `cat subject_list` and feed to `parallel` to specify input and subject, split `subject_list` to run on multiple machines. ```shell export postfix=_medft.nii.gz cat subject_list | parallel recon-all -s {} -i {}$postfix -autorecon# ``` :::warning **Note:** Make a backup of SUBJECT_DIR after each step. **Backups** are located at `$SUBJUCTS_DIR/Backups` ::: #### Step 1 ==MUST== run `recon-all -autorecon1` at all the subjects autorecon1 includes: >Motion Correction and Conform NU (Non-Uniform intensity normalization) Talairach transform computation Intensity Normalization 1 Skull Strip <table style="text-align:left; ; text-align:left"><tbody><tr> <td><p class="line891"><strong>recon-all step</strong> </p></td> <td><p class="line891"><strong>Individual Flag</strong> </p></td> <td><p class="line891"><strong>Input</strong> </p></td> <td><p class="line891"><strong>Command Line</strong> </p></td> <td><p class="line891"><strong>Output</strong> </p></td> </tr> <tr> <td colspan="1" rowspan="20" style="text-align:left"><span class="anchor" id="line-5"></span><p class="line891"><strong><a class="https" href="https://surfer.nmr.mgh.harvard.edu/fswiki/recon-all">recon-all</a> -autorecon1 -subjid &lt;subjid&gt;</strong> </p></td> </tr> <tr> <td colspan="1" rowspan="1" style="text-align:left"><span class="anchor" id="line-6"></span><p class="line862">-i &lt;invol1&gt; </p></td> <td><p class="line862">invol1.dcm <em>or .nii or .mgz</em> </p></td> <td><p class="line891"><a class="https" href="https://surfer.nmr.mgh.harvard.edu/fswiki/mri_convert">mri_convert</a> invol1.dcm orig/001.mgz </p></td> <td><p class="line862">orig/001.mgz </p></td> </tr> <tr> <td colspan="1" rowspan="1" style="text-align:left"><span class="anchor" id="line-7"></span><p class="line862">-i &lt;invol2&gt; <em>optional</em> </p></td> <td><p class="line862">invol2.dcm<em> or .nii or .mgz</em> </p></td> <td><p class="line891"><a class="https" href="https://surfer.nmr.mgh.harvard.edu/fswiki/mri_convert">mri_convert</a> invol2.dcm orig/002.mgz </p></td> <td><p class="line862">orig/002.mgz </p></td> </tr> <tr> <td colspan="1" rowspan="1" style="text-align:left"><span class="anchor" id="line-8"></span><p class="line862">-T2 &lt;invol&gt; <em>or</em> -FLAIR &lt;invol&gt; <em>optional</em> </p></td> <td colspan="1" rowspan="1" style="text-align:left"><p class="line862">invol.dcm <em>or .nii or .mgz</em> </p></td> <td colspan="1" rowspan="1" style="text-align:left"><p class="line891"><a class="https" href="https://surfer.nmr.mgh.harvard.edu/fswiki/mri_convert">mri_convert</a> --no_scale 1 invol.dcm orig/T2raw.mgz <em>(or orig/FLAIRraw.mgz)</em> </p></td> <td colspan="1" rowspan="1" style="text-align:left"><p class="line862">orig/T2raw.mgz <em>(or orig/FLAIRraw.mgz)</em> </p></td> </tr> <tr> <td colspan="1" rowspan="4" style="text-align:left"><span class="anchor" id="line-9"></span><p class="line862">-<a class="https" href="https://surfer.nmr.mgh.harvard.edu/fswiki/motioncor">motioncor</a> </p></td> <td><p class="line862">orig/001.mgz </p></td> <td colspan="1" rowspan="2" style="text-align:left"><p class="line891"><a class="https" href="https://surfer.nmr.mgh.harvard.edu/fswiki/mri_robust_template">mri_robust_template</a> --mov 001.mgz 002.mgz --average 1 --template rawavg.mgz --satit --inittp 1 --fixtp --noit --iscale --iscaleout --subsample 200 --lta </p></td> <td colspan="1" rowspan="2" style="text-align:left"><p class="line862">rawavg.mgz </p></td> </tr> <tr> <td><span class="anchor" id="line-10"></span><p class="line862">orig/002.mgz </p></td> </tr> <tr> <td><span class="anchor" id="line-11"></span><p class="line862">rawavg.mgz </p></td> <td><p class="line891"><a class="https" href="https://surfer.nmr.mgh.harvard.edu/fswiki/mri_convert">mri_convert</a> rawavg.mgz orig.mgz --conform </p></td> <td><p class="line862">orig.mgz </p></td> </tr> <tr> <td><span class="anchor" id="line-12"></span><p class="line862">orig.mgz </p></td> <td><p class="line891"><a class="https" href="https://surfer.nmr.mgh.harvard.edu/fswiki/mri_add_xform_to_header">mri_add_xform_to_header</a> -c transforms/talairach.xfm orig.mgz orig.mgz </p></td> <td><p class="line862">orig.mgz </p></td> </tr> <tr> <td colspan="1" rowspan="5" style="text-align:left"><span class="anchor" id="line-13"></span><p class="line862">-<a class="https" href="https://surfer.nmr.mgh.harvard.edu/fswiki/talairach">talairach</a> </p></td> <td><p class="line862">orig.mgz </p></td> <td><p class="line891"><a class="https" href="https://surfer.nmr.mgh.harvard.edu/fswiki/mri_nu_correct.mni">mri_nu_correct.mni</a> --n 1 --proto-iters 1000 --distance 50 --no-rescale --i orig.mgz --o orig_nu.mgz </p></td> <td><p class="line862">orig_nu.mgz </p></td> </tr> <tr> <td><span class="anchor" id="line-14"></span><p class="line862">orig_nu.mgz </p></td> <td><p class="line891"><a class="https" href="https://surfer.nmr.mgh.harvard.edu/fswiki/talairach_avi">talairach_avi</a> --i orig_nu.mgz --xfm transforms/talairach.auto.xfm </p></td> <td><p class="line862">transforms/talairach.auto.xfm </p></td> </tr> <tr> <td><span class="anchor" id="line-15"></span><p class="line862">transforms/talairach.auto.xfm </p></td> <td><p class="line862">cp transforms/talairach.auto.xfm transforms/talairach.xfm </p></td> <td><p class="line862">transforms/talairach.xfm </p></td> </tr> <tr> <td><span class="anchor" id="line-16"></span><p class="line862">transforms/talairach.xfm </p></td> <td><p class="line891"><a class="https" href="https://surfer.nmr.mgh.harvard.edu/fswiki/talairach_afd">talairach_afd</a> -T 0.005 -xfm transforms/talairach.xfm </p></td> <td><p class="line862"> </p></td> </tr> <tr> <td><span class="anchor" id="line-17"></span><p class="line862"> </p></td> <td><p class="line862">awk -f $FREESURFER_HOME/bin/extract_talairach_avi_QA.awk transforms/talairach_avi.log </p></td> <td><p class="line862">transforms/talairach_avi.log </p></td> </tr> <tr> <td colspan="1" rowspan="2" style="text-align:left;"><span class="anchor" id="line-18"></span><p class="line862">-<a class="https" href="https://surfer.nmr.mgh.harvard.edu/fswiki/nuintensitycor">nuintensitycor</a> </p></td> <td><p class="line862">orig.mgz </p></td> <td colspan="1" rowspan="2" style="text-align:left;"><p class="line891"><a class="https" href="https://surfer.nmr.mgh.harvard.edu/fswiki/mri_nu_correct.mni">mri_nu_correct.mni</a> --i orig.mgz --o nu.mgz --uchar transforms/talairach.xfm --n 2 </p></td> <td colspan="1" rowspan="2" style="text-align:left;"><p class="line862">nu.mgz </p></td> </tr> <tr> <td><span class="anchor" id="line-19"></span><p class="line862">talairach.xfm </p></td> </tr> <tr> <td colspan="1" rowspan="1" style="text-align:left"><span class="anchor" id="line-20"></span><p class="line862">-<a class="https" href="https://surfer.nmr.mgh.harvard.edu/fswiki/normalization">normalization</a> </p></td> <td><p class="line862">nu.mgz </p></td> <td><p class="line891"><a class="https" href="https://surfer.nmr.mgh.harvard.edu/fswiki/mri_normalize">mri_normalize</a> -g 1 -mprage nu.mgz T1.mgz </p></td> <td><p class="line862">T1.mgz </p></td> </tr> <tr> <td colspan="1" rowspan="3" style="text-align:left"><span class="anchor" id="line-21"></span><p class="line862">-<a class="https" href="https://surfer.nmr.mgh.harvard.edu/fswiki/skullstrip">skullstrip</a> </p></td> <td><p class="line862">nu.mgz </p></td> <td><p class="line891"><a class="https" href="https://surfer.nmr.mgh.harvard.edu/fswiki/mri_em_register">mri_em_register</a> -skull nu.mgz $FREESURFER_HOME/average/RB_all_withskull_2016-05-10.vc700.gca transforms/talairach_with_skull.lta </p></td> <td><p class="line862">transforms/talairach_with_skull.lta </p></td> </tr> <tr> <td><span class="anchor" id="line-22"></span><p class="line862">T1.mgz </p></td> <td><p class="line891"><a class="https" href="https://surfer.nmr.mgh.harvard.edu/fswiki/mri_watershed">mri_watershed</a> -T1 -brain_atlas $FREESURFER_HOME/average/RB_all_withskull_2016-05-10.vc700.gca transforms/talairach_with_skull.lta T1.mgz brainmask.auto.mgz </p></td> <td><p class="line862">brainmask.auto.mgz </p></td> </tr> <tr> <td><span class="anchor" id="line-23"></span><p class="line862">brainmask.auto.mgz </p></td> <td><p class="line862">cp brainmask.auto.mgz brainmask.mgz </p></td> <td><p class="line862">brainmask.mgz </p></td> </tr> </tbody></table> Running: ```shell export postfix=_medft.nii.gz cat subject_list | parallel recon-all -s {} -i {}$postfix -autorecon1 ``` :::success **Step 1 completed without error** Logfile at $SUBJECTS_DIR/<subject_id>/scripts/recon-all.log ::: #### Step 2 ==MUST== `RUNNING` run `recon-all -autorecon2` at all the subjects autorecon2 includes: >EM Register (linear volumetric registration) CA Intensity Normalization CA Non-linear Volumetric Registration Remove Neck LTA with Skull CA Label (Volumetric Labeling, ie Aseg) and Statistics Intensity Normalization 2 (start here for control points) White matter segmentation Edit WM With ASeg Fill (start here for wm edits) Tessellation (begins per-hemisphere operations) Smooth1 Inflate1 QSphere Automatic Topology Fixer Final Surfs (start here for brain edits for pial surf) Smooth2 Inflate2 <table style="text-align:left; ; text-align:left"><tbody><tr> <td><p class="line891"><strong>recon-all step</strong> </p></td> <td><p class="line891"><strong>Individual Flag</strong> </p></td> <td><p class="line891"><strong>Input</strong> </p></td> <td><p class="line891"><strong>Command Line</strong> </p></td> <td><p class="line891"><strong>Output</strong> </p></td> </tr> <tr> <td colspan="1" rowspan="69" style="text-align:left;"><span class="anchor" id="line-27"></span><p class="line891"><strong><a class="https" href="https://surfer.nmr.mgh.harvard.edu/fswiki/recon-all">recon-all</a> -autorecon2 -subjid &lt;subjid&gt;</strong> </p></td> </tr> <tr> <td colspan="1" rowspan="2" style="text-align:left;"><span class="anchor" id="line-28"></span><p class="line862">-<a class="https" href="https://surfer.nmr.mgh.harvard.edu/fswiki/gcareg">gcareg</a> </p></td> <td><p class="line862">brainmask.mgz </p></td> <td colspan="1" rowspan="2" style="text-align:left;"><p class="line891"><a class="https" href="https://surfer.nmr.mgh.harvard.edu/fswiki/mri_em_register">mri_em_register</a> -uns 3 -mask brainmask.mgz nu.mgz $FREESURFER_HOME/average/RB_all_2016-05-10.vc700.gca transforms/talairach.lta </p></td> <td colspan="1" rowspan="2" style="text-align:left;"><p class="line862">transforms/talairach.lta </p></td> </tr> <tr> <td><span class="anchor" id="line-29"></span><p class="line862">nu.mgz </p></td> </tr> <tr> <td colspan="1" rowspan="3" style="text-align:left;"><span class="anchor" id="line-30"></span><p class="line862">-<a class="https" href="https://surfer.nmr.mgh.harvard.edu/fswiki/canorm">canorm</a> </p></td> <td><p class="line862">brainmask.mgz </p></td> <td colspan="1" rowspan="3" style="text-align:left;"><p class="line891"><a class="https" href="https://surfer.nmr.mgh.harvard.edu/fswiki/mri_ca_normalize">mri_ca_normalize</a> -c ctrl_pts.mgz -mask brainmask.mgz nu.mgz $FREESURFER_HOME/average/RB_all_2016-05-10.vc700.gca transforms/talairach.lta norm.mgz </p></td> <td colspan="1" rowspan="3" style="text-align:left;"><p class="line862">norm.mgz </p></td> </tr> <tr> <td><span class="anchor" id="line-31"></span><p class="line862">nu.mgz </p></td> </tr> <tr> <td><span class="anchor" id="line-32"></span><p class="line862">transforms/talairach.lta </p></td> </tr> <tr> <td colspan="1" rowspan="3" style="text-align:left;"><span class="anchor" id="line-33"></span><p class="line862">-<a class="https" href="https://surfer.nmr.mgh.harvard.edu/fswiki/careg">careg</a> </p></td> <td><p class="line862">brainmask.mgz </p></td> <td colspan="1" rowspan="3" style="text-align:left;"><p class="line891"><a class="https" href="https://surfer.nmr.mgh.harvard.edu/fswiki/mri_ca_register">mri_ca_register</a> -align-after -nobigventricles -mask brainmask.mgz -T transforms/talairach.lta norm.mgz $FREESURFER_HOME/average/RB_all_2016-05-10.vc700.gca transforms/talairach.m3z </p></td> <td colspan="1" rowspan="3" style="text-align:left;"><p class="line862">transforms/talairach.m3z </p></td> </tr> <tr> <td><span class="anchor" id="line-34"></span><p class="line862">transforms/talairach.lta </p></td> </tr> <tr> <td><span class="anchor" id="line-35"></span><p class="line862">norm.mgz </p></td> </tr> <tr> <td colspan="1" rowspan="4" style="text-align:left;"><span class="anchor" id="line-36"></span><p class="line862">-<a class="https" href="https://surfer.nmr.mgh.harvard.edu/fswiki/calabel">calabel</a> </p></td> <td><p class="line862">norm.mgz </p></td> <td colspan="1" rowspan="2" style="text-align:left;"><p class="line891"><a class="https" href="https://surfer.nmr.mgh.harvard.edu/fswiki/mri_ca_label">mri_ca_label</a> -relabel_unlikely 9 .3 -prior 0.5 -align norm.mgz transforms/talairach.m3z $FREESURFER_HOME/average/RB_all_2016-05-10.vc700.gca aseg.auto_noCCseg.mgz </p></td> <td colspan="1" rowspan="2" style="text-align:left;"><p class="line862">aseg.auto_noCCseg.mgz </p></td> </tr> <tr> <td><span class="anchor" id="line-37"></span><p class="line862">transforms/talairach.m3z </p></td> </tr> <tr> <td><span class="anchor" id="line-38"></span><p class="line862">aseg.auto_noCCseg.mgz </p></td> <td colspan="1" rowspan="1" style="text-align:left;"><p class="line891"><a class="https" href="https://surfer.nmr.mgh.harvard.edu/fswiki/mri_cc">mri_cc</a> -lta &lt;subjid&gt;/mri/transforms/cc_up.lta -aseg aseg.auto_noCCseg.mgz -o aseg.auto.mgz &lt;subjid&gt; </p></td> <td><p class="line862">aseg.auto.mgz </p></td> </tr> <tr> <td><span class="anchor" id="line-39"></span><p class="line862">aseg.auto.mgz </p></td> <td><p class="line862">cp aseg.auto.mgz aseg.presurf.mgz </p></td> <td><p class="line862">aseg.presurf.mgz </p></td> </tr> <tr> <td colspan="1" rowspan="3" style="text-align:left;"><span class="anchor" id="line-40"></span><p class="line862">-<a class="https" href="https://surfer.nmr.mgh.harvard.edu/fswiki/normalization2">normalization2</a> </p></td> <td><p class="line862">brainmask.mgz </p></td> <td colspan="1" rowspan="3" style="text-align:left;"><p class="line891"><a class="https" href="https://surfer.nmr.mgh.harvard.edu/fswiki/mri_normalize">mri_normalize</a> -mprage -aseg aseg.presurf.mgz -mask brainmask.mgz norm.mgz brain.mgz </p></td> <td colspan="1" rowspan="3" style="text-align:left;"><p class="line862">brain.mgz </p></td> </tr> <tr> <td><span class="anchor" id="line-41"></span><p class="line862">norm.mgz </p></td> </tr> <tr> <td><span class="anchor" id="line-42"></span><p class="line862">aseg.presurf.mgz </p></td> </tr> <tr> <td colspan="1" rowspan="2" style="text-align:left;"><span class="anchor" id="line-43"></span><p class="line862">-<a class="https" href="https://surfer.nmr.mgh.harvard.edu/fswiki/maskbfs">maskbfs</a> </p></td> <td><p class="line862">brain.mgz </p></td> <td colspan="1" rowspan="2" style="text-align:left;"><p class="line891"><a class="https" href="https://surfer.nmr.mgh.harvard.edu/fswiki/mri_mask">mri_mask</a> -T 5 brain.mgz brainmask.mgz brain.finalsurfs.mgz </p></td> <td colspan="1" rowspan="2" style="text-align:left;"><p class="line862">brain.finalsurfs.mgz </p></td> </tr> <tr> <td><span class="anchor" id="line-44"></span><p class="line862">brainmask.mgz </p></td> </tr> <tr> <td colspan="1" rowspan="6" style="text-align:left;"><span class="anchor" id="line-45"></span><p class="line862">-<a class="https" href="https://surfer.nmr.mgh.harvard.edu/fswiki/segmentation">segmentation</a> </p></td> <td><p class="line862">brain.mgz </p></td> <td><p class="line891"><a class="https" href="https://surfer.nmr.mgh.harvard.edu/fswiki/mri_segment">mri_segment</a> -mprage brain.mgz wm.seg.mgz </p></td> <td><p class="line862">wm.seg.mgz </p></td> </tr> <tr> <td><span class="anchor" id="line-46"></span><p class="line862">wm.seg.mgz </p></td> <td colspan="1" rowspan="3" style="text-align:left;"><p class="line891"><a class="https" href="https://surfer.nmr.mgh.harvard.edu/fswiki/mri_edit_wm_with_aseg">mri_edit_wm_with_aseg</a> wm.seg.mgz brain.mgz aseg.presurf.mgz wm.asegedit.mgz </p></td> <td colspan="1" rowspan="3" style="text-align:left;"><p class="line862">wm.asegedit.mgz </p></td> </tr> <tr> <td><span class="anchor" id="line-47"></span><p class="line862">aseg.presurf.mgz </p></td> </tr> <tr> <td><span class="anchor" id="line-48"></span><p class="line862">brain.mgz </p></td> </tr> <tr> <td><span class="anchor" id="line-49"></span><p class="line862">wm.asegedit.mgz </p></td> <td colspan="1" rowspan="2" style="text-align:left;"><p class="line891"><a class="https" href="https://surfer.nmr.mgh.harvard.edu/fswiki/mri_pretess">mri_pretess</a> wm.asegedit.mgz wm norm.mgz wm.mgz </p></td> <td colspan="1" rowspan="2" style="text-align:left;"><p class="line862">wm.mgz </p></td> </tr> <tr> <td><span class="anchor" id="line-50"></span><p class="line862">norm.mgz </p></td> </tr> <tr> <td colspan="1" rowspan="3" style="text-align:left;"><span class="anchor" id="line-51"></span><p class="line862">-<a class="https" href="https://surfer.nmr.mgh.harvard.edu/fswiki/fill">fill</a> </p></td> <td><p class="line862">wm.mgz </p></td> <td colspan="1" rowspan="3" style="text-align:left;"><p class="line891"><a class="https" href="https://surfer.nmr.mgh.harvard.edu/fswiki/mri_fill">mri_fill</a> -a ../scripts/ponscc.cut.log -xform transforms/talairach.lta -segmentation aseg.auto_noCCseg.mgz wm.mgz filled.mgz </p></td> <td><p class="line862">filled.mgz </p></td> </tr> <tr> <td><span class="anchor" id="line-52"></span><p class="line862">aseg.auto_noCCseg.mgz </p></td> <td colspan="1" rowspan="2" style="text-align:left;"><p class="line862">../scripts/ponscc.cut.log </p></td> </tr> <tr> <td><span class="anchor" id="line-53"></span><p class="line862">transforms/talairach.lta </p></td> </tr> <tr> <td colspan="1" rowspan="8" style="text-align:left;"><span class="anchor" id="line-54"></span><p class="line862">-<a class="https" href="https://surfer.nmr.mgh.harvard.edu/fswiki/tessellate">tessellate</a> </p></td> <td><p class="line862">filled.mgz </p></td> <td colspan="1" rowspan="2" style="text-align:left;"><p class="line891"><a class="https" href="https://surfer.nmr.mgh.harvard.edu/fswiki/mri_pretess">mri_pretess</a> filled.mgz 255 norm.mgz filled-pretess255.mgz </p></td> <td colspan="1" rowspan="2" style="text-align:left;"><p class="line862">filled-pretess255.mgz </p></td> </tr> <tr> <td><span class="anchor" id="line-55"></span><p class="line862">norm.mgz </p></td> </tr> <tr> <td><span class="anchor" id="line-56"></span><p class="line862">filled-pretess255.mgz </p></td> <td><p class="line891"><a class="https" href="https://surfer.nmr.mgh.harvard.edu/fswiki/mri_tessellate">mri_tessellate</a> filled-pretess255.mgz 255 lh.orig.nofix </p></td> <td><p class="line862">lh.orig.nofix </p></td> </tr> <tr> <td><span class="anchor" id="line-57"></span><p class="line862">filled.mgz </p></td> <td colspan="1" rowspan="2" style="text-align:left;"><p class="line891"><a class="https" href="https://surfer.nmr.mgh.harvard.edu/fswiki/mri_pretess">mri_pretess</a> filled.mgz 127 norm.mgz filled-pretess127.mgz </p></td> <td colspan="1" rowspan="2" style="text-align:left;"><p class="line862">filled-pretess127.mgz </p></td> </tr> <tr> <td><span class="anchor" id="line-58"></span><p class="line862">norm.mgz </p></td> </tr> <tr> <td><span class="anchor" id="line-59"></span><p class="line862">filled-pretess127.mgz </p></td> <td><p class="line891"><a class="https" href="https://surfer.nmr.mgh.harvard.edu/fswiki/mri_tessellate">mri_tessellate</a> filled-pretess127.mgz 127 rh.orig.nofix </p></td> <td><p class="line862">rh.orig.nofix </p></td> </tr> <tr> <td><span class="anchor" id="line-60"></span><p class="line862">?h.orig.nofix </p></td> <td><p class="line862">mris_extract_main_component ?h.orig.nofix ?h.orig.nofix </p></td> <td><p class="line862">?h.orig.nofix </p></td> </tr> <tr> <td><span class="anchor" id="line-61"></span><p class="line862"> </p></td> <td><p class="line862">rm -f filled-pretess255.mgz filled-pretess127.mgz </p></td> <td><p class="line862"> </p></td> </tr> <tr> <td><span class="anchor" id="line-62"></span><p class="line862">-<a class="https" href="https://surfer.nmr.mgh.harvard.edu/fswiki/smooth">smooth1</a> </p></td> <td><p class="line862">?h.orig.nofix </p></td> <td><p class="line891"><a class="https" href="https://surfer.nmr.mgh.harvard.edu/fswiki/mris_smooth">mris_smooth</a> -nw ?h.orig.nofix ?h.smoothwm.nofix </p></td> <td><p class="line862">?h.smoothwm.nofix </p></td> </tr> <tr> <td><span class="anchor" id="line-63"></span><p class="line862">-<a class="https" href="https://surfer.nmr.mgh.harvard.edu/fswiki/inflate">inflate1</a> </p></td> <td><p class="line862">?h.smoothwm.nofix </p></td> <td><p class="line891"><a class="https" href="https://surfer.nmr.mgh.harvard.edu/fswiki/mris_inflate">mris_inflate</a> -no-save-sulc ?h.smoothwm.nofix ?h.inflated.nofix </p></td> <td><p class="line862">?h.inflated.nofix </p></td> </tr> <tr> <td><span class="anchor" id="line-64"></span><p class="line862">-<a class="https" href="https://surfer.nmr.mgh.harvard.edu/fswiki/qsphere">qsphere</a> </p></td> <td><p class="line862">?h.inflated.nofix </p></td> <td><p class="line891"><a class="https" href="https://surfer.nmr.mgh.harvard.edu/fswiki/mris_sphere">mris_sphere</a> -q ?h.inflated.nofix ?h.qsphere.nofix </p></td> <td><p class="line862">?h.qsphere.nofix </p></td> </tr> <tr> <td colspan="1" rowspan="6" style="text-align:left;"><span class="anchor" id="line-65"></span><p class="line862">-<a class="https" href="https://surfer.nmr.mgh.harvard.edu/fswiki/fix">fix</a> </p></td> <td><p class="line862">?h.orig.nofix </p></td> <td><p class="line862">cp ?h.orig.nofix ?h.orig </p></td> <td><p class="line862">?h.orig </p></td> </tr> <tr> <td><span class="anchor" id="line-66"></span><p class="line862">?h.inflated.nofix </p></td> <td><p class="line862">cp ?h.inflated.nofix ?h.inflated </p></td> <td><p class="line862">?h.inflated </p></td> </tr> <tr> <td><span class="anchor" id="line-67"></span><p class="line862">?h.qsphere.nofix </p></td> <td><p class="line891"><a class="https" href="https://surfer.nmr.mgh.harvard.edu/fswiki/mris_fix_topology">mris_fix_topology</a> -mgz -sphere qsphere.nofix -ga &lt;subjid&gt; ?h </p></td> <td><p class="line862">?h.orig </p></td> </tr> <tr> <td><span class="anchor" id="line-68"></span><p class="line862">?h.orig </p></td> <td><p class="line891"><a class="https" href="https://surfer.nmr.mgh.harvard.edu/fswiki/mris_euler_number">mris_euler_number</a> ?h.orig </p></td> <td><p class="line862">?h.orig </p></td> </tr> <tr> <td><span class="anchor" id="line-69"></span><p class="line862">?h.orig </p></td> <td><p class="line862">mris_remove_intersection ?h.orig ?h.orig </p></td> <td><p class="line862">?h.orig </p></td> </tr> <tr> <td><span class="anchor" id="line-70"></span><p class="line862"> </p></td> <td><p class="line862">rm ?h.inflated </p></td> <td><p class="line862"> </p></td> </tr> <tr> <td colspan="1" rowspan="8" style="text-align:left;"><span class="anchor" id="line-71"></span><p class="line862">-white </p></td> <td colspan="1" rowspan="1" style="text-align:left;"><p class="line862">aseg.presurf.mgz </p></td> <td colspan="1" rowspan="8" style="text-align:left;"><p class="line891"><a class="https" href="https://surfer.nmr.mgh.harvard.edu/fswiki/mris_make_surfaces">mris_make_surfaces</a> -aseg ../mri/aseg.presurf -whiteonly -noaparc -mgz -T1 brain.finalsurfs &lt;subjid&gt; ?h </p></td> <td colspan="1" rowspan="4" style="text-align:left"><p class="line862">?h.white.preaparc </p></td> </tr> <tr> <td style="text-align:left"><span class="anchor" id="line-72"></span><p class="line862">brain.finalsurfs.mgz </p></td> </tr> <tr> <td style="text-align:left"><span class="anchor" id="line-73"></span><p class="line862">wm.mgz </p></td> </tr> <tr> <td style="text-align:left"><span class="anchor" id="line-74"></span><p class="line862">filled.mgz </p></td> </tr> <tr> <td colspan="1" rowspan="4" style="text-align:left;"><span class="anchor" id="line-75"></span><p class="line862">?h.orig </p></td> </tr> <tr> <td><span class="anchor" id="line-76"></span><p class="line862">?h.curv </p></td> </tr> <tr> <td><span class="anchor" id="line-77"></span><p class="line862">?h.area </p></td> </tr> <tr> <td><span class="anchor" id="line-78"></span><p class="line862">?h.cortex.label </p></td> </tr> <tr> <td><span class="anchor" id="line-79"></span><p class="line862">-<a class="https" href="https://surfer.nmr.mgh.harvard.edu/fswiki/smooth">smooth2</a> </p></td> <td><p class="line862">?h.white.preaparc </p></td> <td><p class="line891"><a class="https" href="https://surfer.nmr.mgh.harvard.edu/fswiki/mris_smooth">mris_smooth</a> -n 3 -nw ?h.white.preaparc ?h.smoothwm </p></td> <td><p class="line862">?h.smoothwm </p></td> </tr> <tr> <td colspan="1" rowspan="2" style="text-align:left"><span class="anchor" id="line-80"></span><p class="line862">-<a class="https" href="https://surfer.nmr.mgh.harvard.edu/fswiki/inflate">inflate2</a> </p></td> <td colspan="1" rowspan="2" style="text-align:left"><p class="line862">?h.smoothwm </p></td> <td colspan="1" rowspan="2" style="text-align:left"><p class="line891"><a class="https" href="https://surfer.nmr.mgh.harvard.edu/fswiki/mris_inflate">mris_inflate</a> ?h.smoothwm ?h.inflated </p></td> <td><p class="line862">?h.inflated </p></td> </tr> <tr> <td><span class="anchor" id="line-81"></span><p class="line862">?h.sulc </p></td> </tr> <tr> <td colspan="1" rowspan="4" style="text-align:left"><span class="anchor" id="line-82"></span><p class="line862">-curvHK </p></td> <td colspan="1" rowspan="2" style="text-align:left"><p class="line862">?h.white.preaparc </p></td> <td colspan="1" rowspan="2" style="text-align:left"><p class="line891"><a class="https" href="https://surfer.nmr.mgh.harvard.edu/fswiki/mris_curvature">mris_curvature</a> -w ?h.white.preaparc </p></td> <td colspan="1" rowspan="1" style="text-align:left"><p class="line862">?h.white.H </p></td> </tr> <tr> <td><span class="anchor" id="line-83"></span><p class="line862">?h.white.K </p></td> </tr> <tr> <td colspan="1" rowspan="2" style="text-align:left"><span class="anchor" id="line-84"></span><p class="line862">?h.inflated </p></td> <td colspan="1" rowspan="2" style="text-align:left"><p class="line891"><a class="https" href="https://surfer.nmr.mgh.harvard.edu/fswiki/mris_curvature">mris_curvature</a> -thresh .999 -n -a 5 -w -distances 10 10 ?h.inflated </p></td> <td colspan="1" rowspan="1" style="text-align:left"><p class="line862">?h.inflated.H </p></td> </tr> <tr> <td><span class="anchor" id="line-85"></span><p class="line862">?h.inflated.K </p></td> </tr> <tr> <td colspan="1" rowspan="3" style="text-align:left"><span class="anchor" id="line-86"></span><p class="line862">-curvstats </p></td> <td style="text-align:left"><p class="line862">?h.smoothwm </p></td> <td colspan="1" rowspan="3" style="text-align:left"><p class="line862">mris_curvature_stats -m --writeCurvatureFiles -G -o ../stats/?h.curv.stats -F smoothwm &lt;subjid&gt; ?h curv sulc </p></td> <td colspan="1" rowspan="3" style="text-align:left"><p class="line862">stats/?h.curv.stats </p></td> </tr> <tr> <td style="text-align:left"><span class="anchor" id="line-87"></span><p class="line862">?h.curv </p></td> </tr> <tr> <td style="text-align:left"><span class="anchor" id="line-88"></span><p class="line862">?h.sulc </p></td> </tr> </tbody></table> Running: ```shell cat subject_list | parallel recon-all -s {} -autorecon2 ``` :::info **Step 2 completed expect** 3002_3 2014_3 Logfile at /data/huze/Fs.subjects/<subject_id>/scripts/recon-all.log ::: #### Step 3 `MAY` Troubleshooting, check if there were failures in each model, and run the repair command ```shell cat subject_list | parallel recon-all -s {} -autorecon2-wm/-autorecon2-cp/-autorecon2-pial ``` :::info **Step 3 skipped** ::: #### Step 4 `OPTIONAL` `RUNNING` run `recon-all -autorecon3` at subjects to calculate the features autorecon3 includes: >Spherical Mapping Spherical Registration Spherical Registration, Contralateral hemisphere Map average curvature to subject Cortical Parcellation - Desikan_Killiany and Christophe (Labeling) Cortical Parcellation Statistics Cortical Ribbon Mask Cortical Parcellation mapping to Aseg <table style="text-align:left; ; text-align:left"><tbody><tr> <td><p class="line891"><strong>recon-all step</strong> </p></td> <td><p class="line891"><strong>Individual Flag</strong> </p></td> <td><p class="line891"><strong>Input</strong> </p></td> <td><p class="line891"><strong>Command Line</strong> </p></td> <td><p class="line891"><strong>Output</strong> </p></td> </tr> <tr> <td colspan="1" rowspan="85" style="text-align:left;"><span class="anchor" id="line-92"></span><p class="line891"><strong><a class="https" href="https://surfer.nmr.mgh.harvard.edu/fswiki/recon-all">recon-all</a> -autorecon3 -subjid &lt;subjid&gt;</strong> </p></td> </tr> <tr> <td colspan="1" rowspan="2" style="text-align:left"><span class="anchor" id="line-93"></span><p class="line862">-<a class="https" href="https://surfer.nmr.mgh.harvard.edu/fswiki/sphere">sphere</a> </p></td> <td><p class="line862">?h.inflated </p></td> <td colspan="1" rowspan="2" style="text-align:left"><p class="line891"><a class="https" href="https://surfer.nmr.mgh.harvard.edu/fswiki/mris_sphere">mris_sphere</a> ?h.inflated ?h.sphere </p></td> <td colspan="1" rowspan="2" style="text-align:left"><p class="line862">?h.sphere </p></td> </tr> <tr> <td style="text-align:left"><span class="anchor" id="line-94"></span><p class="line862">?h.smoothwm </p></td> </tr> <tr> <td><span class="anchor" id="line-95"></span><p class="line862">-<a class="https" href="https://surfer.nmr.mgh.harvard.edu/fswiki/surfreg">surfreg</a> </p></td> <td><p class="line862">?h.sphere </p></td> <td><p class="line891"><a class="https" href="https://surfer.nmr.mgh.harvard.edu/fswiki/mris_register">mris_register</a> -curv ?h.sphere $FREESURFER_HOME/average/?h.folding.atlas.acfb40.noaparc.i12.2016-08-02.tif ?h.sphere.reg </p></td> <td><p class="line862">?h.sphere.reg </p></td> </tr> <tr> <td colspan="1" rowspan="2" style="text-align:left;"><span class="anchor" id="line-96"></span><p class="line862">-<a class="https" href="https://surfer.nmr.mgh.harvard.edu/fswiki/jacobian_white">jacobian_white</a> </p></td> <td><p class="line862">?h.white.preaparc </p></td> <td colspan="1" rowspan="2" style="text-align:left;"><p class="line891"><a class="https" href="https://surfer.nmr.mgh.harvard.edu/fswiki/mris_jacobian">mris_jacobian</a> ?h.white.preaparc ?h.sphere.reg ?h.jacobian_white </p></td> <td colspan="1" rowspan="2" style="text-align:left;"><p class="line862">?h.jacobian_white </p></td> </tr> <tr> <td><span class="anchor" id="line-97"></span><p class="line862">?h.sphere.reg </p></td> </tr> <tr> <td><span class="anchor" id="line-98"></span><p class="line862">-<a class="https" href="https://surfer.nmr.mgh.harvard.edu/fswiki/avgcurv">avgcurv</a> </p></td> <td><p class="line862">?h.sphere.reg </p></td> <td><p class="line891"><a class="https" href="https://surfer.nmr.mgh.harvard.edu/fswiki/mrisp_paint">mrisp_paint</a> -a 5 $FREESURFER_HOME/average/?h.folding.atlas.acfb40.noaparc.i12.2016-08-02.tif#6 ?h.sphere.reg ?h.avg_curv </p></td> <td><p class="line862">?h.avg_curv </p></td> </tr> <tr> <td colspan="1" rowspan="3" style="text-align:left;"><span class="anchor" id="line-99"></span><p class="line862">-<a class="https" href="https://surfer.nmr.mgh.harvard.edu/fswiki/cortparc">cortparc</a> </p></td> <td><p class="line862">aseg.presurf.mgz </p></td> <td colspan="1" rowspan="3" style="text-align:left;"><p class="line891"><a class="https" href="https://surfer.nmr.mgh.harvard.edu/fswiki/mris_ca_label">mris_ca_label</a> -l ../label/?h.cortex.label -aseg mri/aseg.presurf.mgz &lt;subjid&gt; ?h ?h.sphere.reg $FREESURFER_HOME/average/?h.curvature.buckner40.filled.desikan_killiany.2007-06-20.gcs ?h.aparc.annot </p></td> <td colspan="1" rowspan="3" style="text-align:left;"><p class="line862">label/?h.aparc.annot </p></td> </tr> <tr> <td style="text-align:left"><span class="anchor" id="line-100"></span><p class="line862">?h.cortex.label </p></td> </tr> <tr> <td><span class="anchor" id="line-101"></span><p class="line862">?h.sphere.reg </p></td> </tr> <tr> <td colspan="1" rowspan="8" style="text-align:left;"><span class="anchor" id="line-102"></span><p class="line862">-pial </p></td> <td colspan="1" rowspan="1" style="text-align:left;"><p class="line862">aseg.presurf.mgz </p></td> <td colspan="1" rowspan="8" style="text-align:left;"><p class="line891"><a class="https" href="https://surfer.nmr.mgh.harvard.edu/fswiki/mris_make_surfaces">mris_make_surfaces</a> -orig_white white.preaparc -orig_pial white.preaparc -aseg ../mri/aseg.presurf -mgz -T1 brain.finalsurfs &lt;subjid&gt; ?h </p></td> <td colspan="1" rowspan="4" style="text-align:left"><p class="line862">?h.pial </p></td> </tr> <tr> <td><span class="anchor" id="line-103"></span><p class="line862">brain.finalsurfs.mgz </p></td> </tr> <tr> <td><span class="anchor" id="line-104"></span><p class="line862">wm.mgz </p></td> </tr> <tr> <td><span class="anchor" id="line-105"></span><p class="line862">filled.mgz </p></td> </tr> <tr> <td colspan="1" rowspan="3" style="text-align:left;"><span class="anchor" id="line-106"></span><p class="line862">?h.orig </p></td> </tr> <tr> <td><span class="anchor" id="line-107"></span><p class="line862">?h.curv.pial </p></td> </tr> <tr> <td style="text-align:left"><span class="anchor" id="line-108"></span><p class="line862">?h.area.pial </p></td> </tr> <tr> <td colspan="1" rowspan="1" style="text-align:left"><span class="anchor" id="line-109"></span><p class="line862">label/?h.aparc.annot </p></td> <td><p class="line862">?h.thickness </p></td> </tr> <tr> <td colspan="1" rowspan="17" style="text-align:left;"><span class="anchor" id="line-110"></span><p class="line862">-T2pial <em>or</em> <br> -FLAIRpial <em>optional</em> </p></td> <td><p class="line862">orig/T2raw.mgz </p></td> <td><p class="line862">bbregister --s &lt;subjid&gt; --mov mri/orig/T2raw.mgz --lta mri/transforms/T2raw.lta --init-fsl --T2 </p></td> <td><p class="line862">transforms/T2raw.lta </p></td> </tr> <tr> <td><span class="anchor" id="line-111"></span><p class="line862">orig/T2raw.mgz </p></td> <td colspan="1" rowspan="2" style="text-align:left"><p class="line862">mri_convert -odt float -at mri/transforms/T2raw.lta -rt cubic -ns 1 -rl mri/orig.mgz mri/orig/T2raw.mgz mri/T2.prenorm.mgz </p></td> <td colspan="1" rowspan="2" style="text-align:left"><p class="line862">T2.prenorm.mgz </p></td> </tr> <tr> <td><span class="anchor" id="line-112"></span><p class="line862">transforms/T2raw.lta </p></td> </tr> <tr> <td><span class="anchor" id="line-113"></span><p class="line862">aseg.presurf.mgz </p></td> <td colspan="1" rowspan="3" style="text-align:left"><p class="line862">mri_normalize -sigma 0.5 -nonmax_suppress 0 -min_dist 1 -aseg mri/aseg.presurf.mgz -surface surf/rh.white identity.nofile -surface surf/lh.white identity.nofile mri/T2.prenorm.mgz mri/T2.norm.mgz </p></td> <td colspan="1" rowspan="3" style="text-align:left"><p class="line862">T2.norm.mgz </p></td> </tr> <tr> <td><span class="anchor" id="line-114"></span><p class="line862">?h.white </p></td> </tr> <tr> <td><span class="anchor" id="line-115"></span><p class="line862">T2.prenorm.mgz </p></td> </tr> <tr> <td><span class="anchor" id="line-116"></span><p class="line862">T2.norm.mgz </p></td> <td colspan="1" rowspan="2" style="text-align:center"><p class="line862">mri_mask mri/T2.norm.mgz mri/brainmask.mgz mri/T2.mgz </p></td> <td colspan="1" rowspan="2" style="text-align:center"><p class="line862">T2.mgz </p></td> </tr> <tr> <td><span class="anchor" id="line-117"></span><p class="line862">brainmask.mgz </p></td> </tr> <tr> <td><span class="anchor" id="line-118"></span><p class="line862">?h.pial </p></td> <td><p class="line862">cp -v surf/?h.pial surf/?h.woT2.pial </p></td> <td><p class="line862">?h.woT2.pial </p></td> </tr> <tr> <td><span class="anchor" id="line-119"></span><p class="line862">aseg.presurf.mgz </p></td> <td colspan="1" rowspan="9" style="text-align:left"><p class="line891"><a href="/fswiki/mris_make_surfaces">mris_make_surfaces</a> -orig_white white -orig_pial woT2.pial -aseg ../mri/aseg.presurf -nowhite -mgz -T1 brain.finalsurfs -T2 ../mri/T2 -nsigma_above 2 -nsigma_below 5 &lt;subjid&gt; ?h </p></td> <td colspan="1" rowspan="3" style="text-align:left"><p class="line862">?h.pial </p></td> </tr> <tr> <td><span class="anchor" id="line-120"></span><p class="line862">brain.finalsurfs.mgz </p></td> </tr> <tr> <td><span class="anchor" id="line-121"></span><p class="line862">wm.mgz </p></td> </tr> <tr> <td><span class="anchor" id="line-122"></span><p class="line862">filled.mgz </p></td> <td colspan="1" rowspan="2" style="text-align:left"><p class="line862">?h.curv.pial </p></td> </tr> <tr> <td><span class="anchor" id="line-123"></span><p class="line862">?h.white </p></td> </tr> <tr> <td colspan="1" rowspan="1" style="text-align:left"><span class="anchor" id="line-124"></span><p class="line862">label/?h.aparc.annot </p></td> <td colspan="1" rowspan="1" style="text-align:left"><p class="line862">?h.area.pial </p></td> </tr> <tr> <td colspan="1" rowspan="1" style="text-align:left"><span class="anchor" id="line-125"></span><p class="line862">T2.mgz </p></td> <td colspan="1" rowspan="3" style="text-align:left"><p class="line862">?h.thickness </p></td> </tr> <tr> <td><span class="anchor" id="line-126"></span><p class="line862">?h.woT2.pial </p></td> </tr> <tr> <td><span class="anchor" id="line-127"></span><p class="line862"> </p></td> </tr> <tr> <td colspan="1" rowspan="3" style="text-align:left;"><span class="anchor" id="line-128"></span><p class="line862">-<a class="https" href="https://surfer.nmr.mgh.harvard.edu/fswiki/cortribbon">cortribbon</a> </p></td> <td><p class="line862">aseg.presurf.mgz </p></td> <td colspan="1" rowspan="3" style="text-align:left"><p class="line891"><a class="https" href="https://surfer.nmr.mgh.harvard.edu/fswiki/mris_volmask">mris_volmask</a> --aseg_name aseg.presurf --label_left_white 2 --label_left_ribbon 3 --label_right_white 41 --label_right_ribbon 42 --save_ribbon &lt;subjid&gt; </p></td> <td colspan="1" rowspan="2" style="text-align:left;"><p class="line862">?h.ribbon.mgz </p></td> </tr> <tr> <td><span class="anchor" id="line-129"></span><p class="line862">?h.white </p></td> </tr> <tr> <td><span class="anchor" id="line-130"></span><p class="line862">?h.pial </p></td> <td colspan="1" rowspan="1" style="text-align:left"><p class="line862">ribbon.mgz </p></td> </tr> <tr> <td colspan="1" rowspan="5" style="text-align:left"><span class="anchor" id="line-131"></span><p class="line862">-<a class="https" href="https://surfer.nmr.mgh.harvard.edu/fswiki/parcstats">parcstats</a> </p></td> <td colspan="1" rowspan="1" style="text-align:left"><p class="line862">label/?h.aparc.annot </p></td> <td colspan="1" rowspan="5" style="text-align:left"><p class="line891"><a class="https" href="https://surfer.nmr.mgh.harvard.edu/fswiki/mris_anatomical_stats">mris_anatomical_stats</a> -th3 -mgz -cortex ../label/?h.cortex.label -f stats/?h.aparc.stats -b -a label/?h.aparc.annot -c label/aparc.annot.ctab &lt;subjid&gt; ?h &lt;white or pial&gt; </p></td> <td><p class="line862">stats/?h.aparc.stats </p></td> </tr> <tr> <td colspan="1" rowspan="1" style="text-align:left"><span class="anchor" id="line-132"></span><p class="line862">wm.mgz, ribbon.mgz </p></td> <td colspan="1" rowspan="4" style="text-align:left"><p class="line862">label/aparc.annot.ctab </p></td> </tr> <tr> <td><span class="anchor" id="line-133"></span><p class="line862">?h.white </p></td> </tr> <tr> <td><span class="anchor" id="line-134"></span><p class="line862">?h.pial </p></td> </tr> <tr> <td><span class="anchor" id="line-135"></span><p class="line862">?h.thickness </p></td> </tr> <tr> <td colspan="1" rowspan="3" style="text-align:left;"><span class="anchor" id="line-136"></span><p class="line862">-<a class="https" href="https://surfer.nmr.mgh.harvard.edu/fswiki/cortparc">cortparc2</a> </p></td> <td><p class="line862">aseg.presurf.mgz </p></td> <td colspan="1" rowspan="3" style="text-align:left;"><p class="line891"><a class="https" href="https://surfer.nmr.mgh.harvard.edu/fswiki/mris_ca_label">mris_ca_label</a> -l ../label/?h.cortex.label -aseg aseg.presurf.mgz &lt;subjid&gt; ?h ?h.sphere.reg $FREESURFER_HOME/average/?h.destrieux.simple.2009-07-29.gcs label/?h.aparc.a2009s.annot </p></td> <td colspan="1" rowspan="3" style="text-align:left;"><p class="line862">label/?h.aparc.a2009s.annot </p></td> </tr> <tr> <td><span class="anchor" id="line-137"></span><p class="line862">?h.sphere.reg </p></td> </tr> <tr> <td><span class="anchor" id="line-138"></span><p class="line862">label/?h.cortex.label </p></td> </tr> <tr> <td colspan="1" rowspan="5" style="text-align:left"><span class="anchor" id="line-139"></span><p class="line862">-<a class="https" href="https://surfer.nmr.mgh.harvard.edu/fswiki/parcstats">parcstats2</a> </p></td> <td colspan="1" rowspan="1" style="text-align:left"><p class="line862">label/?h.aparc.a2009s.annot </p></td> <td colspan="1" rowspan="5" style="text-align:left"><p class="line891"><a class="https" href="https://surfer.nmr.mgh.harvard.edu/fswiki/mris_anatomical_stats">mris_anatomical_stats</a> -th3 -mgz -cortex ../label/?h.cortex.label -f stats/?h.aparc.a2009s.stats -b -a label/?h.aparc.a2009s.annot -c label/aparc.annot.a2009s.ctab &lt;subjid&gt; ?h </p></td> <td><p class="line862">stats/?h.aparc.a2009s.stats </p></td> </tr> <tr> <td colspan="1" rowspan="1" style="text-align:left"><span class="anchor" id="line-140"></span><p class="line862">wm.mgz, ribbon.mgz </p></td> <td colspan="1" rowspan="4" style="text-align:left"><p class="line862">label/aparc.annot.a2009s.ctab </p></td> </tr> <tr> <td><span class="anchor" id="line-141"></span><p class="line862">?h.white </p></td> </tr> <tr> <td><span class="anchor" id="line-142"></span><p class="line862">?h.pial </p></td> </tr> <tr> <td><span class="anchor" id="line-143"></span><p class="line862">?h.thickness </p></td> </tr> <tr> <td colspan="1" rowspan="3" style="text-align:left;"><span class="anchor" id="line-144"></span><p class="line862">-<a class="https" href="https://surfer.nmr.mgh.harvard.edu/fswiki/cortparc">cortparc3</a> </p></td> <td><p class="line862">aseg.presurf.mgz </p></td> <td colspan="1" rowspan="3" style="text-align:left;"><p class="line891"><a class="https" href="https://surfer.nmr.mgh.harvard.edu/fswiki/mris_ca_label">mris_ca_label</a> -l ../label/?h.cortex.label -aseg aseg.presurf.mgz &lt;subjid&gt; ?h ?h.sphere.reg $FREESURFER_HOME/average/?h.DKTatlas.2016-03-20.gcs ../label/?h.aparc.DKTatlas.annot </p></td> <td colspan="1" rowspan="3" style="text-align:left;"><p class="line862">label/?h.aparc.DKTatlas.annot </p></td> </tr> <tr> <td><span class="anchor" id="line-145"></span><p class="line862">?h.sphere.reg </p></td> </tr> <tr> <td><span class="anchor" id="line-146"></span><p class="line862">label/?h.cortex.label </p></td> </tr> <tr> <td colspan="1" rowspan="5" style="text-align:left"><span class="anchor" id="line-147"></span><p class="line862">-<a class="https" href="https://surfer.nmr.mgh.harvard.edu/fswiki/parcstats">parcstats3</a> </p></td> <td colspan="1" rowspan="1" style="text-align:left"><p class="line862">label/?h.aparc.DKTatlas.annot </p></td> <td colspan="1" rowspan="5" style="text-align:left"><p class="line891"><a class="https" href="https://surfer.nmr.mgh.harvard.edu/fswiki/mris_anatomical_stats">mris_anatomical_stats</a> -th3 -mgz -cortex ../label/?h.cortex.label -f stats/?h.aparc.DKTatlas.stats -b -a label/?h.aparc.DKTatlas.annot -c label/aparc.annot.DKTatlas.ctab &lt;subjid&gt; ?h </p></td> <td><p class="line862">stats/?h.aparc.DKTatlas.stats </p></td> </tr> <tr> <td colspan="1" rowspan="1" style="text-align:left"><span class="anchor" id="line-148"></span><p class="line862">wm.mgz, ribbon.mgz </p></td> <td colspan="1" rowspan="4" style="text-align:left"><p class="line862">label/aparc.annot.DKTatlas.ctab </p></td> </tr> <tr> <td><span class="anchor" id="line-149"></span><p class="line862">?h.white </p></td> </tr> <tr> <td><span class="anchor" id="line-150"></span><p class="line862">?h.pial </p></td> </tr> <tr> <td><span class="anchor" id="line-151"></span><p class="line862">?h.thickness </p></td> </tr> <tr> <td colspan="1" rowspan="4" style="text-align:left;"><span class="anchor" id="line-152"></span><p class="line862">-pctsurfcon </p></td> <td><p class="line862">rawavg.mgz </p></td> <td colspan="1" rowspan="4" style="text-align:left;"><p class="line862">pctsurfcon --s &lt;subjid&gt; --?h-only </p></td> <td colspan="1" rowspan="2" style="text-align:left;"><p class="line862">?h.w-g.pct.mgh </p></td> </tr> <tr> <td><span class="anchor" id="line-153"></span><p class="line862">orig.mgz </p></td> </tr> <tr> <td><span class="anchor" id="line-154"></span><p class="line862">?h.cortex.label </p></td> <td colspan="1" rowspan="2" style="text-align:left"><p class="line862">stats/?h.w-g.pct.stats </p></td> </tr> <tr> <td><span class="anchor" id="line-155"></span><p class="line862">?h.white </p></td> </tr> <tr> <td colspan="1" rowspan="2" style="text-align:left"><span class="anchor" id="line-156"></span><p class="line862">-hyporelabel </p></td> <td colspan="1" rowspan="1" style="text-align:left"><p class="line862">aseg.presurf.mgz </p></td> <td colspan="1" rowspan="2" style="text-align:left"><p class="line862">mri_relabel_hypointensities aseg.presurf.mgz ../surf aseg.presurf.hypos.mgz </p></td> <td colspan="1" rowspan="2" style="text-align:left"><p class="line862">aseg.presurf.hypos.mgz </p></td> </tr> <tr> <td><span class="anchor" id="line-157"></span><p class="line862">?h.white </p></td> </tr> <tr> <td colspan="1" rowspan="12" style="text-align:left;"><span class="anchor" id="line-158"></span><p class="line862">-<a class="https" href="https://surfer.nmr.mgh.harvard.edu/fswiki/aparc2aseg">aparc2aseg</a> </p></td> <td><p class="line862">aseg.presurf.hypos.mgz </p></td> <td colspan="1" rowspan="4" style="text-align:left;"><p class="line891"><a class="https" href="https://surfer.nmr.mgh.harvard.edu/fswiki/mri_aparc2aseg">mri_aparc2aseg</a> --s &lt;subjid&gt; --volmask --aseg aseg.presurf.hypos --relabel mri/norm.mgz mri/transforms/talairach.m3z $FREESURFER_HOME/average/RB_all_2016-05-10.vc700.gca mri/aseg.auto_noCCseg.label_intensities.txt </p></td> <td colspan="1" rowspan="4" style="text-align:left;"><p class="line862">aparc+aseg.mgz </p></td> </tr> <tr> <td><span class="anchor" id="line-159"></span><p class="line862">?h.ribbon.mgz </p></td> </tr> <tr> <td><span class="anchor" id="line-160"></span><p class="line862">label/?h.aparc.annot </p></td> </tr> <tr> <td style="text-align:left"><span class="anchor" id="line-161"></span><p class="line862">ribbon.mgz </p></td> </tr> <tr> <td><span class="anchor" id="line-162"></span><p class="line862">aseg.presurf.hypos.mgz </p></td> <td colspan="1" rowspan="4" style="text-align:left;"><p class="line891"><a class="https" href="https://surfer.nmr.mgh.harvard.edu/fswiki/mri_aparc2aseg">mri_aparc2aseg</a> --s &lt;subjid&gt; --volmask --annot aparc.a2009s --aseg aseg.presurf.hypos --relabel mri/norm.mgz mri/transforms/talairach.m3z $FREESURFER_HOME/average/RB_all_2016-05-10.vc700.gca mri/aseg.auto_noCCseg.label_intensities.txt </p></td> <td colspan="1" rowspan="4" style="text-align:left;"><p class="line862">aparc.a2009s+aseg.mgz </p></td> </tr> <tr> <td><span class="anchor" id="line-163"></span><p class="line862">?h.ribbon.mgz </p></td> </tr> <tr> <td><span class="anchor" id="line-164"></span><p class="line862">label/?h.aparc.a2009s.annot </p></td> </tr> <tr> <td style="text-align:left"><span class="anchor" id="line-165"></span><p class="line862">ribbon.mgz </p></td> </tr> <tr> <td><span class="anchor" id="line-166"></span><p class="line862">aseg.presurf.hypos.mgz </p></td> <td colspan="1" rowspan="4" style="text-align:left;"><p class="line891"><a class="https" href="https://surfer.nmr.mgh.harvard.edu/fswiki/mri_aparc2aseg">mri_aparc2aseg</a> --s &lt;subjid&gt; --volmask --annot aparc.DKTatlas --aseg aseg.presurf.hypos --relabel mri/norm.mgz mri/transforms/talairach.m3z $FREESURFER_HOME/average/RB_all_2016-05-10.vc700.gca mri/aseg.auto_noCCseg.label_intensities.txt </p></td> <td colspan="1" rowspan="4" style="text-align:left;"><p class="line862">aparc.DKTatlas+aseg.mgz </p></td> </tr> <tr> <td><span class="anchor" id="line-167"></span><p class="line862">?h.ribbon.mgz </p></td> </tr> <tr> <td><span class="anchor" id="line-168"></span><p class="line862">label/?h.aparc.DKTatlas.annot </p></td> </tr> <tr> <td style="text-align:left"><span class="anchor" id="line-169"></span><p class="line862">ribbon.mgz </p></td> </tr> <tr> <td colspan="1" rowspan="1" style="text-align:left;"><span class="anchor" id="line-170"></span><p class="line862">-apas2aseg </p></td> <td><p class="line862">aparc+aseg.mgz </p></td> <td colspan="1" rowspan="1" style="text-align:left;"><p class="line862">apas2aseg --i aparc+aseg.mgz --o aseg.mgz </p></td> <td colspan="1" rowspan="1" style="text-align:left;"><p class="line862">aseg.mgz </p></td> </tr> <tr> <td colspan="1" rowspan="2" style="text-align:left"><span class="anchor" id="line-171"></span><p class="line862">-<a class="https" href="https://surfer.nmr.mgh.harvard.edu/fswiki/segstats">segstats</a> </p></td> <td><p class="line862">brainmask.mgz, norm.mgz, aseg.mgz, aseg.presurf.mgz, ribbon.mgz </p></td> <td colspan="1" rowspan="2" style="text-align:left"><p class="line891"><a class="https" href="https://surfer.nmr.mgh.harvard.edu/fswiki/mri_segstats">mri_segstats</a> --seg mri/aseg.mgz --sum stats/aseg.stats --pv mri/norm.mgz --empty --brainmask mri/brainmask.mgz --brain-vol-from-seg --excludeid 0 --excl-ctxgmwm --supratent --subcortgray --in mri/norm.mgz --in-intensity-name norm --in-intensity-units MR --etiv --surf-wm-vol --surf-ctx-vol --totalgray --euler --ctab $FREESURFER_HOME/ASegStatsLUT.txt --subject &lt;subjid&gt; </p></td> <td colspan="1" rowspan="2" style="text-align:left"><p class="line862">stats/aseg.stats </p></td> </tr> <tr> <td><span class="anchor" id="line-172"></span><p class="line862">?h.orig.nofix, ?h.white, ?h.pial </p></td> </tr> <tr> <td colspan="1" rowspan="2" style="text-align:left;"><span class="anchor" id="line-173"></span><p class="line862">-<a class="https" href="https://surfer.nmr.mgh.harvard.edu/fswiki/wmparc">wmparc</a> </p></td> <td><p class="line862">aparc+aseg.mgz </p></td> <td colspan="1" rowspan="1" style="text-align:left;"><p class="line891"><a class="https" href="https://surfer.nmr.mgh.harvard.edu/fswiki/mri_aparc2aseg">mri_aparc2aseg</a> --s &lt;subjid&gt; --labelwm --hypo-as-wm --rip-unknown --volmask --o mri/wmparc.mgz --ctxseg aparc+aseg.mgz </p></td> <td colspan="1" rowspan="1" style="text-align:left;"><p class="line862">wmparc.mgz </p></td> </tr> <tr> <td><span class="anchor" id="line-174"></span><p class="line862">talairach.xfm, brainmask.mgz, norm.mgz, ribbon.mgz, wmparc.mgz, aseg.presurf.mgz, ?h.white, ?h.pial </p></td> <td colspan="1" rowspan="1" style="text-align:left;"><p class="line891"><a class="https" href="https://surfer.nmr.mgh.harvard.edu/fswiki/mri_segstats">mri_segstats</a> --seg mri/wmparc.mgz --sum stats/wmparc.stats --pv mri/norm.mgz --excludeid 0 --brainmask mri/brainmask.mgz --in mri/norm.mgz --in-intensity-name norm --in-intensity-units MR --etiv --subject &lt;subjid&gt; --surf-wm-vol --ctab $FREESURFER_HOME/WMParcStatsLUT.txt </p></td> <td colspan="1" rowspan="1" style="text-align:left;"><p class="line862">stats/wmparc.stats </p></td> </tr> <tr> <td><span class="anchor" id="line-175"></span><p class="line862">-<a class="https" href="https://surfer.nmr.mgh.harvard.edu/fswiki/BrodmannAreaMaps">balabels</a> </p></td> <td><p class="line862">?h.sphere.reg </p></td> <td><p class="line891"><a class="https" href="https://surfer.nmr.mgh.harvard.edu/fswiki/mri_label2label">mri_label2label</a> --srcsubject fsaverage --srclabel fsaverage/label/?h.BA*.label --trgsubject &lt;subjid&gt; --trglabel ?h.BA*.label --hemi ?h --regmethod surface </p></td> <td><p class="line862">label/?h.BA*_exvivo.label label/?h.perirhinal_exvivo.label label/?h.entorhinal_exvivo.label </p></td> </tr> </tbody></table> Running: ```shell cat subject_list | parallel recon-all -s {} -autorecon3 ``` :::info **Step 3 finished** Logfile at /data/huze/Fs.subjects/<subject_id>/scripts/recon-all.log ::: ### T1 Results :::warning **Note:** These subjects may be problematic ( running `mris_fix_topology` for over 100 hours ) ```shell 3017_3 3002_1 3003_1 *2014_3*: Running `mris_fix_topology` for 300h *3002_3*: Running `mris_fix_topology` for 300h 3018_3 2025_3 ``` ::: #### Visualization Visualize and inspect 3 randomly picked output via freeview `TODO` ```shell freeview -v \ ./mri/T1.mgz \ ./mri/wm.mgz \ ./mri/brainmask.mgz \ ./mri/aseg.mgz:colormap=lut:opacity=0.2 \ -f ./surf/lh.white:edgecolor=blue \ ./surf/lh.pial:edgecolor=red \ ./surf/rh.white:edgecolor=blue \ ./surf/rh.pial:edgecolor=red ``` The flag `-v` is used to open some of the most commonly used volumes including: - brainmask.mgz : skull-stripped volume primarily used for troubleshooting - wm.mgz : white matter mask also used for troubleshooting - aseg.mgz : subcortical segmentation loaded with its corresponding color table and at a low opacity. The flag `-f` is used to load surfaces: - white & pial surfaces are loaded for each hemisphere & with color indicated by 'edgecolor' **TODO**: screenshot --- ## FS-FAST ### Adapting to FS-FAST Directory Structure ![](https://i.imgur.com/MuuoHv5.png) [Documentations](https://surfer.nmr.mgh.harvard.edu/fswiki/FsFastTutorialV6.0/FsFastDirStruct) Run `copy.py` to copy all .nii file to match FS-FAST directory structure, `copy.py` shown as blow: ```python import os from os import listdir, mkdir from os.path import isfile, isdir, join, basename import sys import logging from shutil import copyfile logging.basicConfig() logger = logging.getLogger('Adapting to FS-FAST Directory Structure') logger.setLevel(logging.DEBUG) def main(fsfast_dir, working_dir): logger.critical("Working on directory: {0}".format(working_dir)) logger.critical("Target directory: {0}".format(fsfast_dir)) onlyniis = [join(working_dir, f) for f in \ listdir(working_dir) if f.endswith('.nii.gz')] for i, nii in enumerate(onlyniis): sess_dir_name = basename(nii).replace('_whole.nii.gz', '') subject_name = sess_dir_name sess_dir = join(fsfast_dir, sess_dir_name) fsd_dir = join(sess_dir, 'bold') run_dir = join(fsd_dir, '001') subject_name_file = join(sess_dir, 'subjectname') logger.info("Working on sess_dir: {0}, \t subject_name: {1}".format(sess_dir, subject_name)) try: mkdir(sess_dir) mkdir(fsd_dir) mkdir(run_dir) with open(subject_name_file, 'w') as f: f.write(subject_name) orig_file, targ_file = nii, join(run_dir, 'f.nii.gz') copyfile(orig_file, targ_file) except Exception as e: logger.critical(e) continue if __name__ == '__main__': main(*sys.argv[1:]) ``` Running `copy.py`: ```shell python3 copy.py fsfast-functional/ FunImg/ ``` :::info **Note**: **FS-FAST project directory** saved at `121.48.165.31:/data/huze/FsFastFunctional` as blow: ![](https://i.imgur.com/XEfGXDM.png) ![](https://i.imgur.com/C38W7Qg.png) ::: ### FS-FAST Preprocessing #### Documentations https://surfer.nmr.mgh.harvard.edu/fswiki/preproc-sess #### Running FS-FAST Preprocessing ```shell cat sessidfile | parallel preproc-sess -s {} -fsd bold -mni305 -fwhm 5 -per-run ``` :::success Completed `preproc-sess` on `fmri_with_t1_part11`(sessidfile) Logfile at /data/huze/FsFastFunctional/<subject_id>/ ::: :::info **Note**: STC is not configured yet, run `stc-sess` with slice order ::: #### Quality Assurance https://surfer.nmr.mgh.harvard.edu/fswiki/FsFastTutorialV6.0/FsFastPreProc **Terrible results?** ![](https://i.imgur.com/vmldU6h.png) ![](https://i.imgur.com/30FuE9O.png) :::danger Preprocessing via FS-FAST was abandoned due to terrible results ::: ## FEAT ### Pre-step BET The structual image that FEAT requires as input is the output of BET (brain extraction), run bet before feat ``` cat subject_list | parallel bet {}_mdeft.nii.gz {}_mdeft_brain.nii.gz ``` ### Configuration config FEAT via GUI, and save `design.fsf` for a batch run, `design.fsf` as below #### Nonlinear ``` # FEAT version number set fmri(version) 6.00 # Are we in MELODIC? set fmri(inmelodic) 0 # Analysis level # 1 : First-level analysis # 2 : Higher-level analysis set fmri(level) 1 # Which stages to run # 0 : No first-level analysis (registration and/or group stats only) # 7 : Full first-level analysis # 1 : Pre-processing # 2 : Statistics set fmri(analysis) 1 # Use relative filenames set fmri(relative_yn) 0 # Balloon help set fmri(help_yn) 1 # Run Featwatcher set fmri(featwatcher_yn) 0 # Cleanup first-level standard-space images set fmri(sscleanup_yn) 0 # Output directory set fmri(outputdir) "/data/huze/MRS/FEAT/2008_1" # TR(s) set fmri(tr) 3.000000 # Total volumes set fmri(npts) 244 # Delete volumes set fmri(ndelete) 0 # Perfusion tag/control order set fmri(tagfirst) 1 # Number of first-level analyses set fmri(multiple) 1 # Higher-level input type # 1 : Inputs are lower-level FEAT directories # 2 : Inputs are cope images from FEAT directories set fmri(inputtype) 2 # Carry out pre-stats processing? set fmri(filtering_yn) 1 # Brain/background threshold, % set fmri(brain_thresh) 10 # Critical z for design efficiency calculation set fmri(critical_z) 5.3 # Noise level set fmri(noise) 0.66 # Noise AR(1) set fmri(noisear) 0.34 # Motion correction # 0 : None # 1 : MCFLIRT set fmri(mc) 1 # Spin-history (currently obsolete) set fmri(sh_yn) 0 # B0 fieldmap unwarping? set fmri(regunwarp_yn) 0 # GDC Test set fmri(gdc) "" # EPI dwell time (ms) set fmri(dwell) 0.7 # EPI TE (ms) set fmri(te) 35 # % Signal loss threshold set fmri(signallossthresh) 10 # Unwarp direction set fmri(unwarp_dir) y- # Slice timing correction # 0 : None # 1 : Regular up (0, 1, 2, 3, ...) # 2 : Regular down # 3 : Use slice order file # 4 : Use slice timings file # 5 : Interleaved (0, 2, 4 ... 1, 3, 5 ... ) set fmri(st) 0 # Slice timings file set fmri(st_file) "" # BET brain extraction set fmri(bet_yn) 1 # Spatial smoothing FWHM (mm) set fmri(smooth) 5 # Intensity normalization set fmri(norm_yn) 0 # Perfusion subtraction set fmri(perfsub_yn) 0 # Highpass temporal filtering set fmri(temphp_yn) 1 # Lowpass temporal filtering set fmri(templp_yn) 0 # MELODIC ICA data exploration set fmri(melodic_yn) 0 # Carry out main stats? set fmri(stats_yn) 0 # Carry out prewhitening? set fmri(prewhiten_yn) 1 # Add motion parameters to model # 0 : No # 1 : Yes set fmri(motionevs) 0 set fmri(motionevsbeta) "" set fmri(scriptevsbeta) "" # Robust outlier detection in FLAME? set fmri(robust_yn) 0 # Higher-level modelling # 3 : Fixed effects # 0 : Mixed Effects: Simple OLS # 2 : Mixed Effects: FLAME 1 # 1 : Mixed Effects: FLAME 1+2 set fmri(mixed_yn) 2 # Higher-level permutations set fmri(randomisePermutations) 5000 # Number of EVs set fmri(evs_orig) 1 set fmri(evs_real) 2 set fmri(evs_vox) 0 # Number of contrasts set fmri(ncon_orig) 1 set fmri(ncon_real) 1 # Number of F-tests set fmri(nftests_orig) 0 set fmri(nftests_real) 0 # Add constant column to design matrix? (obsolete) set fmri(constcol) 0 # Carry out post-stats steps? set fmri(poststats_yn) 0 # Pre-threshold masking? set fmri(threshmask) "" # Thresholding # 0 : None # 1 : Uncorrected # 2 : Voxel # 3 : Cluster set fmri(thresh) 3 # P threshold set fmri(prob_thresh) 0.05 # Z threshold set fmri(z_thresh) 3.1 # Z min/max for colour rendering # 0 : Use actual Z min/max # 1 : Use preset Z min/max set fmri(zdisplay) 0 # Z min in colour rendering set fmri(zmin) 2 # Z max in colour rendering set fmri(zmax) 8 # Colour rendering type # 0 : Solid blobs # 1 : Transparent blobs set fmri(rendertype) 1 # Background image for higher-level stats overlays # 1 : Mean highres # 2 : First highres # 3 : Mean functional # 4 : First functional # 5 : Standard space template set fmri(bgimage) 1 # Create time series plots set fmri(tsplot_yn) 1 # Registration to initial structural set fmri(reginitial_highres_yn) 0 # Search space for registration to initial structural # 0 : No search # 90 : Normal search # 180 : Full search set fmri(reginitial_highres_search) 90 # Degrees of Freedom for registration to initial structural set fmri(reginitial_highres_dof) 3 # Registration to main structural set fmri(reghighres_yn) 1 # Search space for registration to main structural # 0 : No search # 90 : Normal search # 180 : Full search set fmri(reghighres_search) 180 # Degrees of Freedom for registration to main structural set fmri(reghighres_dof) BBR # Registration to standard image? set fmri(regstandard_yn) 1 # Use alternate reference images? set fmri(alternateReference_yn) 0 # Standard image set fmri(regstandard) "/usr/local/fsl/data/standard/MNI152_T1_2mm_brain" # Search space for registration to standard space # 0 : No search # 90 : Normal search # 180 : Full search set fmri(regstandard_search) 180 # Degrees of Freedom for registration to standard space set fmri(regstandard_dof) 12 # Do nonlinear registration from structural to standard space? set fmri(regstandard_nonlinear_yn) 1 # Control nonlinear warp field resolution set fmri(regstandard_nonlinear_warpres) 10 # High pass filter cutoff set fmri(paradigm_hp) 100 # Total voxels set fmri(totalVoxels) 29982720 # Number of lower-level copes feeding into higher-level analysis set fmri(ncopeinputs) 0 # 4D AVW data or FEAT directory (1) set feat_files(1) "/data/huze/MRS/FunImg/2008_1_whole" # Add confound EVs text file set fmri(confoundevs) 0 # Subject's structural image for analysis 1 set highres_files(1) "/data/huze/MRS/T1/2008_1_mdeft_brain" # EV 1 title set fmri(evtitle1) "" # Basic waveform shape (EV 1) # 0 : Square # 1 : Sinusoid # 2 : Custom (1 entry per volume) # 3 : Custom (3 column format) # 4 : Interaction # 10 : Empty (all zeros) set fmri(shape1) 0 # Convolution (EV 1) # 0 : None # 1 : Gaussian # 2 : Gamma # 3 : Double-Gamma HRF # 4 : Gamma basis functions # 5 : Sine basis functions # 6 : FIR basis functions # 8 : Alternate Double-Gamma set fmri(convolve1) 2 # Convolve phase (EV 1) set fmri(convolve_phase1) 0 # Apply temporal filtering (EV 1) set fmri(tempfilt_yn1) 1 # Add temporal derivative (EV 1) set fmri(deriv_yn1) 1 # Skip (EV 1) set fmri(skip1) 0 # Off (EV 1) set fmri(off1) 30 # On (EV 1) set fmri(on1) 30 # Phase (EV 1) set fmri(phase1) 0 # Stop (EV 1) set fmri(stop1) -1 # Gamma sigma (EV 1) set fmri(gammasigma1) 3 # Gamma delay (EV 1) set fmri(gammadelay1) 6 # Orthogonalise EV 1 wrt EV 0 set fmri(ortho1.0) 0 # Orthogonalise EV 1 wrt EV 1 set fmri(ortho1.1) 0 # Contrast & F-tests mode # real : control real EVs # orig : control original EVs set fmri(con_mode_old) orig set fmri(con_mode) orig # Display images for contrast_real 1 set fmri(conpic_real.1) 1 # Title for contrast_real 1 set fmri(conname_real.1) "" # Real contrast_real vector 1 element 1 set fmri(con_real1.1) 1 # Real contrast_real vector 1 element 2 set fmri(con_real1.2) 0 # Display images for contrast_orig 1 set fmri(conpic_orig.1) 1 # Title for contrast_orig 1 set fmri(conname_orig.1) "" # Real contrast_orig vector 1 element 1 set fmri(con_orig1.1) 1 # Contrast masking - use >0 instead of thresholding? set fmri(conmask_zerothresh_yn) 0 # Do contrast masking at all? set fmri(conmask1_1) 0 ########################################################## # Now options that don't appear in the GUI # Alternative (to BETting) mask image set fmri(alternative_mask) "" # Initial structural space registration initialisation transform set fmri(init_initial_highres) "" # Structural space registration initialisation transform set fmri(init_highres) "" # Standard space registration initialisation transform set fmri(init_standard) "" # For full FEAT analysis: overwrite existing .feat output dir? set fmri(overwrite_yn) 0 ``` #### Linear ``` # FEAT version number set fmri(version) 6.00 # Are we in MELODIC? set fmri(inmelodic) 0 # Analysis level # 1 : First-level analysis # 2 : Higher-level analysis set fmri(level) 1 # Which stages to run # 0 : No first-level analysis (registration and/or group stats only) # 7 : Full first-level analysis # 1 : Pre-processing # 2 : Statistics set fmri(analysis) 1 # Use relative filenames set fmri(relative_yn) 0 # Balloon help set fmri(help_yn) 1 # Run Featwatcher set fmri(featwatcher_yn) 0 # Cleanup first-level standard-space images set fmri(sscleanup_yn) 0 # Output directory set fmri(outputdir) "/data/huze/MRS/FEAT.linear/3027_1" # TR(s) set fmri(tr) 3.000000 # Total volumes set fmri(npts) 244 # Delete volumes set fmri(ndelete) 0 # Perfusion tag/control order set fmri(tagfirst) 1 # Number of first-level analyses set fmri(multiple) 1 # Higher-level input type # 1 : Inputs are lower-level FEAT directories # 2 : Inputs are cope images from FEAT directories set fmri(inputtype) 2 # Carry out pre-stats processing? set fmri(filtering_yn) 1 # Brain/background threshold, % set fmri(brain_thresh) 10 # Critical z for design efficiency calculation set fmri(critical_z) 5.3 # Noise level set fmri(noise) 0.66 # Noise AR(1) set fmri(noisear) 0.34 # Motion correction # 0 : None # 1 : MCFLIRT set fmri(mc) 1 # Spin-history (currently obsolete) set fmri(sh_yn) 0 # B0 fieldmap unwarping? set fmri(regunwarp_yn) 0 # GDC Test set fmri(gdc) "" # EPI dwell time (ms) set fmri(dwell) 0.7 # EPI TE (ms) set fmri(te) 35 # % Signal loss threshold set fmri(signallossthresh) 10 # Unwarp direction set fmri(unwarp_dir) y- # Slice timing correction # 0 : None # 1 : Regular up (0, 1, 2, 3, ...) # 2 : Regular down # 3 : Use slice order file # 4 : Use slice timings file # 5 : Interleaved (0, 2, 4 ... 1, 3, 5 ... ) set fmri(st) 0 # Slice timings file set fmri(st_file) "" # BET brain extraction set fmri(bet_yn) 1 # Spatial smoothing FWHM (mm) set fmri(smooth) 5 # Intensity normalization set fmri(norm_yn) 0 # Perfusion subtraction set fmri(perfsub_yn) 0 # Highpass temporal filtering set fmri(temphp_yn) 1 # Lowpass temporal filtering set fmri(templp_yn) 0 # MELODIC ICA data exploration set fmri(melodic_yn) 0 # Carry out main stats? set fmri(stats_yn) 0 # Carry out prewhitening? set fmri(prewhiten_yn) 1 # Add motion parameters to model # 0 : No # 1 : Yes set fmri(motionevs) 0 set fmri(motionevsbeta) "" set fmri(scriptevsbeta) "" # Robust outlier detection in FLAME? set fmri(robust_yn) 0 # Higher-level modelling # 3 : Fixed effects # 0 : Mixed Effects: Simple OLS # 2 : Mixed Effects: FLAME 1 # 1 : Mixed Effects: FLAME 1+2 set fmri(mixed_yn) 2 # Higher-level permutations set fmri(randomisePermutations) 5000 # Number of EVs set fmri(evs_orig) 1 set fmri(evs_real) 2 set fmri(evs_vox) 0 # Number of contrasts set fmri(ncon_orig) 1 set fmri(ncon_real) 1 # Number of F-tests set fmri(nftests_orig) 0 set fmri(nftests_real) 0 # Add constant column to design matrix? (obsolete) set fmri(constcol) 0 # Carry out post-stats steps? set fmri(poststats_yn) 0 # Pre-threshold masking? set fmri(threshmask) "" # Thresholding # 0 : None # 1 : Uncorrected # 2 : Voxel # 3 : Cluster set fmri(thresh) 3 # P threshold set fmri(prob_thresh) 0.05 # Z threshold set fmri(z_thresh) 3.1 # Z min/max for colour rendering # 0 : Use actual Z min/max # 1 : Use preset Z min/max set fmri(zdisplay) 0 # Z min in colour rendering set fmri(zmin) 2 # Z max in colour rendering set fmri(zmax) 8 # Colour rendering type # 0 : Solid blobs # 1 : Transparent blobs set fmri(rendertype) 1 # Background image for higher-level stats overlays # 1 : Mean highres # 2 : First highres # 3 : Mean functional # 4 : First functional # 5 : Standard space template set fmri(bgimage) 1 # Create time series plots set fmri(tsplot_yn) 1 # Registration to initial structural set fmri(reginitial_highres_yn) 0 # Search space for registration to initial structural # 0 : No search # 90 : Normal search # 180 : Full search set fmri(reginitial_highres_search) 90 # Degrees of Freedom for registration to initial structural set fmri(reginitial_highres_dof) 3 # Registration to main structural set fmri(reghighres_yn) 1 # Search space for registration to main structural # 0 : No search # 90 : Normal search # 180 : Full search set fmri(reghighres_search) 90 # Degrees of Freedom for registration to main structural set fmri(reghighres_dof) BBR # Registration to standard image? set fmri(regstandard_yn) 1 # Use alternate reference images? set fmri(alternateReference_yn) 0 # Standard image set fmri(regstandard) "/usr/local/fsl/data/standard/MNI152_T1_2mm_brain" # Search space for registration to standard space # 0 : No search # 90 : Normal search # 180 : Full search set fmri(regstandard_search) 90 # Degrees of Freedom for registration to standard space set fmri(regstandard_dof) 12 # Do nonlinear registration from structural to standard space? set fmri(regstandard_nonlinear_yn) 0 # Control nonlinear warp field resolution set fmri(regstandard_nonlinear_warpres) 10 # High pass filter cutoff set fmri(paradigm_hp) 100 # Total voxels set fmri(totalVoxels) 29982720 # Number of lower-level copes feeding into higher-level analysis set fmri(ncopeinputs) 0 # 4D AVW data or FEAT directory (1) set feat_files(1) "/data/huze/MRS/FunImg/3027_1_whole" # Add confound EVs text file set fmri(confoundevs) 0 # Subject's structural image for analysis 1 set highres_files(1) "/data/huze/MRS/T1/3027_1_mdeft_brain" # EV 1 title set fmri(evtitle1) "" # Basic waveform shape (EV 1) # 0 : Square # 1 : Sinusoid # 2 : Custom (1 entry per volume) # 3 : Custom (3 column format) # 4 : Interaction # 10 : Empty (all zeros) set fmri(shape1) 0 # Convolution (EV 1) # 0 : None # 1 : Gaussian # 2 : Gamma # 3 : Double-Gamma HRF # 4 : Gamma basis functions # 5 : Sine basis functions # 6 : FIR basis functions # 8 : Alternate Double-Gamma set fmri(convolve1) 2 # Convolve phase (EV 1) set fmri(convolve_phase1) 0 # Apply temporal filtering (EV 1) set fmri(tempfilt_yn1) 1 # Add temporal derivative (EV 1) set fmri(deriv_yn1) 1 # Skip (EV 1) set fmri(skip1) 0 # Off (EV 1) set fmri(off1) 30 # On (EV 1) set fmri(on1) 30 # Phase (EV 1) set fmri(phase1) 0 # Stop (EV 1) set fmri(stop1) -1 # Gamma sigma (EV 1) set fmri(gammasigma1) 3 # Gamma delay (EV 1) set fmri(gammadelay1) 6 # Orthogonalise EV 1 wrt EV 0 set fmri(ortho1.0) 0 # Orthogonalise EV 1 wrt EV 1 set fmri(ortho1.1) 0 # Contrast & F-tests mode # real : control real EVs # orig : control original EVs set fmri(con_mode_old) orig set fmri(con_mode) orig # Display images for contrast_real 1 set fmri(conpic_real.1) 1 # Title for contrast_real 1 set fmri(conname_real.1) "" # Real contrast_real vector 1 element 1 set fmri(con_real1.1) 1 # Real contrast_real vector 1 element 2 set fmri(con_real1.2) 0 # Display images for contrast_orig 1 set fmri(conpic_orig.1) 1 # Title for contrast_orig 1 set fmri(conname_orig.1) "" # Real contrast_orig vector 1 element 1 set fmri(con_orig1.1) 1 # Contrast masking - use >0 instead of thresholding? set fmri(conmask_zerothresh_yn) 0 # Do contrast masking at all? set fmri(conmask1_1) 0 ########################################################## # Now options that don't appear in the GUI # Alternative (to BETting) mask image set fmri(alternative_mask) "" # Initial structural space registration initialisation transform set fmri(init_initial_highres) "" # Structural space registration initialisation transform set fmri(init_highres) "" # Standard space registration initialisation transform set fmri(init_standard) "" # For full FEAT analysis: overwrite existing .feat output dir? set fmri(overwrite_yn) 0 ``` create `design.fsf` for ever subject, with the same configuration. and create a subjct list file for batch run. ```python import os from os import listdir from os.path import isfile, isdir, join, basename import sys import logging def main(working_dir): orig_list = [f for f in listdir(working_dir) if f.endswith('mdeft.nii.gz')] subj_list = [basename(s).replace('_mdeft.nii.gz', '') for s in orig_list] designs_file = join(working_dir, 'design_list') designs = '' with open('design.fsf', 'r') as f: design = f.read() for subj in subj_list: subj_design = design.replace('2008_1', subj) design_file = '{0}_design.fsf'.format(subj) with open(design_file, 'w') as f: f.write(subj_design) designs += design_file + '\n' with open(designs_file, 'w') as f: f.write(designs) if __name__ == '__main__': main(*sys.argv[1:]) ``` ### Running FEAT ```shell cat design_list | parallel feat {} ``` ### Results The following subjects (saved in `r2_subj_list` file) have terrible registration results. So A round-2 re-run is processed for these subjects. But the results in round-2 is still terrible, therefore, these subjects were abandoned. ``` 2044_1 2064_3 2077_1 2078_1 2080_1 2087_1 3021_3 3030_3 3033_1 3033_3 3044_1 ``` #### Terrible Results with Nonlinear Registration\ ![](https://i.imgur.com/1n4lFtq.png) ![](https://i.imgur.com/mSNUqq3.png) ![](https://i.imgur.com/VswUN2v.png) ![](https://i.imgur.com/Isgmppk.png) ### QA motion check, remove subjects with mean motion parameter greater than 0.2 over the whole scan. (Q: abs or rel?) run `check_motion.py` ```python import os from os import listdir from os.path import isfile, isdir, join, basename import sys import logging feat_list = [f for f in listdir('/data/huze/MRS/FEAT.linear') if f.endswith('.feat')] abs_bad_motion_subjs, abs_good_motion_subjs, rel_bad_motion_subjs, rel_good_motion_subjs = list(), list(), list(), list() for feat in feat_list: with open(join('/data/huze/MRS/FEAT.linear', feat, 'mc/prefiltered_func_data_mcf_abs_mean.rms'), 'r') as f: abs_mean_motion = f.read() with open(join('/data/huze/MRS/FEAT.linear', feat, 'mc/prefiltered_func_data_mcf_rel_mean.rms'), 'r') as f: rel_mean_motion = f.read() if float(abs_mean_motion) > 0.2: abs_bad_motion_subjs.append(basename(feat).strip('.feat')) else: abs_good_motion_subjs.append(basename(feat).strip('.feat')) if float(rel_mean_motion) > 0.2: rel_bad_motion_subjs.append(basename(feat).strip('.feat')) else: rel_good_motion_subjs.append(basename(feat).strip('.feat')) print(len(abs_bad_motion_subjs), abs_bad_motion_subjs) print(len(rel_bad_motion_subjs), rel_bad_motion_subjs) ``` the result is that there occur to be 209 subjects with a absolute motion mean greater than 0.2, and 32 subjects with a relative mean. ``` 209 ['3033_1', '2012_3', '3038_3', '3055_3', '3022_3', '2086_1', '3019_3', '2113_3', '3032_1', '3040_3', '2029_1', '2061_1', '2106_3', '3014_3', '3015_3', '2111_1', '3027_1', '3016_1', '2062_1', '3018_1', '2112_1', '2029_3', '3013_3', '2078_1', '2022_3', '2044_3', '3044_3', '3036_3', '3012_1', '3036_1', '2061_3', '3025_1', '2005_3', '2006_1', '3020_1', '2047_3', '3024_1', '3054_1', '2048_3', '2058_3', '2058_1', '3018_3', '3015_1', '2028_1', '2077_1', '2082_3', '3022_1', '2090_1', '3002_1', '2096_1', '2014_1', '3029_1', '2046_1', '3048_1', '2112_3', '2086_3', '2048_1', '2053_1', '2121_1', '3055_1', '3029_3', '3028_3', '3006_3', '3042_3', '3048_3', '2019_3', '3049_1', '2075_1', '2059_3', '2054_1', '3044_1', '2021_3', '2053_3', '3020_3', '2068_1', '2020_3', '3046_3', '3045_1', '2016_3', '3059_1', '3049_3', '2077_3', '2088_1', '2094_3', '3021_3', '2011_3', '3010_3', '3032_3', '2093_3', '2064_3', '2024_3', '2122_3', '2065_3', '3009_3', '2075_3', '3066_3', '2122_1', '2087_3', '2005_1', '2094_1', '3024_3', '2033_3', '2025_1', '3028_1', '3030_3', '3008_3', '2080_3', '3003_1', '2020_1', '2011_1', '2095_3', '2016_1', '2047_1', '3012_3', '3010_1', '2015_1', '3037_1', '3003_3', '3046_1', '2044_1', '3021_1', '2021_1', '3019_1', '2054_3', '2092_1', '3030_1', '2032_3', '3027_3', '2025_3', '3059_3', '2090_3', '2087_1', '2022_1', '2106_1', '3025_3', '2123_3', '2065_1', '3035_1', '2113_1', '2091_1', '2123_1', '2062_3', '3042_1', '2024_1', '3064_3', '3057_3', '3066_1', '2050_3', '3002_3', '2091_3', '3035_3', '2028_3', '2032_1', '2095_1', '2080_1', '2078_3', '2046_3', '2082_1', '3017_3', '2019_1', '3033_3', '3017_1', '2109_3', '2012_1', '2006_3', '3045_3', '3051_3', '2064_1', '2103_3', '3050_1', '3050_3', '2099_1', '3052_3', '3054_3', '3014_1', '3009_1', '2015_3', '2033_1', '3064_1', '2050_1', '3001_1', '2111_3', '2083_1', '3013_1', '3047_1', '3008_1', '2096_3', '3040_1', '3047_3', '3006_1', '2109_1', '2014_3', '3051_1', '2008_3', '2068_3', '2099_3', '2092_3', '3057_1', '2059_1', '3001_3', '3052_1', '3037_3', '2052_3', '2008_1', '3038_1', '2088_3', '2121_3', '2052_1', '2103_1'] 32 ['3022_3', '2029_1', '2029_3', '2005_3', '2006_1', '2028_1', '2077_1', '3002_1', '2014_1', '3042_3', '2019_3', '2059_3', '3044_1', '3020_3', '2016_3', '2088_1', '2024_3', '2005_1', '2011_1', '2016_1', '3046_1', '2065_1', '2028_3', '2032_1', '2019_1', '2006_3', '3001_1', '2096_3', '2109_1', '2014_3', '2008_3', '3057_1'] ```