[[FreeSurferWiki|top]]

'''# Unpack Data into the FSFAST Hierarchy using "unpackscmdir"'''

        1.      QA Check after unpacking

            * '''A''' - Check unpacked data (time points, # of slices ..etc)
            * '''B''' - Check FSFAST hierarchy in session folder

'''# Reconstruction – Anatomical using "recon-all –all"'''

        1.      Set SUBJECTS_DIR
        2.      QA Check
            * '''A''' - Check talairach transformation
            * '''B''' - Check skull strip, white matter & pial surface
            * '''C''' - Re-run "recon-all" if edits are made
            * '''D''' - Check hierarchy of reconstructed anatomical data

'''# Assembling the Data into the FSFAST Hierarchy'''

        1.      Make FSFAST basic hierarchy (only if data are not unpacked in FSFAST hierarchy)
        2.      Link to FreeSurfer anatomical analysis 
            * '''A''' - Make ‘subjectname’ file in the session directory to link a subject's functional & structural data
        3.      Create a sessid file (text file with list of your sessions)in your Study DIR.
        4.      Create a Stimulus Schedule (Paradigm file) in bold folder (A "paradigm" file is a record of which stimulus was presented when & for how long. Each paradigm file has four columns:  
            * '''A''' - Stimulus onset time (sec)
            * '''B''' - Condition ID code (0, 1, 2, ...)
            * '''C''' - Stimulus Duration (sec)
            * '''D''' - Stimulus Weight (usually 1)
'''# Preprocessing of fMRI Data ()'''
{{{
preproc-sess -s <subjid> -fwhm <#>
}}}
        1.      By default this will do motion correction, smoothing & brain masking
        2.      Quality Check (plot-twf-sess) 
        3.      Examine additions to FSFAST hierarchy (in each run of bold dir):  
            * ''' ''' - f.nii (the raw data)
            * ''' ''' - fmc.nii (motion corrected-MC)
            * ''' ''' - fmcsm5.nii (MC & smoothed)
            * ''' ''' - fmc.mcdat - text file with the MC parameters (AFNI)
            * ''' ''' - mcextreg.bhdr - binary mask of the brain 

'''# Function-Structure Registration'''
              View unregistered 
{{{
tkregister-sess -s <subjid> -regheader)
}}}
              Run automatic registration 
{{{
spmregister-sess -s <subjid>
}}}
             Check automatic registration 
{{{
tkregister-sess -s <subjid>
}}}  
            * '''A''' - Make edits if needed using scale as the last resort
              Check talairach registration 
{{{
tkregister2 --s <subjid> --fstal --surf
}}}

'''# First-Level (Group) Analysis '''
{{{
mkanalysis-sess –gui
}}}

        1.      Setting up models of the task-related components
        2.      Setting up models of the nuisance components 
        3.      Defining contrasts  
        4.      Fitting the model  
        5.      Making inferences  
        6.      Input files: (*.par & fmcsm#) 

'''# Analyze First Level '''
{{{
selxavg3-sess -s <subjid> -analysis <analysis name>
}}}

        1.      Examine additions to the FSFAST hierarchy (~bold/analysis):
            * ''' ''' - beta.nii - regression coefficients 
            * ''' ''' - rvar.nii - residual error variance
            * ''' ''' - mask.nii - mask (copy of bold/masks/brain.nii)
            * ''' ''' - meanfunc.nii - mean functional image
            * ''' ''' - fsnr.nii - functional SNR map 
            * ''' ''' - X.mat - design matrix (in matlab format) 
            * ''' ''' - dof - text file with degrees of freedom 
            * ''' ''' - fwhm.dat - smoothness estimate (Full-Width/Half-Max)
            * ''' ''' - ~contrast folder/s:
                 * ''' ''' - ces.nii - contrast effect size (contrast matrix * regression coef)
                 * ''' ''' - cesvar.nii - variance of CES  
                 * ''' ''' - sig.nii - significance map (-log10(p))
        2.      Visualization
           * '''A''' - Volume-based visualization  using "tkmedit-sess" 
           * '''B''' - Surface-based visualization using "tksurfer-sess"

'''# Higher-Level (Group) Analysis--Volume-based (MNI305/fsaverage)'''

        1.      Assemble the contrast Data using "isxconcat-sess"
{{{
isxconcat-sess -s <sessid> -analysis <analysis name> -c <contrast name> -o <outdir>
}}}
         * '''A ''' - (~ output dir): 
          * ''' ''' - tal.meanfunc.nii (stack where each "time point" is the mean f image of each subject sampled in the MNI305 space)
          * ''' ''' - tal.masks.nii (binary masks for all the subjects)
          * ''' ''' - tal.fsnr.nii (functional SNR maps from each subject)
          * ''' ''' - tal.mask.nii (single binary mask made from the intersection of the individuals)
          * ''' ''' - ffxdof.dat (fixed-effects DOF across all subjects) 
          * ''' ''' - sessid.txt (list of sessions, the corresponding freesurfer subject name, & the DOF contributed by each subject)) 
          * ''' ''' - ~contrast folder: 
               * ''' ''' - tal.ces.nii (contrast maps for each of the subjects)
               * ''' ''' - tal.cesvar.nii (variance of the contrast for each subject (i.e., the square of the standard error). This variance is needed for fixed-effects & weighted random-effects analysis.)  
               * ''' ''' - "osgm" directory (one-sample-group-mean corresponds to a group design matrix that is simply a column of 1s. This will be used later in group analysis (i.e. in mri_gmfit))

        2.      Quality Assurance
          * '''A''' - Check registration using "tkregister2" 
          * '''B''' - Check the individual masks using "tkmedit"
          * '''C''' - Look at the functional SNR mapsusing "tkmedit"

        3.      Group GLM Analysis using "mri_glmfit"

          * '''A''' - Random Effects 
{{{
mri_glmfit --y tal.ces.nii --osgm --mask ../tal.mask.nii --glmdir tal.rfx.osgm --nii 
}}}
               * ''' ''' - Input: tal.ces.nii,tal.mask.nii
               * ''' ''' - Output: tal.rfx.osgm, beta.nii, sig.nii & osgm folder
          * '''B''' - Weighted Random Effects
{{{
mri_glmfit --y tal.ces.nii --osgm --glmdir tal.wrfx.osgm --nii --mask ../tal.mask.nii \
    --wls tal.cesvar.nii
}}}
               * ''' ''' - Similar to Random effects except that the first-level noise variances (tal.cesvar.nii) are passed
          * '''C''' - Fixed Effects
{{{
mri_glmfit --y tal.ces.nii --osgm --glmdir tal.ffx.osgm --nii --mask ../tal.mask.nii \
   --yffxvar tal.cesvar.nii --ffxdofdat ../ffxdof.dat
}}}
               * ''' ''' - Also included --yffxvar, & -- ffxdofdat

        4.      Output & visualization
          * '''A''' - First concatenate sig.nii files to a single file using "mri_concat" 
          * '''B''' - Visualize using "tkmedit"

        5.      Correction for Multiple Comparisons/Cluster Analysis using "mri_volcluster"
          * '''A''' - Examine additions to the FSFAST hierarchy:
          * ''' ''' - tal.rfx.osgm/osgm/cluster.sum (table shows the size of each cluster in voxels and mm^3, the talairach coordinate, the maximum significance in the cluster, & the clusterwise p-value (CWP))
          * ''' ''' - cwsig.cluster.nii (map of the clusters with the voxel value equal to the -log10(pvalue))
          * ''' ''' - sig.cluster.nii (original sig map with non-cluster voxels removed)
          * ''' ''' - ocn.cluster.nii (map where the value at each voxel is replaced by the number of the cluster that the voxel is associated with)

'''# Higher-Level (Group) Analysis--Surface-based (MNI305/fsaverage)'''
        1.      Assemble the Data (isxconcat-sess)
{{{
isxconcat-sess -s <sessid> -analysis <analysis name> -c <contrast name> -o <outdir> -hemi <?h>
}}}
          * '''A''' - Examine additions to the FSFAST hierarchy (~ output dir):
          * ''' ''' - ?h.meanfunc.nii
          * ''' ''' - ?h.mask.nii
          * ''' ''' - ?h.fsnr.nii
          * ''' ''' - ?h.ces.nii
          * ''' ''' - ?h.cesvar.nii

        2.      Group GLM Analysis(mri_glmfit)"--surf fsaverage lh" added to volume based.)
          * '''A''' - Random Effects
          * '''B''' - Weighted Random Effects
          * '''C''' - Fixed Effects

        3.      Output and visualization (mri_concat and tksurfer)
          * '''A''' - Random Effects
          * '''B''' - Weighted Random Effects
          * '''C''' - Fixed Effects
        4.      Correction for Multiple Comparisons/Cluster Analysis (mri_volcluster)


An active [[FreeSurferSupport|e-mail list]] is available to answer specific questions about processing procedures.