unravel.segment.ilastik_pixel_classification module#
Use seg_ilastik
(si
) from UNRAVEL to use segment features of interest using Ilastik.
- Prereqs:
Organize training tifs into a folder (e.g., w/
seg_copy_tifs
) .Train Ilastik (https://b-heifets.github.io/UNRAVEL/guide.html#train-an-ilastik-project).
- Inputs:
ilastik_project: path/ilastik_project.ilp
Input: path/tif_dir or path/image (relative to current dir or sample??/)
Input image types: .tif, .czi, .nii.gz, .h5, .zarr
If a glob pattern is used, the first match is used.
- Outputs:
seg_dir/seg_dir/*.tif series (segmented images; delete w/ –rm_out_tifs)
Optional: seg_dir/seg_dir_<label>.nii.gz (binary masks for each label specified w/ –labels)
Skips processing if output already exists (.nii.gz with –labels or .tif without)
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.
Usage:#
seg_ilastik -ilp path/ilastik_project.ilp -i <tif_dir or image> -o seg_dir [–labels 1 2 3] [–rm_out_tifs] [–channel 1] [-ie path/ilastik_executable] [-d list of paths] [-p sample??] [-v]
- unravel.segment.ilastik_pixel_classification.count_files(directory)[source]#
Count the number of files in a directory, excluding subdirectories.