Skip to content

Commit

Permalink
Clip SDM to avoid instabilities (#71)
Browse files Browse the repository at this point in the history
Closes #68
  • Loading branch information
weningerleon authored and rutgerfick committed Jul 29, 2019
1 parent 5f03f42 commit fc3f5a1
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions dmipy/tissue_response/three_tissue_response.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import warnings
from scipy.optimize import brute
from scipy.stats import pearsonr
import numpy as np
Expand Down Expand Up @@ -221,6 +222,12 @@ def signal_decay_metric(acquisition_scheme, data):
mean_dwi_shells), axis=-1), axis=-1)>0
ratio = np.log(mean_b0[mask, None] / mean_dwi_shells[mask])
SDM[mask] = np.mean(ratio, axis=-1)

if np.max(SDM)>10 or np.min(SDM)<0:
warnings.warn(("The signal decay metric reached unrealistically " +
"high or negative values and was clipped to [0, 10]"),
RuntimeWarning)
SDM = np.clip(SDM, 0, 10)
return SDM


Expand Down

0 comments on commit fc3f5a1

Please sign in to comment.