Skip to main content

Deep-learning Tool for White Matter (WM) lesions and Claustrum structure segmentation in brain magnetic resonance imaging (MRI).

Project description

deepNeuroSeg

There are two different segmentation tasks you can perform: White Matter Lesions (WMH - White Matter Hyperintensities) and Claustrum Segmentation. The required models will be downloaded to ~/.deepNeuroSeg as soon as needed. WMH segmentation can be performed either using FLAIR only or both FLAIR and T1. The results would be similar to our experience [1]. 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.

Claustrum segmentation is still in development.

How to:

Run deepNeuroSeg either in command line or Python.

Command line

deepNeuroSeg performs two different segmentation tasks. The desired task must be specified with --type that is either equals to wmh (White Matter Hyperintensities (Lesions)) or c (Claustrum). For example:

deepNeuroSeg --type wmh --flair 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 TEXT    Path to .nii.gz file of a FLAIR scan.  [required]
  --t1 TEXT       Path to .nii.gz file of a T1 scan. [optional]
  --o TEXT        Directory path where to save the resulting segmentation.
                  [required]

The resulting mask will be saved in the user-specified directory under the name out_mask.nii.gz.

Python

In Python user will have to follow the following steps by creating a SegmentationFactory object that can have a segmentation type either SegmentationType.WMH or SegmentationType.Claustrum. An example for WMH Segmentation with both FLAIR and T1 modalities:

from deepNeuroSeg import SegmentationFactory, SegmentationType

segmenter = SegmentationFactory.create_segmenter(SegmentationType.WMH, 
                                                    FLAIR_path='YOUR_PATH',
                                                    T1_path='YOUR_PATH')

An example for WMH Segmentation with FLAIR only:

from deepNeuroSeg import SegmentationFactory, SegmentationType

segmenter = SegmentationFactory.create_segmenter(SegmentationType.WMH, 
                                                    FLAIR_path='YOUR_PATH')

Then the segmentation can be performed. Here user can specify the output directory where the segmentation mask will be saved as out_mask.nii.gz:

prediction = segmenter.perform_segmentation(outputDir='YOUR_PATH')

or inspect the numpy array yourself and save it with save_segmentation method.

prediction = segmenter.perform_segmentation()
segmenter.save_segmentation(mask=prediction, outputDir='YOUR_PATH')

In both cases, the prediction can be saved in the output directory desired by the user under the name out_mask.nii.gz.

[1]: Li, Hongwei, et al. "Fully convolutional network ensembles for white matter hyperintensities segmentation in MR images." NeuroImage 183 (2018): 650-665.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

deepNeuroSeg-0.1.tar.gz (9.6 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page