Skip to content

Commit f72458f

Browse files
committed
Merge branch 'main' into wrapper_dev
2 parents 155eb5f + d5ffe8a commit f72458f

File tree

3 files changed

+21
-20
lines changed

3 files changed

+21
-20
lines changed

.github/workflows/docker-build-and-run.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
- name: Set up Python
1919
uses: actions/setup-python@v4
2020
with:
21-
python-version: '3.x'
21+
python-version: '3.11'
2222

2323
- name: Install Python dependencies
2424
run: |

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ junit/*
2828
ivim_simulation.bval
2929
ivim_simulation.bvec
3030
*.pt
31+
papers/paper1/figs
32+
papers/paper1/test-results*.xml
3133

3234
# Unit test / coverage reports
3335
.tox/
@@ -40,4 +42,3 @@ phantoms/MR_XCAT_qMRI/*.json
4042
phantoms/MR_XCAT_qMRI/*.txt
4143
tests/IVIMmodels/unit_tests/models
4244
models
43-
test_output.csv

src/original/PV_MUMC/two_step_IVIM_fit.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""
22
January 2022 by Paulien Voorter
3-
p.voorter@maastrichtuniversity.nl
3+
p.voorter@maastrichtuniversity.nl
44
https://www.github.com/paulienvoorter
55
66
requirements:
@@ -20,11 +20,11 @@
2020
def two_exp_noS0(bvalues, Dpar, Fmv, Dmv):
2121
""" bi-exponential IVIM function, and S0 set to 1"""
2222
return Fmv * np.exp(-bvalues * Dmv) + (1 - Fmv ) * np.exp(-bvalues * Dpar)
23-
23+
2424
def two_exp(bvalues, S0, Dpar, Fmv, Dmv):
2525
""" bi-exponential IVIM function"""
2626
return S0 * (Fmv * np.exp(-bvalues * Dmv) + (1 - Fmv ) * np.exp(-bvalues * Dpar))
27-
27+
2828

2929

3030
def fit_least_squares_array(bvalues, dw_data, fitS0=False, bounds=([0.9, 0.0001, 0.0, 0.0025], [1.1, 0.0025, 0.5, 0.2]), cutoff=200):
@@ -34,8 +34,8 @@ def fit_least_squares_array(bvalues, dw_data, fitS0=False, bounds=([0.9, 0.0001,
3434
is done on an array.
3535
:param bvalues: 1D Array with the b-values
3636
:param dw_data: 2D Array with diffusion-weighted signal in different voxels at different b-values
37-
:param bounds: Array with fit bounds ([S0min, Dparmin, Fmvmin, Dmvmin],[S0max, Dparmax, Fmvmax, Dmvmax]).
38-
:param cutoff: cutoff b-value used in step 1
37+
:param bounds: Array with fit bounds ([S0min, Dparmin, Fmvmin, Dmvmin],[S0max, Dparmax, Fmvmax, Dmvmax]).
38+
:param cutoff: cutoff b-value used in step 1
3939
:return Dpar: 1D Array with Dpar in each voxel
4040
:return Fmv: 1D Array with Fmv in each voxel
4141
:return Dmv: 1D Array with Dmv in each voxel
@@ -60,48 +60,48 @@ def fit_least_squares(bvalues, dw_data, S0_output=False, fitS0=False,
6060
is done on an array. It fits a single curve
6161
:param bvalues: 1D Array with the b-values
6262
:param dw_data: 1D Array with diffusion-weighted signal in different voxels at different b-values
63-
:param S0_output: Boolean determining whether to output (often a dummy) variable S0;
63+
:param S0_output: Boolean determining whether to output (often a dummy) variable S0;
6464
:param fitS0: Boolean determining whether to fix S0 to 1;
65-
:param bounds: Array with fit bounds ([S0min, Dparmin, Fmvmin, Dmvmin],[S0max, Dparmax, Fmvmax, Dmvmax]).
66-
:param cutoff: cutoff b-value used in step 1
65+
:param bounds: Array with fit bounds ([S0min, Dparmin, Fmvmin, Dmvmin],[S0max, Dparmax, Fmvmax, Dmvmax]).
66+
:param cutoff: cutoff b-value used in step 1
6767
:return S0: optional 1D Array with S0 in each voxel
6868
:return Dpar: scalar with Dpar of the specific voxel
6969
:return Fmv: scalar with Fmv of the specific voxel
7070
:return Dmv: scalar with Dmv of the specific voxel
7171
"""
72-
72+
7373
#try:
7474
def monofit(bvalues, Dpar, Fmv):
7575
return (1-Fmv)*np.exp(-bvalues * Dpar)
76-
76+
7777
high_b = bvalues[bvalues >= cutoff]
7878
high_dw_data = dw_data[bvalues >= cutoff]
7979
boundsmonoexp = ([bounds[0][1], bounds[0][2]], [bounds[1][1], bounds[1][2]])
80-
params, _ = curve_fit(monofit, high_b, high_dw_data, p0=[(bounds[1][1]-bounds[0][1])/2,(bounds[1][2]-bounds[0][2])/2], bounds=boundsmonoexp)
80+
params, _ = curve_fit(monofit, high_b, high_dw_data, p0=[(bounds[1][1]+bounds[0][1])/2,(bounds[1][2]+bounds[0][2])/2], bounds=boundsmonoexp)
8181
Dpar1 = params[0]
8282
if not fitS0:
8383
boundsupdated=([bounds[0][2] , bounds[0][3] ],
84-
[bounds[1][2] , bounds[1][3] ])
84+
[bounds[1][2] , bounds[1][3] ])
8585
params, _ = curve_fit(lambda b, Fmv, Dmv: two_exp_noS0(b, Dpar1, Fmv, Dmv), bvalues, dw_data, p0=[(bounds[0][2]+bounds[1][2])/2, (bounds[0][3]+bounds[1][3])/2], bounds=boundsupdated)
8686
Fmv, Dmv = params[0], params[1]
8787
#when the fraction of a compartment equals zero (or very very small), the corresponding diffusivity is non-existing (=NaN)
8888
#if Fmv < 1e-4:
8989
# Dmv = float("NaN")
90-
91-
else:
90+
91+
else:
9292
boundsupdated = ([bounds[0][0] , bounds[0][2] , bounds[0][3] ],
93-
[bounds[1][0] , bounds[1][2] , bounds[1][3] ])
93+
[bounds[1][0] , bounds[1][2] , bounds[1][3] ])
9494
params, _ = curve_fit(lambda b, S0, Fmv, Dmv: two_exp(b, S0, Dpar1, Fmv, Dmv), bvalues, dw_data, p0=[1, (bounds[0][2]+bounds[1][2])/2, (bounds[0][3]+bounds[1][3])/2], bounds=boundsupdated)
9595
S0 = params[0]
9696
Fmv, Dmv = params[1] , params[2]
9797
#when the fraction of a compartment equals zero (or very very small), the corresponding diffusivity is non-existing (=NaN)
9898
#if Fmv < 1e-4:
99-
# Dmv = float("NaN")
100-
99+
# Dmv = float("NaN")
100+
101101
if S0_output:
102102
return Dpar1, Fmv, Dmv, S0
103103
else:
104104
return Dpar1, Fmv, Dmv
105105

106106

107-
107+

0 commit comments

Comments
 (0)