From ff486c3705d3ea9357ad5fdb6f1d877fda7be5f6 Mon Sep 17 00:00:00 2001 From: IvanARashid Date: Fri, 19 Jan 2024 14:27:38 +0100 Subject: [PATCH] Added support for >1D fits --- src/wrappers/OsipiBase.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/wrappers/OsipiBase.py b/src/wrappers/OsipiBase.py index c6a2bcb..17e58ac 100644 --- a/src/wrappers/OsipiBase.py +++ b/src/wrappers/OsipiBase.py @@ -47,7 +47,7 @@ def initialize(**kwargs): pass #def osipi_fit(self, data=None, bvalues=None, thresholds=None, bounds=None, initial_guess=None, **kwargs): - def osipi_fit(self, data, bvalues, **kwargs): + def osipi_fit(self, data, bvalues=None, **kwargs): """Fits the data with the bvalues Returns [S0, f, Dstar, D] """ @@ -68,7 +68,6 @@ def osipi_fit(self, data, bvalues, **kwargs): #kwargs["bvalues"] = use_bvalues #args = [data, use_bvalues, use_thresholds] - args = [data, use_bvalues] #if self.required_bounds or self.required_bounds_optional: #args.append(use_bounds) #if self.required_initial_guess or self.required_initial_guess_optional: @@ -83,7 +82,12 @@ def osipi_fit(self, data, bvalues, **kwargs): #args = [data, use_bvalues, use_initial_guess, use_bounds, use_thresholds] #args = [arg for arg in args if arg is not None] - results = self.ivim_fit(*args, **kwargs) + + # Assuming the last dimension of the data is the signal values of each b-value + results = np.empty(data.shape[:-1], dtype=object) + for ijk in np.ndindex(data.shape[:-1]): + args = [data[ijk], use_bvalues] + results[ijk] = self.ivim_fit(*args, **kwargs) #self.parameter_estimates = self.ivim_fit(data, bvalues) return results