Skip to content

Commit

Permalink
REF: TensorFlow 2.0 and Keras API (#43)
Browse files Browse the repository at this point in the history
* change volume module

* rm histogram files

* change io module

* change metrics and losses modules

* add files to tests

* update cli

* use versioneer to version nobrainer

* ignore version and tests

* rm requirements

* remove makefile

* update year on license

* use travis instead of circleci

* update ignored files

* update utils

* add nobrainer.transform module

* update training module

* remove testing file

* update metrics tests

* rm test scripts

* update to tf.keras models

* remove unused files

* make some module names nouns

* use tf.keras for variational conv

* use tf nightly

* use tf.keras api

* add initial guide

* add new variational meshnet

* update docs and change layer names

* add nobrainer.training

* add loss for meshnet_vwn

* use sigmoid only for 1 class

* do not use batchnorm and dropout + enh docs

* remove previous meshnet vwn implementations in favor of meshnet.py

* add meshnet_vwn

* update tpu notebook

* rename variational weight notebook

* add guide notebooks

* update using new vwn code

* separate this notebook into multiple notebooks

* remove examples

* fix tversky test

* enable eager execution for <2.0 compat

* update readme to nobrainer-tf2!

* add travis badge
  • Loading branch information
Jakub Kaczmarzyk authored Mar 6, 2019
1 parent 0b59721 commit 393e9d2
Show file tree
Hide file tree
Showing 85 changed files with 7,537 additions and 7,352 deletions.
31 changes: 0 additions & 31 deletions .circleci/config.yml

This file was deleted.

5 changes: 3 additions & 2 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
[run]
branch = True
source = .
omit =
nobrainer/_version.py
*/tests*

[report]
exclude_lines =
pragma: no cover
raise NotImplementedError
if __name__ == .__main__.:
ignore_errors = True
omit =
*_test.py
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nobrainer/_version.py export-subst
30 changes: 11 additions & 19 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,21 +1,13 @@
/build
/dist
/*.egg-info
.DS_Store
.ipynb_checkpoints
scratch.ipynb

/models*
.pytest_cache

build
.coverage
dist
*.egg-info
*.ipynb_checkpoints
/*.ipynb
__pycache__
*.pyc

*.gz
*.h5
*.json
*.log
*.pkl
._*

slurm-*.out
*.pyc
*.pytest_cache
*.sif
*.simg
*.tfrecords
8 changes: 8 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
dist: xenial
language: python
python:
- "3.6"
install:
- pip install --no-cache-dir --editable=".[dev]" tf-nightly
script:
- pytest --cov=nobrainer nobrainer
24 changes: 5 additions & 19 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,20 +1,6 @@
# Nobrainer container specification.

ARG TF_VERSION="1.12.0"
# Use "gpu-py3" to build GPU-enabled container and "py3" for non-GPU container.
ARG TF_ENV="gpu-py3"
FROM tensorflow/tensorflow:${TF_VERSION}-${TF_ENV}

COPY . /opt/nobrainer
RUN \
# Extras do not have to be installed because the only extra is tensorflow,
# which is installed in the base image.
pip install --no-cache-dir -e /opt/nobrainer \
&& rm -rf ~/.cache/pip/* \
&& useradd --no-user-group --create-home --shell /bin/bash neuro

USER neuro
WORKDIR /home/neuro
ENTRYPOINT ["/usr/bin/python"]

FROM tensorflow/tensorflow:nightly-gpu-py3-jupyter
COPY [".", "/opt/nobrainer"]
RUN pip install --no-cache-dir click nibabel numpy pytest scipy scikit-image seaborn \
&& pip install --no-cache-dir --editable /opt/nobrainer
ENTRYPOINT ["jupyter-notebook", "--ip=0.0.0.0", "--no-browser"]
LABEL maintainer="Jakub Kaczmarzyk <[email protected]>"
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright 2018 The Nobrainer Authors.
Copyright 2019 The Nobrainer Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 2 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
include versioneer.py
include nobrainer/_version.py
20 changes: 0 additions & 20 deletions Makefile

This file was deleted.

50 changes: 27 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,42 +1,46 @@
# nobrainer
# Nobrainer

Neural networks for brain extraction and labelling from structural magnetic resonance images.
[![Build Status](https://travis-ci.com/kaczmarj/nobrainer.svg?branch=master)](https://travis-ci.com/kaczmarj/nobrainer)

Nobrainer is a deep learning framework for 3D image processing. It implements several 3D convolutional models from recent literature, methods for loading and augmenting volumetric data than can be used with any TensorFlow or Keras model, losses and metrics for 3D data, and simple utilities for model training, evaluation, prediction, and transfer learning.

## Examples
Soon, Nobrainer will also provide pre-trained models for brain extraction, brain segmentation, and other tasks.

Please see the [examples](examples) directory.
The Nobrainer project is supported by NIH R01 EB020470 and is distributed under the Apache 2.0 license.

## Guide Jupyter Notebooks [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/kaczmarj/nobrainer)

## Getting started
Please refer to the Jupyter notebooks in the [guide]('/guide') directory to get started with _Nobrainer_. [Try them out](https://colab.research.google.com/github/kaczmarj/nobrainer) in Google Collaboratory!

### Get the container
## Installing Nobrainer

```shell
$ docker pull kaczmarj/nobrainer
# or
$ singularity build nobrainer.sqsh docker://kaczmarj/nobrainer
```
### Container

### Train your own models
We recommend using the official _Nobrainer_ Docker container, which includes all of the dependencies necessary to use the framework.

Models can be trained on neuroimaging volumes on the command line or with a Python script. All of the examples can be run within the _Nobrainer_ container. Please see the [examples](examples) for more information.
```
$ docker pull kaczmarj/nobrainer
```

Training data pre-requisites:
1. Volumes must be in a format supported by [nibabel](http://nipy.org/nibabel/).
2. Feature and label data must be available (e.g., T1 and aparc+aseg).
### pip

Training progress can be visualized with [TensorBoard](https://www.tensorflow.org/programmers_guide/summaries_and_tensorboard):
_Nobrainer_ can also be installed with pip. Use the extra `[gpu]` to install TensorFlow with GPU support and the `[cpu]` extra to install TensorFlow without GPU support.

```
$ singularity exec --clean-env --bind /path/to/models:/models nobrainer.sqsh \
tensorboard --logdir /models
$ pip install --no-cache-dir nobrainer[gpu]
```

### Predict using trained models
## Package layout

We are in the process of training robust models for brain extraction and brain labelling. Stay tuned for information on how to use these models.
- `nobrainer.io`: input/output methods
- `nobrainer.layers`: custom layers, which conform to the Keras API
- `nobrainer.losses`: loss functions for volumetric segmentation
- `nobrainer.metrics`: metrics for volumetric segmentation
- `nobrainer.models`: pre-defined Keras models
- `nobrainer.training`: training utilities (supports training on single and multiple GPUs)
- `nobrainer.transform`: random rigid transformations for data augmentation
- `nobrainer.volume`: `tf.data.Dataset` creation and data augmentation utilities

### Funding
## Questions or issues

The nobrainer project is supported by NIH R01 EB020470.
If you have questions about Nobrainer or encounter any issues using the framework, please submit a GitHub issue. If you have a feature request, we encourage you to submit a pull request.
12 changes: 0 additions & 12 deletions examples/README.md

This file was deleted.

71 changes: 0 additions & 71 deletions examples/brain-extraction-cli/README.md

This file was deleted.

6 changes: 0 additions & 6 deletions examples/brain-extraction-cli/evaluation_data.csv

This file was deleted.

6 changes: 0 additions & 6 deletions examples/brain-extraction-cli/features_labels.csv

This file was deleted.

6 changes: 0 additions & 6 deletions examples/brain-extraction-python/features_labels.csv

This file was deleted.

14 changes: 0 additions & 14 deletions examples/brain-extraction-python/predict.py

This file was deleted.

22 changes: 0 additions & 22 deletions examples/brain-extraction-python/save.py

This file was deleted.

Loading

0 comments on commit 393e9d2

Please sign in to comment.