Create Template brain - GarzaLab/Documentation GitHub Wiki
This tutorial uses the Axolotl brian project.
In this project, I needed to create a new template brain for atlas segmentation. These are the steps I took and can be taken with any other animal brain. I also made a script example for the preprocesing.
I used only minc tools
because the clean_and_center.pl
from Gabriel A. Devenyi is used in minc. You can find that script in the minc-toolkit-extras
module and in this github.
The steps are:
- Preprocess and N4 the raw inputs conservatively (otsu mask)
- Build a bootstrap average with antsMultivariateTemplateConstruction.sh
- Brainmask the average
- Transform brainmask back to bias field correct the inputs better
- Re-orient, upsample, and extract average
- Extract the inputs
- Run a new modelbuild with the re-oriented upsampled average as the target
- Depending on results of 7, redo order again to further improve depends on how well 7 does.
Preprocess and N4 the raw inputs conservatively (otsu mask)
- Center in space and cleanup slicing (cosines are screwed). normal cosines are 1 0 0; 0 1 0; 0 0 1 (check mincheader)
clean_and_center.pl $tmpdir/flip.mnc $tmpdir/centered.mnc
- Swap orientations so that scans start oriented the same and in neurological view.
volrot -y_rotation -90 $tmpdir/centered.mnc $tmpdir/rotate.mnc
volflip -y $tmpdir/rotate.mnc $tmpdir/flip.mnc
- Make 0tsu mask
ImageMath 3 mask.mnc ThresholdAtMean flip.mnc 0.5
ImageMath 3 mask2.mnc GetLargestComponent mask.mnc
rm -v mask.mnc; mv mask2.mnc mask.mnc
-
Make a full-scan mask to short-circuit some N4 sillyness
minccalc -byte -unsigned -expression 'A[0]?1:1' $tmpdir/flip.mnc $tmpdir/fullmask.mnc
-
Run N4 correction N4BiasFieldCorrection -d 3 -i $tmpdir/flip.mnc -b [20] -c [200x200x200,0.0] -w $tmpdir/mask.mnc -r 1 -x $tmpdir/fullmask.mnc -o $tmpdir/denoise.N4.mnc
-
Check the outputs of the N4 and do QC before running the templante builder.
Build a bootstrap average with antsMultivariateTemplateConstruction.sh
- In the LAVIS ADA cluster, run with this line.
-c 1
stands for SGE parallel,-r
stands for linear registration,-n 0
does not run a new N4 correction.
antsMultivariateTemplateConstruction.sh -d 3 -o test1 -c 1 -r 1 -n 0 *_f_denoise.N4.mnc
- Check the result and move on.