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

Do not convert non-neural channels to ElectricalSeries on OpenEphysBinaryRecordingInterface #1179

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,13 @@ def __init__(
if stub_test:
self.subset_channels = [0, 1]

# Check if the recording has ADC channels
recording = self.recording_extractor
channel_ids = recording.get_channel_ids()
neural_channels = [id for id in channel_ids if "ADC" not in id]
if len(neural_channels) < len(channel_ids):
self.recording_extractor = recording.select_channels(channel_ids=neural_channels)

def get_metadata(self) -> dict:
from ._openephys_utils import _get_session_start_time

Expand Down
20 changes: 20 additions & 0 deletions tests/test_on_data/ecephys/test_recording_interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,26 @@ def check_extracted_metadata(self, metadata: dict):
assert metadata["NWBFile"]["session_start_time"] == datetime(2022, 5, 3, 10, 52, 24)


class TestOpenEphysBinaryRecordingInterfaceNonNeuralDatExcluded(RecordingExtractorInterfaceTestMixin):
"""Test that non-neural channels are not written as ElectricalSeries"""

data_interface_cls = OpenEphysBinaryRecordingInterface
interface_kwargs = dict(
folder_path=str(ECEPHY_DATA_PATH / "openephysbinary" / "neural_and_non_neural_data_mixed"),
stream_name="Rhythm_FPGA-100.0",
)
save_directory = OUTPUT_PATH

def test_non_neural_channels_not_added(self, setup_interface):
interface, test_name = setup_interface
nwbfile = interface.create_nwbfile()

written_channels = nwbfile.acquisition["ElectricalSeries"].electrodes["channel_name"].data
# Note the absence of "ADC1" and "ADC2"
assert all("ADC" not in channel for channel in written_channels)
assert np.array_equal(written_channels, np.asarray(["CH1", "CH2", "CH3", "CH4"]))


class TestOpenEphysLegacyRecordingInterface(RecordingExtractorInterfaceTestMixin):
data_interface_cls = OpenEphysLegacyRecordingInterface
interface_kwargs = dict(folder_path=str(ECEPHY_DATA_PATH / "openephys" / "OpenEphys_SampleData_1"))
Expand Down
Loading