Skip to content

Commit 0167af9

Browse files
committed
initial attempt at LSQ fitting from Amsterdam UMC, tests failing
1 parent 2e318b2 commit 0167af9

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
from src.wrappers.OsipiBase import OsipiBase
2+
from src.original.OGC_AmsterdamUMC.LSQ_fitting import fit_least_squares_array
3+
4+
5+
class OGC_AmsterdamUMC_biexp(OsipiBase):
6+
"""
7+
Bi-exponential fitting algorithm by Oliver Gurney-Champion, Amsterdam UMC
8+
"""
9+
10+
# I'm thinking that we define default attributes for each submission like this
11+
# And in __init__, we can call the OsipiBase control functions to check whether
12+
# the user inputs fulfil the requirements
13+
14+
# Some basic stuff that identifies the algorithm
15+
id_author = "Oliver Gurney Champion, Amsterdam UMC"
16+
id_algorithm_type = "Bi-exponential fit"
17+
id_return_parameters = "f, D*, D, S0"
18+
id_units = "seconds per milli metre squared or milliseconds per micro metre squared"
19+
20+
# Algorithm requirements
21+
required_bvalues = 4
22+
required_thresholds = [0,
23+
0] # Interval from "at least" to "at most", in case submissions allow a custom number of thresholds
24+
required_bounds = False
25+
required_bounds_optional = True # Bounds may not be required but are optional
26+
required_initial_guess = False
27+
required_initial_guess_optional = True
28+
accepted_dimensions = 1 # Not sure how to define this for the number of accepted dimensions. Perhaps like the thresholds, at least and at most?
29+
30+
def __init__(self, bvalues, bounds=([0, 0, 0.005, 0.7],[0.005, 0.7, 0.2, 1.3])):
31+
"""
32+
Everything this algorithm requires should be implemented here.
33+
Number of segmentation thresholds, bounds, etc.
34+
35+
Our OsipiBase object could contain functions that compare the inputs with
36+
the requirements.
37+
"""
38+
super(OGC_AmsterdamUMC_biexp, self).__init__(bvalues, None, bounds, None)
39+
self.OGC_algorithm = fit_least_squares_array
40+
41+
def ivim_fit(self, signals, bvalues=None):
42+
"""Perform the IVIM fit
43+
44+
Args:
45+
signals (array-like)
46+
bvalues (array-like, optional): b-values for the signals. If None, self.bvalues will be used. Default is None.
47+
48+
Returns:
49+
_type_: _description_
50+
"""
51+
52+
fit_results = self.OGC_algorithm(bvalues, signals)
53+
54+
D = fit_results[0]
55+
f = fit_results[1]
56+
Dstar = fit_results[2]
57+
58+
return f, Dstar, D

0 commit comments

Comments
 (0)