Code Monkey home page Code Monkey logo

brainweb-dl's Introduction

Brainweb-DL

Welcome to Brainweb-DL, a powerful Python toolkit for downloading and converting the Brainweb dataset.

Features

  • Effortless Dataset Management: Automatically download, cache, and format the Brainweb dataset with ease. Convert it to the convenient nifti format or numpy array hassle-free.

  • Multiple Image Generation: Generate high-quality T1, T2, T2*, and PD images directly from the Brainweb dataset. Perfect for testing purposes, although keep in mind that the values provided are approximate.

Available data

The Brainweb project kindly provides:

  • A normal brain phantom (named subject 0 afterwards), with T1, T2 and PD contrasts, with a variety of noise levels and intensity non-uniformities. As well as a anatomical model (in the form of either crisp or fuzzy segmentation of brain tissues, at a fixed resolution of 181x217x181 images).
  • The same for a multiple sclerosis brain phantom (named subject 1 afterwards).
  • A set of 20 normal brains (with ids equal to [4, 5, 6, 18, 20, 38, 41-54]) , with a T1 contrast (with 1mm resolution at (181, 217,181)), as well as the crisp and fuzzy segmentation of brain tissues (with a shape of (362, 434,362)) 1.

This project provides a CLI and a Python API to download and convert theses data. On top of that, it can generate new contrasts (e.g. T2*) from the segmentations, and reshape the data to the desired resolution 2.

Get Started

Data Location

The cached data directory follows this priority order:

  1. User-specific argument (brainweb_dir in most functions)
  2. BRAINWEB_DIR environment variable
  3. ~/.cache/brainweb folder

Python Script Usage

from brainweb_dl import get_mri 

data = get_mri(sub_id=44, contrast="T1")

The Brainweb dataset is downloaded and cached by default in the ~/.cache/brainweb folder.

Command Line Interface

brainweb-dl 44 --contrast=T1

For more information, see brainweb-dl --help.

Installation

Get up and running quickly!

pip install brainweb-dl

Development

Join our community and contribute to Brainweb-DL!

git clone [email protected]/paquiteau/brainweb-dl 
cd brainweb-dl
pip install -e .[dev,test,doc]

TODO List

Help us improve and shape the future of Brainweb-DL:

  • Add unit tests.
  • Implement fuzzy search and multiple subjects download in parallel.
  • Develop an interface to generate T1, T2, T2*, and PD images.
  • Enhance the search for the location of the Brainweb dataset (User > Environment Variable > Default Location).
  • Introduce an interface to download as BIDS format.

Acknowledgement

We extend our gratitude to the following for their contributions:

  • Casper De Clercq for the preliminary work and original idea. Check out his great work if you are interested in PET imaging and registration functionalities.

  • BrainWeb for providing this valuable dataset to the community.

๐ŸŒŸ If you like this work, don't forget to star it and share it ๐ŸŒŸ

Footnotes

  1. Note that the classification of tissue is not the same as for subject 0 and 1 โ†ฉ

  2. This requires scipy to be installed. โ†ฉ

brainweb-dl's People

Contributors

paquiteau avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

chaithyagr

brainweb-dl's Issues

Issue with package import

Hi Pierre-Antoine, thank you for providing this nice brainweb extension! :)

I wanted to check out the fuzzy segmentation but I am struggling a bit with the import of the python package, as I am getting the following error:

Traceback (most recent call last): File "D:\PycharmProjects\project\stuff.py", line 5, in <module> import brainweb_dl File "C:\User\Anaconda3\envs\ptenv2\lib\site-packages\brainweb_dl\__init__.py", line 2, in <module> from .mri import get_mri File "C:\User\Anaconda3\envs\ptenv2\lib\site-packages\brainweb_dl\mri.py", line 11, in <module> from ._brainweb import ( File "C:\User\Anaconda3\envs\ptenv2\lib\site-packages\brainweb_dl\_brainweb.py", line 87, in <module> class BrainWebTissueMap(Enum): File "C:\User\Anaconda3\envs\ptenv2\lib\site-packages\brainweb_dl\_brainweb.py", line 88, in BrainWebTissueMap v1 = Path(str(files("brainweb_dl.data") / "brainweb1_tissues.csv")) File "C:\User\Anaconda3\envs\ptenv2\lib\importlib\resources.py", line 147, in files return _common.from_package(_get_package(package)) File "C:\User\Anaconda3\envs\ptenv2\lib\importlib\_common.py", line 14, in from_package return fallback_resources(package.__spec__) File "C:\User\Anaconda3\envs\ptenv2\lib\importlib\_common.py", line 18, in fallback_resources package_directory = pathlib.Path(spec.origin).parent File "C:\User\Anaconda3\envs\ptenv2\lib\pathlib.py", line 1082, in __new__ self = cls._from_parts(args, init=False) File "C:\User\Anaconda3\envs\ptenv2\lib\pathlib.py", line 707, in _from_parts drv, root, parts = self._parse_args(args) File "C:\User\Anaconda3\envs\ptenv2\lib\pathlib.py", line 691, in _parse_args a = os.fspath(a) TypeError: expected str, bytes or os.PathLike object, not NoneType

Do you have any idea how to fix this?

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.