Cmorph calculations step by step:
0. software preparation All you need::
-Freesurfer -with lGI module
-Docker/Singularity [i.e. muon docker]
-cmorph -Cmorph 1.2 by ilwoolyu -Matlab
-GNU paralel
1. recon-all all the data with -qcache option, check if the process exited with or without errors
# $F - subject dir
1) recon-all -i T1.nii.gz -all -qcache -subjid $F 2) recon-all -s $F -localGI -qcache -measure pial_lgi
2. check the pial surfaces, correct them manually if needed - or remove subjects with surface reconstruction errors from further step of analysis
see : https://www.youtube.com/watch?v=WaPtktm2EX4
and: https://surfer.nmr.mgh.harvard.edu/fswiki/FsTutorial/PialEdits_freeview and: https://usermanual.wiki/Document/FSEDITGUIDE2.1159529235.pdf
useful commands: 4grey matter correction: recon-all -autorecon-pial -subjid sub1 -qcache ;
4white matter correction: recon-all -autorecon2-cp -autorecon3 -s sub1 -qcache
3. convert lh and rh.pial and white to lh and rh.pial.vtk and white.vtk (copy_convert_to_vtk_pial_white.sh)
mris_convert lh.pial lh.pial.vtk mris_convert lh.white lh.white.vtk mris_convert rh.pial rh.pial.vtk mris_convert rh.white rh.white.vtk
1
4. install singularity [if you use cluster computer] or Docker [simgle machine] on a server, create an image (cmorph.img) from the ilwoolyu dockerhub (https://hub.docker.com/r/ilwoolyu/cmorph) docker pull ilwoolyu/cmorph:1.2
# 4.1. if use server - upload vtk data into folder "data" on a server with docker/singularity on it, separate folder for each subject and the list of subjects for analysis (in txt) before 5#
5. separate folder for each subject with vtk data and the list of subjects for analysis (in txt)
# subject_list.csv
GroupDescriptorFile 1 Title subject_list
Class SCH Class CON
Variables AGE
Input 101 SCH 37
Input 102 SCH 38
…
6. run cmorph for each subject and each hemisphere (perform_cmorph_calculations.sh)
sudo docker run -v /home/cmorph/$F/surf:/INPUT/ --rm ilwoolyu/cmorph:1.2 lgi --out /INPUT --i /INPUT/lh.pial.vtk --white /INPUT/lh.white.vtk
sudo docker run -v /home/cmorph/$F/surf:/INPUT/ --rm ilwoolyu/cmorph:1.2 lgi --out /INPUT --i /INPUT/rh.pial.vtk --white /INPUT/rh.white.vtk
#6 copy results of each subject from server to its folder in subjects’ directory on local machine
(copy_lgi_results_from_server.sh) - now for each subject program may asks for password to the account on server#
6.1. check that you have all LGI and cmorph in each sbj/surface data!
7. PREPROCESSING FOR GROUP ANALYSIS - run prepare_cmorph_results_to_group_analysis.sh from sub_dir_path with subjects_list
sub_dir_path - path to folder with subjects
subjects_list - simple txt file with one folder (subject) in one line
2
8. run group analysis with the contrast of your choice (one of the versions of run_NewDataSet.sh, soon the contrast will be an input to this function; e.g. cmorph_newdata.sh)
if you did export SUBJECTS_DIR=<path to your subjects’ folder>,
if you created empty folder “code” in your SUBJECTS_DIR,
if you have fsaverage subjects in the default path: /Applications/freesurfer/subjects/fsaverage,
if you changed line 20 in the run_NewDataSet.sh to be the path to all the scripts (leaving the space and dot at the end like in the original file),
if you checked lines 44 and 45 in run_NewDataSet.sh and the contrasts there (numbers in the quotes) are good for your classes in FSGD file, then:
go to ../3_code/ and run in the console:
MAC eg. bash run_NewDataSet.sh analysis1-1 fsaverage \ /home/cmorph/analysis1-1 $SUBJECTS_DIR Linux e.g. ./cmorph_newdata.sh a13 fsaverage /home/cmorph/a13 /home/cmorph
then you will be asked for actual fsgd.txt file in appropriate contrast folder, e.g. analysis1-1/FSGD
!before check in fsgd file that the class order is correct!
Then choose the DODS option for analysis (not DOSS!)
Finally, wait a moment for analysis, look that any error occured, if no, after ca 1,5 h you will be asked for drawing results in FreeView [y or n option]
# study=$1
# trgt=$2 #if not fsaverage then best to enter $study_Average
# study_path=$3
#subjects_dir=$4
## For more info on group analysis see also: https://www.youtube.com/watch?v=hdSkEPG-G8s andhttps://surfer.nmr.mgh.harvard.edu/fswiki/FsTutorial/GroupAnalysis
## info for contrast file see: https://surfer.nmr.mgh.harvard.edu/fswiki/FsgdExamples
9. Drawing results images with FreeView - plot_NewDataSet.sh
Run: bash plot_NewDataSet.sh <analysis folder path> fsaverage <analysis folder path>
e.g. bash plot_NewDataSet.sh analysis1-1 fsaverage /user/folder/analysis1-1 ./plot_NewDataSet.sh a fsaverage /home/cmorph/a
3
then you will be asked in console for:
1. enter the level of smoothing (0, 5 or 10)
2. enter the vertex-wise threshold for 0.05 or 0.01 results (13 or 20)
3. enter the cluster-wise threshold log10(p) for visualisation (positive floating number, i.e. 1.3 for cwp=0.05)
4. choose the contrast used for the analysis without extension (ie blind-sighted) e.g. con_sch_dods.mtx sch_con_dods.mtx x_con_dods.mtx x_sch_dods.mtx 5. choose measure (1=thickness / 2=pial_lgi/ 3=Ilwoo Lyu lgi)
6. do you want surfaces to be inflated? (y/n)
#significant cluster summaries you can find in appropriate subfolder of analasis#
Thats all folks!
4