Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for different encoding in ANT neuro CNT format reader #13035

Merged
merged 15 commits into from
Dec 17, 2024
18 changes: 13 additions & 5 deletions mne/io/ant/ant.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ class RawANT(BaseRaw):
Note that the impedance annotation will likely have a duration of ``0``.
If the measurement marks a discontinuity, the duration should be modified to
cover the discontinuity in its entirety.
encoding : str
Encoding to use for :class:`str` in the CNT file. Defaults to ``'latin-1'``.
%(preload)s
%(verbose)s
"""
Expand All @@ -93,6 +95,7 @@ def __init__(
bipolars: list[str] | tuple[str, ...] | None,
impedance_annotation: str,
*,
encoding: str = "latin-1",
preload: bool | NDArray,
verbose=None,
) -> None:
Expand All @@ -102,7 +105,7 @@ def __init__(
"Missing optional dependency 'antio'. Use pip or conda to install "
"'antio'."
)
check_version("antio", "0.3.0")
check_version("antio", "0.5.0")
larsoner marked this conversation as resolved.
Show resolved Hide resolved

from antio import read_cnt
from antio.parser import (
Expand All @@ -122,8 +125,7 @@ def __init__(
raise ValueError("The impedance annotation cannot be an empty string.")
cnt = read_cnt(fname)
# parse channels, sampling frequency, and create info
ch_info = read_info(cnt) # load in 2 lines for compat with antio 0.2 and 0.3
ch_names, ch_units, ch_refs = ch_info[0], ch_info[1], ch_info[2]
ch_names, ch_units, ch_refs, _, _ = read_info(cnt, encoding=encoding)
ch_types = _parse_ch_types(ch_names, eog, misc, ch_refs)
if bipolars is not None: # handle bipolar channels
bipolars_idx = _handle_bipolar_channels(ch_names, ch_refs, bipolars)
Expand All @@ -139,9 +141,9 @@ def __init__(
ch_names, sfreq=cnt.get_sample_frequency(), ch_types=ch_types
)
info.set_meas_date(read_meas_date(cnt))
make, model, serial, site = read_device_info(cnt)
make, model, serial, site = read_device_info(cnt, encoding=encoding)
info["device_info"] = dict(type=make, model=model, serial=serial, site=site)
his_id, name, sex, birthday = read_subject_info(cnt)
his_id, name, sex, birthday = read_subject_info(cnt, encoding=encoding)
info["subject_info"] = dict(
his_id=his_id,
first_name=name,
Expand Down Expand Up @@ -315,6 +317,7 @@ def read_raw_ant(
bipolars=None,
impedance_annotation="impedance",
*,
encoding: str = "latin-1",
preload=False,
verbose=None,
) -> RawANT:
Expand All @@ -324,13 +327,18 @@ def read_raw_ant(
raw : instance of RawANT
A Raw object containing ANT data.
See :class:`mne.io.Raw` for documentation of attributes and methods.

Notes
-----
.. versionadded:: 1.9
"""
return RawANT(
fname,
eog=eog,
misc=misc,
bipolars=bipolars,
impedance_annotation=impedance_annotation,
encoding=encoding,
preload=preload,
verbose=verbose,
)
7 changes: 1 addition & 6 deletions tools/circleci_dependencies.sh
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
#!/bin/bash -ef

python -m pip install --upgrade "pip!=20.3.0" build
# This can be removed once dipy > 1.9.0 is released
python -m pip install --upgrade --progress-bar off \
numpy scipy h5py
python -m pip install --pre --progress-bar off \
--extra-index-url "https://pypi.anaconda.org/scientific-python-nightly-wheels/simple" \
"dipy>1.9"
python -m pip install --upgrade --progress-bar off \
--only-binary "numpy,dipy,scipy,matplotlib,pandas,statsmodels" \
-ve .[full,test,doc] "numpy>=2" \
"git+https://github.com/pyvista/pyvista.git" \
"git+https://github.com/sphinx-gallery/sphinx-gallery.git" \
"git+https://github.com/mne-tools/mne-bids.git" \
\
"openmeeg<2.5.13" \
alphaCSC autoreject bycycle conpy emd fooof meggie \
mne-ari mne-bids-pipeline mne-faster mne-features \
mne-icalabel mne-lsl mne-microstates mne-nirs mne-rsa \
Expand Down
9 changes: 4 additions & 5 deletions tutorials/intro/70_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@

:class:`mne.Report` is a way to create interactive HTML summaries of your data.
These reports can show many different visualizations for one or multiple participants.
A common use case is creating diagnostic summaries to check data
quality at different stages in the processing pipeline. The report can show
things like plots of data before and after each preprocessing step, epoch
rejection statistics, MRI slices with overlaid BEM shells, all the way up to
plots of estimated cortical activity.
A common use case is creating diagnostic summaries to check data quality at different
stages in the processing pipeline. The report can show things like plots of data before
and after each preprocessing step, epoch rejection statistics, MRI slices with overlaid
BEM shells, all the way up to plots of estimated cortical activity.

Compared to a Jupyter notebook, :class:`mne.Report` is easier to deploy, as the
HTML pages it generates are self-contained and do not require a running Python
Expand Down
Loading