Skip to content

Commit 46e121d

Browse files
Merge pull request #44 from pnlbwh/single-shell-compliant
On the way to combining single and multi shell software
2 parents 09ecd1e + 97ef447 commit 46e121d

20 files changed

Lines changed: 788 additions & 429 deletions

CITATION.CFF

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ message: "If you use this software, please cite as below."
33
authors:
44
- family-names: "Billah"
55
given-names: "T"
6+
- family-names: "Cetin Karayumak"
7+
given-names: "S"
68
- family-names: "Bouix"
79
given-names: "S"
810
- family-names: "Rathi"

README.md

Lines changed: 63 additions & 174 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,16 @@
44

55
*multi-shell-dMRIharmonization* repository is developed by Tashrif Billah and Yogesh Rathi, Brigham and Women's Hospital (Harvard Medical School).
66

7-
*multi-shell-dMRIharmonization* is an extension of [dMRIharmonization](https://github.com/pnlbwh/dMRIharmonization) for single-shell dMRI.
7+
*multi-shell-dMRIharmonization* is an extension of single-shell dMRIharmonization.
88

99

1010
Table of Contents
1111
=================
1212

1313
* [Algorithm](#algorithm)
1414
* [Citation](#citation)
15-
* [Dependencies](#dependencies)
15+
* [Requirements for data](#requirements-for-data)
1616
* [Installation](#installation)
17-
* [1. Install prerequisites](#1-install-prerequisites)
18-
* [Check system architecture](#check-system-architecture)
19-
* [Python 3](#python-3)
20-
* [MATLAB Runtime Compiler](#matlab-runtime-compiler)
21-
* [unringing](#unringing)
22-
* [2. Install pipeline](#2-install-pipeline)
23-
* [3. Download IIT templates](#3-download-iit-templates)
24-
* [4. Configure your environment](#4-configure-your-environment)
2517
* [Running](#running)
2618
* [Consistency checks](#consistency-checks)
2719
* [Varying number of gradients](#varying-number-of-gradients)
@@ -35,9 +27,6 @@ Table of Contents
3527
* [1. pipeline](#1-pipeline)
3628
* [2. unittest](#2-unittest)
3729
* [Preprocessing](#preprocessing)
38-
* [1. Denoising](#1-denoising)
39-
* [2. Bvalue mapping](#2-bvalue-mapping)
40-
* [3. Resampling](#3-resampling)
4130
* [Debugging](#debugging)
4231
* [1. With the pipeline](#1-with-the-pipeline)
4332
* [2. Use separately](#2-use-separately)
@@ -73,16 +62,10 @@ https://github.com/pnlbwh/dMRIharmonization#data-harmonization
7362

7463
If this repository is useful in your research, please cite all of the following:
7564

76-
* Billah T, Bouix S, Rathi Y. Multi-site multi-shell Diffusion MRI Harmonization,
65+
* Billah T, Cetin Karayumak S, Bouix S, Rathi Y. Multi-site multi-shell Diffusion MRI Harmonization,
7766
https://github.com/pnlbwh/multi-shell-dMRIharmonization, 2019, doi: 10.5281/zenodo.3451427
7867

7968

80-
* Billah T*, Cetin Karayumak S*, Bouix S, Rathi Y. Multi-site Diffusion MRI Harmonization,
81-
https://github.com/pnlbwh/dMRIharmonization, 2019, doi: 10.5281/zenodo.2584275
82-
83-
\* *denotes equal first authroship*
84-
85-
8669
* Cetin Karayumak S, Bouix S, Ning L, James A, Crow T, Shenton M, Kubicki M, Rathi Y. Retrospective harmonization of multi-site diffusion MRI data
8770
acquired with different acquisition parameters. Neuroimage. 2019 Jan 1;184:180-200.
8871
doi: 10.1016/j.neuroimage.2018.08.073. Epub 2018 Sep 8. PubMed PMID: 30205206; PubMed Central PMCID: PMC6230479.
@@ -118,146 +101,32 @@ the other one should have in the range [900,1100]).
118101

119102
If your data does not satisfy these requirements, please open an issue [here](https://github.com/pnlbwh/multi-shell-dMRIharmonization/issues) or contact -
120103

121-
*skarayumak@bwh.harvard.edu*
122-
123-
*tbillah@bwh.harvard.edu*
124-
104+
*skarayumak[at]bwh[dot]harvard[dot]edu*
125105

106+
*tbillah[at]bwh[dot]harvard[dot]edu*
126107

127-
# Dependencies
128-
129-
* ANTs = 2.2.0
130-
* reisert/unring
131-
* FSL = 5.0.11
132-
* numpy = 1.16.2
133-
* scipy = 1.2.1
134-
* scikit-image = 0.15.0
135-
* dipy = 0.16.0
136-
* nibabel = 2.3.0
137-
* pynrrd = 0.3.6
138-
* conversion = 2.0
139-
140-
**NOTE** The above versions were used for developing the repository. However, *multi-shell-dMRIharmonization* should work on
141-
any advanced version.
142108

143109

144110
# Installation
145111

146-
## 1. Install prerequisites
147-
148-
You may ignore installation instruction for any software module that you have already.
149-
150-
### Check system architecture
151-
152-
uname -a # check if 32 or 64 bit
153-
154-
### Python 3
155-
156-
Download [Miniconda Python 3.6 bash installer](https://docs.conda.io/en/latest/miniconda.html) (32/64-bit based on your environment):
157-
158-
sh Miniconda3-latest-Linux-x86_64.sh -b # -b flag is for license agreement
159-
160-
Activate the conda environment:
161-
162-
source ~/miniconda3/bin/activate # should introduce '(base)' in front of each line
163-
164-
165-
166-
167-
**NOTE** With the current design, *MATLAB Runtime Compiler* and *unringing* are not used. So, you may pass them.
168-
169-
### MATLAB Runtime Compiler
170-
171-
In the harmonization process, all volumes have to be resampled to a common spatial resolution.
172-
We have chosen bspline as the interpolation method. For better result, bspline order has been chosen to be 7.
173-
Since Python and ANTs provide bspline order less than or equal to 5, we have resorted to [spm package](https://github.com/spm/spm12) for this task.
174-
Using their source codes [bspline.c](https://github.com/spm/spm12/blob/master/src/spm_bsplinc.c) and [bsplins.c](https://github.com/spm/spm12/blob/master/src/spm_bsplins.c),
175-
we have made a standalone executable that performs the above interpolation. Execution of the standalone executable
176-
requires [MATLAB Runtime Compiler](https://www.mathworks.com/products/compiler/matlab-runtime.html). It is available free of charge.
177-
Download a suitable version from the above, and install as follows:
178-
179-
unzip MCR_R2017a_glnxa64_installer.zip -d MCR_R2017a_glnxa64/
180-
MCR_R2017a_glnxa64/install -mode silent -agreeToLicense yes -destinationFolder `pwd`/MATLAB_Runtime
181-
182-
183-
See details about installation [here](https://www.mathworks.com/help/compiler/install-the-matlab-runtime.html).
184-
185-
After successful installation, you should see a suggestion about editing your LD_LIBRARY_PATH.
186-
You should save the suggestion in a file `env.sh`.
187-
188-
echo "/path/to/v92/runtime/glnxa64:/path/to/v92/bin/glnxa64:/path/to/v92/sys/os/glnxa64:/path/to/v92/opengl/lib/glnxa64:" > env.sh
189-
190-
Then, every time you run dMRIharmonization, you can just source the `env.sh` for your LD_LIBRARY_PATH to be updated.
191-
192-
**NOTE** If you have MATLAB already installed in your system, replace `/path/to/v92` with `/path/to/Matlab/`
193-
194-
195-
### unringing
196-
197-
git clone https://bitbucket.org/reisert/unring.git
198-
cd unring/fsl
199-
export PATH=$PATH:`pwd`
200-
201-
You should be able to see the help message now:
202-
203-
unring.a64 --help
204-
205-
206-
**NOTE** FSL unringing executable requires Centos7 operating system.
207-
208-
209-
210-
## 2. Install pipeline
211-
212-
Now that you have installed the prerequisite software, you are ready to install the pipeline:
213-
214-
git clone https://github.com/pnlbwh/multi-shell-dMRIharmonization.git && cd multi-shell-dMRIharmonization
215-
conda env create -f environment.yml # you may comment out any existing package from environment.yml
216-
conda activate harmonization # should introduce '(harmonization)' in front of each line
217-
218-
219-
Alternatively, if you already have ANTs, you can continue using your python environment by directly installing
220-
the prerequisite libraries:
221-
222-
pip install -r requirements.txt --upgrade
223-
224-
112+
Step-by-step installation instruction can be found [here](https://github.com/pnlbwh/dMRIharmonization/blob/c5bc02149d9e0f96402b3fabc90c2d7bb0e87fe5/README.md).
113+
But for ease of use, we provide a [Singularity](Singularity) container. Download it as:
225114

115+
wget https://www.dropbox.com/scl/fi/onkvy3gdvw99m05v0c52q/dMRIharmonization.sif?rlkey=qptch5779p0h9y3vkz55v0s9g&st=inlduybh&dl=0
226116

227-
## 3. Download IIT templates
228-
229-
dMRIharmonization toolbox is provided with a debugging capability to test how good has been the
230-
harmonization. For debug to work and **tests** to run, download the following data from [IIT HUMAN BRAIN ATLAS](http://www.iit.edu/~mri/IITHumanBrainAtlas.html)
231-
and place them in `multi-shell-dMRIharmonization/IITAtlas/` directory:
232-
233-
* [IITmean_FA.nii.gz](https://www.nitrc.org/frs/download.php/6898/IITmean_FA.nii.gz)
234-
* [IITmean_FA_skeleton.nii.gz](https://www.nitrc.org/frs/download.php/6897/IITmean_FA_skeleton.nii.gz)
235-
236-
237-
## 4. Configure your environment
238-
239-
Make sure the following executables are in your path:
240-
241-
antsMultivariateTemplateConstruction2.sh
242-
antsApplyTransforms
243-
antsRegistrationSyNQuick.sh
244-
unring.a64
245-
246-
You can check them as follows:
247-
248-
which dtifit
249-
250-
If any of them does not exist, add that to your path:
117+
You should bind your data and shell into the container to use it:
251118

252-
export PATH=$PATH:/directory/of/executable
253-
254-
`conda activate harmonization` should already put the ANTs scripts in your path. Yet, you should set ANTSPATH as follows:
255-
256-
export ANTSPATH=~/miniconda3/envs/harmonization/bin/
119+
singularity shell -B /path/to/data:/path/to/data dMRIharmonization.sif
120+
cd /home/pnlbwh/multi-shell-dMRIharmonization/lib
121+
./multi-shell-harmonization.py --help
122+
./harmonization.py --help
257123

258-
However, if you choose to use pre-installed ANTs scripts, you can define `ANTSPATH` according to [this](https://github.com/ANTsX/ANTs/wiki/Compiling-ANTs-on-Linux-and-Mac-OS#set-path-and-antspath) instruction.
259124

125+
(Optional) For running tests and debugging, [download IIT templates](https://github.com/pnlbwh/dMRIharmonization/blob/c5bc02149d9e0f96402b3fabc90c2d7bb0e87fe5/README.md#3-download-iit-templates)
126+
and bind them into the container:
260127

128+
singularity shell -B /path/to/data:/path/to/data \
129+
-B /path/to/IITAtlas:/home/pnlbwh/multi-shell-dMRIharmonization/IITAtlas/ dMRIharmonization.sif
261130

262131

263132
# Running
@@ -297,8 +166,45 @@ Upon successful installation, you should be able to see the help message:
297166

298167

299168

300-
For details about the above arguments, see https://github.com/pnlbwh/dMRIharmonization#running
169+
`multi-shell-harmonization.py` is the one single executable for both multi-shell and single-shell data.
170+
For details about the above arguments, see https://github.com/pnlbwh/dMRIharmonization#running.
171+
Though the link uses `lib/harmonization.py`, the details are applicable to `multi-shell-harmonization.py` too.
172+
However, you may use `lib/harmonization.py` for single-shell data. The former supports
173+
`--bvalMap`, `--resample`, and `--denoise`.
301174

175+
<details>
176+
<summary>lib/harmonization.py --help</summary>
177+
178+
Usage:
179+
harmonization.py [SWITCHES]
180+
181+
Meta-switches:
182+
-h, --help Prints this help message and quits
183+
--help-all Prints help messages of all sub-commands and quits
184+
-v, --version Prints the program's version and quits
185+
186+
Switches:
187+
--bshell_b VALUE:str bvalue of the bshell, needed for multi-shell data only; the default is X
188+
--bvalMap VALUE:str specify a bmax to scale bvalues into
189+
--create turn on this flag to create template
190+
--debug turn on this flag to debug harmonized data (valid only with --process)
191+
--denoise turn on this flag to denoise voxel data
192+
--force turn on this flag to overwrite existing data
193+
--harm_list VALUE:ExistingFile harmonized csv/txt file with first column for dwi and 2nd column for mask: dwi1,mask1\n dwi2,mask2\n...
194+
--nproc VALUE:str number of processes/threads to use (-1 for all available, may slow down your system); the default is 4
195+
--nshm VALUE:str spherical harmonic order, by default maximum possible is used; the default is -1
196+
--nzero VALUE:str number of zero padding for denoising skull region during signal reconstruction; the default is 10
197+
--process turn on this flag to harmonize
198+
--ref_list VALUE:ExistingFile reference csv/txt file with first column for dwi and 2nd column for mask: dwi1,mask1\n dwi2,mask2\n...
199+
--ref_name VALUE:str reference site name
200+
--resample VALUE:str voxel size MxNxO to resample into
201+
--tar_list VALUE:ExistingFile target csv/txt file with first column for dwi and 2nd column for mask: dwi1,mask1\n dwi2,mask2\n...
202+
--tar_name VALUE:str target site name; required
203+
--template VALUE:str template directory; required
204+
--travelHeads travelling heads
205+
--verbose print everything to STDOUT
206+
207+
</details>
302208

303209

304210
# Consistency checks
@@ -436,13 +342,10 @@ The steps are described below:
436342

437343
# Tests
438344

439-
**TBD** Tests are incomplete as of now but will be completed soon.
440-
441-
442345
## 1. pipeline
443346

444-
Clone single-shell dMRIharmonization pipeline and test that:
445-
https://github.com/pnlbwh/dMRIharmonization?tab=readme-ov-file#1-pipeline
347+
A small test data is provided with each [release](https://github.com/pnlbwh/dMRIharmonization/releases).
348+
Instruction for running tests can be found [here](https://github.com/pnlbwh/dMRIharmonization?tab=readme-ov-file#1-pipeline).
446349

447350
Success of this test will confirm that your environment is properly set up to run multi-shell-dMRIharmonization.
448351

@@ -454,27 +357,13 @@ Success of this test will confirm that your environment is properly set up to ru
454357

455358
# Preprocessing
456359

457-
Unlike single-shell dMRIharmonization, multi-shell-dMRIharmonization does **NOT** support data preprocessing as of now.
458-
This is likely to change in a future release. Hence, the following arguments are present for legacy purpose but you
459-
should not use them.
460-
461-
## 1. Denoising
462-
463-
--denoise # turn on this flag to denoise voxel data
464-
465-
## 2. Bvalue mapping
466-
467-
--bvalMap VALUE # specify a bmax to scale bvalues into
468-
469-
## 3. Resampling
470-
471-
--resample VALUE # voxel size MxNxO to resample into
472-
473-
474-
After preprocessing, the image lists are saved with `.modified` extension in the same location of provided lists,
475-
and used for further processing.
476-
360+
Since the beginning of multi-shell-dMRIharmonization development,
361+
it is expected that multi-shell DWIs are matched by bvalues and resolution.
362+
Hence, `--bvalMap`, `--resample`, `--denoise` flags are not supported for `multi-shell-harmonization.py`.
363+
This is likely to change in a future release.
477364

365+
However, you can use these options with `harmonization.py`.
366+
See [here](https://github.com/pnlbwh/dMRIharmonization/tree/master?tab=readme-ov-file#preprocessing) for details.
478367

479368

480369
# Debugging

0 commit comments

Comments
 (0)