Fs Linear Models - PennBBL/envsAnalysisPNC GitHub Wiki
FS Linear Models for PNC ENVs Analysis
Overview of directory structure
Working directory: /data/joy/BBL/projects/envsMeduAnalysis/fs_analysis
Subjects directory: /data/joy/BBL/studies/pnc/processedData/structural/freesurfer53
General scripts: /data/joy/BBL/projects/envsMeduAnalysis/envsAnalysisPNC
Map output for this project
-
Parental education
Left hemisphere: /data/joy/BBL/projects/envsMeduAnalysis/fs_analysis/lh.glm/medu_area/lh.n1205.area.age_ageSqrd_sex_race_averageManualRating_medu.fwhm20.fsaverage5/pngs
Right hemisphere: /data/joy/BBL/projects/envsMeduAnalysis/fs_analysis/rh.glm/medu_area/rh.n1205.area.age_ageSqrd_sex_race_averageManualRating_medu.fwhm20.fsaverage5/pngs
-
Family income
Left hemisphere: /data/joy/BBL/projects/envsMeduAnalysis/fs_analysis/lh.glm/ses_area/lh.n1205.area.age_ageSqrd_sex_race_averageManualRating_envSES.fwhm20.fsaverage5/pngs
Right hemisphere: /data/joy/BBL/projects/envsMeduAnalysis/fs_analysis/rh.glm/ses_area/rh.n1205.area.age_ageSqrd_sex_race_averageManualRating_envSES.fwhm20.fsaverage5/pngs
-
Parental education & family income
Left hemisphere: /data/joy/BBL/projects/envsMeduAnalysis/fs_analysis/lh.glm/medu_ses_area/lh.n1205.area.age_ageSqrd_sex_race_averageManualRating_medu_envSES.fwhm20.fsaverage5/pngs
Right hemisphere: /data/joy/BBL/projects/envsMeduAnalysis/fs_analysis/rh.glm/medu_ses_area/rh.n1205.area.age_ageSqrd_sex_race_averageManualRating_envSES_medu.fwhm20.fsaverage5/pngs
For the purposes of this project, all images were set to express all areas where the variable in question was significantly associated with cortical surface area (with p<0.001 & fdr of 0.05).
Scripts breakdown
Directory: /data/joy/BBL/projects/envsMeduAnalysis/envsAnalysisPNC
-
FS_GLM_EnvsPncAnalysis.sh
This is the script used to make the linear models. The first time the script runs it will submit two commands to the grid (one for each hemisphere) that register and concatenate the subject files into a 4D surface file freesurfer can read. If it needs to do this then you need to wait for those jobs to finish running on the grid before you can rerun the script to perform analyses. If the concatenated files exist for the sample size you have, then the script will run the linear models, perform FDR correction for each contrast, write some cluster files, and write out ascii format files of the cluster files.
-
Input:
- demographics: /data/joy/BBL/projects/envsMeduAnalysis/fs_analysis/subjectLists/n1205_fsGLM_demos.csv
-
Outputs: From the mri_glmfit command --> output directory:
-
beta.mgh -- all parameter estimates (surface overlay)
-
dof.dat -- degrees of freedom (text)
-
fwhm.dat -- average FWHM of residual (text)
-
contrast# -- contrast subdirectory
-
mask.mgh -- binary mask (surface overlay)
-
mri_glmfit.log -- log file (text, send this with bug reports)
-
rstd.mgh -- residual standard deviation (surface overlay)
-
rvar.mgh -- residual variance (surface overlay)
-
sar1.mgh -- residual spatial AR1 (surface overlay)
-
surface -- the subject and hemisphere used for this analysis (text)
-
Xg.dat -- design matrix (text)
-
X.mat -- design matrix (MATLAB format)
-
yhat.mgh -- copy of design file
-
yhat.asc -- ASCII form of yhat.mgh
Example directory: /data/joy/BBL/projects/envsMeduAnalysis/fs_analysis/lh.glm/ses_area/lh.n1205.area.age_ageSqrd_sex_race_averageManualRating_envSES.fwhm20.fsaverage5
-
-
From the mri_glmfit command --> contrast subdirectory of the output directory:
- C.dat -- original contrast matrix (text)
- cnr.mgh -- contrast-to-noise ratio (surface overlay)
- F.mgh -- F ratio of contrast (surface overlay)
- gamma.mgh -- contrast effect size (surface overlay)
- gammavar.mgh --contrast variance (surface overlay)
- maxvox.dat -- voxel with the maximum statistic (text)
- sig.mgh -- significance, -log10(pvalue), uncorrected (surface overlay)
Example directory: /data/joy/BBL/projects/envsMeduAnalysis/fs_analysis/lh.glm/ses_area/lh.n1205.area.age_ageSqrd_sex_race_averageManualRating_envSES.fwhm20.fsaverage5/contrast1
-
From the mri_surfcluster command: These files are converted to ASCII via the mir_convert command.
- cluster.sum.p05fdr.txt
- cluster.sum.p01fdr.txt
Example directory: /data/joy/BBL/projects/envsMeduAnalysis/fs_analysis/lh.glm/ses_area/lh.n1205.area.age_ageSqrd_sex_race_averageManualRating_envSES.fwhm20.fsaverage5/contrast1
-
FS_GLM_designMatrix.R
Called by the FS_GLM_EnvsPncAnalysis.sh script to create the design matrix and contrast files.
- Output:
-
subjlist.txt -- list of all bblid/datexscanid identifiers
-
contrast#.mat -- ASCII text file with the contrast matrix (test hypotheses)
-
design_colnames.txt -- column names for contrast files (for clarification)
-
X.mat -- design matrix
Ex directory: /data/joy/BBL/projects/envsMeduAnalysis/fs_analysis/lh.glm/ses_area/lh.n1205.area.age_ageSqrd_sex_race_averageManualRating_envSES.fwhm20.fsaverage5
-
-
FS_screeenshots.sh
Screenshots for model results can be taken automatically using this script. Creates a pngs folder in directory of model output of png files.
- Call this script: /path/to/script /directory/of/model/output lowerthresh,upperthresh contrast#
- Choosing a threshold: if threshold is set to 4, then vertices with p<.0001 will have color (=-log10(pvalue))
- Output:
- $hemi.n$n.$meas.$model.$template.lateral_contrast#_logp$lowerthresh-$upperthresh_cluster.sig.p05fdr.png
- $hemi.n$n.$meas.$model.$template.medial_contrast#_logp$lowerthresh-$upperthresh_cluster.sig.p05fdr.png
Useful FreeSurfer Resources
Group analysis wiki: https://surfer.nmr.mgh.harvard.edu/fswiki/FsTutorial/GroupAnalysis
Group analysis tutorial: http://www.freesurfer.net/pub/docs/BostonMay2014/freesurfer.groupanalysis.pdf
Visualization: https://surfer.nmr.mgh.harvard.edu/fswiki/FsTutorial/Visualization