Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding jupyter notebook usage code and IVIM analysis #65

Merged
merged 7 commits into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think here we could start a header with

How to use

and give some explanation on how to look at the Git and how to use it. Also we could refer to the wrapper explanation that Ivan wrote too.

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.

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
Loading