This is an old revision of the document!
Table of Contents
FreeSurfer Group Analysis
FSDG
https://surfer.nmr.mgh.harvard.edu/fswiki/FsgdExamples
https://surfer.nmr.mgh.harvard.edu/fswiki/FsgdFormat
Primero hay que construir el archivo de diseño del experimento,
[osotolongo@detritus fsdg]$ head codes.csv Subject,PSubject 0001,F001 0002,F002 0003,F003 0004,F004 0005,F005 0006,F006 0007,F007 0008,F008 0009,F009 [osotolongo@detritus fsdg]$ head demographics.csv PSubject,edat_v0,Anyos_Escolaridad_FAC_v0,Sex_1H_0M_v0 F001,71,8,0 F002,70,12,1 F003,70,8,0 F004,76,16,0 F005,68,20,1 F006,64,14,0 F007,59,19,1 F008,55,16,0 F009,67,16,0 [osotolongo@detritus fsdg]$ join -t"," -1 2 -2 1 codes.csv demographics.csv | awk -F"," '{print "facehbi_"$2","$3","$4","$5}' | sed 's/facehbi_Subject/Variables/;s/edat_v0/Age/;s/Anyos_Escolaridad_FAC_v0/Education/;s/Sex_1H_0M_v0/Gender/' | sed 's/facehbi_\([^,]*\),/Input facehbi_\1 Main /; s/,/ /g' > body.csv [osotolongo@detritus fsdg]$ head body.csv Variables Age Education Gender Input facehbi_0001 Main 71 8 0 Input facehbi_0002 Main 70 12 1 Input facehbi_0003 Main 70 8 0 Input facehbi_0004 Main 76 16 0 Input facehbi_0005 Main 68 20 1 Input facehbi_0006 Main 64 14 0 Input facehbi_0007 Main 59 19 1 Input facehbi_0008 Main 55 16 0 Input facehbi_0009 Main 67 16 0 [osotolongo@detritus fsdg]$ cat headers.txt GroupDescriptorFile 1 Title FACEHBI_all Class Main [osotolongo@detritus fsdg]$ cat headers.txt body.csv > facehbi.fsdg [osotolongo@detritus fsdg]$ head facehbi.fsdg GroupDescriptorFile 1 Title FACEHBI_all Class Main Variables Age Education Gender Input facehbi_0001 Main 71 8 0 Input facehbi_0002 Main 70 12 1 Input facehbi_0003 Main 70 8 0 Input facehbi_0004 Main 76 16 0 Input facehbi_0005 Main 68 20 1 Input facehbi_0006 Main 64 14 0
GLM Analysis (mri_glmfit)
Primero construimos los contrastes, diciendole a FS cual es la variable que nos interesa, en este caso la edad,
https://surfer.nmr.mgh.harvard.edu/fswiki/Fsgdf1G2V
[osotolongo@detritus fsdg]$ cat facehbi.mtx 0 1 0 0
Ahora vamos a correr el modelo con este contraste,
[osotolongo@detritus fsdg]$ mris_preproc --fsgd facehbi.fsdg --cache-in thickness.fwhm10.fsaverage --target fsaverage --hemi lh --out lh.facehbi.age.thickness.10.mgh [osotolongo@detritus fsdg]$ mri_glmfit --y lh.facehbi.age.thickness.10.mgh --fsgd facehbi.fsdg --C facehbi.mtx --surf fsaverage lh --cortex --glmdir lh.facehbi.age.glmdir
Para usar freeview me he tenido que ir a la FSL VM
[fsluser@FSLVm7_64 fsdg]$ freeview -f $SUBJECTS_DIR/fsaverage/surf/lh.inflated:annot=aparc.annot:annot_outline=1:overlay=lh.facehbi.age.glmdir/facehbi/sig.mgh:overlay_threshold=4,5 -viewport 3d
Cambiando el overlay threshold para que muestre toda la significancia,
Ejemplo, fijando uncorrected p<0.001,
Clusterwise Correction for Multiple Comparisons
Ahora voy a buscar los clusters con una p>0.05
[osotolongo@detritus fsdg]$ mri_glmfit-sim --glmdir lh.facehbi.age.glmdir --cache 4 neg --cwp 0.05 --2spaces
A ver,
freeview -f $SUBJECTS_DIR/fsaverage/surf/lh.inflated:overlay=lh.facehbi.age.glmdir/facehbi/cache.th40.neg.sig.cluster.mgh:overlay_threshold=2,5:annot=lh.facehbi.age.glmdir/facehbi/cache.th40.neg.sig.ocn.annot -viewport 3d
También hay un resumen de los clusters que se han encontrado a esta significancia,
[osotolongo@detritus fsdg]$ cat lh.facehbi.age.glmdir/facehbi/cache.th40.neg.sig.cluster.summary # Cluster Growing Summary (mri_surfcluster) # $Id: mri_surfcluster.c,v 1.57.2.3 2016/11/17 18:19:42 zkaufman Exp $ # $Id: mrisurf.c,v 1.781.2.6 2016/12/27 16:47:14 zkaufman Exp $ # CreationTime 2020/06/11-08:12:12-GMT # cmdline mri_surfcluster.bin --in lh.facehbi.age.glmdir/facehbi/sig.mgh --mask lh.facehbi.age.glmdir/mask.mgh --cwsig lh.facehbi.age.glmdir/facehbi/cache.th40.neg.sig.cluster.mgh --sum lh.facehbi.age.glmdir/facehbi/cache.th40.neg.sig.cluster.summary --ocn lh.facehbi.age.glmdir/facehbi/cache.th40.neg.sig.ocn.mgh --annot aparc --cwpvalthresh 0.05 --o lh.facehbi.age.glmdir/facehbi/cache.th40.neg.sig.masked.mgh --no-fixmni --csd /usr/local/freesurfer/average/mult-comp-cor/fsaverage/lh/cortex/fwhm14/neg/th40/mc-z.csd --csdpdf lh.facehbi.age.glmdir/facehbi/cache.th40.neg.pdf.dat --vwsig lh.facehbi.age.glmdir/facehbi/cache.th40.neg.sig.voxel.mgh --vwsigmax lh.facehbi.age.glmdir/facehbi/cache.th40.neg.sig.voxel.max.dat --oannot lh.facehbi.age.glmdir/facehbi/cache.th40.neg.sig.ocn.annot --bonferroni 2 --surf white # cwd /nas/data/facehbi/fsdg # sysname Linux # hostname detritus.fundacioace.com # machine x86_64 # FixVertexAreaFlag 1 # FixSurfClusterArea 1 # # Input lh.facehbi.age.glmdir/facehbi/sig.mgh # Frame Number 0 # srcsubj fsaverage # hemi lh # surface white # group_avg_surface_area 82220 # group_avg_vtxarea_loaded 1 # annot aparc # SUBJECTS_DIR /nas/data/subjects # SearchSpace_mm2 75610.7 # SearchSpace_vtx 147840 # Bonferroni 2 # Minimum Threshold 4 # Maximum Threshold infinity # Threshold Sign neg # AdjustThreshWhenOneTail 1 # CW PValue Threshold: 0.05 # Area Threshold 0 mm^2 # CSD thresh 4.000000 # CSD nreps 10000 # CSD simtype null-z # CSD contrast NA # CSD confint 90.000000 # Overall max 2.34317 at vertex 124430 # Overall min -11.9208 at vertex 75951 # NClusters 27 # FixMNI = 0 # # ClusterNo Max VtxMax Size(mm^2) MNIX MNIY MNIZ CWP CWPLow CWPHi NVtxs WghtVtx Annot 1 -6.017 60982 491.13 -47.9 -18.5 -2.1 0.00020 0.00000 0.00040 1098 -5034.35 superiortemporal 2 -11.921 75951 428.53 -31.7 -41.3 -9.1 0.00020 0.00000 0.00040 941 -6762.90 parahippocampal 3 -7.640 112606 361.05 -20.6 -99.6 -2.3 0.00020 0.00000 0.00040 432 -2179.37 lateraloccipital 4 -5.486 105941 331.99 -17.1 -32.3 56.5 0.00020 0.00000 0.00040 865 -3748.97 precentral 5 -5.449 35788 316.75 -44.9 6.5 -23.4 0.00020 0.00000 0.00040 611 -2771.80 superiortemporal 6 -7.472 67375 290.75 -20.6 30.7 50.4 0.00020 0.00000 0.00040 424 -2270.56 superiorfrontal 7 -4.824 159440 286.63 -8.8 -58.3 11.9 0.00020 0.00000 0.00040 622 -2552.03 precuneus 8 -6.970 138044 273.27 -30.3 -20.0 68.2 0.00020 0.00000 0.00040 626 -3090.95 precentral 9 -6.527 35125 264.21 -35.4 -12.7 18.8 0.00020 0.00000 0.00040 820 -4057.14 insula 10 -5.259 113827 256.47 -58.3 -17.5 -17.2 0.00020 0.00000 0.00040 522 -2207.87 middletemporal 11 -6.063 142574 227.96 -18.1 -91.7 16.1 0.00020 0.00000 0.00040 329 -1494.23 lateraloccipital 12 -4.901 142130 215.89 -61.7 -35.5 5.4 0.00020 0.00000 0.00040 478 -2005.09 bankssts 13 -7.124 88387 197.22 -10.7 -56.5 26.6 0.00020 0.00000 0.00040 436 -2167.82 precuneus 14 -5.977 112248 187.37 -31.2 -83.9 6.5 0.00040 0.00000 0.00080 312 -1449.31 lateraloccipital 15 -5.741 127670 174.29 -54.6 -0.9 -30.3 0.00080 0.00040 0.00140 210 -946.11 middletemporal 16 -5.957 110612 155.97 -44.6 23.1 18.8 0.00180 0.00100 0.00260 258 -1195.22 parsopercularis 17 -5.156 102514 136.16 -22.9 56.1 15.5 0.00459 0.00340 0.00579 163 -710.54 rostralmiddlefrontal 18 -5.618 43104 128.92 -24.3 6.2 48.4 0.00619 0.00479 0.00759 289 -1317.77 caudalmiddlefrontal 19 -5.445 91005 128.90 -21.8 -66.5 0.5 0.00619 0.00479 0.00759 285 -1241.01 lingual 20 -4.760 47386 121.71 -8.2 33.1 33.9 0.00759 0.00599 0.00918 190 -780.64 superiorfrontal 21 -4.778 107013 120.23 -19.8 -83.3 38.4 0.00798 0.00639 0.00958 223 -941.62 superiorparietal 22 -4.954 58975 118.93 -10.8 25.6 -17.8 0.00818 0.00659 0.00978 269 -1155.28 medialorbitofrontal 23 -4.799 38711 117.04 -60.9 -46.0 -1.9 0.00898 0.00739 0.01077 232 -956.50 bankssts 24 -6.095 1815 116.62 -47.1 -19.1 56.1 0.00918 0.00739 0.01097 319 -1485.15 postcentral 25 -4.976 77509 113.61 -35.6 37.8 13.2 0.01057 0.00878 0.01236 190 -814.05 rostralmiddlefrontal 26 -4.228 51760 87.69 -45.5 -72.1 10.1 0.02524 0.02247 0.02800 140 -552.81 inferiorparietal 27 -6.056 126177 68.80 -27.1 -68.1 22.7 0.04898 0.04508 0.05288 181 -854.08 superiorparietal
Full data
osotolongo@detritus:facehbi$ head datacomb_freesurfer_neuro_v0_scdSUMCC.csv Subject,SubjID,code_facehbi,N_Interno,Date,edat,Anyos_Escolaridad_FAC,Sex_1H_0M,SCDplus_Memorycomplaint,SCDplus_APOE4,SCDplus_concernsaboutcognition,SCDplus_feelingworsethancontemporarypeers,SCDplus_informantcorroboratessymptoms,SCDplus_onset60Y,SCDplus_onsetwithinlast5Y,SCDplus_SUVRgt1.35,SCDplus_SUVRgt1.45,SCDplus_Total7,Q_QSM_JPO,SUVR,Centilod,APOE,COMPOSITE_executive_fluency ,COMPOSITE_executive_processing speed ,COMPOSITE_executive_attention ,COMPOSITE_memory_FNAME professions,COMPOSITE_memory_FNAME names ,COMPOSITES_memory_WMS ,COMPOSITE_memory_RBANS ,COMPOSITE_gnosis,COMPOSITE_praxis,COMPOSITE_languge_naming 1,/nas/data/subjects/facehbi_0001,F001,20090806,11.12.2014,71,8,0,0,1,1,0,1,1,1,0,0,5,39,0.973316491,-5.593250248,e3e4,-0.5748,-0.270392,-0.532514,-0.616904,0.876729,-0.453361,1.130826,0.168598,0.515105,-0.579091 2,/nas/data/subjects/facehbi_0002,F002,20131084,11.12.2014,70,12,1,0,0,0,0,1,1,1,0,0,3,18,1.088375542,12.05680811,e3e3,0.849066,-0.703145,0.071122,0.91243,0.399876,0.259093,1.048653,1.256325,0.515105,0.926364 3,/nas/data/subjects/facehbi_0003,F003,20130456,18.12.2014,70,8,0,0,0,0,0,0,1,1,0,0,2,19,0.961914381,-7.342333945,e3e3,-1.381163,1.677785,-1.150127,-1.024665,0.195343,-0.809587,1.426227,1.256325,-0.772658,-0.388182 4,/nas/data/subjects/facehbi_0004,F004,20080130,18.12.2014,76,16,0,0,0,1,0,0,1,1,0,0,3,21,1.075781955,10.12495194,e3e3,-0.630893,-0.4805,-1.13615,-0.512863,-0.622202,-0.152722,-0.907758,0.168598,-2.060421,0.164545 5,/nas/data/subjects/facehbi_0005,F005,20141272,22.01.2015,68,20,1,0,0,0,1,1,1,0,0,0,3,29,0.95654587,-8.16586361,e2e3,1.256741,-0.549082,1.320324,0.704347,1.321653,0.630976,0.512283,0.168598,-2.060421,0.396364 6,/nas/data/subjects/facehbi_0006,F006,20141107,15.01.2015,64,14,0,0,1,1,1,1,1,1,1,0,6,56,1.253344903,37.36310815,e3e4,1.002492,0.610598,0.688735,0.610631,-0.71047,0.116602,-0.507294,-0.91913,-2.060421,-0.039091 7,/nas/data/subjects/facehbi_0007,F007,20080716,15.01.2015,59,19,1,1,0,1,0,0,0,0,1,1,2,15,1.504516347,75.89280769,e3e3,1.040233,0.70185,-0.518537,-0.204993,0.311608,0.345995,-0.114041,-0.91913,-3.348184,0.090909 8,/nas/data/subjects/facehbi_0008,F008,20131483,15.01.2015,55,16,0,0,0,1,0,1,0,1,0,0,3,72,0.897682014,-17.19557899,e3e3,-1.363541,0.552768,-0.532514,-0.111277,0.980961,-0.781793,1.473992,-0.91913,0.515105,-0.439091 9,/nas/data/subjects/facehbi_0009,F009,20141277,29.01.2015,67,16,0,0,0,0,0,0,1,1,0,0,2,18,1.033333445,3.613350513,e3e3,0.674792,0.532426,0.688735,-0.920727,-0.826734,-1.110226,-1.451403,-0.91913,-0.772658,1.016462 osotolongo@detritus:facehbi$ head -n 1 datacomb_freesurfer_neuro_v0_scdSUMCC.csv | sed 's/,/\n/g' | cat -n 1 Subject 2 SubjID 3 code_facehbi 4 N_Interno 5 Date 6 edat 7 Anyos_Escolaridad_FAC 8 Sex_1H_0M 9 SCDplus_Memorycomplaint 10 SCDplus_APOE4 11 SCDplus_concernsaboutcognition 12 SCDplus_feelingworsethancontemporarypeers 13 SCDplus_informantcorroboratessymptoms 14 SCDplus_onset60Y 15 SCDplus_onsetwithinlast5Y 16 SCDplus_SUVRgt1.35 17 SCDplus_SUVRgt1.45 18 SCDplus_Total7 19 Q_QSM_JPO 20 SUVR 21 Centilod 22 APOE 23 COMPOSITE_executive_fluency 24 COMPOSITE_executive_processing speed 25 COMPOSITE_executive_attention 26 COMPOSITE_memory_FNAME professions 27 COMPOSITE_memory_FNAME names 28 COMPOSITES_memory_WMS 29 COMPOSITE_memory_RBANS 30 COMPOSITE_gnosis 31 COMPOSITE_praxis 32 COMPOSITE_languge_naming
Voy a tomar uno de los composites para probar,
osotolongo@detritus:facehbi$ awk -F"," {'print $2","$6","$7","$8","$23'} datacomb_freesurfer_neuro_v0_scdSUMCC.csv | sed 's/.*\/facehbi_/facehbi_/;s/SubjID/Variables/;s/edat/age/;s/Anyos_Escolaridad_FAC/education/;s/Sex_1H_0M/gender/;s/COMPOSITE_//;s/facehbi_\([^,]*\),/Input facehbi_\1 Main /; s/,/ /g' > executive_fluency_body.tsv osotolongo@detritus:facehbi$ cat executive_fluency_header.txt GroupDescriptorFile 1 Title FACEHBI_executive_fluency Class Main osotolongo@detritus:facehbi$ cat executive_fluency_header.txt executive_fluency_body.tsv > executive_fluency.fsgd osotolongo@detritus:facehbi$ head executive_fluency.fsgd GroupDescriptorFile 1 Title FACEHBI_executive_fluency Class Main Variables age education gender executive_fluency Input facehbi_0001 Main 71 8 0 -0.5748 Input facehbi_0002 Main 70 12 1 0.849066 Input facehbi_0003 Main 70 8 0 -1.381163 Input facehbi_0004 Main 76 16 0 -0.630893 Input facehbi_0005 Main 68 20 1 1.256741 Input facehbi_0006 Main 64 14 0 1.002492 osotolongo@detritus:facehbi$ cat comps.mtx 0 0 0 0 1
ahora empezamos,
osotolongo@detritus:facehbi$ mris_preproc --fsgd executive_fluency.fsgd --cache-in thickness.fwhm10.fsaverage --target fsaverage --hemi lh --out lh.executive_fluency.thickness.10.mgh osotolongo@detritus:facehbi$ mri_glmfit --y lh.executive_fluency.thickness.10.mgh --fsgd executive_fluency.fsgd --C comps.mtx --surf fsaverage lh --cortex --glmdir lh.executive_fluency.glmdir osotolongo@detritus:facehbi$ mri_glmfit-sim --glmdir lh.executive_fluency.glmdir --cache 4 neg --cwp 0.05 --2spaces osotolongo@detritus:facehbi$ grep -v "#" lh.executive_fluency.glmdir/comps/cache.th40.neg.sig.cluster.summary osotolongo@detritus:facehbi$ mri_glmfit-sim --glmdir lh.executive_fluency.glmdir --cache 4 pos --cwp 0.05 --2spaces
Aqui no hay nada asi que podemos seguir hacia la siguiente variable,