Skip to content

Commit db0c335

Browse files
author
IvanARashid
committed
Added signal normalization to osipi_fit() and osipi_fit_full_volume()
1 parent 07a6d6a commit db0c335

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/wrappers/OsipiBase.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,12 @@ def osipi_fit(self, data, bvalues=None, **kwargs):
105105
#results[ijk] = fit
106106

107107
for ijk in tqdm(np.ndindex(data.shape[:-1]), total=np.prod(data.shape[:-1])):
108-
args = [data[ijk], use_bvalues]
108+
# Normalize array
109+
single_voxel_data = data[ijk]
110+
single_voxel_data_s0 = single_voxel_data[0]
111+
single_voxel_data_normalized = single_voxel_data/single_voxel_data_s0
112+
113+
args = [single_voxel_data_normalized, use_bvalues]
109114
fit = self.ivim_fit(*args, **kwargs) # For single voxel fits, we assume this is a dict with a float value per key.
110115
for key in list(fit.keys()):
111116
results[key][ijk] = fit[key]
@@ -141,7 +146,11 @@ def osipi_fit_full_volume(self, data, bvalues=None, **kwargs):
141146
for key in self.result_keys:
142147
results[key] = np.empty(list(data.shape[:-1]))
143148

144-
args = [data, use_bvalues]
149+
normalization_factors = np.array([data[..., 0] for i in range(data.shape[-1])])
150+
normalization_factors = np.moveaxis(normalization_factors, 0, -1)
151+
data_normalized = data/normalization_factors
152+
153+
args = [data_normalized, use_bvalues]
145154
fit = self.ivim_fit_full_volume(*args, **kwargs) # Assume this is a dict with an array per key representing the parametric maps
146155
for key in list(fit.keys()):
147156
results[key] = fit[key]

0 commit comments

Comments
 (0)