Skip to content

Commit 4787fde

Browse files
Update Super_IVIM_DC.py
1 parent 90d9027 commit 4787fde

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/standardized/Super_IVIM_DC.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,9 @@ def ivim_fit(self, signals, bvalues, **kwargs):
112112
f = float(np.atleast_1d(f).ravel()[0])
113113

114114
results = {}
115-
results["D"] = Dt
116-
results["f"] = f
117-
results["Dp"] = Dp
115+
results["D"] = safe_scalar(float(np.array(Dt).item()))
116+
results["f"] = safe_scalar(float(np.array(f).item()))
117+
results["Dp"] = safe_scalar(float(np.array(Dp).item()))
118118

119119
return results
120120

@@ -163,3 +163,9 @@ def reshape_to_voxelwise(self, data):
163163
voxels = int(np.prod(data.shape[:-1])) # e.g., X*Y*Z
164164
return data.reshape(voxels, B), data.shape
165165

166+
def safe_scalar(val):
167+
"""Ensure val is always a Python float scalar."""
168+
try:
169+
return float(np.array(val).ravel()[0])
170+
except Exception:
171+
return 0.0 # fallback if conversion fails

0 commit comments

Comments
 (0)