There are two different segmentation tasks you can perform with deepNeuroSeg: White Matter Hyperintensities (WMH) and Claustrum Segmentation. To learn details about the used deep-learning models please refer to the publications [1] and [2]. As soon as the underlying models are required, they will be downloaded to your computer and placed in ~/.deepNeuroSeg folder.
WMH segmentation can be performed either using FLAIR only or both FLAIR and T1 scans. The results would be similar to our experience [1], but the default is using both of them.
Fig.1: Segmentation result on Singapore 34 [1]. From left to right: FLAIR MR image, the associated ground truth, segmentation result using FLAIR modality only and segmentation result using FLAIR and T1 modalities. In column SegF LAIR and SegF LAIR+T1, the green area is the overlap between the segmentation maps and the ground-truth, the red pixels are the false negatives and the black ones are the false positives.
For Claustrum Segmentation the T1 scan must be provided.
Run deepNeuroSeg either in command line or Python.
deepNeuroSeg performs two different segmentation tasks. The desired task must be specified with --type
that is either equals to wmh
(White Matter Hyperintensities) or c
(Claustrum). For example:
deepNeuroSeg --type wmh --flair YOUR_PATH.nii.gz --t1 YOUR_PATH.nii.gz --o YOUR_PATH
Or:
deepNeuroSeg --type c --t1 YOUR_PATH.nii.gz --o YOUR_PATH
For more details see:
deepNeuroSeg --help
Options:
--type [wmh|c] Either 'wmh' (White Matter Hyperintensities) or 'c'
(Claustrum)
--flair PATH Path to nii.gz file with a FLAIR scan.
--t1 PATH Path to nii.gz file with a T1 scan.
--o TEXT Path where to save the resulting segmentation. Directory path or specific nii.gz file path.
[required]
--help Show this message and exit.
The resulting mask will be saved with user-specified .nii.gz file name or in the user-specified directory under the name out_mask.nii.gz.
In Python user will have to follow the next steps:
Step 1: Import deepNeuroSeg
from deepNeuroSeg import SegmentationFactory, SegmentationType
Step 2: Create a SegmentationFactory
object with segmentation type either SegmentationType.Claustrum
or SegmentationType.WMH
. An example for WMH Segmentation with both FLAIR and T1 modalities:
segmenter = SegmentationFactory.create_segmenter(SegmentationType.WMH,
FLAIR_path='YOUR_PATH',
T1_path='YOUR_PATH')
Or claustrum segmentation:
segmenter = SegmentationFactory.create_segmenter(SegmentationType.Claustrum,
T1_path='YOUR_PATH')
Step 3: Next the segmentation can be performed.
Option a: The user can specify the output path directly in perform_segmentation
method.
prediction = segmenter.perform_segmentation(outputDir='YOUR_PATH')
Option b: The output numpy array can be inspected first, and then saved with save_segmentation
function.
prediction = segmenter.perform_segmentation()
segmenter.save_segmentation(mask=prediction, outputDir='YOUR_PATH')
In both cases, the output mask will be saved with user-specified .nii.gz file name or in user-specified directory under the name out_mask.nii.gz.
See also the jupyter notebook for a quick start.
Special feature of Claustrum Segmentation:
The user can check the orientation of the coronal and axial images by selecting the special feature in perform_segmentation
method:
prediction = segmenter.perform_segmentation(check_orientation=True)
check_orientation=True
will save the images of coronal and axial slices under ~/.deepNeuroSeg/images/.
[1]: Li, Hongwei, et al. "Fully convolutional network ensembles for white matter hyperintensities segmentation in MR images." NeuroImage 183 (2018): 650-665.
[2]: Li, Hongwei, et al. "Complex Grey Matter Structure Segmentation in Brains via Deep Learning: Example of the Claustrum." arXiv preprint arXiv:2008.03465 (2020).