Skip to main content

A framework for inference and re-training of pretrained neuroimaging models

Project description

Nobrainer-zoo

Nobrainer-zoo is a toolbox with a collection of deep learning neuroimaging models that eases the use of pretrained models for various applications. Nobrainer-zoo provides the required environment with all the dependencies for training/inference of models. You need singularity/apptainer (>= 3.7.x/1.0.x) or docker to run the Nobrainer-zoo.

Installation

We highly recommend to create a separate environment for the nobrainer-zoo. You can use conda or python to create the environment.

conda create -n nobrainer-zoo python=3
conda activate nobrainer-zoo

or

python3 -m venv /path/to/new/virtual/environment/nobrainer-zoo
source /path/to/new/virtual/environment/nobrainer-zoo/bin/activate

Then install the nobrainer-zoo:

[Releases]    pip install nobrainer-zoo
[Dev version] pip install https://github.com/neuronets/nobrainer-zoo/archive/refs/heads/main.zip

After installation, Nobrainer-zoo should be initialized. It also needs a cache folder to download some helper files based on your needs. By default, it creates a cache folder in your home directory (~/.nobrainer). If you do not want the cache folder in your home directory, you can setup a different cache location by setting the environmental variable NOBRAINER_CACHE. run below command to set it.

export NOBRAINER_CACHE=<path_to_your_cache_directory>

since this environmental variable will be lost when you close your terminal session you need to run it next time or a better solution is, to add it to your ~/.bashrc file. simply open the file with your text editor and add the above line at the end. Restart your terminal or re-run your bashrc file by .~/bashrc to make this change effective.

To initialize the nobrainer-zoo run:

nobrainer-zoo init

*Note: You need to initialize the nobrainer-zoo only once.

Run help to see the functions and each function's options.

nobrainer-zoo --help
nobrainer-zoo ls --help
nobrainer-zoo predict --help
nobrainer-zoo fit --help
nobrainer-zoo register --help
nobrainer-zoo generate --help

Available models

To see the list of available models in the nobrainer-zoo run nobrainer-zoo ls

Models are added based on their organization, model name , and version. One model might have different versions. Some models (such as kwyk or SyntSR) have various types which means there was various training method or dataset that lead to different trained models. You can select the model type with model_type option for the train and inference.

List of models which will be added in near future can be find here. You can suggest a model here.

Note: models are distributed under their original license.

Inference Example

Inference with default options,

nobrainer-zoo predict -m neuronets/brainy/0.1.0 <path_to_input> <path_to_save_output>

nobrainer-zoo register -m DDIG/SynthMorph/1.0.0 --model_type brains <path_to_moving> <path_to_fixed> <path_to_moved>

pass the model specific options with --options argument to the model.

nobrainer-zoo predict -m neuronets/brainy/0.1.0 <path_to_input> <path_to_save_output> --options verbose block_shape=[128,128,128]

nobrainer-zoo predict -m UCL/SynthSeg/0.1 <path_to_input> <path_to_save_output> --options post=<path_to_posteriors>

Note: Nobrainer-zoo will use the gpu by default. So, if you want to force it to use the cpu while the gpu is available you need to pass --cpu flag. If you are using docker without any gpu passing the --cpu flag is a must. Otherwise, you will get an error.

Note: If you are using docker make sure to use the absolute path for input and putput files.

Train Example

For training with sample dataset you do not need to pass any dataset pattern.

nobrainer-zoo fit -m neuronets/brainy

To train the network with your own data pass the dataset pattern in the form of tfrecords.

nobrainer-zoo fit -m neuronets/brainy "<data_train_pattern>" "<data_evaluate_pattern>"

Other parameters can be changed by providing a spec file or changing them with cli command.

nobrainer-zoo fit -m neuronets/brainy --spec_file <path_to_spec_file>
nobrainer-zoo fit -m neuronets/brainy --train epoch=2

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

nobrainer-zoo-0.2.0.tar.gz (30.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nobrainer_zoo-0.2.0-py3-none-any.whl (14.0 kB view details)

Uploaded Python 3

File details

Details for the file nobrainer-zoo-0.2.0.tar.gz.

File metadata

  • Download URL: nobrainer-zoo-0.2.0.tar.gz
  • Upload date:
  • Size: 30.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.6

File hashes

Hashes for nobrainer-zoo-0.2.0.tar.gz
Algorithm Hash digest
SHA256 61460bed0fed01fcc1b72bb177ffcc5e7056b6131d7e827b35619ee0497a834d
MD5 0db79378b380834807f449187d89f90c
BLAKE2b-256 cc1aff92e602a113122e8dfce58e4051af3740e044cdc8d66edab09a27d6a42c

See more details on using hashes here.

File details

Details for the file nobrainer_zoo-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: nobrainer_zoo-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 14.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.6

File hashes

Hashes for nobrainer_zoo-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 675717ac8324258317b397ea850d93b45459a5b5ddfe284aa2c24e96271f9817
MD5 05c83ec57aa54ee6a813bc8a53cb82c7
BLAKE2b-256 7a80721604af961e247b6f829bd2bbe08ef92d89c63823a21f5d0ae00be04cae

See more details on using hashes here.

Supported by

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