This is a deep learning-based method to segment deep brain structures and a brain mask from T1 weighted MRI.

Overview

DBSegment

This tool generates 30 deep brain structures segmentation, as well as a brain mask from T1-Weighted MRI. The whole procedure should take ~1 min for one case.

The tool is available as a pip package. To run the package a GPU is required.

We highly recommend installing the package inside a virtual environment. For some instruction on virtual envrionment and pip package installation, please refer to: https://packaging.python.org/guides/installing-using-pip-and-virtual-environments/

Installation

pip install DBSegment

Once the package is installed, you can get the segmention by running the following command:

Example

DBSegment -i input_folder -o output_folder -mp path_to_model

The input folder should contain you input image, e.g. filename.nii.gz. Once it is done, two folders will be created, a preprocessed and an output folder. The output folder contains the segmentations of the the 30 brain structures and one label for the rest of the brain, filename.nii.gz, a file containing 30 brian structures segmenation, filename_seg.nii.gz, and a brain mask, filename_brainmask.nii.gz. The ouput files should be applied on the preprocessed image in the preprocessed folder, filename_0000.nii.gz.

Flags

-i is the input folder where your MR images are located. The input folder should contain nifti format T1 weighted MRI in ".nii.gz"* or ".nii"* format.

-i /Users/mehri.baniasadi/Documents/mr_data

-o is the output folder where the model outputs the segmentations.

-o /Users/mehri.baniasadi/Documents/mr_seg

-mp is the path to save the model. The default is /usr/local/share

-mp /Users/mehri.baniasadi/Documents/models

-f are the folds (networks) used for segmentation. The available folds are 0, 1, 2, 3, 4, 5, 6. The default folds are 4 and 6. We recommend to keep the default settings, and do not define this parameter.

-f 4 6

-v is the the version of the preprocessing you would like to aply before segmenation. The default is v3 (LPI oritnation, 1mm voxel spacing, 256 Dimension). The alternative option is v1 (LPI orientaiton). Please note that by chaning the version to v1 the segmenation quality will reduce by 1-2%.

-v v1

--disable_tta This Flag is for the test time augmentation. The default is True and tta is disabled, to enable the tta, set this flag to True. By setting the flag to True, the segmenation quality will improve by ~0.2%, and the inference time will increase by 10-20 seconds.

--disable_tta True

You might also like...
Using deep learning to predict gene structures of the coding genes in DNA sequences of Arabidopsis thaliana

DeepGeneAnnotator: A tool to annotate the gene in the genome The master thesis of the "Using deep learning to predict gene structures of the coding ge

NAACL'2021: Factual Probing Is [MASK]: Learning vs. Learning to Recall
NAACL'2021: Factual Probing Is [MASK]: Learning vs. Learning to Recall

OptiPrompt This is the PyTorch implementation of the paper Factual Probing Is [MASK]: Learning vs. Learning to Recall. We propose OptiPrompt, a simple

Applications using the GTN library and code to reproduce experiments in "Differentiable Weighted Finite-State Transducers"

gtn_applications An applications library using GTN. Current examples include: Offline handwriting recognition Automatic speech recognition Installing

Peek-a-Boo: What (More) is Disguised in a Randomly Weighted Neural Network, and How to Find It Efficiently

Peek-a-Boo: What (More) is Disguised in a Randomly Weighted Neural Network, and How to Find It Efficiently This repository is the official implementat

Multiple-criteria decision-making (MCDM) with Electre, Promethee, Weighted Sum and Pareto

EasyMCDM - Quick Installation methods Install with PyPI Once you have created your Python environment (Python 3.6+) you can simply type: pip3 install

Official Tensorflow implementation of
Official Tensorflow implementation of "M-LSD: Towards Light-weight and Real-time Line Segment Detection"

M-LSD: Towards Light-weight and Real-time Line Segment Detection Official Tensorflow implementation of "M-LSD: Towards Light-weight and Real-time Line

Pytorch implementation of
Pytorch implementation of "M-LSD: Towards Light-weight and Real-time Line Segment Detection"

M-LSD: Towards Light-weight and Real-time Line Segment Detection Pytorch implementation of "M-LSD: Towards Light-weight and Real-time Line Segment Det

 COD-Rank-Localize-and-Segment (CVPR2021)
COD-Rank-Localize-and-Segment (CVPR2021)

COD-Rank-Localize-and-Segment (CVPR2021) Simultaneously Localize, Segment and Rank the Camouflaged Objects Full camouflage fixation training dataset i

Comments
  • DBSegment not compatible with RTX 3080 GPUs

    DBSegment not compatible with RTX 3080 GPUs

    Hello!

    First of all congratulations on this really exciting tool! I was trying to use it with a RTX 3080 NVIDIA GPU but got the following error:

    Segmenting.
    /usr/share/miniconda3/envs/dbssegment/lib/python3.8/site-packages/torch/cuda/__init__.py:143: UserWarning: 
    NVIDIA GeForce RTX 3080 with CUDA capability sm_86 is not compatible with the current PyTorch installation.
    The current PyTorch install supports CUDA capabilities sm_37 sm_50 sm_60 sm_70.
    If you want to use the NVIDIA GeForce RTX 3080 GPU with PyTorch, please check the instructions at https://pytorch.org/get-started/locally/
    
      warnings.warn(incompatible_device_warn.format(device_name, capability, " ".join(arch_list), device_name))
    Traceback (most recent call last):
      File "/usr/share/miniconda3/envs/dbssegment/bin/DBSegment", line 8, in <module>
        sys.exit(main())
      File "/usr/share/miniconda3/envs/dbssegment/lib/python3.8/site-packages/DBSegment/DBSegment.py", line 597, in main
        main_infer()
      File "/usr/share/miniconda3/envs/dbssegment/lib/python3.8/site-packages/DBSegment/DBSegment.py", line 501, in main_infer
        inference(parser)
      File "/usr/share/miniconda3/envs/dbssegment/lib/python3.8/site-packages/DBSegment/DBSegment.py", line 357, in inference
        predict_from_folder(model_folder_name, input_folder, output_folder, folds, save_npz, num_threads_preprocessing,
      File "/usr/share/miniconda3/envs/dbssegment/lib/python3.8/site-packages/DBSegment/nnunet/inference/predict.py", line 666, in predict_from_folder
        return predict_cases(model, list_of_lists[part_id::num_parts], output_files[part_id::num_parts], folds,
      File "/usr/share/miniconda3/envs/dbssegment/lib/python3.8/site-packages/DBSegment/nnunet/inference/predict.py", line 218, in predict_cases
        softmax = trainer.predict_preprocessed_data_return_seg_and_softmax(
      File "/usr/share/miniconda3/envs/dbssegment/lib/python3.8/site-packages/DBSegment/nnunet/training/network_training/nnUNetTrainerV2.py", line 213, in predict_preprocessed_data_return_seg_and_softmax
        ret = super().predict_preprocessed_data_return_seg_and_softmax(data,
      File "/usr/share/miniconda3/envs/dbssegment/lib/python3.8/site-packages/DBSegment/nnunet/training/network_training/nnUNetTrainer.py", line 520, in predict_preprocessed_data_return_seg_and_softmax
        ret = self.network.predict_3D(data, do_mirroring=do_mirroring, mirror_axes=mirror_axes,
      File "/usr/share/miniconda3/envs/dbssegment/lib/python3.8/site-packages/DBSegment/nnunet/network_architecture/neural_network.py", line 147, in predict_3D
        res = self._internal_predict_3D_3Dconv_tiled(x, step_size, do_mirroring, mirror_axes, patch_size,
      File "/usr/share/miniconda3/envs/dbssegment/lib/python3.8/site-packages/DBSegment/nnunet/network_architecture/neural_network.py", line 386, in _internal_predict_3D_3Dconv_tiled
        predicted_patch = self._internal_maybe_mirror_and_pred_3D(
      File "/usr/share/miniconda3/envs/dbssegment/lib/python3.8/site-packages/DBSegment/nnunet/network_architecture/neural_network.py", line 533, in _internal_maybe_mirror_and_pred_3D
        pred = self.inference_apply_nonlin(self(x))
      File "/usr/share/miniconda3/envs/dbssegment/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl
        return forward_call(*input, **kwargs)
      File "/usr/share/miniconda3/envs/dbssegment/lib/python3.8/site-packages/DBSegment/nnunet/network_architecture/generic_UNet.py", line 391, in forward
        x = self.conv_blocks_context[d](x)
      File "/usr/share/miniconda3/envs/dbssegment/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl
        return forward_call(*input, **kwargs)
      File "/usr/share/miniconda3/envs/dbssegment/lib/python3.8/site-packages/DBSegment/nnunet/network_architecture/generic_UNet.py", line 142, in forward
        return self.blocks(x)
      File "/usr/share/miniconda3/envs/dbssegment/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl
        return forward_call(*input, **kwargs)
      File "/usr/share/miniconda3/envs/dbssegment/lib/python3.8/site-packages/torch/nn/modules/container.py", line 141, in forward
        input = module(input)
      File "/usr/share/miniconda3/envs/dbssegment/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl
        return forward_call(*input, **kwargs)
      File "/usr/share/miniconda3/envs/dbssegment/lib/python3.8/site-packages/DBSegment/nnunet/network_architecture/generic_UNet.py", line 65, in forward
        x = self.conv(x)
      File "/usr/share/miniconda3/envs/dbssegment/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl
        return forward_call(*input, **kwargs)
      File "/usr/share/miniconda3/envs/dbssegment/lib/python3.8/site-packages/torch/nn/modules/conv.py", line 590, in forward
        return self._conv_forward(input, self.weight, self.bias)
      File "/usr/share/miniconda3/envs/dbssegment/lib/python3.8/site-packages/torch/nn/modules/conv.py", line 585, in _conv_forward
        return F.conv3d(
    RuntimeError: CUDA error: no kernel image is available for execution on the device
    CUDA kernel errors might be asynchronously reported at some other API call,so the stacktrace below might be incorrect.
    For debugging consider passing CUDA_LAUNCH_BLOCKING=1.
    

    Is it possible to add compatibility for this GPU as well?

    Thanks!

    opened by jAchtzehn 1
  • warning to be removed

    warning to be removed

    Remove the following warning when run on CPU:

    /mnt/lscratch/users/mbaniasadi2/dbsegment_test/env_cpu/lib/python3.7/site-packages/torch/cuda/amp/grad_scaler.py:115: UserWarning: torch.cuda.amp.GradScaler is enabled, but CUDA is not available. Disabling. warnings.warn("torch.cuda.amp.GradScaler is enabled, but CUDA is not available. Disabling.") /mnt/lscratch/users/mbaniasadi2/dbsegment_test/env_cpu/lib/python3.7/site-packages/torch/autocast_mode.py:141: UserWarning: User provided device_type of 'cuda', but CUDA is not available. Disabling warnings.warn('User provided device_type of 'cuda', but CUDA is not available. Disabling')

    opened by MehriB 0
Owner
Luxembourg Neuroimaging (Platform OpNeuroImg)
Collaboration between Interventional Neuroscience Group @uni.lu and National Dept. of Neurosurgery @centre hospitalier de Luxembourg
Luxembourg Neuroimaging (Platform OpNeuroImg)
Face Mask Detection is a project to determine whether someone is wearing mask or not, using deep neural network.

face-mask-detection Face Mask Detection is a project to determine whether someone is wearing mask or not, using deep neural network. It contains 3 scr

amirsalar 13 Jan 18, 2022
DCT-Mask: Discrete Cosine Transform Mask Representation for Instance Segmentation

DCT-Mask: Discrete Cosine Transform Mask Representation for Instance Segmentation This project hosts the code for implementing the DCT-MASK algorithms

Alibaba Cloud 57 Nov 27, 2022
The Face Mask recognition system uses AI technology to detect the person with or without a mask.

Face Mask Detection Face Mask Detection system built with OpenCV, Keras/TensorFlow using Deep Learning and Computer Vision concepts in order to detect

Rohan Kasabe 4 Apr 5, 2022
MRQy is a quality assurance and checking tool for quantitative assessment of magnetic resonance imaging (MRI) data.

Front-end View Backend View Table of Contents Description Prerequisites Running Basic Information Measurements User Interface Feedback and usage Descr

Center for Computational Imaging and Personalized Diagnostics 58 Dec 2, 2022
Implementation of Advantage-Weighted Regression: Simple and Scalable Off-Policy Reinforcement Learning

advantage-weighted-regression Implementation of Advantage-Weighted Regression: Simple and Scalable Off-Policy Reinforcement Learning, by Peng et al. (

Omar D. Domingues 1 Dec 2, 2021
Code for paper: Group-CAM: Group Score-Weighted Visual Explanations for Deep Convolutional Networks

Group-CAM By Zhang, Qinglong and Rao, Lu and Yang, Yubin [State Key Laboratory for Novel Software Technology at Nanjing University] This repo is the o

zhql 98 Nov 16, 2022
[CVPR2021] DoDNet: Learning to segment multi-organ and tumors from multiple partially labeled datasets

DoDNet This repo holds the pytorch implementation of DoDNet: DoDNet: Learning to segment multi-organ and tumors from multiple partially labeled datase

null 116 Dec 12, 2022
Pytorch implementation of paper "Learning Co-segmentation by Segment Swapping for Retrieval and Discovery"

SegSwap Pytorch implementation of paper "Learning Co-segmentation by Segment Swapping for Retrieval and Discovery" [PDF] [Project page] If our project

xshen 41 Dec 10, 2022
Code for "Learning to Segment Rigid Motions from Two Frames".

rigidmask Code for "Learning to Segment Rigid Motions from Two Frames". ** This is a partial release with inference and evaluation code.

Gengshan Yang 157 Nov 21, 2022
【ACMMM 2021】DSANet: Dynamic Segment Aggregation Network for Video-Level Representation Learning

DSANet: Dynamic Segment Aggregation Network for Video-Level Representation Learning (ACMMM 2021) Overview We release the code of the DSANet (Dynamic S

Wenhao Wu 46 Dec 27, 2022