Skip to content

Commit 67c90a5

Browse files
authored
Merge pull request #18 from mjt320/develop
Checking ve+vp<=1 can now be disabled
2 parents 1ca7967 + 2f4528f commit 67c90a5

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ Most functionality is demonstrated in Jupyter notebook format in ./demo
4242
---
4343

4444
### Updates
45+
Release 1.3.0 - Checking ve+vp<=1 can now be disabled
4546
Release 1.2.1 - "Georgiou" AIF added to *aifs* module
4647
Release 1.1.1 - *roi_measure* exclude NaNs when calculating percentiles
4748
Release 1.1.0 - *roi_measure* modified to generate more ROI statistics

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ build-backend = "setuptools.build_meta"
66

77
[project]
88
name = "sepal"
9-
version = "1.2.1"
9+
version = "1.3.1"
1010
description = "Quantitative MRI processing"
1111
readme = "README.md"
1212
authors = [{ name = "Michael Thrippleton", email = "mjt320@googlemail.com" }]

src/sepal/dce_fit.py

+12-4
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ class ConcToPKP(Fitter):
185185
186186
Subclass of Fitter.
187187
"""
188-
def __init__(self, pk_model, pk_pars_0=None, weights=None):
188+
def __init__(self, pk_model, pk_pars_0=None, weights=None, check_ve_vp_sum=True):
189189
"""
190190
Args:
191191
pk_model (PkModel): Pharmacokinetic model used to predict tracer
@@ -200,6 +200,8 @@ def __init__(self, pk_model, pk_pars_0=None, weights=None):
200200
for sum-of-squares calculation. Can be used to "exclude" data
201201
points from optimisation. Defaults to equal weighting for all
202202
points.
203+
check_ve_vp_sum (bool, optional): Whether to check if sum of ve and vp >=1.
204+
If condition is met, outputs will be set to NaN. Defaults to True.
203205
"""
204206
self.pk_model = pk_model
205207
if pk_pars_0 is None:
@@ -210,6 +212,7 @@ def __init__(self, pk_model, pk_pars_0=None, weights=None):
210212
self.weights = np.ones(pk_model.n)
211213
else:
212214
self.weights = weights
215+
self.check_ve_vp_sum = check_ve_vp_sum
213216
# Convert initial pars from list of dicts to list of arrays
214217
self.x_0_all = [pk_model.pkp_array(pars) for pars in self.pk_pars_0]
215218

@@ -244,7 +247,8 @@ def proc(self, C_t):
244247
f'Unable to calculate pharmacokinetic parameters'
245248
f': {result.message}')
246249
pk_pars_opt = self.pk_model.pkp_dict(result.x)
247-
check_ve_vp_sum(pk_pars_opt)
250+
if self.check_ve_vp_sum:
251+
check_ve_vp_sum(pk_pars_opt)
248252
Ct_fit, _C_cp, _C_e = self.pk_model.conc(*result.x)
249253
Ct_fit[self.weights == 0] = np.nan
250254
return tuple(result.x) + (Ct_fit,)
@@ -269,7 +273,7 @@ class EnhToPKP(Fitter):
269273
R2 and R2* effects neglected.
270274
"""
271275
def __init__(self, hct, pk_model, t10_blood, c_to_r_model, water_ex_model,
272-
signal_model, pk_pars_0=None, weights=None):
276+
signal_model, pk_pars_0=None, weights=None, check_ve_vp_sum=True):
273277
"""
274278
Args:
275279
hct (float): Capillary haematocrit
@@ -295,6 +299,8 @@ def __init__(self, hct, pk_model, t10_blood, c_to_r_model, water_ex_model,
295299
sum-of-squares calculation. Can be used to "exclude" data
296300
points from optimisation. Defaults to equal weighting for all
297301
points.
302+
check_ve_vp_sum (bool, optional): Whether to check if sum of ve and vp >=1.
303+
If condition is met, outputs will be set to NaN. Defaults to True.
298304
"""
299305
self.hct = hct
300306
self.pk_model = pk_model
@@ -310,6 +316,7 @@ def __init__(self, hct, pk_model, t10_blood, c_to_r_model, water_ex_model,
310316
self.weights = np.ones(pk_model.n)
311317
else:
312318
self.weights = weights
319+
self.check_ve_vp_sum = check_ve_vp_sum
313320
# Convert initial pars from list of dicts to list of arrays
314321
self.x_0_all = [pk_model.pkp_array(pars) for pars in self.pk_pars_0]
315322

@@ -349,7 +356,8 @@ def proc(self, enh, k_fa, t10_tissue):
349356
f'Unable to calculate pharmacokinetic parameters'
350357
f': {result.message}')
351358
pk_pars_opt = self.pk_model.pkp_dict(result.x)
352-
check_ve_vp_sum(pk_pars_opt)
359+
if self.check_ve_vp_sum:
360+
check_ve_vp_sum(pk_pars_opt)
353361
enh_fit = pkp_to_enh(pk_pars_opt, self.hct, k_fa, t10_tissue,
354362
self.t10_blood, self.pk_model, self.c_to_r_model,
355363
self.water_ex_model, self.signal_model)

0 commit comments

Comments
 (0)