GithubHelp home page GithubHelp logo

iitzco / deepbrain Goto Github PK

View Code? Open in Web Editor NEW
129.0 4.0 37.0 41.4 MB

Deep Learning tools for brain medical images

License: MIT License

Python 100.00%
deep-learning medical-imaging artificial-intelligence brain-mri tensorflow neural-networks machine-learning

deepbrain's Introduction

DeepBrain

PyPI - Version PyPI - Python Version

Brain image processing tools using Deep Learning focused on speed and accuracy.

How to install

$ pip install deepbrain

Available tools:

Extractor

img

Extract brain tissue from T1 Brain MRI (i.e skull stripping).

Extractor runs a custom U-Net model trained on a variety of manual-verified skull-stripping datasets.

Why choose Extractor over others (e.g. BET FSL, ANTs, PINCRAM)?

  1. Extractor is fast. It's CNN was implemented on Tensorflow and carefully designed to be as small as possible (i.e. lower amount of parameters). See below for speed comparison. You can achieve < 2 second extraction on GPU.

  2. Running Extractor is easy. You don't need to provide any complicated parameters (like brain templates or prior probability masks), just with the brain MRI is enough. This is because the model was trained with a data augmentation process that involved all kind of rotations and orientations of the brain MRI. This means that the extraction will be successfull regardless the orientation of the input brain MRI. No registration process is done.

  3. Extractor is accurate. It does not fail in some cases where others (specially BET) fails.

Speed

Extractor CPU (i5 2015 MBP) Extractor GPU (Nvidia TitanXP)
~20 seconds ~2 seconds

Accuracy

Extractor achieves state-of-the art accuracy > 0.97 Dice metric on the test set that is compound with a subset of entries from the CC359 dataset, NFBS dataset and ADNI dataset.

How to run

As command line program

$ deepbrain-extractor -i brain_mri.nii.gz -o ~/Desktop/output/

Where:

  • -i: the brain MRI that will be skull-stripped. It can be a nii or nii.gz image (or whatever format nibabel supports).
  • -o: an output directory (does not need to exist) where the program will save the brain_mask.nii and brain.nii files.

See deepbrain-extractor -h for more information.

As python

import nibabel as nb
from deepbrain import Extractor

# Load a nifti as 3d numpy image [H, W, D]
img = nib.load(img_path).get_fdata()

ext = Extractor()

# `prob` will be a 3d numpy image containing probability 
# of being brain tissue for each of the voxels in `img`
prob = ext.run(img) 

# mask can be obtained as:
mask = prob > 0.5

See deepbrain-extractor -h for more information.

Future Tools:

  • Brain T1 tissue segmentation [WORK IN PROGRESS]

deepbrain's People

Contributors

iitzco avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

deepbrain's Issues

Network Architecture

Hi, I would like to have a detailed description of the network architecture. Can anyone help me? Thank you.

Reference paper

Thanks a lot for sharing the nice code!

And when I use this code for brain extraction, which papers should I add as references?
Thanks, have a nice day: )

Input image normalization

Hi, I'm using deepbrain to perform a whole brain extraction from T1 MRI.

Which normalization algorithm has been applied to input images during the training procedure of U-Net?

deepbrain-extractor is not recognized as an internal or external command

Hi, apologies if this is a basic issue - I'm new to this.

After installing the deepbrain library using pip, I tried running the program through command line but it returns the error message "deepbrain-extractor is not recognized as an internal or external command".

deepbrain-extractor -h returns the same error message.

Please help! Very excited to see if this skull-stripping program is better than BET.

Problem with Scipy

Hi, I cannot run the extractor, due to error with scipy library (I'm using 1.4.1 on spyder, win10):
AttributeError: module 'scipy' has no attribute '_lib'

the full error:

File "C:\Users\YE3467\Downloads\Project Code\DataPreprocess.py", line 67, in
from deepbrain import Extractor

File "C:\Users\YE3467\Anaconda3\lib\site-packages\deepbrain_init_.py", line 1, in
from deepbrain.extractor import Extractor

File "C:\Users\YE3467\Anaconda3\lib\site-packages\deepbrain\extractor.py", line 3, in
from skimage.transform import resize

File "C:\Users\YE3467\Anaconda3\lib\site-packages\skimage\transform_init_.py", line 4, in
from .radon_transform import (radon, iradon, iradon_sart,

File "C:\Users\YE3467\Anaconda3\lib\site-packages\skimage\transform\radon_transform.py", line 5, in
from ._warps import warp

File "C:\Users\YE3467\Anaconda3\lib\site-packages\skimage\transform_warps.py", line 7, in
from ..measure import block_reduce

File "C:\Users\YE3467\Anaconda3\lib\site-packages\skimage\measure_init_.py", line 7, in
from ._polygon import approximate_polygon, subdivide_polygon

File "C:\Users\YE3467\Anaconda3\lib\site-packages\skimage\measure_polygon.py", line 2, in
from scipy import signal

File "C:\Users\YE3467\Anaconda3\lib\site-packages\scipy\signal_init_.py", line 301, in
from .filter_design import *

File "C:\Users\YE3467\Anaconda3\lib\site-packages\scipy\signal\filter_design.py", line 18, in
from scipy import special, optimize, fft as sp_fft

File "C:\Users\YE3467\Anaconda3\lib\site-packages\scipy\optimize_init_.py", line 390, in
from ._minimize import *

File "C:\Users\YE3467\Anaconda3\lib\site-packages\scipy\optimize_minimize.py", line 30, in
from ._trustregion_constr import _minimize_trustregion_constr

File "C:\Users\YE3467\Anaconda3\lib\site-packages\scipy\optimize_trustregion_constr_init_.py", line 4, in
from .minimize_trustregion_constr import _minimize_trustregion_constr

File "C:\Users\YE3467\Anaconda3\lib\site-packages\scipy\optimize_trustregion_constr\minimize_trustregion_constr.py", line 4, in
from scipy.sparse.linalg import LinearOperator

File "C:\Users\YE3467\Anaconda3\lib\site-packages\scipy\sparse\linalg_init_.py", line 113, in
from .isolve import *

File "C:\Users\YE3467\Anaconda3\lib\site-packages\scipy\sparse\linalg\isolve_init_.py", line 6, in
from .iterative import *

File "C:\Users\YE3467\Anaconda3\lib\site-packages\scipy\sparse\linalg\isolve\iterative.py", line 136, in
def bicg(A, b, x0=None, tol=1e-5, maxiter=None, M=None, callback=None, atol=None):

File "C:\Users\YE3467\Anaconda3\lib\site-packages\scipy_lib_threadsafety.py", line 59, in decorator
return lock.decorate(func)

File "C:\Users\YE3467\Anaconda3\lib\site-packages\scipy_lib_threadsafety.py", line 47, in decorate
return scipy._lib.decorator.decorate(func, caller)

AttributeError: module 'scipy' has no attribute '_lib'

Import issue

Setup:

pip install deepbrain
from deepbrain import Extractor

Error:

ImportError                               Traceback (most recent call last)
 in 
      5 
      6 import nibabel as nib
----> 7 from deepbrain import Extractor

/usr/local/Caskroom/miniconda/base/envs/ndmg/lib/python3.6/site-packages/deepbrain/__init__.py in 
----> 1 from deepbrain.extractor import Extractor

/usr/local/Caskroom/miniconda/base/envs/ndmg/lib/python3.6/site-packages/deepbrain/extractor.py in 
      1 import tensorflow as tf
      2 import numpy as np
----> 3 from skimage.transform import resize
      4 import os
      5 

/usr/local/Caskroom/miniconda/base/envs/ndmg/lib/python3.6/site-packages/skimage/__init__.py in 
    156     except ImportError as e:
    157         _raise_build_error(e)
--> 158     from .util.dtype import *
    159 
    160 

/usr/local/Caskroom/miniconda/base/envs/ndmg/lib/python3.6/site-packages/skimage/util/__init__.py in 
      5 from .apply_parallel import apply_parallel
      6 
----> 7 from .arraycrop import crop
      8 from ._regular_grid import regular_grid, regular_seeds
      9 from .unique import unique_rows

/usr/local/Caskroom/miniconda/base/envs/ndmg/lib/python3.6/site-packages/skimage/util/arraycrop.py in 
      6 
      7 import numpy as np
----> 8 from numpy.lib.arraypad import _validate_lengths
      9 
     10 

ImportError: cannot import name '_validate_lengths'

T2orDTI

Hello, can this code segment other modalities as well? For example, T2 and DTI modalities.

How to cite your work?

Hi,
Great work. I have tried deepbrain on multiple datasets and it works really well.

Kindly let us know if you have any published paper or citation source for this work.

Thanks

Error: tensorflow has no attribute Session

Hi,
I've installed your library and both tried to use it directly from python and as command line.
I get the following error in both situations. I have tensorflow installed...
Do you have any idea about what can be causing this ?

Screenshot from 2020-01-28 14-45-53

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.