Skip to content

Commit 7004a89

Browse files
Fixed some bugs
1 parent fdc6333 commit 7004a89

File tree

4 files changed

+20
-29
lines changed

4 files changed

+20
-29
lines changed

src/standardized/OGC_AmsterdamUMC_Bayesian_biexp.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class OGC_AmsterdamUMC_Bayesian_biexp(OsipiBase):
2828
accepted_dimensions = 1 # Not sure how to define this for the number of accepted dimensions. Perhaps like the thresholds, at least and at most?
2929
accepts_priors = True
3030

31-
def __init__(self, bvalues=None, bounds=([0, 0, 0.005, 0.7],[0.005, 0.7, 0.2, 1.3]), initial_guess=None, fitS0=False, thresholds=None, prior_in=None):
31+
def __init__(self, bvalues=None, bounds=([0, 0, 0.005, 0.7],[0.005, 0.7, 0.2, 1.3]), initial_guess=None, fitS0=True, thresholds=None, prior_in=None):
3232
"""
3333
Everything this algorithm requires should be implemented here.
3434
Number of segmentation thresholds, bounds, etc.
@@ -43,7 +43,7 @@ def __init__(self, bvalues=None, bounds=([0, 0, 0.005, 0.7],[0.005, 0.7, 0.2, 1.
4343
self.OGC_algorithm = fit_bayesian
4444
self.initialize(bounds, initial_guess, fitS0, thresholds, prior_in)
4545

46-
def initialize(self, bounds=([0, 0, 0.005, 0.7],[0.005, 0.7, 0.2, 1.3]), initial_guess=None, fitS0=False, thresholds=None, prior_in=None):
46+
def initialize(self, bounds=([0, 0, 0.005, 0.7],[0.005, 0.7, 0.2, 1.3]), initial_guess=None, fitS0=True, thresholds=None, prior_in=None):
4747
if bounds is None:
4848
self.bounds=([0, 0, 0.005, 0.7],[0.005, 1, 0.2, 1.3])
4949
else:
@@ -61,7 +61,7 @@ def initialize(self, bounds=([0, 0, 0.005, 0.7],[0.005, 0.7, 0.2, 1.3]), initial
6161
self.initial_guess = initial_guess
6262
self.fitS0=fitS0
6363

64-
def ivim_fit(self, signals, bvalues, bounds=None, initial_guess=None, fitS0=False, thresholds=None, prior_in=None, **kwargs):
64+
def ivim_fit(self, signals, bvalues, bounds=None, initial_guess=None, fitS0=True, thresholds=None, prior_in=None, **kwargs):
6565
"""Perform the IVIM fit
6666
6767
Args:

src/standardized/OGC_AmsterdamUMC_biexp_segmented.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,10 @@ def initialize(self, bounds, initial_guess, thresholds=300):
5050
self.initial_guess = [0.001, 0.1, 0.03, 1]
5151
else:
5252
self.initial_guess = initial_guess
53-
self.thresholds=thresholds
53+
if thresholds is None:
54+
self.thresholds = 150
55+
else:
56+
self.thresholds = thresholds
5457

5558
def ivim_fit(self, signals, bvalues, bounds=None, initial_guess=None, thresholds=None, **kwargs):
5659
"""Perform the IVIM fit

tests/IVIMmodels/unit_tests/algorithms.json

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -134,29 +134,17 @@
134134
}
135135
},
136136
"OGC_AmsterdamUMC_biexp_segmented": {
137-
"xfail_names": {
138-
"Vein": true,
139-
"pericardium": true,
140-
"small intestine": true,
141-
"desc lower intestine": true,
142-
"trans lower intestine": true,
143-
"asc lower intestine": true,
144-
"Artery": true,
145-
"spleen": true,
146-
"left kidney medulla": true,
147-
"Left kidney cortex": true,
148-
"right kidney medulla": true,
149-
"Right kydney cortex": true,
150-
"pancreas": true,
151-
"st wall": true,
152-
"esophagus cont": true,
153-
"esophagus": true,
154-
"Liver": true,
155-
"Blood RA": true,
156-
"Blood RV": true,
157-
"myocardium ra": true,
158-
"myocardium RV": true,
159-
"Myocardium LV": true
137+
"tolerances": {
138+
"rtol": {
139+
"f": 5,
140+
"D": 5,
141+
"Dp": 25
142+
},
143+
"atol": {
144+
"f": 1e-2,
145+
"D": 1e-2,
146+
"Dp": 1e-1
147+
}
160148
}
161149
}
162150
}

tests/IVIMmodels/unit_tests/test_ivim_synthetic.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def test_generated(ivim_algorithm, ivim_data, SNR, rtol, atol, fit_count, rician
2626
fit = OsipiBase(algorithm=ivim_algorithm)
2727
# here try a prior, but it's not seeing it, why?
2828
# if hasattr(fit, "accepts_priors") and fit.accepts_priors:
29-
prior = [np.repeat(D, 10), np.repeat(f, 10), np.repeat(Dp, 10)] # D, f, D*
29+
prior = [np.repeat(D, 10)+np.random.normal(0,D/3,np.shape(np.repeat(D, 10))), np.repeat(f, 10)+np.random.normal(0,f/3,np.shape(np.repeat(D, 10))), np.repeat(Dp, 10)+np.random.normal(0,Dp/3,np.shape(np.repeat(D, 10))),np.repeat(np.ones_like(Dp), 10)+np.random.normal(0,1/3,np.shape(np.repeat(D, 10)))] # D, f, D*
3030
# fit.initialize(prior_in=prior)
3131
time_delta = datetime.timedelta()
3232
for idx in range(fit_count):
@@ -35,7 +35,7 @@ def test_generated(ivim_algorithm, ivim_data, SNR, rtol, atol, fit_count, rician
3535
# else:
3636
# signal = data["data"]
3737
start_time = datetime.datetime.now()
38-
[f_fit, Dp_fit, D_fit] = fit.osipi_fit(signal, bvals) #, prior_in=prior
38+
[f_fit, Dp_fit, D_fit] = fit.osipi_fit(signal, bvals, prior_in=prior)
3939
time_delta += datetime.datetime.now() - start_time
4040
if save_file:
4141
save_results(save_file, ivim_algorithm, name, SNR, idx, [f, Dp, D], [f_fit, Dp_fit, D_fit])

0 commit comments

Comments
 (0)