Skip to content

Commit

Permalink
Fix unit handling for µV and parsing of birthday in ANT format (#12933)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mathieu Scheltienne authored Oct 31, 2024
1 parent 424f0b4 commit de7f767
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions mne/io/ant/ant.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

from numpy.typing import NDArray

units = {"uv": 1e-6}
_UNITS: dict[str, float] = {"uv": 1e-6, "µv": 1e-6}


@fill_doc
Expand Down Expand Up @@ -143,8 +143,12 @@ def __init__(
info["device_info"] = dict(type=make, model=model, serial=serial, site=site)
his_id, name, sex, birthday = read_subject_info(cnt)
info["subject_info"] = dict(
his_id=his_id, first_name=name, sex=sex, birthday=birthday
his_id=his_id,
first_name=name,
sex=sex,
)
if birthday is not None:
info["subject_info"]["birthday"] = birthday
if bipolars is not None:
with info._unlock():
for idx in bipolars_idx:
Expand Down Expand Up @@ -294,8 +298,8 @@ def _scale_data(data: NDArray[np.float64], ch_units: list[str]) -> None:
for idx, unit in enumerate(ch_units):
units_index[unit].append(idx)
for unit, value in units_index.items():
if unit in units:
data[np.array(value, dtype=np.int16), :] *= units[unit]
if unit in _UNITS:
data[np.array(value, dtype=np.int16), :] *= _UNITS[unit]
else:
warn(
f"Unit {unit} not recognized, not scaling. Please report the unit on "
Expand Down

0 comments on commit de7f767

Please sign in to comment.