Deformation Based Morphometry MBM.py no atlas - GarzaLab/Documentation GitHub Wiki

MICe-build-model is a toolkit that allows you to perform image registration on mouse brains. This works by trying to fit two ore more images into an average. Differences between the average image and individual images allow us to calculate differences between 2 or more groups of mice. For detailed information on how the pipline works at every stage, please consult: https://wiki.mouseimaging.ca/display/MICePub/MiceBuildModelAlgorithm.

In order to run MICe-build-model, you will first create a run directory, ex: mbm_run_date.

First, you must create a .csv file with a list of absolute paths to all of your input files. The first file in the list will be the target file for your registration, as we will be using a bootstrapping option, so choose wisely. The first row of your .csv file should be "file", following by the list of scan paths.

Example:

file
/mnt/MD1200B/egarza/egarza/fatrat/preproc/01_t1_pp.mnc
/mnt/MD1200B/egarza/egarza/fatrat/preproc/02_t1_pp.mnc
/mnt/MD1200B/egarza/egarza/fatrat/preproc/03_t1_pp.mnc
/mnt/MD1200B/egarza/egarza/fatrat/preproc/04_t1_pp.mnc
/mnt/MD1200B/egarza/egarza/fatrat/preproc/05_t1_pp.mnc
/mnt/MD1200B/egarza/egarza/fatrat/preproc/06_t1_pp.mnc
/mnt/MD1200B/egarza/egarza/fatrat/preproc/07_t1_pp.mnc
/mnt/MD1200B/egarza/egarza/fatrat/preproc/08_t1_pp.mnc
/mnt/MD1200B/egarza/egarza/fatrat/preproc/09_t1_pp.mnc
/mnt/MD1200B/egarza/egarza/fatrat/preproc/10_t1_pp.mnc
/mnt/MD1200B/egarza/egarza/fatrat/preproc/11_t1_pp.mnc
/mnt/MD1200B/egarza/egarza/fatrat/preproc/12_t1_pp.mnc
/mnt/MD1200B/egarza/egarza/fatrat/preproc/13_t1_pp.mnc
.
.
.

Now you can create a config: CIC.cfg file to override the defaults as follows:

[CIC]
queue-type=sge
queue-name=all.q
time-to-accept-jobs=180
mem-request-attribute=mem_free
mem=46
num-executors=240
lsq6-simple=True
lsq12-protocol=/mnt/MD1200A/QUARANTINE/resources/protocols/linear/Pydpiper_default_lsq12_protocol.csv
no-nuc=True
registration-method=ANTS

Next, you'll create your run script, which will look something like this:

module load python36/3.6.8 imagemagick/7.0.5.4 minc-toolkit-v2/1.9.17 torch7/29jul2019 minc2-simple/2.2.30 minc-toolkit-extras/24abr2019 hdf5/1.8.18 netcdf/gcc/64/4.4.1.1 gcc/5.2.0 minc-stuffs/0.1.24 pydpiper/2.0.13 parallel/20190522 qbatch/2.1.3
module load ants/9may2019

# export HDF5_DISABLE_VERSION_CHECK=1 (only if minc-stuffs is not directed to minc-toolkit)
export PYDPIPER_CONFIG_FILE=/mnt/MD1200B/egarza/egarza/fatrat/mbm/CIC.cfg


MBM.py \
--verbose \
--pipeline-name=fatrat_20SEP2019 \
--num-executors 48 \
--csv-file /mnt/MD1200B/egarza/egarza/fatrat/mbm/input.csv \
--bootstrap \
--no-nuc \
--lsq6-simple \
--no-run-maget \
--no-common-space-registration \
--maget-no-mask \
--output-dir /mnt/MD1200B/egarza/egarza/fatrat/mbm/output

Then just run the script ./run-script.sh. If it doesn't run, make it executable.

The Pydpiper runs on the cluster AND the terminal, therefore you cannot close the window.

MBM.py: the pipeline that will run the registrations. Running MBM.py --help in your terminal will give you a list of all the pipeline options.

--verbose: will print jobs to screen

--pipeline-name: whatever name makes sense to you

--num-executors: number of processing units you will use

--csv-file: your input csv-file. You can also just use --files and point to a folder with your input files.

--bootstrap: uses the first scan as the target scan (instead of the atlas) for the registrations

--no-nuc: turns off non-uniformity correction

--lsq6-simple: this is useful if your scans are well aligned (it will cut down on computational time). The default is --lsq6-large-rotations, which you may want to use if your scans are not aligned (more that 15 degrees offcenter)

--no-run-maget: turns off the MAGeT run.

--no-common-space-registration: self-explanatory.

Once your pipeline has run to completion, you are ready to quality control your outputs. In your run directory, look for the pipeline_name_processed directory, in which there will be a folder for each subject, within which there is a tmp folder. In the tmp folder, you will have a image you can use to check if your registrations were successful, ending in lsq6_QC_image.png. Check this for each subject.

LSQ6 Montage: LSQ6 Montage

LSQ12 Montage: LSQ12 Montage

Assuming your scans have passed quality control, you are ready to look for results. Within your run folder you will have a determinants.csv, in which the absolute paths to your absolute and relative jacobians lives. You'll have columns with paths to both the Absolute Jacobians (log_full_det) and the Relative Jacobinas (log_nlin_det).

xfm,inv_xfm,fwhm,log_nlin_det,log_full_det
/mnt/MD1200B/egarza/egarza/fatrat/mbm/output/fatrat_20SEP2019_processed/01_t1_pp/transforms/01_t1_pp_I_lsq6_lsq12_and_nlin_inverted.xfm,/mnt/MD1200B/egarza/egarza/fatrat/mbm/output/fatrat_20SEP2019_processed/01_t1_pp/transforms/01_t1_pp_I_lsq6_lsq12_and_nlin.xfm,0.2,/mnt/MD1200B/egarza/egarza/fatrat/mbm/output/fatrat_20SEP2019_processed/01_t1_pp/stats-volumes/01_t1_pp_I_lsq6_lsq12_and_nlin__concat_inverted_linear_part_displ_log_det_rel_fwhm0.2.mnc,/mnt/MD1200B/egarza/egarza/fatrat/mbm/output/fatrat_20SEP2019_processed/01_t1_pp/stats-volumes/01_t1_pp_I_lsq6_lsq12_and_nlin_inverted_displ_log_det_abs_fwhm0.2.mnc
/mnt/MD1200B/egarza/egarza/fatrat/mbm/output/fatrat_20SEP2019_processed/02_t1_pp/transforms/02_t1_pp_I_lsq6_lsq12_and_nlin_inverted.xfm,/mnt/MD1200B/egarza/egarza/fatrat/mbm/output/fatrat_20SEP2019_processed/02_t1_pp/transforms/02_t1_pp_I_lsq6_lsq12_and_nlin.xfm,0.2,/mnt/MD1200B/egarza/egarza/fatrat/mbm/output/fatrat_20SEP2019_processed/02_t1_pp/stats-volumes/02_t1_pp_I_lsq6_lsq12_and_nlin__concat_inverted_linear_part_displ_log_det_rel_fwhm0.2.mnc,/mnt/MD1200B/egarza/egarza/fatrat/mbm/output/fatrat_20SEP2019_processed/02_t1_pp/stats-volumes/02_t1_pp_I_lsq6_lsq12_and_nlin_inverted_displ_log_det_abs_fwhm0.2.mnc
/mnt/MD1200B/egarza/egarza/fatrat/mbm/output/fatrat_20SEP2019_processed/03_t1_pp/transforms/03_t1_pp_I_lsq6_lsq12_and_nlin_inverted.xfm,/mnt/MD1200B/egarza/egarza/fatrat/mbm/output/fatrat_20SEP2019_processed/03_t1_pp/transforms/03_t1_pp_I_lsq6_lsq12_and_nlin.xfm,0.2,/mnt/MD1200B/egarza/egarza/fatrat/mbm/output/fatrat_20SEP2019_processed/03_t1_pp/stats-volumes/03_t1_pp_I_lsq6_lsq12_and_nlin__concat_inverted_linear_part_displ_log_det_rel_fwhm0.2.mnc,/mnt/MD1200B/egarza/egarza/fatrat/mbm/output/fatrat_20SEP2019_processed/03_t1_pp/stats-volumes/03_t1_pp_I_lsq6_lsq12_and_nlin_inverted_displ_log_det_abs_fwhm0.2.mnc
/mnt/MD1200B/egarza/egarza/fatrat/mbm/output/fatrat_20SEP2019_processed/04_t1_pp/transforms/04_t1_pp_I_lsq6_lsq12_and_nlin_inverted.xfm,/mnt/MD1200B/egarza/egarza/fatrat/mbm/output/fatrat_20SEP2019_processed/04_t1_pp/transforms/04_t1_pp_I_lsq6_lsq12_and_nlin.xfm,0.2,/mnt/MD1200B/egarza/egarza/fatrat/mbm/output/fatrat_20SEP2019_processed/04_t1_pp/stats-volumes/04_t1_pp_I_lsq6_lsq12_and_nlin__concat_inverted_linear_part_displ_log_det_rel_fwhm0.2.mnc,/mnt/MD1200B/egarza/egarza/fatrat/mbm/output/fatrat_20SEP2019_processed/04_t1_pp/stats-volumes/04_t1_pp_I_lsq6_lsq12_and_nlin_inverted_displ_log_det_abs_fwhm0.2.mnc

The next thing to look at is blurring factor, which shows up near the end of the file (0,0.2). This allows some amount of deformation "bleeding" from one voxel to the nearby voxels. Some amount of influence on neighbouring voxels is necessary. It's unlikely that only a single voxel would grow or shrink in isolation, it must "tug" on surrounding tissue. It smooths out the deformation field which you can imagine as a 3D grid embedded in your scans. Generally, 0.2 is what you want to use.

The Jacobian maps look like this:

Jacobian Map subject 1

In the terminal, navigate to the folder you made in step 1 for the statistical analysis. Load up the following modules in this order:

Start rstudio

module load R/3.4.0
module load rstudio
module load R-extras/3.4.0
module load minc-toolkit/1.9.16
module load RMINC/1.5.1.0^minc-toolkit-1.9.16^R-3.4.0
module load rstudio

Set the working directory for rstudio to the folder that you made for this analysis.

Write and run a script to model your Jacobians.

The mincLm() function is a good starting place. This will perform a linear model at every voxel. You can use a brain mask to limit statistical comparisons to the brain, and use the False Discovery Rate correction to perform a multiple comparisons correction.