Skip to content

MAGeTbrain Morphology

Gabriel A. Devenyi edited this page Nov 30, 2021 · 2 revisions

MAGeT Morph

For setup/run instructions see https://github.com/CobraLab/documentation/wiki/MAGeTBrain

Check the Output

The output is checked in the same way as in the simplified branch, except for the modelspace, gridavg and displacement now included. You will also have one folder for each of the .obj surfaces in your input/model/objects folder, containing surface area outputs

project_folder/
    output/
      modelspace/     - subject images registered (lsq9) to the model image
      registrations/  - XFM files (e.g. from pairwise registrations)
      gridavg/        - averaged grid transform for each subject, as <subject>_grid.mnc
      displacement/   - .txt vertex displacement files for each subject, as <subject>_<obj>_<blurringkernel>mm_blur.txt
      obj_from_input/ - folder will be named according to files in you `input/model/objects/` folder.  Eg, you may have a `striatum_left` folder. .txt surface area files for each subject are here as <subject>_vorn_SA_<blurringkernel>_blur.txt

Morph Outputs

In addition to labels, you will also get displacement and surface area outputs from the morph branch. This section describes where to find them, and what to use for your stats.

Displacement output/displacement/ - displacement .txt files, describing the displacement of each vertex in a structure, for each subject. In this folder, you will find displacement outputs for all .obj files in your input/model/objects folder. The files of interest for statistics are the *blur.txt files. For a given .obj, you will have one of these for every subject. Naming is as follows: <inputfilebasename>_<objectfilebasename>_<blurringkernel>_blur.txt eg, for the file input/subjects/subjectbrain.mnc, and for input/model/striatum_left.obj, you will find: output/displacement/subjectbrain_striatum_left_5mm_blur.txt

Surface Area output/<objectbasename>/ - for each .obj in your input/model/objects folder, there will be an output folder with the same basename containing surface area outputs (eg for input/model/objects/striatum_left.obj, look in output/striatum_left for left striatum surface area files). The files of interest for statistics are the *blur.txt files. Naming is as follows: output/<objectbasename>/<inputfilebasename>_vorn_SA_<blurringkernel>_blur.txt

Eg: for input/model/objects/striatum_left.obj, look for: output/striatum_left/subjectbrain_vorn_SA_5mm_blur.txt

for input/model/objects/striatum_right.obj, look for: output/striatum_right/subjectbrain_vorn_SA_5mm_blur.txt

Note that for surface area outputs, you must look in the appropriately named folder or else you will confuse outputs. The surface area files for striatum_left.obj and striatum_right.obj will have the same basename, but will be found in different folders. Therefore, it is important to keep surface area outputs in separate folders.

Quality Control

For checking the labels, use the same QC as in simplified. For the morpho QC, you can use brain-view2.

First, check the models:

cd ~/SUBCORT_MODELS_Oct282011

brain-view2 striatum_left_rot.obj striatum_right_rot.obj

Models also exist for the thalamus and the gp (globus pallidus)

Then, to visualize an individual's morphmetry data we can also use brain-view2:

cd ~/MRI/MAGeT_morph/Eduardopp_ap_015_t1

brain-view2 ~/SUBCORT_MODELS_Oct282011/striatum_left_rot.obj Eduardopp_ap_015_t1_striatum_left_dp.txt

This shows the dot product after any residual linear components are removed (this is the one you should use for analysis):

brain-view2 ~/SUBCORT_MODELS_Oct282011/striatum_left_rot.obj Eduardopp_ap_015_t1_striatum_left_nl_only_dp.txt

This shows only local surface area changes (use the 5 mm or 3 mm blur files):

brain-view2 ~/SUBCORT_MODELS_Oct282011/striatum_left_rot.obj Eduardopp_ap_015_t1_striatum_left_vorn_SA_5mm_blur.txt

Analysis

Your variables of interest are in the TXT files in the output/displacement folder. Those variables are displacement and surface area. The analysis is done in the same fashion as CIVET cortical thickness analysis.

First start R in the directory that contains all of the MAGeTmorph outputs. Remember from here on, the commands are in R:

R

(As an insider's tip, I prefer to use Rstudio because it let's me see the command line and the database at the same time).

Then in the R terminal load the RMINC library:

library(RMINC)

To do analysis we need to read in a data file (make sure you have one subject per row, and one variable per column):

gf <- read.csv('Absolutepitch_Ed2.csv')

Do a quick check that you read the file in directory:

names(gf)

summary(gf)

Access the contents of a column using '$' eg:

gf$ID

Create a new column with all of the file names within it (and paths). RMINC needs the paths to each subject TXT file:

gf$left_thalamus_morph <- paste("/home/egarza/MRI/MAGeT_morph/Eduardopp_", gf$ID,"_t1/Eduardopp_", gf$ID, "_t1_thalamus_left_dp.txt", sep="")

Now check to see that you did this correctly.

In R print the new column:

gf$left_thalamus_morph

Then check for the existance of at least one of the files:

ls /home/egarza/MRI/MAGeT_morph/Eduardopp_c_035_t1/Eduardopp_c_035_t1_thalamus_left_dp.txt

So now its time for stats!!! Yeah!

Use vertexLm for the GLM analysis (if you don't know what GLM or ANOVA is, you shouldn't be doing this alone). In this example, I'm doing the displacement as my dependent variable and group as the independent dichotic variable. The other variables are my covariates:

vs <- vertexLm(left_thalamus_morph ~ group + age + gender, gf)

Now check for significance after multiple comparisons:

vertexFDR(vs)

The output tells you if anything survives FDR correction. My interest column here is group. In this example, there is a significant difference between groups. Each line represents an alpha, use the one you chose (usually 0.05):

FDR Thresholds:
 	F-statistic (Intercept) group age gender
0.01     	NaN     	NaN   NaN NaN	NaN
0.05     	NaN     	3.5433  NaN NaN	NaN
0.1      	NaN     	NaN   NaN NaN	NaN
0.15     	NaN     	NaN   NaN NaN	NaN
0.2      	NaN	2.327472   NaN NaN	NaN

If you get anything significant, output the vertex-wise t-stats so you can visualize them with brain-view2:

 write.table(vs, file='AP_processors_thalamus_left.txt',col.names=F, row.names=F)

Visualize stats:

$ brain-view2 thalamus_left_rot.obj Eduardopp_c_035_t1_thalamus_left_dp.txt

The VS file contains the columns of what the results mean in brain-view2:

Columns:  
0 F-statistic
1 R-squared
2 beta-(Intercept)
3 beta-sexM
4 beta-age
5 t-value-(intercept)
6 t-value-group
7 tvalue-age

In brain-view2, choose the appropriate column (in my case 6+1 because brain-view2 does not have 0) and threshold it to the significant T value after FDR correction (i.e. t= 3.54).

Gabe: The way the metrics are computed for morpho, we average all the displacement fields between the subject and the model and then we evaluate the dot product of the surface normal at every vertex with the displacement field the surface normal always points outwards. So, by virtue of dot product, normal*outward deformation field is a positive displacement metric normal*inward is always negative -ve = negative +ve = positive

Clone this wiki locally