@@ -733,12 +733,17 @@ def write_csv(file, probe):
733733 raise NotImplementedError
734734
735735
736- def read_spikegadgets (file : str | Path , raise_error : bool = True ) -> ProbeGroup :
736+ def read_spikegadgets_neuropixels (file : str | Path , raise_error : bool = True ) -> ProbeGroup :
737737 """
738738 Find active channels of the given Neuropixels probe from a SpikeGadgets .rec file.
739739 SpikeGadgets headstages support up to three Neuropixels 1.0 probes (as of March 28, 2024),
740740 and information for all probes will be returned in a ProbeGroup object.
741741
742+ This function only supports Neuropixels probes recorded with SpikeGadgets
743+ headstages (``HardwareConfiguration`` entries with ``name == "NeuroPixels1"``).
744+ It does not handle tetrodes or other probe types that SpikeGadgets can
745+ record. Use :func:`has_spikegadgets_neuropixels_probes` to check whether a
746+ ``.rec`` file contains Neuropixels probe geometry before calling this reader.
742747
743748 Parameters
744749 ----------
@@ -834,6 +839,67 @@ def read_spikegadgets(file: str | Path, raise_error: bool = True) -> ProbeGroup:
834839 return probe_group
835840
836841
842+ def read_spikegadgets (* args , ** kwargs ) -> ProbeGroup :
843+ """
844+ Deprecated alias for :func:`read_spikegadgets_neuropixels`.
845+
846+ The name ``read_spikegadgets`` is misleading because the function only reads
847+ Neuropixels probe geometry, not arbitrary SpikeGadgets ``.rec`` recordings.
848+ Use :func:`read_spikegadgets_neuropixels` instead, and
849+ :func:`has_spikegadgets_neuropixels_probes` to check whether a ``.rec`` file
850+ has Neuropixels geometry before calling it.
851+ """
852+ warnings .warn (
853+ "read_spikegadgets is deprecated and will be removed in a future release. "
854+ "Use read_spikegadgets_neuropixels instead." ,
855+ category = DeprecationWarning ,
856+ stacklevel = 2 ,
857+ )
858+ return read_spikegadgets_neuropixels (* args , ** kwargs )
859+
860+
861+ def has_spikegadgets_neuropixels_probes (file : str | Path ) -> bool :
862+ """
863+ Return True if the SpikeGadgets ``.rec`` file describes at least one
864+ Neuropixels probe.
865+
866+ Detection scans the ``HardwareConfiguration`` block of the ``.rec`` XML
867+ header for ``Device`` entries whose ``name`` attribute matches a known
868+ Neuropixels source name (currently ``"NeuroPixels1"``). The presence of
869+ any such entry is the ground-truth signal that the file contains
870+ Neuropixels probe geometry, independent of what other hardware the
871+ headstage is also streaming.
872+
873+ Intended use: callers that route heterogeneous SpikeGadgets recordings
874+ (mixing tetrodes, Neuropixels, etc.) can gate the call to
875+ :func:`read_spikegadgets_neuropixels` on this helper and skip probe
876+ attachment for non-Neuropixels recordings.
877+
878+ Parameters
879+ ----------
880+ file : str or Path
881+ Path to the SpikeGadgets ``.rec`` file.
882+
883+ Returns
884+ -------
885+ bool
886+ """
887+ try :
888+ header_txt = parse_spikegadgets_header (file )
889+ root = ElementTree .fromstring (header_txt )
890+ except Exception :
891+ return False
892+
893+ hconf = root .find ("HardwareConfiguration" )
894+ if hconf is None :
895+ return False
896+
897+ for device in hconf :
898+ if device .attrib .get ("name" ) == "NeuroPixels1" :
899+ return True
900+ return False
901+
902+
837903def parse_spikegadgets_header (file : str | Path ) -> str :
838904 """
839905 Parse file (SpikeGadgets .rec format) into a string until "</Configuration>",
0 commit comments