Skip to content

Commit 25b45af

Browse files
Merge pull request #65 from merelvdthiel/main
adding jupyter notebook usage code and IVIM analysis
2 parents 02b20c8 + 5986d85 commit 25b45af

File tree

4 files changed

+1121
-3
lines changed

4 files changed

+1121
-3
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ __pycache__/
1010
*.raw
1111
bvals.txt
1212
download
13+
.Introduction_to_TF24_IVIM-MRI_CodeCollection_github_and_IVIM_Analysis_using_Python.ipynb
14+
.ipynb_checkpoints
1315
md5sums.txt
1416
*.gz
1517
*.zip

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ If you would like to contribute with code, please follow the instructions below:
1717
* [Guidelines for IVIM code contribution](doc/guidelines_for_contributions.md)
1818
* [Guidelines to creating a test file](doc/creating_test.md)
1919

20+
If you would like to use code from the repository and/or are new to Github or IVIM, please see the jupyter notebook below:
21+
* [Introduction to TF2.4_IVIM-MRI_CodeCollection github and IVIM Analysis using Python](doc/Introduction_to_TF24_IVIM-MRI_CodeCollection_github_and_IVIM_Analysis_using_Python.ipynb)
22+
2023
## Repository Organization
2124

2225
The repository is organized in four main folders along with configuration files for automated testing.

doc/Introduction_to_TF24_IVIM-MRI_CodeCollection_github_and_IVIM_Analysis_using_Python.ipynb

Lines changed: 1107 additions & 0 deletions
Large diffs are not rendered by default.

src/wrappers/OsipiBase.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from scipy.stats import norm
44
import pathlib
55
import sys
6+
from tqdm import tqdm
67

78
class OsipiBase:
89
"""The base class for OSIPI IVIM fitting"""
@@ -47,7 +48,7 @@ def initialize(**kwargs):
4748
pass
4849

4950
#def osipi_fit(self, data=None, bvalues=None, thresholds=None, bounds=None, initial_guess=None, **kwargs):
50-
def osipi_fit(self, data, bvalues, **kwargs):
51+
def osipi_fit(self, data, bvalues=None, **kwargs):
5152
"""Fits the data with the bvalues
5253
Returns [S0, f, Dstar, D]
5354
"""
@@ -68,7 +69,6 @@ def osipi_fit(self, data, bvalues, **kwargs):
6869
#kwargs["bvalues"] = use_bvalues
6970

7071
#args = [data, use_bvalues, use_thresholds]
71-
args = [data, use_bvalues]
7272
#if self.required_bounds or self.required_bounds_optional:
7373
#args.append(use_bounds)
7474
#if self.required_initial_guess or self.required_initial_guess_optional:
@@ -83,7 +83,13 @@ def osipi_fit(self, data, bvalues, **kwargs):
8383

8484
#args = [data, use_bvalues, use_initial_guess, use_bounds, use_thresholds]
8585
#args = [arg for arg in args if arg is not None]
86-
results = self.ivim_fit(*args, **kwargs)
86+
87+
# Assuming the last dimension of the data is the signal values of each b-value
88+
results = np.empty(list(data.shape[:-1])+[3]) # Create an array with the voxel dimensions + the ones required for the fit
89+
for ijk in tqdm(np.ndindex(data.shape[:-1]), total=np.prod(data.shape[:-1])):
90+
args = [data[ijk], use_bvalues]
91+
fit = list(self.ivim_fit(*args, **kwargs))
92+
results[ijk] = fit
8793

8894
#self.parameter_estimates = self.ivim_fit(data, bvalues)
8995
return results

0 commit comments

Comments
 (0)