Skip to content

Separate NWB reading from extractor construction#4630

Open
h-mayorquin wants to merge 7 commits into
SpikeInterface:mainfrom
h-mayorquin:nwb_refactor
Open

Separate NWB reading from extractor construction#4630
h-mayorquin wants to merge 7 commits into
SpikeInterface:mainfrom
h-mayorquin:nwb_refactor

Conversation

@h-mayorquin

Copy link
Copy Markdown
Collaborator

I am planning to fix the following open issues:

Before doing so I want to do a refactor. The nwb reading logic (three formats, two streaming modes) is currently tangled with the extractor construction logic for all three extractors (recording, sorting, time-series), so a fix in reading requires finding and changing multiple duplicated sites. This PR separates those two concerns so I can do a centralized fix.

This will fix #2910

Replace the parallel _pynwb/_backend methods in the NWB recording path with a single _NwbGeneralReader (reading_method discriminator). The reader owns open/locate/close and the electrode-column reads; the extractor keeps only the SpikeInterface mapping (uV scaling, brain_area rename, core-vs-extra column policy). Sorting and time-series extractors are unchanged.
Migrate NwbSortingExtractor onto the single _NWBReader: add the units side (load_units, unit_ids, spike_times, spike_times_index, units_column_names, available_units_tables, rate_and_t_start_from_electrical_series) and thread storage_options through _open_handle. The sorting extractor drops its parallel _fetch_sorting_segment_info_pynwb/_backend pair, self.backend, and the _BaseNWBExtractor mixin; the ragged-property logic in _fetch_properties is preserved, just sourcing units_table from the reader. Time-series extractor unchanged.
Migrate NwbTimeSeriesExtractor onto the single _NWBReader (load_timeseries / available_timeseries) and retire the _BaseNWBExtractor mixin: no extractor inherits it anymore, so file-handle cleanup lives entirely in _NWBReader.close()/__del__ shared by all three extractors via composition. Also drop a stray no-op '1' line. All three NWB extractors now speak one idiom.
@h-mayorquin h-mayorquin self-assigned this Jun 25, 2026
@alejoe91 alejoe91 added the extractors Related to extractors module label Jun 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extractors Related to extractors module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add static method fetch_available_units_table to NWBSortingExtractor

2 participants