Skip to content

Commit

Permalink
Merge pull request #65 from merelvdthiel/main
Browse files Browse the repository at this point in the history
adding jupyter notebook usage code and IVIM analysis
  • Loading branch information
oliverchampion authored Aug 14, 2024
2 parents 02b20c8 + 5986d85 commit 25b45af
Show file tree
Hide file tree
Showing 4 changed files with 1,121 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ __pycache__/
*.raw
bvals.txt
download
.Introduction_to_TF24_IVIM-MRI_CodeCollection_github_and_IVIM_Analysis_using_Python.ipynb
.ipynb_checkpoints
md5sums.txt
*.gz
*.zip
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ If you would like to contribute with code, please follow the instructions below:
* [Guidelines for IVIM code contribution](doc/guidelines_for_contributions.md)
* [Guidelines to creating a test file](doc/creating_test.md)

If you would like to use code from the repository and/or are new to Github or IVIM, please see the jupyter notebook below:
* [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)

## Repository Organization

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

Large diffs are not rendered by default.

12 changes: 9 additions & 3 deletions src/wrappers/OsipiBase.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from scipy.stats import norm
import pathlib
import sys
from tqdm import tqdm

class OsipiBase:
"""The base class for OSIPI IVIM fitting"""
Expand Down Expand Up @@ -47,7 +48,7 @@ def initialize(**kwargs):
pass

#def osipi_fit(self, data=None, bvalues=None, thresholds=None, bounds=None, initial_guess=None, **kwargs):
def osipi_fit(self, data, bvalues, **kwargs):
def osipi_fit(self, data, bvalues=None, **kwargs):
"""Fits the data with the bvalues
Returns [S0, f, Dstar, D]
"""
Expand All @@ -68,7 +69,6 @@ def osipi_fit(self, data, bvalues, **kwargs):
#kwargs["bvalues"] = use_bvalues

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

#args = [data, use_bvalues, use_initial_guess, use_bounds, use_thresholds]
#args = [arg for arg in args if arg is not None]
results = self.ivim_fit(*args, **kwargs)

# Assuming the last dimension of the data is the signal values of each b-value
results = np.empty(list(data.shape[:-1])+[3]) # Create an array with the voxel dimensions + the ones required for the fit
for ijk in tqdm(np.ndindex(data.shape[:-1]), total=np.prod(data.shape[:-1])):
args = [data[ijk], use_bvalues]
fit = list(self.ivim_fit(*args, **kwargs))
results[ijk] = fit

#self.parameter_estimates = self.ivim_fit(data, bvalues)
return results
Expand Down

0 comments on commit 25b45af

Please sign in to comment.