33from scipy .stats import norm
44import pathlib
55import sys
6+ from tqdm import tqdm
67
78class OsipiBase :
89 """The base class for OSIPI IVIM fitting"""
@@ -47,7 +48,7 @@ def initialize(**kwargs):
4748 pass
4849
4950 #def osipi_fit(self, data=None, bvalues=None, thresholds=None, bounds=None, initial_guess=None, **kwargs):
50- def osipi_fit (self , data , bvalues , ** kwargs ):
51+ def osipi_fit (self , data , bvalues = None , ** kwargs ):
5152 """Fits the data with the bvalues
5253 Returns [S0, f, Dstar, D]
5354 """
@@ -68,7 +69,6 @@ def osipi_fit(self, data, bvalues, **kwargs):
6869 #kwargs["bvalues"] = use_bvalues
6970
7071 #args = [data, use_bvalues, use_thresholds]
71- args = [data , use_bvalues ]
7272 #if self.required_bounds or self.required_bounds_optional:
7373 #args.append(use_bounds)
7474 #if self.required_initial_guess or self.required_initial_guess_optional:
@@ -83,7 +83,13 @@ def osipi_fit(self, data, bvalues, **kwargs):
8383
8484 #args = [data, use_bvalues, use_initial_guess, use_bounds, use_thresholds]
8585 #args = [arg for arg in args if arg is not None]
86- results = self .ivim_fit (* args , ** kwargs )
86+
87+ # Assuming the last dimension of the data is the signal values of each b-value
88+ results = np .empty (list (data .shape [:- 1 ])+ [3 ]) # Create an array with the voxel dimensions + the ones required for the fit
89+ for ijk in tqdm (np .ndindex (data .shape [:- 1 ]), total = np .prod (data .shape [:- 1 ])):
90+ args = [data [ijk ], use_bvalues ]
91+ fit = list (self .ivim_fit (* args , ** kwargs ))
92+ results [ijk ] = fit
8793
8894 #self.parameter_estimates = self.ivim_fit(data, bvalues)
8995 return results
0 commit comments