Skip to content

Commit 52cd6aa

Browse files
authored
Add skip channels to EDF interface (#1110)
1 parent bfbbe4b commit 52cd6aa

File tree

2 files changed

+30
-3
lines changed

2 files changed

+30
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
## Features
88
* Using in-house `GenericDataChunkIterator` [PR #1068](https://github.com/catalystneuro/neuroconv/pull/1068)
99
* Data interfaces now perform source (argument inputs) validation with the json schema [PR #1020](https://github.com/catalystneuro/neuroconv/pull/1020)
10+
* Added `channels_to_skip` to `EDFRecordingInterface` so the user can skip non-neural channels [PR #1110](https://github.com/catalystneuro/neuroconv/pull/1110)
1011

1112
## Improvements
1213
* Remove dev test from PR [PR #1092](https://github.com/catalystneuro/neuroconv/pull/1092)

src/neuroconv/datainterfaces/ecephys/edf/edfdatainterface.py

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from typing import Optional
2+
13
from pydantic import FilePath
24

35
from ..baserecordingextractorinterface import BaseRecordingExtractorInterface
@@ -23,7 +25,22 @@ def get_source_schema(cls) -> dict:
2325
source_schema["properties"]["file_path"]["description"] = "Path to the .edf file."
2426
return source_schema
2527

26-
def __init__(self, file_path: FilePath, verbose: bool = True, es_key: str = "ElectricalSeries"):
28+
def _source_data_to_extractor_kwargs(self, source_data: dict) -> dict:
29+
30+
extractor_kwargs = source_data.copy()
31+
extractor_kwargs.pop("channels_to_skip")
32+
extractor_kwargs["all_annotations"] = True
33+
extractor_kwargs["use_names_as_ids"] = True
34+
35+
return extractor_kwargs
36+
37+
def __init__(
38+
self,
39+
file_path: FilePath,
40+
verbose: bool = True,
41+
es_key: str = "ElectricalSeries",
42+
channels_to_skip: Optional[list] = None,
43+
):
2744
"""
2845
Load and prepare data for EDF.
2946
Currently, only continuous EDF+ files (EDF+C) and original EDF files (EDF) are supported
@@ -36,15 +53,24 @@ def __init__(self, file_path: FilePath, verbose: bool = True, es_key: str = "Ele
3653
verbose : bool, default: True
3754
Allows verbose.
3855
es_key : str, default: "ElectricalSeries"
56+
Key for the ElectricalSeries metadata
57+
channels_to_skip : list, default: None
58+
Channels to skip when adding the data to the nwbfile. These parameter can be used to skip non-neural
59+
channels that are present in the EDF file.
60+
3961
"""
4062
get_package(
4163
package_name="pyedflib",
42-
excluded_platforms_and_python_versions=dict(darwin=dict(arm=["3.8", "3.9"])),
64+
excluded_platforms_and_python_versions=dict(darwin=dict(arm=["3.9"])),
4365
)
4466

45-
super().__init__(file_path=file_path, verbose=verbose, es_key=es_key)
67+
super().__init__(file_path=file_path, verbose=verbose, es_key=es_key, channels_to_skip=channels_to_skip)
4668
self.edf_header = self.recording_extractor.neo_reader.edf_header
4769

70+
# We remove the channels that are not neural
71+
if channels_to_skip:
72+
self.recording_extractor = self.recording_extractor.remove_channels(remove_channel_ids=channels_to_skip)
73+
4874
def extract_nwb_file_metadata(self) -> dict:
4975
nwbfile_metadata = dict(
5076
session_start_time=self.edf_header["startdate"],

0 commit comments

Comments
 (0)