Skip to content

Commit 79645c3

Browse files
committed
ENH: Add type hints across miscellaneous methods
Add type hints across miscellaneous methods.
1 parent 7237ecf commit 79645c3

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

src/nifreeze/data/dmri.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -369,10 +369,10 @@ def load(
369369

370370

371371
def find_shelling_scheme(
372-
bvals,
373-
num_bins=DEFAULT_NUM_BINS,
374-
multishell_nonempty_bin_count_thr=DEFAULT_MULTISHELL_BIN_COUNT_THR,
375-
bval_cap=DEFAULT_HIGHB_THRESHOLD,
372+
bvals : np.ndarray,
373+
num_bins : int = DEFAULT_NUM_BINS,
374+
multishell_nonempty_bin_count_thr : int = DEFAULT_MULTISHELL_BIN_COUNT_THR,
375+
bval_cap : int = DEFAULT_HIGHB_THRESHOLD,
376376
):
377377
"""
378378
Find the shelling scheme on the given b-values.

src/nifreeze/model/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class ModelFactory:
3636
"""A factory for instantiating data models."""
3737

3838
@staticmethod
39-
def init(model=None, **kwargs):
39+
def init(model : str | None = None, **kwargs):
4040
"""
4141
Instantiate a diffusion model.
4242
@@ -136,7 +136,7 @@ def __init__(self, dataset, stat="median", **kwargs):
136136
super().__init__(dataset, **kwargs)
137137
self._stat = stat
138138

139-
def fit_predict(self, index, **kwargs):
139+
def fit_predict(self, index : int, **kwargs):
140140
"""
141141
Return the expectation map.
142142

src/nifreeze/model/dmri.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
# https://www.nipreps.org/community/licensing/
2222
#
2323

24+
import numbers
2425
from importlib import import_module
2526

2627
import numpy as np
@@ -29,6 +30,7 @@
2930
from nifreeze.data.dmri import (
3031
DEFAULT_CLIP_PERCENTILE,
3132
DTI_MIN_ORIENTATIONS,
33+
DWI,
3234
)
3335
from nifreeze.model.base import BaseModel, ExpectationModel
3436

@@ -51,7 +53,7 @@ class BaseDWIModel(BaseModel):
5153
"_modelargs": "Arguments acceptable by the underlying DIPY-like model.",
5254
}
5355

54-
def __init__(self, dataset, **kwargs):
56+
def __init__(self, dataset : DWI, **kwargs):
5557
r"""Initialization.
5658
5759
Parameters
@@ -117,7 +119,7 @@ def _fit(self, index, n_jobs=None, **kwargs):
117119
self._model = None # Preempt further actions on the model
118120
return n_jobs
119121

120-
def fit_predict(self, index, **kwargs):
122+
def fit_predict(self, index : int, **kwargs):
121123
"""
122124
Predict asynchronously chunk-by-chunk the diffusion signal.
123125
@@ -173,7 +175,7 @@ class AverageDWIModel(ExpectationModel):
173175

174176
__slots__ = ("_th_low", "_th_high", "_detrend")
175177

176-
def __init__(self, dataset, stat="median", th_low=100, th_high=100, detrend=False, **kwargs):
178+
def __init__(self, dataset : DWI, stat : str = "median", th_low : numbers.Number = 100, th_high : numbers.Number = 100, detrend : bool = False, **kwargs):
177179
r"""
178180
Implement object initialization.
179181

0 commit comments

Comments
 (0)