difit: A diffusion MRI models fitting software
difit is being developed as an attempt to bring in major diffusion models into one place (v1.0.0 can do DTI and DKI models). difit allows to choose b-values and b0-images from multi-shell data as the user desires. This enable the user to test different combinations easily without splitting data prior to the model fitting.
Major software packages in the background
difit’s versions of DTI and DKI models come from dipy. Nodes were built using nipype. Other dependancies are listed in the setup.cfg file.
Installation
pip install difit
Models fitting command
DTI
python -m difit 'path/to/input/dir' 'path/to/output/dir' 'path/to/work/dir' --models dti --dti_b_values 1000 --dti_b0_images 3 --mem 6 --nprocs 2
DKI
python -m difit 'path/to/input/dir' 'path/to/output/dir' 'path/to/work/dir' --models dki --dki_b_values 500 1000 3000 --dki_b0_images 4 --mem 9 --nprocs 2
Both DTI and DKI
It is possible to fit more than one model in one run. DTI followed by DKI will be fitted with the below command.
python -m difit 'path/to/input/dir' 'path/to/output/dir' 'path/to/work/dir' --models dti dki --dki_b_values 500 1000 2000 --dki_b0_images 3 --dti_b_values 1000 --dti_b0_images 3 --mem 12 --nprocs 2
Parallel Processing
difit can fit multiple subjects in parallel. If you have more than one subject, you can issue the command similar to below with the wildcard (*). If you want to fit few of the available subjects, you can use the curly bracket notaions to specify the subjects.
python -m difit 'path/to/input/sub*/data' 'path/to/output/sub*/out' 'path/to/work/dir' --models dti dki --dki_b_values 500 1000 2000 --dki_b0_images 3 --dti_b_values 1000 --dti_b0_images 3 --mem 32 --nprocs 8
Input dwi data files
difit searches for files ending with *_dwi.nii.gz, *_dwi.bval, *_dwi.bvec and *_mask.nii.gz in the input directory. Make sure to name your files with the same endings. If you use qsiprep to preprocess data, you will end up with the above format which uses BIDS convention. If you used a different software to preprocess your data, name your files to match the above convention. The * indicate any name/s before the underscore can take place.
An example for multi models and multi subjects parallel processing
Assume there are two subject directories namely sub01 and sub02 and in each directory there are data and out directories available. In this example, diffusion data have four shells (500,1000,2000,3000) and 6 b0 images. But we are going to use only one shell for DTI and three shells for DKI model. The both models will use 3 b0 images (consecutive).
projectdifit ├── sub01 │ ├── data │ │ ├── example_dwi.bval │ │ ├── example_dwi.bvec │ │ ├── example_dwi.nii.gz │ │ └── example_mask.nii.gz │ └── out ├── sub02 │ ├── data │ │ ├── example_dwi.bval │ │ ├── example_dwi.bvec │ │ ├── example_dwi.nii.gz │ │ └── example_mask.nii.gz │ └── out └── work
python -m difit '/projectdifit/sub*/data' '/projectdifit/sub*/out' '/projectdifit/work' --models dti dki --dki_b_values 500 1000 2000 --dki_b0_images 3 --dti_b_values 1000 --dti_b0_images 3 --mem 32 --nprocs 8
Output files
out
├── dki
│ ├── AK.nii.gz
│ ├── dki_AD_mosaic.png
│ ├── dki_AD.nii.gz
│ ├── dki_AK_mosaic.png
│ ├── dki_FA_mosaic.png
│ ├── dki_FA.nii.gz
│ ├── dki_kFA_mosaic.png
│ ├── dki_MD_mosaic.png
│ ├── dki_MD.nii.gz
│ ├── dki_MK_mosaic.png
│ ├── dki_RD_mosaic.png
│ ├── dki_RD.nii.gz
│ ├── dki_RK_mosaic.png
│ ├── dki_summary_plots.html
│ ├── kFA.nii.gz
│ ├── MK.nii.gz
│ └── RK.nii.gz
└── dti
├── dti_AD_mosaic.png
├── dti_AD.nii.gz
├── dti_FA_mosaic.png
├── dti_FA.nii.gz
├── dti_MD_mosaic.png
├── dti_MD.nii.gz
├── dti_RD_mosaic.png
├── dti_RD.nii.gz
└── dti_summary_plots.html
difit creates dti and dki directories in the out directory to store the above output files for each subject.
HELP
python -m difit -h
dmri models fitter work flow
positional arguments:
input_dir Input data directory. This directory must contain *_dwi.nii.gz, *_mask.nii.gz, *_dwi.bval,
*_dwi.bvec. Multiple subjects can be list with wild cards e.g. ~/data/sub_*/data ; each
subject directory contain its own set of diffusion files.
output_dir The output directory for models metrices. In this directory seperate subdirectories will be
created for each model; For multiple subjects, output can be given with a wildcard e.g.
~/data/sub_*/out
work_dir directory for intermediate results
optional arguments:
-h, --help show this help message and exit
--models MODELS [MODELS ...]
Choose the model or models you want to fit to your data. Choose one or a combination from dti,
dki (default: None)
Options for choosing shell numbers for DTI processing:
--dti_b_values DTI_B_VALUES [DTI_B_VALUES ...]
Choose a b-value/s of multishell data to use for DTI model fitting (default: None)
--dti_b0_images DTI_B0_IMAGES
If dwi data contain more than one b0 images, choose how many you want to use for DTI model
fitting (default: 1)
Options for choosing shell numbers and b0 images for DKI processing:
--dki_b_values DKI_B_VALUES [DKI_B_VALUES ...]
Choose a b-values of multishell data to use for DKI model fitting (default: None)
--dki_b0_images DKI_B0_IMAGES
If dwi data contain more than one b0 images, choose how many you want to use for DKI model
fitting (default: 1)
Options to specify computer resources:
--nprocs NPROCS maximum number of cpus across all processes (default: None)
--omp-nthreads OMP_NTHREADS
maximum number of threads per-process (default: None)
--mem MEMORY_GB upper bound memory limit (GB) for difit models fitting (default: None)
--use-plugin FILE nipype plugin configuration file (default: None)
Future Additions
MSMT-CSD particle filtering tractography, NODDI and FSL PROBTRACKX.
Note
This project has been set up using PyScaffold 4.1. For details and usage information on PyScaffold see https://pyscaffold.
Metadata
Release files for difit 1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| difit-1.0.tar.gz | 39.2 kB | Without provenance | Details for difit-1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| difit-1.0-py3-none-any.whl | Python 3 | none | any | Details for difit-1.0-py3-none-any.whl |
Total release size: 54.8 kB
Release files / difit-1.0.tar.gz
| Download URL | difit-1.0.tar.gz |
|---|---|
| Size | 39.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cddb92e96d156a809ce0f12f2fea30df44f13e87e8a6d79750c599d476515510
|
|
BLAKE2b-256 checksum How to use checksums |
51d9afe9ddcef54f115ee4a82af0d7aca29c8d70fede3a80572ef70cf9f8d120
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.5
|
Release files / difit-1.0-py3-none-any.whl
| Download URL | difit-1.0-py3-none-any.whl |
|---|---|
| Size | 15.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
85bf5f75fc639ab099984f0d2c3a80a4f68808063a3ccbf401dffd805dcfea26
|
|
BLAKE2b-256 checksum How to use checksums |
1b69d4723ae3e4cfe3a97a8cd4fe7a6acb422b0c392a954dbcc16a1918c9928d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.5
|
Security for difit 1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.