Skip to content

Commit 59767b5

Browse files
Merge branch 'main' into Unit_Testing_Tolerances
2 parents ba9fa91 + c9af8ef commit 59767b5

24 files changed

+157
-220
lines changed

.github/workflows/analysis.yml

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,20 +70,21 @@ jobs:
7070
run: |
7171
python -m pytest -m slow --selectAlgorithm ${{ matrix.algorithm }} --saveFileName test_output_${{ matrix.algorithm }}_${{ matrix.SNR }}.csv --SNR ${{ matrix.SNR }} --fitCount 300 --saveDurationFileName test_duration_${{ matrix.algorithm }}_${{ matrix.SNR }}.csv
7272
- name: Upload raw data
73-
uses: actions/upload-artifact@v3
73+
uses: actions/upload-artifact@v4
7474
with:
7575
name: Working_Data
7676
retention-days: 1
7777
path: |
7878
test_output_${{ matrix.algorithm }}_${{ matrix.SNR }}.csv
7979
test_duration_${{ matrix.algorithm }}_${{ matrix.SNR }}.csv
80+
overwrite: true
8081

8182
merge:
8283
runs-on: ubuntu-latest
8384
needs: build
8485
steps:
8586
- name: Download artifacts
86-
uses: actions/download-artifact@v3
87+
uses: actions/download-artifact@v4
8788
with:
8889
path: artifacts
8990
- name: Merge fitting results
@@ -95,12 +96,13 @@ jobs:
9596
head -n 1 $(ls artifacts/Working_Data/test_duration_*.csv | head -n 1) > test_duration.csv
9697
tail -q -n +2 artifacts/Working_Data/test_duration_*.csv >> test_duration.csv
9798
- name: Upload merged artifacts
98-
uses: actions/upload-artifact@v3
99+
uses: actions/upload-artifact@v4
99100
with:
100101
name: Data
101102
path: |
102103
test_output.csv
103104
test_duration.csv
105+
overwrite: true
104106

105107
analyze:
106108
runs-on: ubuntu-latest
@@ -121,13 +123,13 @@ jobs:
121123
any::data.table
122124
any::ggplot2
123125
- name: Download artifacts
124-
uses: actions/download-artifact@v3
126+
uses: actions/download-artifact@v4
125127
with:
126128
name: Data
127129
- name: Generate figures
128130
run: Rscript --vanilla tests/IVIMmodels/unit_tests/analyze.r test_output.csv test_duration.csv
129131
- name: Upload figures
130-
uses: actions/upload-artifact@v3
132+
uses: actions/upload-artifact@v4
131133
if: always()
132134
with:
133135
name: Figures
@@ -141,6 +143,8 @@ jobs:
141143
durations.pdf
142144
curve_plot.pdf
143145
fitted_curves.pdf
146+
overwrite: true
147+
144148

145149
compare:
146150
runs-on: ubuntu-latest
@@ -158,16 +162,17 @@ jobs:
158162
any::tidyverse
159163
any::assertr
160164
- name: Download artifacts
161-
uses: actions/download-artifact@v3
165+
uses: actions/download-artifact@v4
162166
with:
163167
name: Data
164168
- name: Test against previous results
165169
run: Rscript --vanilla tests/IVIMmodels/unit_tests/compare.r test_output.csv test_reference.csv tests/IVIMmodels/unit_tests/reference_output.csv test_results.csv
166170
- name: Upload data
167-
uses: actions/upload-artifact@v3
171+
uses: actions/upload-artifact@v4
168172
if: always()
169173
with:
170174
name: Comparison
171175
path: |
172176
test_reference.csv
173177
test_results.csv
178+
overwrite: true

src/original/IAR_LundUniversity/ivim_fit_method_biexp.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,13 @@ def ivim_model(self, b, S0, f, D_star, D):
6161

6262
def set_bounds(self, bounds):
6363
# Use this function for fits that uses curve_fit
64-
if bounds == None:
64+
if bounds is None:
6565
self.bounds = np.array([(0, 0, 0.005, 0), (np.inf, 1, 0.1, 0.004)])
6666
else:
67-
self.bounds = np.array([(0, *bounds[0]), (np.inf, *bounds[1])])
67+
self.bounds = np.array([bounds[0], bounds[1]])
6868

6969
def set_initial_guess(self, initial_guess):
70-
if initial_guess == None:
70+
if initial_guess is None:
7171
self.initial_guess = (1, 0.2, 0.03, 0.001)
7272
else:
7373
self.initial_guess = initial_guess

src/original/IAR_LundUniversity/ivim_fit_method_linear.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,13 @@ def sivim_model(self, b, S0, f, D):
8383

8484
def set_bounds(self, bounds):
8585
# Use this function for fits that uses curve_fit
86-
if bounds == None:
86+
if bounds is None:
8787
self.bounds = np.array([(0, 0, 0), (np.inf, 1, 0.004)])
8888
else:
89-
self.bounds = np.array([(0, *bounds[0]), (np.inf, *bounds[1])])
89+
self.bounds = np.array([bounds[0], bounds[1]])
9090

9191
def set_initial_guess(self, initial_guess):
92-
if initial_guess == None:
92+
if initial_guess is None:
9393
self.initial_guess = (1, 0.2, 0.001)
9494
else:
9595
self.initial_guess = initial_guess

src/original/IAR_LundUniversity/ivim_fit_method_modified_mix.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def __init__(self, gtab, bounds=None, maxiter=10, xtol=1e-8, rescale_units=False
7878
if gtab.bvals[-1] >= 10:
7979
self.bvals = gtab.bvals/1000
8080

81-
if bounds == None:
81+
if bounds is None:
8282
# Bounds expressed as (lower bound, upper bound) for [f, D*, D].
8383
self.bounds = np.array([(0, 1), (5, 100), (0, 4)])
8484
elif (bounds[0][1] <= 1) or rescale_units: # Realistically, if mm2/s units are used, D* bound is <= 1

src/original/IAR_LundUniversity/ivim_fit_method_modified_topopro.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def __init__(self, gtab, bounds=[[0, 0.005, 1e-5], [1, 0.1, 0.004]], \
7676
# and are thus not changed.
7777
if gtab.bvals[-1] >= 10:
7878
self.bvals = gtab.bvals/1000
79-
if bounds == None:
79+
if bounds is None:
8080
# Bounds expressed as (lower bound, upper bound) for [f, D*, D].
8181
self.bounds = np.array([(0, 1), (5, 100), (0, 4)])
8282
elif (bounds[0][1] <= 1) or rescale_units: # Realistically, if mm2/s units are used, D* bound is <= 1

src/original/IAR_LundUniversity/ivim_fit_method_segmented_2step.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,13 @@ def ivim_signal(self, b, S0, f, D_star, D):
8686

8787
def set_bounds(self, bounds):
8888
# Use this function for fits that uses curve_fit
89-
if bounds == None:
89+
if bounds is None:
9090
self.bounds = np.array([(0, 0, 0.005, 0), (np.inf, 1, 0.1, 0.004)])
9191
else:
92-
self.bounds = np.array([(0, *bounds[0]), (np.inf, *bounds[1])])
92+
self.bounds = np.array([bounds[0], bounds[1]])
9393

9494
def set_initial_guess(self, initial_guess):
95-
if initial_guess == None:
95+
if initial_guess is None:
9696
self.initial_guess = (1, 0.2, 0.03, 0.001)
9797
else:
9898
self.initial_guess = initial_guess

src/original/IAR_LundUniversity/ivim_fit_method_segmented_3step.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,13 +105,13 @@ def ivim_signal(self, b, S0, f, D_star, D):
105105

106106
def set_bounds(self, bounds):
107107
# Use this function for fits that uses curve_fit
108-
if bounds == None:
108+
if bounds is None:
109109
self.bounds = np.array([(0, 0, 0.005, 0), (np.inf, 1, 0.1, 0.004)])
110110
else:
111-
self.bounds = np.array([(0, *bounds[0]), (np.inf, *bounds[1])])
111+
self.bounds = np.array([bounds[0], bounds[1]])
112112

113113
def set_initial_guess(self, initial_guess):
114-
if initial_guess == None:
114+
if initial_guess is None:
115115
self.initial_guess = (1, 0.2, 0.03, 0.001)
116116
else:
117117
self.initial_guess = initial_guess

src/original/IAR_LundUniversity/ivim_fit_method_sivim.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,13 @@ def sivim_model(self, b, S0, f, D):
7777

7878
def set_bounds(self, bounds):
7979
# Use this function for fits that uses curve_fit
80-
if bounds == None:
80+
if bounds is None:
8181
self.bounds = np.array([(0, 0, 0), (np.inf, 1, 0.004)])
8282
else:
83-
self.bounds = np.array([(0, *bounds[0]), (np.inf, *bounds[1])])
83+
self.bounds = np.array([bounds[0], bounds[1]])
8484

8585
def set_initial_guess(self, initial_guess):
86-
if initial_guess == None:
86+
if initial_guess is None:
8787
self.initial_guess = (1, 0.2, 0.001)
8888
else:
8989
self.initial_guess = initial_guess

src/original/IAR_LundUniversity/ivim_fit_method_subtracted.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,13 @@ def perfusion_signal(self, b, S0, D_star):
9393

9494
def set_bounds(self, bounds):
9595
# Use this function for fits that uses curve_fit
96-
if bounds == None:
96+
if bounds is None:
9797
self.bounds = np.array([(0, 0, 0.005, 0), (np.inf, 1, 0.1, 0.004)])
9898
else:
99-
self.bounds = np.array([(0, *bounds[0]), (np.inf, *bounds[1])])
99+
self.bounds = np.array([bounds[0], bounds[1]])
100100

101101
def set_initial_guess(self, initial_guess):
102-
if initial_guess == None:
102+
if initial_guess is None:
103103
self.initial_guess = (1, 0.2, 0.03, 0.001)
104104
else:
105105
self.initial_guess = initial_guess

src/original/IAR_LundUniversity/simple_test_of_fits.py

Lines changed: 0 additions & 130 deletions
This file was deleted.

src/standardized/ETP_SRI_LinearFitting.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ class ETP_SRI_LinearFitting(OsipiBase):
2727
required_initial_guess_optional = False
2828
accepted_dimensions = 1
2929
# Not sure how to define this for the number of accepted dimensions. Perhaps like the thresholds, at least and at most?
30+
31+
# Supported inputs in the standardized class
32+
supported_bounds = False
33+
supported_initial_guess = False
34+
supported_thresholds = True
3035

3136
def __init__(self, bvalues=None, thresholds=None, bounds=None, initial_guess=None, weighting=None, stats=False):
3237
"""
@@ -36,11 +41,13 @@ def __init__(self, bvalues=None, thresholds=None, bounds=None, initial_guess=Non
3641
Our OsipiBase object could contain functions that compare the inputs with
3742
the requirements.
3843
"""
44+
3945
super(ETP_SRI_LinearFitting, self).__init__(bvalues, thresholds, bounds, initial_guess)
4046
if bounds is not None:
4147
print('warning, bounds from wrapper are not (yet) used in this algorithm')
4248
self.use_bounds = False
4349
self.use_initial_guess = False
50+
4451
# Could be a good idea to have all the submission-specfic variable be
4552
# defined with initials?
4653
self.ETP_weighting = weighting
@@ -71,7 +78,7 @@ def ivim_fit(self, signals, bvalues=None, linear_fit_option=False, **kwargs):
7178

7279
results = {}
7380
if linear_fit_option:
74-
f, Dstar = ETP_object.linear_fit(bvalues, signals)
81+
f, Dstar = ETP_object.linear_fit(bvalues, signals, self.ETP_weighting, self.ETP_stats)
7582

7683
results["f"] = f
7784
results["Dp"] = Dstar

0 commit comments

Comments
 (0)