https://github.com/natlee/nipype-preprocess-on-brain-mr
The project is used to do preprocessing on brain MR images by using Nipype.
https://github.com/natlee/nipype-preprocess-on-brain-mr
acpc ants bias-field-correction brain brain-imaging brain-mri brain-segmentation dockerfile enhancement fsl medical-image-processing mr mri nipype pipeline python registration segmentation skull-stripping
Last synced: 11 months ago
JSON representation
The project is used to do preprocessing on brain MR images by using Nipype.
- Host: GitHub
- URL: https://github.com/natlee/nipype-preprocess-on-brain-mr
- Owner: NatLee
- License: mit
- Created: 2020-01-06T03:32:05.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2024-06-18T01:03:49.000Z (almost 2 years ago)
- Last Synced: 2025-04-05T19:04:32.731Z (about 1 year ago)
- Topics: acpc, ants, bias-field-correction, brain, brain-imaging, brain-mri, brain-segmentation, dockerfile, enhancement, fsl, medical-image-processing, mr, mri, nipype, pipeline, python, registration, segmentation, skull-stripping
- Language: Python
- Homepage:
- Size: 3.63 MB
- Stars: 36
- Watchers: 2
- Forks: 7
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# **Nipype: Preprocessing Pipeline on Brain MR Images**
> Tested on x86/64 Linux-based system.
The project is used to do preprocessing on brain MR images (`.nii` files).
There is a pipeline include those features:
- Dockerize the environment
- Auto AC-PC detection & alignment
- Registration
- Skull Stripping
- Segmentation (using `K-means` to split GM, WM and CSF)
- Visualize the results (using `nilearn`)
All the features implemented as `nipype`'s interface are connected in a workflow.
## Prerequisites
In this repo, the dataset is downloaded from [LONI Image Data Archive (IDA)](https://ida.loni.usc.edu/login.jsp).
Collect and download AD and NC screening sample of ADNI1 and ADNI2, and extract them into this folder.
You can just place the `.nii` samples in `./data`.
> If you only have DICOM files, you can use [DICOM to NIfTI Online Converter](https://www.onlineconverter.com/dicom-to-nifti) to convert them into NIfTI format.
For example, folder `./data` structure is like this:
```
./data
├── 099_S_4206.nii
└── 099_S_4205.nii
0 directories, 2 files
```
## Usage
1. Build Neuro Docker image
```bash
docker build --tag neuro:latest --file Dockerfile.neuro .
```
2. Build custom Docker image
> We need to install custom tools in the Docker image.
```bash
docker build --tag neuro_custom:latest --file Dockerfile .
```
3. Run the workflow
```bash
docker run --rm -it \
--workdir /src \
--volume ./src:/src \
--volume ./utils:/utils \
--volume ./data:/data \
--volume ./output:/output \
--name neuro_workflow \
neuro_custom python workflow.py
```
### Results
Segmentation results are shown as cover.
When the workflow ran successfully, all the results of each step will be saved in `./output`.
And the workflow graph will be saved in `./src/graph_detailed.png`.

## Utilities
The useful `Automatic Registration Toolbox` we used are listed below:
- acpcdetect v2.1 Linux
- ATRA v1.0 Linux
They are downloaded from [NITRC](https://www.nitrc.org/projects/art) and put in `./utils`.
## Reference
- [quqixun/BrainPrep](https://github.com/quqixun/BrainPrep)
- [nipype](https://nipype.readthedocs.io/en/latest/)
- [nilearn](https://nilearn.github.io/)
- [neurodocker](https://github.com/ReproNim/neurodocker)
## Misc
### Generate Neuro Dockerfile and Build Docker Image
1. Install `neurodocker`
```bash
pip install neurodocker
```
2. Generate Dockerfile using `neurodocker`
```bash
neurodocker generate docker \
--pkg-manager apt \
--base-image neurodebian:bullseye \
--fsl version=6.0.5.1 \
--ants version=2.4.1 \
--miniconda version=latest conda_install="nipype" \
> Dockerfile.neuro
```
3. Build the docker image with the generated Dockerfile
```bash
docker build --tag neuro:latest --file Dockerfile.neuro .
```
## Contributor