3
3
from scipy .stats import norm
4
4
import pathlib
5
5
import sys
6
+ from tqdm import tqdm
6
7
7
8
class OsipiBase :
8
9
"""The base class for OSIPI IVIM fitting"""
@@ -47,7 +48,7 @@ def initialize(**kwargs):
47
48
pass
48
49
49
50
#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 ):
51
52
"""Fits the data with the bvalues
52
53
Returns [S0, f, Dstar, D]
53
54
"""
@@ -68,7 +69,6 @@ def osipi_fit(self, data, bvalues, **kwargs):
68
69
#kwargs["bvalues"] = use_bvalues
69
70
70
71
#args = [data, use_bvalues, use_thresholds]
71
- args = [data , use_bvalues ]
72
72
#if self.required_bounds or self.required_bounds_optional:
73
73
#args.append(use_bounds)
74
74
#if self.required_initial_guess or self.required_initial_guess_optional:
@@ -83,7 +83,13 @@ def osipi_fit(self, data, bvalues, **kwargs):
83
83
84
84
#args = [data, use_bvalues, use_initial_guess, use_bounds, use_thresholds]
85
85
#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
87
93
88
94
#self.parameter_estimates = self.ivim_fit(data, bvalues)
89
95
return results
0 commit comments