Skip to content

Commit 185540a

Browse files
committed
Better openephys naming
1 parent 192dc86 commit 185540a

3 files changed

Lines changed: 164 additions & 51 deletions

File tree

src/probeinterface/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
parse_spikeglx_snsGeomMap,
2929
get_saved_channel_indices_from_spikeglx_meta,
3030
read_openephys,
31+
read_openephys_neuropixels,
32+
has_neuropixels_probes,
3133
get_saved_channel_indices_from_openephys_settings,
3234
)
3335
from .utils import combine_probes

src/probeinterface/neuropixels_tools.py

Lines changed: 73 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1484,7 +1484,7 @@ def _annotate_openephys_probe(probe: Probe, probe_info: dict) -> None:
14841484
_annotate_probe_with_adc_sampling_info(probe, adc_sampling_table)
14851485

14861486

1487-
def read_openephys(
1487+
def read_openephys_neuropixels(
14881488
settings_file: str | Path,
14891489
stream_name: str | None = None,
14901490
probe_name: str | None = None,
@@ -1495,6 +1495,14 @@ def read_openephys(
14951495
"""
14961496
Read a Neuropixels probe geometry from an Open Ephys settings.xml file.
14971497
1498+
This function only supports Neuropixels probes (those with ``<NP_PROBE>``
1499+
or ``<NEUROPIXELSV1E>`` / ``<NEUROPIXELSV1F>`` / ``<NEUROPIXELSV2E>``
1500+
elements in the settings file). It does not handle other Open Ephys
1501+
hardware such as Intan acquisition boards, tetrodes, NI-DAQmx, etc.
1502+
Use :func:`has_neuropixels_probes` to check whether a settings file (or
1503+
a specific stream within it) has Neuropixels probe geometry before calling
1504+
this reader.
1505+
14981506
A single settings.xml can describe multiple probes (one ``<NP_PROBE>`` element
14991507
per probe). When the file contains more than one probe, use one of the three
15001508
mutually exclusive selectors (``stream_name``, ``probe_name``, or
@@ -1575,6 +1583,70 @@ def read_openephys(
15751583
return probe
15761584

15771585

1586+
def read_openephys(*args, **kwargs) -> Probe:
1587+
"""
1588+
Deprecated alias for :func:`read_openephys_neuropixels`.
1589+
1590+
The name ``read_openephys`` is misleading because the function only reads
1591+
Neuropixels probe geometry, not arbitrary Open Ephys recordings. Use
1592+
:func:`read_openephys_neuropixels` instead, and :func:`has_neuropixels_probes`
1593+
to check whether a settings file has Neuropixels geometry before calling it.
1594+
"""
1595+
warnings.warn(
1596+
"read_openephys is deprecated and will be removed in a future release. "
1597+
"Use read_openephys_neuropixels instead.",
1598+
category=DeprecationWarning,
1599+
stacklevel=2,
1600+
)
1601+
return read_openephys_neuropixels(*args, **kwargs)
1602+
1603+
1604+
def has_neuropixels_probes(settings_file: str | Path, stream_name: str | None = None) -> bool:
1605+
"""
1606+
Return True if the Open Ephys settings file contains parseable Neuropixels
1607+
probe geometry.
1608+
1609+
Detection is element-based: the function parses the settings file using the
1610+
same path as :func:`read_openephys_neuropixels` and returns True only when
1611+
at least one ``<NP_PROBE>`` (or ONIX equivalent ``<NEUROPIXELSV1E>`` /
1612+
``<NEUROPIXELSV1F>`` / ``<NEUROPIXELSV2E>``) element is present under a
1613+
Neuropixels-capable processor. This is the ground-truth signal that the
1614+
reader will be able to build a probe from the file.
1615+
1616+
Intended use: callers that route heterogeneous streams (e.g. Open Ephys
1617+
recordings mixing Intan / NI-DAQmx / Neuropixels) can gate the call to
1618+
:func:`read_openephys_neuropixels` on this helper and skip probe attachment
1619+
for non-Neuropixels streams.
1620+
1621+
Parameters
1622+
----------
1623+
settings_file : str or Path
1624+
Path to the Open Ephys settings.xml file.
1625+
stream_name : str or None
1626+
If provided, only return True when a Neuropixels probe matching this
1627+
stream name is present. Matching mirrors the selection logic in
1628+
:func:`read_openephys_neuropixels`: a probe's name must appear as a
1629+
substring of ``stream_name`` (so ``"ProbeC"`` matches
1630+
``"Neuropix-PXI-100.ProbeC-AP"``). If None, returns True whenever any
1631+
Neuropixels probe is present.
1632+
1633+
Returns
1634+
-------
1635+
bool
1636+
True if Neuropixels probe geometry is present (and matches
1637+
``stream_name`` when given), False otherwise.
1638+
"""
1639+
try:
1640+
probes_info = _parse_openephys_settings(settings_file, raise_error=False)
1641+
except Exception:
1642+
return False
1643+
if not probes_info:
1644+
return False
1645+
if stream_name is None:
1646+
return True
1647+
return any(info["name"] in stream_name for info in probes_info)
1648+
1649+
15781650
def get_saved_channel_indices_from_openephys_settings(settings_file: str | Path, stream_name: str) -> np.ndarray | None:
15791651
"""
15801652
Returns an array with the subset of saved channels indices (if used)

0 commit comments

Comments
 (0)