From c0ab6af0441bb1ebca5deb708227d088a274da76 Mon Sep 17 00:00:00 2001 From: LucyKershaw Date: Tue, 2 May 2023 16:48:46 +0100 Subject: [PATCH 1/4] LEK SI2Conc edit Edited LEK code for SI2Conc to include a range for the baseline points to be used. Test function updated accordingly --- .../LEK_UoEdinburghUK/SignalToConcentration/SI2Conc.py | 8 ++++---- test/SI_to_Conc/test_SI2Conc_LEK_EdinburghUK.py | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/original/LEK_UoEdinburghUK/SignalToConcentration/SI2Conc.py b/src/original/LEK_UoEdinburghUK/SignalToConcentration/SI2Conc.py index 74cec6e2..ceb8afbb 100644 --- a/src/original/LEK_UoEdinburghUK/SignalToConcentration/SI2Conc.py +++ b/src/original/LEK_UoEdinburghUK/SignalToConcentration/SI2Conc.py @@ -11,17 +11,17 @@ # Inputs: # SIcurve numpy array of SI values - # TR TR for FLAHS sequence, in seconds + # TR TR for FLASH sequence, in seconds # flip Flip angle for FLASH sequence in degrees # T1base Native T1 corresponding to the baseline signal intensity, in seconds - # baselinepts Number of data points before the arrival of contrast agent + # baselinepts Range of data points to be used for baseline, indexes to start and end at [start,end] # S0 Equilibrium signal, if known. Default is to calculate it here # Output: #H numpy array of curve as delta R1 in s^-1 -def SI2Conc(SIcurve,TR,flip,T1base,baselinepts,S0=None): +def SI2Conc(SIcurve,TR,flip,T1base,baselinepts_range,S0=None): # Convert flip angle to radians rflip=flip*np.pi/180 @@ -31,7 +31,7 @@ def SI2Conc(SIcurve,TR,flip,T1base,baselinepts,S0=None): # If S0 isn't specified, calculate from baseline if S0 is None: - SIbase=np.mean(SIcurve[1:baselinepts]) + SIbase=np.mean(SIcurve[baselinepts_range[0]:baselinepts_range[1]]) S0=CalcM0(SIbase,TR,flip,T1base) # Now calculate the R1 curve diff --git a/test/SI_to_Conc/test_SI2Conc_LEK_EdinburghUK.py b/test/SI_to_Conc/test_SI2Conc_LEK_EdinburghUK.py index 4839bdc9..f116d88c 100755 --- a/test/SI_to_Conc/test_SI2Conc_LEK_EdinburghUK.py +++ b/test/SI_to_Conc/test_SI2Conc_LEK_EdinburghUK.py @@ -20,7 +20,7 @@ def test_LEK_UoEdinburghUK_SI2Conc(label, fa, tr, T1base, BLpts, r1, s_array, co #Nothing to do for this function # run test - conc_curve = SI2Conc.SI2Conc(s_array,tr,fa,T1base,BLpts,S0=None) + conc_curve = SI2Conc.SI2Conc(s_array,tr,fa,T1base,[1,BLpts],S0=None) conc_array=conc_array*r1 # This function doesn't include r1, so multiply it out before testing np.testing.assert_allclose( [conc_curve], [conc_array], rtol=r_tol, atol=a_tol) From a06ff8e45f95c17e81313f430c01528b52a8e183 Mon Sep 17 00:00:00 2001 From: Zaki A Date: Mon, 4 Sep 2023 20:47:39 -0400 Subject: [PATCH 2/4] Update import --- test/SI_to_Conc/test_SI2Conc_LEK_EdinburghUK.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/SI_to_Conc/test_SI2Conc_LEK_EdinburghUK.py b/test/SI_to_Conc/test_SI2Conc_LEK_EdinburghUK.py index f116d88c..cf88d074 100755 --- a/test/SI_to_Conc/test_SI2Conc_LEK_EdinburghUK.py +++ b/test/SI_to_Conc/test_SI2Conc_LEK_EdinburghUK.py @@ -3,7 +3,7 @@ from ..helpers import osipi_parametrize from . import SI2Conc_data -from src.original.LEK_UoEdinburghUK.SignalToConcentration import SI2Conc +from osipi_code_collection.original.LEK_UoEdinburghUK.SignalToConcentration import SI2Conc # All tests will use the same arguments and same data... From 0b1c6abe5f2286d4cb7c3768290628020a681a32 Mon Sep 17 00:00:00 2001 From: stadmill <35917545+stadmill@users.noreply.github.com> Date: Tue, 5 Sep 2023 13:04:21 +1000 Subject: [PATCH 3/4] Delete test/SI_to_Conc/test_SI2Conc_LEK_EdinburghUK.py Copied edits into develop branch manually, deleting this file to allow the branches to be merged --- .../test_SI2Conc_LEK_EdinburghUK.py | 26 ------------------- 1 file changed, 26 deletions(-) delete mode 100755 test/SI_to_Conc/test_SI2Conc_LEK_EdinburghUK.py diff --git a/test/SI_to_Conc/test_SI2Conc_LEK_EdinburghUK.py b/test/SI_to_Conc/test_SI2Conc_LEK_EdinburghUK.py deleted file mode 100755 index cf88d074..00000000 --- a/test/SI_to_Conc/test_SI2Conc_LEK_EdinburghUK.py +++ /dev/null @@ -1,26 +0,0 @@ -import pytest -import numpy as np - -from ..helpers import osipi_parametrize -from . import SI2Conc_data -from osipi_code_collection.original.LEK_UoEdinburghUK.SignalToConcentration import SI2Conc - - -# All tests will use the same arguments and same data... -arg_names = 'label', 'fa', 'tr', 'T1base', 'BLpts', 'r1', 's_array', 'conc_array', 'a_tol', 'r_tol' -test_data = SI2Conc_data.SI2Conc_data() - - -# Use the test data to generate a parametrize decorator. This causes the following -# test to be run for every test case listed in test_data... -@osipi_parametrize(arg_names, test_data, xf_labels = []) -def test_LEK_UoEdinburghUK_SI2Conc(label, fa, tr, T1base, BLpts, r1, s_array, conc_array, a_tol, r_tol): - - #Prepare input data - #Nothing to do for this function - - # run test - conc_curve = SI2Conc.SI2Conc(s_array,tr,fa,T1base,[1,BLpts],S0=None) - conc_array=conc_array*r1 # This function doesn't include r1, so multiply it out before testing - np.testing.assert_allclose( [conc_curve], [conc_array], rtol=r_tol, atol=a_tol) - From 1b18536580dc9385e1260a9a2b9d968140683583 Mon Sep 17 00:00:00 2001 From: Zaki A Date: Tue, 5 Sep 2023 03:25:55 +0000 Subject: [PATCH 4/4] Use newer API for LEK SI2Conc --- test/SI_to_Conc/test_SI2Conc_LEK_Edinburgh_UK.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/SI_to_Conc/test_SI2Conc_LEK_Edinburgh_UK.py b/test/SI_to_Conc/test_SI2Conc_LEK_Edinburgh_UK.py index ce094bf7..10cf84c6 100644 --- a/test/SI_to_Conc/test_SI2Conc_LEK_Edinburgh_UK.py +++ b/test/SI_to_Conc/test_SI2Conc_LEK_Edinburgh_UK.py @@ -32,7 +32,7 @@ def test_LEK_UoEdinburgh_UK_SI2Conc(label, fa, tr, T1base, BLpts, r1, s_array, c # run test tic = perf_counter() - conc_curve = SI2Conc.SI2Conc(s_array,tr,fa,T1base,BLpts,S0=None) + conc_curve = SI2Conc.SI2Conc(s_array,tr,fa,T1base,[1,BLpts],S0=None) exc_time = 1e6 * (perf_counter() - tic) # log results