Skip to content

Commit 95b2623

Browse files
added code description PV_MUMC
1 parent 0167af9 commit 95b2623

File tree

2 files changed

+58
-2
lines changed

2 files changed

+58
-2
lines changed

src/original/PV_MUMC/two_step_IVIM_fit.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,11 @@ def fit_least_squares_array(bvalues, dw_data, fitS0=True, bounds=([0.9, 0.0001,
5050
Fmv = np.zeros(len(dw_data))
5151
for i in tqdm.tqdm(range(len(dw_data)), position=0, leave=True):
5252
# fill arrays with fit results on a per voxel base:
53-
Dpar[i], Fmv[i], Dmv[i], S0[i] = fit_least_squares(bvalues, dw_data[i, :], S0_output=True, fitS0=fitS0, bounds=bounds)
53+
Dpar[i], Fmv[i], Dmv[i], S0[i] = fit_least_squares(bvalues, dw_data[i, :], S0_output=False, fitS0=fitS0, bounds=bounds)
5454
return [Dpar, Fmv, Dmv, S0]
5555

5656

57-
def fit_least_squares(bvalues, dw_data, IR=True, S0_output=False, fitS0=True,
57+
def fit_least_squares(bvalues, dw_data, IR=False, S0_output=False, fitS0=True,
5858
bounds=([0.9, 0.0001, 0.0, 0.0025], [1.1, 0.0025, 0.2, 0.2]), cutoff=200):
5959
"""
6060
This is the LSQ implementation, in which we first estimate Dpar using a curve fit to b-values>=cutoff;

src/standardized/PV_MUMC_biexp.py

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import numpy as np
2+
from src.wrappers.OsipiBase import OsipiBase
3+
from src.original.PV_MUMC.ivim_fit_method_biexp import fit_least_squares_array
4+
5+
6+
class PV_MUMC_biexp(OsipiBase):
7+
"""
8+
Bi-exponential fitting algorithm by Paulien Voorter, Maastricht University
9+
"""
10+
11+
# Some basic stuff that identifies the algorithm
12+
id_author = "Paulien Voorter MUMC"
13+
id_algorithm_type = "Bi-exponential fit"
14+
id_return_parameters = "f, D*, D"
15+
id_units = "seconds per milli metre squared or milliseconds per micro metre squared"
16+
17+
# Algorithm requirements
18+
required_bvalues = 4
19+
required_thresholds = [0,0] # Interval from "at least" to "at most", in case submissions allow a custom number of thresholds
20+
required_bounds = False
21+
required_bounds_optional = True # Bounds may not be required but are optional
22+
required_initial_guess = False
23+
required_initial_guess_optional = True
24+
accepted_dimensions = 1 # Not sure how to define this for the number of accepted dimensions. Perhaps like the thresholds, at least and at most?
25+
26+
def __init__(self, bvalues=None, thresholds=None, bounds=([0.9, 0.0001, 0.0, 0.0025], [1.1, 0.0025, 0.2, 0.2]), initial_guess=None, weighting=None, stats=False):
27+
"""
28+
Everything this algorithm requires should be implemented here.
29+
Number of segmentation thresholds, bounds, etc.
30+
31+
Our OsipiBase object could contain functions that compare the inputs with
32+
the requirements.
33+
"""
34+
super(PV_MUMC, self).__init__(bvalues, None, bounds, None)
35+
self.PV_algorithm = fit_least_squares_array
36+
37+
38+
def ivim_fit(self, signals, bvalues=None):
39+
"""Perform the IVIM fit
40+
41+
Args:
42+
signals (array-like)
43+
bvalues (array-like, optional): b-values for the signals. If None, self.bvalues will be used. Default is None.
44+
45+
Returns:
46+
_type_: _description_
47+
"""
48+
49+
50+
fit_results = self.PV_algorithm(bvalues, signals)
51+
52+
f = fit_results[1]
53+
Dstar = fit_results[2]
54+
D = fit_results[0]
55+
56+
return f, Dstar, D

0 commit comments

Comments
 (0)