-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/testing/wrapper' into analysis/w…
…orkflow
- Loading branch information
Showing
5 changed files
with
151 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import numpy as np | ||
from src.wrappers.OsipiBase import OsipiBase | ||
from src.original.PV_MUMC.two_step_IVIM_fit import fit_least_squares_array, fit_least_squares | ||
|
||
|
||
class PV_MUMC_biexp(OsipiBase): | ||
""" | ||
Bi-exponential fitting algorithm by Paulien Voorter, Maastricht University | ||
""" | ||
|
||
# Some basic stuff that identifies the algorithm | ||
id_author = "Paulien Voorter MUMC" | ||
id_algorithm_type = "Bi-exponential fit" | ||
id_return_parameters = "f, D*, D" | ||
id_units = "seconds per milli metre squared or milliseconds per micro metre squared" | ||
|
||
# Algorithm requirements | ||
required_bvalues = 4 | ||
required_thresholds = [0,0] # Interval from "at least" to "at most", in case submissions allow a custom number of thresholds | ||
required_bounds = False | ||
required_bounds_optional = True # Bounds may not be required but are optional | ||
required_initial_guess = False | ||
required_initial_guess_optional = True | ||
accepted_dimensions = 1 # Not sure how to define this for the number of accepted dimensions. Perhaps like the thresholds, at least and at most? | ||
|
||
def __init__(self, bvalues=None, thresholds=None, bounds=None, initial_guess=None, weighting=None, stats=False): | ||
""" | ||
Everything this algorithm requires should be implemented here. | ||
Number of segmentation thresholds, bounds, etc. | ||
Our OsipiBase object could contain functions that compare the inputs with | ||
the requirements. | ||
""" | ||
super(PV_MUMC_biexp, self).__init__(bvalues, None, bounds, None) | ||
self.PV_algorithm = fit_least_squares | ||
|
||
|
||
def ivim_fit(self, signals, bvalues=None): | ||
"""Perform the IVIM fit | ||
Args: | ||
signals (array-like) | ||
bvalues (array-like, optional): b-values for the signals. If None, self.bvalues will be used. Default is None. | ||
Returns: | ||
_type_: _description_ | ||
""" | ||
|
||
|
||
fit_results = self.PV_algorithm(bvalues, signals) | ||
|
||
f = fit_results[1] | ||
Dstar = fit_results[2] | ||
D = fit_results[0] | ||
|
||
return f, Dstar, D |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
from src.wrappers.OsipiBase import OsipiBase | ||
from src.original.PvH_KB_NKI.DWI_functions_standalone import generate_IVIMmaps_standalone, generate_ADC_standalone | ||
import numpy as np | ||
|
||
class PvH_KB_NKI_IVIMfit(OsipiBase): | ||
""" | ||
Bi-exponential fitting algorithm by Petra van Houdt and Koen Baas, NKI | ||
""" | ||
|
||
# I'm thinking that we define default attributes for each submission like this | ||
# And in __init__, we can call the OsipiBase control functions to check whether | ||
# the user inputs fulfil the requirements | ||
|
||
# Some basic stuff that identifies the algorithm | ||
id_author = "Group Uulke van der Heide, NKI" | ||
id_algorithm_type = "Bi-exponential fit" | ||
id_return_parameters = "f, D*, D" | ||
id_units = "seconds per milli metre squared or milliseconds per micro metre squared" | ||
|
||
# Algorithm requirements | ||
required_bvalues = 4 | ||
required_thresholds = [0, | ||
0] # Interval from "at least" to "at most", in case submissions allow a custom number of thresholds | ||
required_bounds = False | ||
required_bounds_optional = False # Bounds may not be required but are optional | ||
required_initial_guess = False | ||
required_initial_guess_optional =False | ||
accepted_dimensions = 1 # Not sure how to define this for the number of accepted dimensions. Perhaps like the thresholds, at least and at most? | ||
|
||
def __init__(self, bvalues=None, thresholds=None,bounds=None,initial_guess=None): | ||
""" | ||
Everything this algorithm requires should be implemented here. | ||
Number of segmentation thresholds, bounds, etc. | ||
Our OsipiBase object could contain functions that compare the inputs with | ||
the requirements. | ||
""" | ||
super(PvH_KB_NKI_IVIMfit, self).__init__(bvalues, thresholds,bounds,initial_guess) | ||
self.NKI_algorithm = generate_IVIMmaps_standalone | ||
|
||
|
||
def ivim_fit(self, signals, bvalues=None): | ||
"""Perform the IVIM fit | ||
Args: | ||
signals (array-like) | ||
bvalues (array-like, optional): b-values for the signals. If None, self.bvalues will be used. Default is None. | ||
Returns: | ||
_type_: _description_ | ||
""" | ||
#bvalues = np.array(bvalues) | ||
bvalues = bvalues.tolist() #NKI code expects a list instead of nparray | ||
# reshape signal as the NKI code expects a 4D array | ||
signals = np.reshape(signals, (1, 1, 1, len(signals))) # assuming that in this test the signals are always single voxel | ||
fit_results = self.NKI_algorithm(signals,bvalues) | ||
|
||
D = fit_results[0][0,0,0]/1000 | ||
f = fit_results[1][0,0,0] | ||
Dstar = fit_results[2][0,0,0]/1000 | ||
|
||
return f, Dstar, D |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters