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

Fix extra electrode groups ephys #1164

Merged
merged 3 commits into from
Dec 19, 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
Expand Up @@ -13,6 +13,8 @@
* Fix a bug where data in `DeepLabCutInterface` failed to write when `ndx-pose` was not imported. [#1144](https://github.com/catalystneuro/neuroconv/pull/1144)
* `SpikeGLXConverterPipe` converter now accepts multi-probe structures with multi-trigger and does not assume a specific folder structure [#1150](https://github.com/catalystneuro/neuroconv/pull/1150)
* `SpikeGLXNIDQInterface` is no longer written as an ElectricalSeries [#1152](https://github.com/catalystneuro/neuroconv/pull/1152)
* Fix a bug on ecephys interfaces where extra electrode group and devices were written if the property of the "group_name" was set in the recording extractor [#1164](https://github.com/catalystneuro/neuroconv/pull/1164)


## Features
* Propagate the `unit_electrode_indices` argument from the spikeinterface tools to `BaseSortingExtractorInterface`. This allows users to map units to the electrode table when adding sorting data [PR #1124](https://github.com/catalystneuro/neuroconv/pull/1124)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@ def get_metadata_schema(self) -> dict:
def get_metadata(self) -> DeepDict:
metadata = super().get_metadata()

channel_groups_array = self.recording_extractor.get_channel_groups()
from ...tools.spikeinterface.spikeinterface import _get_group_name

channel_groups_array = _get_group_name(recording=self.recording_extractor)
unique_channel_groups = set(channel_groups_array) if channel_groups_array is not None else ["ElectrodeGroup"]
electrode_metadata = [
dict(name=str(group_id), description="no description", location="unknown", device="DeviceEcephys")
Expand Down
14 changes: 13 additions & 1 deletion tests/test_ecephys/test_ecephys_interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def test_electrode_indices_assertion_error_when_missing_table(self, setup_interf

class TestRecordingInterface(RecordingExtractorInterfaceTestMixin):
data_interface_cls = MockRecordingInterface
interface_kwargs = dict(durations=[0.100])
interface_kwargs = dict(num_channels=4, durations=[0.100])

def test_stub(self, setup_interface):
interface = self.interface
Expand All @@ -146,6 +146,18 @@ def test_always_write_timestamps(self, setup_interface):
expected_timestamps = self.interface.recording_extractor.get_times()
np.testing.assert_array_equal(electrical_series.timestamps[:], expected_timestamps)

def test_group_naming_not_adding_extra_devices(self, setup_interface):

interface = self.interface
recording_extractor = interface.recording_extractor
recording_extractor.set_channel_groups(groups=[0, 1, 2, 3])
recording_extractor.set_property(key="group_name", values=["group1", "group2", "group3", "group4"])

nwbfile = interface.create_nwbfile()

assert len(nwbfile.devices) == 1
assert len(nwbfile.electrode_groups) == 4


class TestAssertions(TestCase):
@pytest.mark.skipif(python_version.minor != 10, reason="Only testing with Python 3.10!")
Expand Down
Loading