Skip to content

Making a stats mask for 2level dbm output

Elisa Guma edited this page Feb 8, 2021 · 17 revisions

This page covers the basics of creating a stats mask for the 2level dbm outputs obtained after following this wiki: https://github.com/CoBrALab/documentation/wiki/Running-twolevel_ants_dbm-on-Niagara for this pipeline: https://github.com/cobralab/twolevel_ants_dbm

You may have noticed in your outputs from the twolevel_ants_dbm that the mask provided is an otsu mask, not appropriate for use in your model. Here we will walk through the process of registering a mask to the template produced by your DBM. As an example, I will be using mouse brains, but the procedure is the same for humans.

What you need:

  1. a model average, such as the DSURQE_40micron_average, henceforth referred to as <model> (you may use a higher resolution, resample average here if you created one for your ANTs DBM run)
  2. a mask associated with the model, such as the DSURQE_40micron_mask, henceforth referred to as <mask>
  3. the template produced from your dbm run, which can be found within your run directory at ./output/secondlevel/secondlevel_template0.nii.gz henceforth referred to as <template>

All files must be niftis.

$ module load minc-toolkit minc-toolkit-extras ANTs
# All modules are already included in the cobralab module on Niagara

Step 1: Register your template to your model. Here is the command:

$ antsRegistration_affine_SyN.sh --fixed-mask <mask> <template> <model> template_to_model

Step 2: Apply the transformations garnered from Step 1 to the mask so it is fits the template Command:

$ antsApplyTransforms -d 3 -i <mask>  -t [ template_to_model0GenericAffine.mat,1 ] \
    -t template_to_model1InverseWarp.nii.gz -o mask.nii.gz -r <template> --verbose -n GenericLabel

-d signifies the images are 3 dimensional

-i is the input mask

-o is the name of the output file, which will be the mask on the template.

-t are your transform files

-r is your reference image.

-n the interpolator used will be Generic Label, which is the best interpolator for discrete data (added by the venerable Gabriel A. Devenyi)

--verbose provides terminal outputs

Once you have run both of these you can use convert the output, mask.nii, to a mnc with nii2mnc and use this in your statistical analyses.

If you prefer to run use minc files you can do so. Step 1 will be the same, and Step 2 will be the following:

antsApplyTransforms -d 3 -i <mask>  -t [ template_to_model0_GenericAffine.xfm,1 ] \
    -t template_to_model1_inverse_NL.xfm -o mask.nii.gz -r <template> --verbose -n GenericLabel

Checking your mask

View your mask on your template average.

Display <template.mnc> -label mask.mnc

Switch the background image to greyscale.

If your mask seems to fall over the edge a bit, like the example, you may need to erode it.

image

In the terminal, type: mincmorph -erosion mask.mnc eroded_mask.mnc

This will perform a single erosion on the mask and output the file eroded_mask.mnc.

You can then display this the same way and visually compare the results!

image

Clone this wiki locally