unravel.segment.brain_mask module#
Use seg_brain_mask
(sbm
) from UNRAVEL to use a trained ilastik project (pixel classification) to mask the brain in resampled autofluo images (often improves registration).
- Prereqs:
Organize training tif slices (from
seg_copy_tifs
) into a single folder.Train an Ilastik project to segment the brain (https://b-heifets.github.io/UNRAVEL/guide.html#train-an-ilastik-project).
Train ilastik (tissue = label 1) w/ tifs from reg_inputs/autofl_`*`um_tifs/*.tif (from
reg_prep
)Save brain_mask.ilp in experiment directory of use -ilp
- Inputs:
reg_inputs/autofl_`*`um.nii.gz
brain_mask.ilp # in exp dir
- Outputs:
reg_inputs/autofl_`*`um_tifs_ilastik_brain_seg/slice_`*`.tif series
reg_inputs/autofl_`*`um_brain_mask.nii.gz (can be used for
reg
andvstats_z_score
)reg_inputs/autofl_`*`um_masked.nii.gz
Note
Ilastik executable files for each OS (update path and version as needed):
Linux and WSL: /usr/local/ilastik-1.4.0.post1-Linux/run_ilastik.sh
Mac: /Applications/ilastik-1.4.0.post1-OSX.app/Contents/ilastik-release/run_ilastik.sh
Windows: C:Program Filesilastik-1.4.0.post1run_ilastik.bat
The Ilastik project should be closed before running this script.
- Next command:
reg
Usage:#
seg_brain_mask -ilp <path/brain_mask.ilp> [-ie path/ilastik_executable ] [-i reg_inputs/autofl_50um.nii.gz] [-d list of paths] [-p sample??] [-v]