Skip to content

Commit 6a26bcb

Browse files
committed
STY: Define the S0 clipping percentile as a global variable
Define the S0 clipping percentile in the dMRI model as a global variable and document its purpose.
1 parent 69f4c4d commit 6a26bcb

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/nifreeze/model/dmri.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@
3232
from nifreeze.data.filtering import BVAL_ATOL, dwi_select_shells, grand_mean_normalization
3333
from nifreeze.model.base import BaseModel, ExpectationModel
3434

35+
DEFAULT_S0_CLIP_PERCENTILE = 98
36+
"""Upper percentile threshold for non-diffusion-weighted signal estimation."""
37+
3538

3639
def _exec_fit(model, data, chunk=None, **kwargs):
3740
return model.fit(data, **kwargs), chunk
@@ -85,10 +88,12 @@ def __init__(self, dataset: DWI, max_b: float | int | None = None, **kwargs):
8588
else np.ones(dataset.dataobj.shape[:3], dtype=bool)
8689
)
8790

88-
# By default, set S0 to the 98% percentile of the DWI data within mask
91+
# By default, set S0 to the q-th percentile of the DWI data within mask
8992
self._S0 = np.full(
9093
self._data_mask.sum(),
91-
np.round(np.percentile(dataset.dataobj[self._data_mask, ...], 98)),
94+
np.round(
95+
np.percentile(dataset.dataobj[self._data_mask, ...], DEFAULT_S0_CLIP_PERCENTILE)
96+
),
9297
)
9398

9499
# If b=0 is present and not to be ignored, update brain mask and set

0 commit comments

Comments
 (0)