Skip to content

Commit e442a23

Browse files
Apply suggestions from code review
Co-authored-by: Eric Larson <larson.eric.d@gmail.com>
1 parent a694657 commit e442a23

3 files changed

Lines changed: 12 additions & 13 deletions

File tree

mne/preprocessing/nirs/_beer_lambert_law.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
)
2020

2121

22-
def beer_lambert_law(raw, ppf=6.0, sd_distances=None):
22+
def beer_lambert_law(raw, ppf=6.0, *, sd_distances=None):
2323
r"""Convert NIRS optical density data to haemoglobin concentration.
2424
2525
Parameters
@@ -36,6 +36,8 @@ def beer_lambert_law(raw, ppf=6.0, sd_distances=None):
3636
from ``raw.info['chs']``. If array-like, the values must have a distance
3737
for each channel, matching the order in ``info['chs']``.
3838
39+
.. versionadded:: 1.13
40+
3941
Returns
4042
-------
4143
raw : instance of Raw
@@ -167,13 +169,13 @@ def _get_sd_distances(raw, sd_distances):
167169
"sd_distances must be a float or a 1D array-like, got "
168170
f"shape {sd_distances.shape}"
169171
)
170-
if len(sd_distances) == n_channels:
171-
return sd_distances
172-
raise ValueError(
173-
"sd_distances must be a float or an array-like with length matching "
174-
f"the len(raw.info['chs']) ({n_channels}), "
175-
f"got length {len(sd_distances)}"
176-
)
172+
if len(sd_distances) != n_channels:
173+
raise ValueError(
174+
"sd_distances must be a float or an array-like with length matching "
175+
f"the len(raw.info['chs']) ({n_channels}), "
176+
f"got length {len(sd_distances)}"
177+
)
178+
return sd_distances
177179

178180

179181
def _load_absorption(freqs):

mne/preprocessing/nirs/nirs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def short_channels(info, threshold=0.01):
6565
def _has_source_detector_distances(info, picks=None):
6666
"""Return True if source-detector distances can be computed."""
6767
distances = source_detector_distances(info, picks=picks)
68-
return len(distances) > 0 and np.isfinite(distances).all() and np.all(distances > 0)
68+
return len(distances) > 0 and np.all(distances > 0)
6969

7070

7171
def _channel_frequencies(info):

mne/preprocessing/nirs/tests/test_beer_lambert_law.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,10 +187,7 @@ def test_get_sd_distances():
187187

188188
for idx in range(len(raw.info["chs"])):
189189
raw.info["chs"][idx]["loc"][3:9] = np.nan
190-
with warnings.catch_warnings(record=True) as caught:
191-
warnings.simplefilter("always")
192-
assert_allclose(_get_sd_distances(raw, expected), expected, rtol=1e-12, atol=0)
193-
assert len(caught) == 0
190+
assert_allclose(_get_sd_distances(raw, expected), expected, rtol=1e-12, atol=0)
194191

195192
with pytest.raises(ValueError, match=r"1D array-like"):
196193
_get_sd_distances(raw, np.ones((2, 2)))

0 commit comments

Comments
 (0)