Skip to content

Add num_channels to BaseRecordingSegment#4526

Draft
h-mayorquin wants to merge 2 commits intoSpikeInterface:mainfrom
h-mayorquin:channel_names_to_segment
Draft

Add num_channels to BaseRecordingSegment#4526
h-mayorquin wants to merge 2 commits intoSpikeInterface:mainfrom
h-mayorquin:channel_names_to_segment

Conversation

@h-mayorquin
Copy link
Copy Markdown
Collaborator

draft

@alejoe91 alejoe91 added the core Changes to core module label Apr 17, 2026
Copy link
Copy Markdown
Member

@alejoe91 alejoe91 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @h-mayorquin

Given that segments will always be added to a BaseRecording object, see my proposed changes! Curious to hear your thoughts!

Comment on lines +922 to +929
if self._num_channels is not None:
return self._num_channels
if self._parent_extractor is None:
return None
container_recording = self._parent_extractor()
if container_recording is None:
return None
return container_recording.get_num_channels()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the segments are supposed to be added with the BaseExtractor.add_segment(), which always registers the self._parent_extractor weakref available as self.parent_extractor property, I wonder whether we need any of this?

Suggested change
if self._num_channels is not None:
return self._num_channels
if self._parent_extractor is None:
return None
container_recording = self._parent_extractor()
if container_recording is None:
return None
return container_recording.get_num_channels()
return self.parent_extractor.get_num_channels()

@h-mayorquin any place in mind where this won't work?

def __init__(self, file_path, sampling_frequency, t_start, num_channels, dtype, time_axis, file_offset):
BaseRecordingSegment.__init__(self, sampling_frequency=sampling_frequency, t_start=t_start)
self.num_channels = num_channels
self._num_channels = num_channels
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the same reason, we can drop this IMO. Segments will always be added to a parent extractor and can inherit the num_channels from it


self.num_samples = num_samples
self.num_channels = num_channels
self._num_channels = num_channels
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

BasePreprocessorSegment.__init__(self, parent_recording_segment)
self.parent_recording_segment = parent_recording_segment
self.num_channels = num_channels
self._num_channels = num_channels
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Changes to core module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants