Skip to content

Commit

Permalink
Merge pull request #16 from poldracklab/v0.1.0
Browse files Browse the repository at this point in the history
V0.1.3
  • Loading branch information
shashankbansal6 authored Apr 11, 2021
2 parents cc71a13 + eac56e0 commit 249ecd1
Show file tree
Hide file tree
Showing 20 changed files with 201 additions and 3,338 deletions.
29 changes: 22 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
# Nondefaced-Detector

[![PyPI version](https://badge.fury.io/py/nondefaced-detector.svg)](https://badge.fury.io/py/nondefaced-detector)
[![Downloads](https://pepy.tech/badge/nondefaced-detector)](https://pepy.tech/project/nondefaced-detector)
[![Documentation Status](https://readthedocs.org/projects/nondefaced-detector/badge/?version=latest)](https://nondefaced-detector.readthedocs.io/en/latest/?badge=latest)
[![License: Apache 2.0](https://img.shields.io/badge/License-Apache_License,_2.0-lightgrey.svg)](https://opensource.org/licenses/Apache-2.0)

A framework to detect if a 3D MRI volume has been defaced.

## Table of contents
Expand Down Expand Up @@ -44,7 +50,7 @@ NOTE: The CPU container will be very slow for training. We highly recommend that
### Pip

```bash
$ pip install --no-cache-dir nondefaced-detector[gpu]
$ pip install --no-cache-dir nondefaced-detector[cpu/gpu]
```

<!-- USAGE EXAMPLES -->
Expand All @@ -56,7 +62,7 @@ Pre-trained networks are avalaible in the *Nondefaced-detector* [models](https:/
```bash
$ docker run --rm -v $PWD:/data nondefaced-detector:latest-cpu \
predict \
--model-path=/opt/nondefaced-detector/nondefaced_detector/models/pretrained_weights \
--model-path=$MODEL_PATH \
/data/example1.nii.gz
```

Expand Down Expand Up @@ -86,8 +92,9 @@ Steps to reproduce inference results from the paper.
**Step 1:** Get the preprocessed dataset. You need to have [datalad](https://handbook.datalad.org/en/latest/intro/installation.html) installed.
```bash
$ datalad clone https://gin.g-node.org/shashankbansal56/nondefaced-detector-reproducibility /data/nondefaced-detector-reproducibility
$ cd /data/nondefaced-detector-reproducibility
$ datalad clone https://gin.g-node.org/shashankbansal56/nondefaced-detector-reproducibility /opt/nondefaced-detector-reproducibility
$ cd /opt/nondefaced-detector-reproducibility
$ datalad get pretrained_weights/*
$ datalad get test_ixi/tfrecords/*
```
Expand All @@ -105,12 +112,20 @@ $ conda activate tf-cpu
```bash
$ git clone https://github.com/poldracklab/nondefaced-detector.git
```
**Step 4:** Run the standalone inference script. The inference script uses the pre-trained model weights under `nondefaced_detector/models/pretrained_weights`
**Step 4:** Run the standalone inference script.
```bash
$ cd nondefaced-detector
$ pip install -e .
$ cd nondefaced_detector
$ python inference.py < PATH_TO_TFRECORDS [/data/nondefaced-detector-reproducibility/test_ixi/tfrecords] >
$ python inference.py -h
usage: inference.py [-h] tfrecords_path model_path
positional arguments:
tfrecords_path Path to tfrecords.
model_path Path to pretrained model weights.
optional arguments:
-h, --help show this help message and exit
```
## Paper
Expand Down Expand Up @@ -148,7 +163,7 @@ Shashank Bansal - [email protected]
<!-- ACKNOWLEDGEMENTS -->
## Acknowledgements
## Acknowledgements
### Training Dataset
The original model was trained on 980 defaced MRI scans from 36 different studies that are publicly available at [OpenNeuro.org](https://openneuro.org/)
Expand Down
32 changes: 31 additions & 1 deletion docker/cpu.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,36 @@
FROM tensorflow/tensorflow:2.4.1-jupyter

RUN apt-get install -y vim
RUN apt-get install software-properties-common -y && add-apt-repository ppa:git-core/ppa -y

RUN apt-get update -y && apt-get upgrade -y

RUN apt-get install -y vim wget

ENV PATH="/root/miniconda3/bin:${PATH}"
ARG PATH="/root/miniconda3/bin:${PATH}"

RUN wget \
https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh \
&& mkdir /root/.conda \
&& bash Miniconda3-latest-Linux-x86_64.sh -b \
&& rm -f Miniconda3-latest-Linux-x86_64.sh

RUN conda --version

RUN conda install -c conda-forge datalad -y

RUN git config --global user.email "[email protected]"
RUN git config --global user.name "nondefaced-detector"

RUN datalad clone https://gin.g-node.org/shashankbansal56/nondefaced-detector-reproducibility /opt/nondefaced-detector-reproducibility

RUN cd /opt/nondefaced-detector-reproducibility

RUN datalad get pretrained_weights/*
RUN datalad get examples/*

ENV MODEL_PATH='/opt/nondefaced-detector-reproducibility/pretrained_weights'
ARG MODEL_PATH='/opt/nondefaced-detector-reproducibility/pretrained_weights'

RUN pip3 install nobrainer \
sklearn \
Expand Down
32 changes: 31 additions & 1 deletion docker/gpu.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,36 @@
FROM tensorflow/tensorflow:latest-gpu-jupyter

RUN apt-get install -y vim
RUN apt-get install software-properties-common -y && add-apt-repository ppa:git-core/ppa -y

RUN apt-get update -y && apt-get upgrade -y

RUN apt-get install -y vim wget

ENV PATH="/root/miniconda3/bin:${PATH}"
ARG PATH="/root/miniconda3/bin:${PATH}"

RUN wget \
https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh \
&& mkdir /root/.conda \
&& bash Miniconda3-latest-Linux-x86_64.sh -b \
&& rm -f Miniconda3-latest-Linux-x86_64.sh

RUN conda --version

RUN conda install -c conda-forge datalad -y

RUN git config --global user.email "[email protected]"
RUN git config --global user.name "nondefaced-detector"

RUN datalad clone https://gin.g-node.org/shashankbansal56/nondefaced-detector-reproducibility /opt/nondefaced-detector-reproducibility

RUN cd /opt/nondefaced-detector-reproducibility

RUN datalad get pretrained_weights/*
RUN datalad get examples/*

ENV MODEL_PATH='/opt/nondefaced-detector-reproducibility/pretrained_weights'
ARG MODEL_PATH='/opt/nondefaced-detector-reproducibility/pretrained_weights'

RUN pip3 install --upgrade tensorflow-gpu==2.3.2
RUN pip3 install nobrainer \
Expand Down
Loading

0 comments on commit 249ecd1

Please sign in to comment.