https://github.com/masilab/deepn4
https://github.com/masilab/deepn4
Last synced: 11 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/masilab/deepn4
- Owner: MASILab
- Created: 2022-11-01T16:12:49.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2025-06-28T22:53:33.000Z (7 months ago)
- Last Synced: 2025-06-28T23:28:27.906Z (7 months ago)
- Language: Jupyter Notebook
- Size: 93.2 MB
- Stars: 4
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# DeepN4
Pytorch implementation of DeepN4, from the paper: DeepN4: Learning ITKN4 Bias Field Correction for T1 weighted Images.
We propose **DeepN4**, a 3D UNet to generate Bias Field for T1w images and inturn correct T1w images for inhomogeneities.
## Prequisite installation
Please look into `requirements.txt` for libraries and versions used in the virutal environment.
## Training and Testing
1. Input train/test/val format: csv file with each row with `/path/to/corrected_T1.nii.gz,/path/to/input.nii.gz,/path/to/bias_field.nii.gz` for each subject
2. Run training
```
python main.py train 0 Synbo_UNet3D False /path/to/save/model /path/to/tensorboard/output \
/path/to/save/predictions checkpoint_epoch_# guass \
```
3. Run testing
```
python main.py pred 0 Synbo_UNet3D False /path/to/saved/model /path/to/tensorboard/output \
/path/to/save/predictions checkpoint_epoch_# guass \
```
## External evaluation
Efficient evaulation can be performed for the public datasets as in `Evaluation_deepN4.ipynb`. The example data used is in `data/`
The trained weights and the singualrity image can be downloaded from https://zenodo.org/records/15765107 or https://drive.google.com/drive/folders/1mdBsV0kHRRV_Alu1QJrTT7N0GGNJDuiu?usp=sharing
## Singularity
To containize the source code
```
sudo singularity build deepn4v1.simg Singularity
```
To run singularity
```
singaulrity run
--contain -e
-B /path/to/inputs/directory/:/INPUTS
-B /path/to/outputs/directory/:/OUTPUTS
-B /tmp:/tmp
-B /path/to/freesurfer/license.txt:/APPS/freesurfer/license.txt
deepn4v1.simg
[options]
```
Inputs and arguments for singularity
Input Directory: one T1 image named as t1.nii.gz
Output Directory: results will be saved as t1processed.nii.gz and (if the option below is on) bias.nii.gz
Options: "--bias_file" to save the bias field field
---