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

Deprecate stream_id keyword from IntanRecordingInterface #794

Merged
merged 2 commits into from
Mar 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Upcoming

### Deprecations
* Removed `stream_id` as an argument from `IntanRecordingInterface` [PR #794](https://github.com/catalystneuro/neuroconv/pull/794)
# v0.4.8 (March 20, 2024)

### Bug fixes
Expand Down
43 changes: 11 additions & 32 deletions src/neuroconv/datainterfaces/ecephys/intan/intandatainterface.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from pathlib import Path
import warnings
from typing import Optional

from packaging.version import Version
from pynwb.ecephys import ElectricalSeries
Expand All @@ -8,35 +9,6 @@
from ....utils import FilePathType, get_schema_from_hdmf_class


def extract_electrode_metadata_with_pyintan(file_path) -> dict:
pyintan = get_package(package_name="pyintan")
CodyCBakerPhD marked this conversation as resolved.
Show resolved Hide resolved

if ".rhd" in Path(file_path).suffixes:
intan_file_metadata = pyintan.intan.read_rhd(file_path)[1]
else:
intan_file_metadata = pyintan.intan.read_rhs(file_path)[1]

exclude_chan_types = ["AUX", "ADC", "VDD", "_STIM", "ANALOG"]

valid_channels = [
x for x in intan_file_metadata if not any([y in x["native_channel_name"] for y in exclude_chan_types])
]

group_names = [channel["native_channel_name"].split("-")[0] for channel in valid_channels]
unique_group_names = set(group_names)
group_electrode_numbers = [channel["native_order"] for channel in valid_channels]
custom_names = [channel["custom_channel_name"] for channel in valid_channels]

electrodes_metadata = dict(
group_names=group_names,
unique_group_names=unique_group_names,
group_electrode_numbers=group_electrode_numbers,
custom_names=custom_names,
)

return electrodes_metadata


def extract_electrode_metadata(recording_extractor) -> dict:

neo_version = get_package_version(name="neo")
Expand Down Expand Up @@ -73,11 +45,12 @@ class IntanRecordingInterface(BaseRecordingExtractorInterface):
display_name = "Intan Recording"
associated_suffixes = (".rhd", ".rhs")
info = "Interface for Intan recording data."
stream_id = "0" # This is the only stream_id of Intan that might have neural data

def __init__(
self,
file_path: FilePathType,
stream_id: str = "0",
stream_id: Optional[str] = None,
verbose: bool = True,
es_key: str = "ElectricalSeries",
):
Expand All @@ -95,7 +68,13 @@ def __init__(
es_key : str, default: "ElectricalSeries"
"""

self.stream_id = stream_id
if stream_id is not None:
warnings.warn(
"Use of the 'stream_id' parameter is deprecated and it will be removed after September 2024.",
DeprecationWarning,
)
self.stream_id = stream_id

super().__init__(file_path=file_path, stream_id=self.stream_id, verbose=verbose, es_key=es_key)
electrodes_metadata = extract_electrode_metadata(recording_extractor=self.recording_extractor)

Expand Down
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
pyintan>=0.3.0
Loading