diff --git a/CHANGELOG.md b/CHANGELOG.md index 200ba26b5..36522f2c1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,10 @@ # v0.9.4 (Upcoming) ## Removals, Deprecations and Changes +* Made `nwbfile_path` a required parameter in `write_recording_to_nwbfile`, `write_sorting_to_nwbfile`, and `write_sorting_analyzer_to_nwbfile`. To add data to an in-memory NWBFile, use `add_recording_to_nwbfile`, `add_sorting_to_nwbfile`, or `add_sorting_analyzer_to_nwbfile` instead. [PR #1689](https://github.com/catalystneuro/neuroconv/pull/1689) +* `write_recording_to_nwbfile`, `write_sorting_to_nwbfile`, and `write_sorting_analyzer_to_nwbfile` now return `None` in append mode (`append_on_disk_nwbfile=True`) instead of the NWBFile object. [PR #1689](https://github.com/catalystneuro/neuroconv/pull/1689) +* Removed the deprecated `iterator_opts` parameter from `write_recording_to_nwbfile`. Use `iterator_options` instead. [PR #1689](https://github.com/catalystneuro/neuroconv/pull/1689) +* Removed stale `iterator_type='v1'` deprecation note from `BaseImagingExtractorInterface.add_to_nwbfile` docstring. [PR #1689](https://github.com/catalystneuro/neuroconv/pull/1689) * Removed the deprecated `iterator_type='v1'` option from `_imaging_frames_to_hdmf_iterator`. Use `iterator_type='v2'` (default) instead. [PR #1679](https://github.com/catalystneuro/neuroconv/pull/1679) * Removed support for passing `rate` in trace metadata for fluorescence traces. The rate is now always calculated automatically from the segmentation extractor's timestamps or sampling frequency. [PR #1679](https://github.com/catalystneuro/neuroconv/pull/1679) * Removed the deprecated `stub_frames` parameter from ophys interfaces (`BaseImagingExtractorInterface`, `BaseSegmentationExtractorInterface`, `BrukerTiffMultiPlaneConverter`, `BrukerTiffSinglePlaneConverter`, `MiniscopeConverter`, `Suite2pSegmentationInterface`, `MinianSegmentationInterface`, `MiniscopeImagingDataInterface`). Use `stub_samples` instead. [PR #1676](https://github.com/catalystneuro/neuroconv/pull/1676) diff --git a/src/neuroconv/datainterfaces/ophys/baseimagingextractorinterface.py b/src/neuroconv/datainterfaces/ophys/baseimagingextractorinterface.py index 483337a71..dfc85dfd8 100644 --- a/src/neuroconv/datainterfaces/ophys/baseimagingextractorinterface.py +++ b/src/neuroconv/datainterfaces/ophys/baseimagingextractorinterface.py @@ -203,7 +203,6 @@ def add_to_nwbfile( The type of iterator for chunked data writing. 'v2': Uses iterative write with control over chunking and progress bars. None: Loads all data into memory before writing (not recommended for large datasets). - Note: 'v1' is deprecated and will be removed on or after March 2026. iterator_options : dict, optional Options for controlling the iterative write process (buffer size, progress bars). See the `pynwb tutorial on iterative write `_ diff --git a/src/neuroconv/tools/spikeinterface/spikeinterface.py b/src/neuroconv/tools/spikeinterface/spikeinterface.py index 8914e3f5e..630a0d10a 100644 --- a/src/neuroconv/tools/spikeinterface/spikeinterface.py +++ b/src/neuroconv/tools/spikeinterface/spikeinterface.py @@ -1654,7 +1654,7 @@ def add_recording_metadata_to_nwbfile( def write_recording_to_nwbfile( recording: BaseRecording, - nwbfile_path: FilePath | None = None, + nwbfile_path: FilePath, nwbfile: pynwb.NWBFile | None = None, metadata: dict | None = None, overwrite: bool = False, @@ -1664,7 +1664,6 @@ def write_recording_to_nwbfile( *, iterator_type: str | None = "v2", iterator_options: dict | None = None, - iterator_opts: dict | None = None, backend: Literal["hdf5", "zarr"] | None = None, backend_configuration: HDF5BackendConfiguration | ZarrBackendConfiguration | None = None, append_on_disk_nwbfile: bool = False, @@ -1676,10 +1675,8 @@ def write_recording_to_nwbfile( Parameters ---------- recording : spikeinterface.BaseRecording - nwbfile_path : FilePath, optional + nwbfile_path : FilePath Path for where to write or load (if overwrite=False) the NWBFile. - If not provided, only adds data to the in-memory nwbfile without writing to disk. - **Deprecated**: Using this function without nwbfile_path is deprecated. Use `add_recording_to_nwbfile` instead. nwbfile : NWBFile, optional If passed, this function will fill the relevant fields within the NWBFile object. E.g., calling:: @@ -1777,53 +1774,10 @@ def write_recording_to_nwbfile( Returns ------- NWBFile or None - The NWBFile object when writing a new file or using an in-memory nwbfile. + The NWBFile object when writing a new file. Returns None when appending to an existing file on disk (append_on_disk_nwbfile=True). - **Deprecated**: Returning NWBFile in append mode is deprecated and will return None in or after March 2026. """ - # Handle deprecated usage without nwbfile_path - if nwbfile_path is None: - warnings.warn( - "Using 'write_recording_to_nwbfile' without 'nwbfile_path' to only add data to an in-memory nwbfile is deprecated " - "and will be removed in or after March 2026. Use 'add_recording_to_nwbfile' instead.", - DeprecationWarning, - stacklevel=2, - ) - if nwbfile is None: - raise ValueError( - "Either 'nwbfile_path' or 'nwbfile' must be provided. " - "To add data to an in-memory nwbfile, use 'add_recording_to_nwbfile' instead." - ) - # Call add_recording_to_nwbfile for deprecated behavior - add_recording_to_nwbfile( - recording=recording, - nwbfile=nwbfile, - metadata=metadata, - write_as=write_as, - es_key=es_key, - iterator_type=iterator_type, - iterator_options=iterator_options if iterator_options is not None else iterator_opts, - null_values_for_properties=null_values_for_properties, - ) - return nwbfile - - # Handle deprecated iterator_opts parameter - if iterator_opts is not None: - warnings.warn( - "The 'iterator_opts' parameter is deprecated and will be removed on or after March 2026. " - "Use 'iterator_options' instead.", - FutureWarning, - stacklevel=2, - ) - if iterator_options is None: - iterator_options = iterator_opts - else: - raise ValueError( - "Both 'iterator_opts' and 'iterator_options' were specified. " - "Please use only 'iterator_options' as 'iterator_opts' is deprecated." - ) - appending_to_in_memory_nwbfile = nwbfile is not None file_initially_exists = nwbfile_path.exists() allowed_to_modify_existing = overwrite or append_on_disk_nwbfile @@ -1885,13 +1839,6 @@ def write_recording_to_nwbfile( else: # Append mode: read existing file, add data, write back - warnings.warn( - "Returning an NWBFile object when using append_on_disk_nwbfile=True is deprecated " - "and will return None in or after March 2026.", - DeprecationWarning, - stacklevel=2, - ) - IO = BACKEND_NWB_IO[backend] with IO(path=str(nwbfile_path), mode="r+", load_namespaces=True) as io: @@ -1918,7 +1865,7 @@ def write_recording_to_nwbfile( if verbose: print(f"NWB file saved at {nwbfile_path}!") - return nwbfile # Will return None in March 2026 + return None def _add_units_table_to_nwbfile( @@ -2335,7 +2282,7 @@ def _add_units_table_to_nwbfile( def write_sorting_to_nwbfile( sorting: BaseSorting, - nwbfile_path: FilePath | None = None, + nwbfile_path: FilePath, nwbfile: pynwb.NWBFile | None = None, metadata: dict | None = None, overwrite: bool = False, @@ -2361,10 +2308,8 @@ def write_sorting_to_nwbfile( Parameters ---------- sorting : spikeinterface.BaseSorting - nwbfile_path : FilePath, optional + nwbfile_path : FilePath Path for where to write or load (if overwrite=False) the NWBFile. - If not provided, only adds data to the in-memory nwbfile without writing to disk. - **Deprecated**: Using this function without nwbfile_path is deprecated. Use `add_sorting_to_nwbfile` instead. nwbfile : NWBFile, optional If passed, this function will fill the relevant fields within the NWBFile object. E.g., calling:: @@ -2421,41 +2366,10 @@ def write_sorting_to_nwbfile( Returns ------- NWBFile or None - The NWBFile object when writing a new file or using an in-memory nwbfile. + The NWBFile object when writing a new file. Returns None when appending to an existing file on disk (append_on_disk_nwbfile=True). - **Deprecated**: Returning NWBFile in append mode is deprecated and will return None in or after March 2026. """ - # Handle deprecated usage without nwbfile_path - if nwbfile_path is None: - warnings.warn( - "Using 'write_sorting_to_nwbfile' without 'nwbfile_path' to only add data to an in-memory nwbfile is deprecated " - "and will be removed in or after March 2026. Use 'add_sorting_to_nwbfile' instead.", - DeprecationWarning, - stacklevel=2, - ) - if nwbfile is None: - raise ValueError( - "Either 'nwbfile_path' or 'nwbfile' must be provided. " - "To add data to an in-memory nwbfile, use 'add_sorting_to_nwbfile' instead." - ) - # Call add_sorting_to_nwbfile for deprecated behavior - add_sorting_to_nwbfile( - sorting=sorting, - nwbfile=nwbfile, - unit_ids=unit_ids, - property_descriptions=property_descriptions, - skip_properties=skip_properties, - write_as=write_as, - units_name=units_name, - units_description=units_description, - waveform_means=waveform_means, - waveform_sds=waveform_sds, - unit_electrode_indices=unit_electrode_indices, - null_values_for_properties=null_values_for_properties, - ) - return nwbfile - appending_to_in_memory_nwbfile = nwbfile is not None file_initially_exists = nwbfile_path.exists() allowed_to_modify_existing = overwrite or append_on_disk_nwbfile @@ -2521,13 +2435,6 @@ def write_sorting_to_nwbfile( else: # Append mode: read existing file, add data, write back - warnings.warn( - "Returning an NWBFile object when using append_on_disk_nwbfile=True is deprecated " - "and will return None in or after March 2026.", - DeprecationWarning, - stacklevel=2, - ) - IO = BACKEND_NWB_IO[backend] with IO(path=str(nwbfile_path), mode="r+", load_namespaces=True) as io: @@ -2557,7 +2464,7 @@ def write_sorting_to_nwbfile( if verbose: print(f"NWB file saved at {nwbfile_path}!") - return nwbfile # Will return None in March 2026 + return None def add_sorting_analyzer_to_nwbfile( @@ -2690,7 +2597,7 @@ def add_sorting_analyzer_to_nwbfile( def write_sorting_analyzer_to_nwbfile( sorting_analyzer: SortingAnalyzer, - nwbfile_path: FilePath | None = None, + nwbfile_path: FilePath, nwbfile: pynwb.NWBFile | None = None, metadata: dict | None = None, overwrite: bool = False, @@ -2722,10 +2629,8 @@ def write_sorting_analyzer_to_nwbfile( ---------- sorting_analyzer : spikeinterface.SortingAnalyzer The sorting analyzer object to be written to the NWBFile. - nwbfile_path : FilePath, optional + nwbfile_path : FilePath Path for where to write or load (if overwrite=False) the NWBFile. - If not provided, only adds data to the in-memory nwbfile without writing to disk. - **Deprecated**: Using this function without nwbfile_path is deprecated. Use `add_sorting_analyzer_to_nwbfile` instead. nwbfile : NWBFile, optional If passed, this function will fill the relevant fields within the NWBFile object. E.g., calling:: @@ -2782,60 +2687,10 @@ def write_sorting_analyzer_to_nwbfile( Returns ------- nwbfile : pynwb.NWBFile or None - The in-memory NWBFile object. Returns None when append_on_disk_nwbfile=True (to be implemented in or after March 2026). + The NWBFile object when writing a new file. + Returns None when appending to an existing file on disk (append_on_disk_nwbfile=True). """ - # Handle deprecated usage without nwbfile_path - if nwbfile_path is None: - warnings.warn( - "Using 'write_sorting_analyzer_to_nwbfile' without 'nwbfile_path' to only add data to an in-memory nwbfile is deprecated " - "and will be removed in or after March 2026. Use 'add_sorting_analyzer_to_nwbfile' instead.", - DeprecationWarning, - stacklevel=2, - ) - if nwbfile is None: - raise ValueError( - "Either 'nwbfile_path' or 'nwbfile' must be provided. " - "To add data to an in-memory nwbfile, use 'add_sorting_analyzer_to_nwbfile' instead." - ) - - # Ensure metadata exists - metadata = metadata if metadata is not None else dict() - - # Get recording - if recording is None and sorting_analyzer.has_recording(): - recording = sorting_analyzer.recording - assert recording is not None, ( - "recording not found. To add the electrode table, the sorting_analyzer " - "needs to have a recording attached or the 'recording' argument needs to be used." - ) - - # Call add_sorting_analyzer_to_nwbfile for deprecated behavior - if write_electrical_series: - add_electrical_series_kwargs = add_electrical_series_kwargs or dict() - add_recording_to_nwbfile( - recording=recording, - nwbfile=nwbfile, - metadata=metadata, - null_values_for_properties=null_values_for_properties, - **add_electrical_series_kwargs, - ) - - add_sorting_analyzer_to_nwbfile( - sorting_analyzer=sorting_analyzer, - nwbfile=nwbfile, - metadata=metadata, - recording=recording, - unit_ids=unit_ids, - skip_properties=skip_properties, - property_descriptions=property_descriptions, - write_as=write_as, - units_name=units_name, - units_description=units_description, - null_values_for_properties=null_values_for_properties, - ) - return nwbfile - # Ensure metadata exists if metadata is None: metadata = dict() @@ -2922,12 +2777,6 @@ def write_sorting_analyzer_to_nwbfile( else: # Append mode: read existing file, add data, write back - warnings.warn( - "Returning an NWBFile object in append mode is deprecated and will return None in or after March 2026.", - DeprecationWarning, - stacklevel=2, - ) - IO = BACKEND_NWB_IO[backend] with IO(path=str(nwbfile_path), mode="r+", load_namespaces=True) as io: @@ -2967,7 +2816,7 @@ def write_sorting_analyzer_to_nwbfile( if verbose: print(f"NWB file saved at {nwbfile_path}!") - return nwbfile # Will return None in March 2026 + return None def _get_electrode_group_indices(recording, nwbfile): diff --git a/tests/test_modalities/test_ecephys/test_tools_spikeinterface.py b/tests/test_modalities/test_ecephys/test_tools_spikeinterface.py index 5e4570eeb..72b68b5ab 100644 --- a/tests/test_modalities/test_ecephys/test_tools_spikeinterface.py +++ b/tests/test_modalities/test_ecephys/test_tools_spikeinterface.py @@ -29,9 +29,8 @@ add_recording_as_spatial_series_to_nwbfile, add_recording_as_time_series_to_nwbfile, add_recording_to_nwbfile, + add_sorting_analyzer_to_nwbfile, add_sorting_to_nwbfile, - write_recording_to_nwbfile, - write_sorting_analyzer_to_nwbfile, ) from neuroconv.tools.spikeinterface.spikeinterfacerecordingdatachunkiterator import ( SpikeInterfaceRecordingDataChunkIterator, @@ -506,22 +505,8 @@ def setUp(self): session_description="session_description1", identifier="file_id1", session_start_time=testing_session_time ) - def test_default_values_single_segment(self): - """This test that the names are written appropriately for the single segment case (numbers not added)""" - write_recording_to_nwbfile( - recording=self.single_segment_recording_extractor, nwbfile=self.nwbfile, iterator_type=None - ) - - acquisition_module = self.nwbfile.acquisition - assert "ElectricalSeriesRaw" in acquisition_module - electrical_series = acquisition_module["ElectricalSeriesRaw"] - - extracted_data = electrical_series.data[:] - expected_data = self.single_segment_recording_extractor.get_traces(segment_index=0) - np.testing.assert_array_almost_equal(expected_data, extracted_data) - def test_write_multiple_segments(self): - write_recording_to_nwbfile( + add_recording_to_nwbfile( recording=self.multiple_segment_recording_extractor, nwbfile=self.nwbfile, iterator_type=None ) @@ -2218,38 +2203,50 @@ def _test_analyzer_write(self, analyzer, nwbfile, test_properties=True): def test_analyzer_single_segment(self): """This tests that the analyzer is written appropriately for the single segment case""" - write_sorting_analyzer_to_nwbfile( - sorting_analyzer=self.single_segment_analyzer, nwbfile=self.nwbfile, write_electrical_series=True + add_recording_to_nwbfile( + recording=self.single_segment_analyzer.recording, + nwbfile=self.nwbfile, + ) + add_sorting_analyzer_to_nwbfile( + sorting_analyzer=self.single_segment_analyzer, + nwbfile=self.nwbfile, ) self._test_analyzer_write(self.single_segment_analyzer, self.nwbfile) self.assertIn("ElectricalSeriesRaw", self.nwbfile.acquisition) def test_analyzer_single_segment_sparse(self): """This tests that the analyzer is written appropriately for the single segment case""" - write_sorting_analyzer_to_nwbfile( - sorting_analyzer=self.single_segment_analyzer_sparse, nwbfile=self.nwbfile, write_electrical_series=True + add_recording_to_nwbfile( + recording=self.single_segment_analyzer_sparse.recording, + nwbfile=self.nwbfile, + ) + add_sorting_analyzer_to_nwbfile( + sorting_analyzer=self.single_segment_analyzer_sparse, + nwbfile=self.nwbfile, ) self._test_analyzer_write(self.single_segment_analyzer_sparse, self.nwbfile) self.assertIn("ElectricalSeriesRaw", self.nwbfile.acquisition) def test_analyzer_multiple_segments(self): """This tests that the analyzer is written appropriately for the multi segment case""" - write_sorting_analyzer_to_nwbfile( - sorting_analyzer=self.multi_segment_analyzer, nwbfile=self.nwbfile, write_electrical_series=False + add_sorting_analyzer_to_nwbfile( + sorting_analyzer=self.multi_segment_analyzer, + nwbfile=self.nwbfile, ) self._test_analyzer_write(self.multi_segment_analyzer, self.nwbfile) def test_analyzer_multiple_segments_sparse(self): """This tests that the analyzer is written appropriately for the multi segment case""" - write_sorting_analyzer_to_nwbfile( - sorting_analyzer=self.multi_segment_analyzer_sparse, nwbfile=self.nwbfile, write_electrical_series=False + add_sorting_analyzer_to_nwbfile( + sorting_analyzer=self.multi_segment_analyzer_sparse, + nwbfile=self.nwbfile, ) self._test_analyzer_write(self.multi_segment_analyzer_sparse, self.nwbfile) def test_write_subset_units(self): """This tests that the analyzer is sliced properly based on unit_ids""" subset_unit_ids = self.single_segment_analyzer.unit_ids[::2] - write_sorting_analyzer_to_nwbfile( + add_sorting_analyzer_to_nwbfile( sorting_analyzer=self.single_segment_analyzer, nwbfile=self.nwbfile, unit_ids=subset_unit_ids ) self._test_analyzer_write(self.analyzer_slice, self.nwbfile, test_properties=False) @@ -2257,23 +2254,25 @@ def test_write_subset_units(self): self.assertEqual(len(self.nwbfile.units), len(subset_unit_ids)) self.assertTrue(all(str(unit_id) in self.nwbfile.units["unit_name"][:] for unit_id in subset_unit_ids)) - def test_write_recordingless_to_write_recording_to_nwbfile(self): + def test_write_recordingless_to_add_sorting_analyzer(self): """This tests that the analyzer is written properly in recordingless mode""" - write_sorting_analyzer_to_nwbfile( + add_recording_to_nwbfile( + recording=self.analyzer_recless_recording, + nwbfile=self.nwbfile, + ) + add_sorting_analyzer_to_nwbfile( sorting_analyzer=self.analyzer_recless, nwbfile=self.nwbfile, recording=self.analyzer_recless_recording, - write_electrical_series=True, ) self._test_analyzer_write(self.analyzer_recless, self.nwbfile, test_properties=False) # check that not passing the recording raises and Exception with self.assertRaises(Exception) as context: - write_sorting_analyzer_to_nwbfile( + add_sorting_analyzer_to_nwbfile( sorting_analyzer=self.analyzer_recless, nwbfile=self.nwbfile, recording=None, - write_electrical_series=True, ) def test_write_multiple_probes_without_electrical_series(self): @@ -2281,18 +2280,16 @@ def test_write_multiple_probes_without_electrical_series(self): # we write the first set of waveforms as belonging to group 0 original_channel_groups = self.analyzer_recless_recording.get_channel_groups() self.analyzer_recless_recording.set_channel_groups([0] * len(self.analyzer_recless_recording.channel_ids)) - write_sorting_analyzer_to_nwbfile( + add_sorting_analyzer_to_nwbfile( sorting_analyzer=self.analyzer_recless, nwbfile=self.nwbfile, - write_electrical_series=False, recording=self.analyzer_recless_recording, ) # now we set new channel groups to mimic a different probe and call the function again self.analyzer_recless_recording.set_channel_groups([1] * len(self.analyzer_recless_recording.channel_ids)) - write_sorting_analyzer_to_nwbfile( + add_sorting_analyzer_to_nwbfile( sorting_analyzer=self.analyzer_recless, nwbfile=self.nwbfile, - write_electrical_series=False, recording=self.analyzer_recless_recording, ) # check that we have 2 groups @@ -2322,26 +2319,32 @@ def test_write_multiple_probes_with_electrical_series(self): ElectricalSeriesRaw2=dict(name="ElectricalSeriesRaw2", description="lfp series"), ) ) - add_electrical_series_kwargs1b = dict(es_key="ElectricalSeriesRaw1") - write_sorting_analyzer_to_nwbfile( + add_recording_to_nwbfile( + recording=recording, + nwbfile=self.nwbfile, + metadata=metadata, + es_key="ElectricalSeriesRaw1", + ) + add_sorting_analyzer_to_nwbfile( sorting_analyzer=self.single_segment_analyzer, nwbfile=self.nwbfile, - write_electrical_series=True, metadata=metadata, - add_electrical_series_kwargs=add_electrical_series_kwargs1b, ) self.assertEqual(len(self.nwbfile.electrodes), len(recording.channel_ids)) self.assertIn("ElectricalSeriesRaw1", self.nwbfile.acquisition) # now we set new channel groups to mimic a different probe and call the function again self.single_segment_analyzer.recording.set_channel_groups([1] * len(recording.channel_ids)) - add_electrical_series_kwargs2_to_add_recording_to_nwbfile = dict(es_key="ElectricalSeriesRaw2") - write_sorting_analyzer_to_nwbfile( + add_recording_to_nwbfile( + recording=recording, + nwbfile=self.nwbfile, + metadata=metadata, + es_key="ElectricalSeriesRaw2", + ) + add_sorting_analyzer_to_nwbfile( sorting_analyzer=self.single_segment_analyzer, nwbfile=self.nwbfile, - write_electrical_series=True, metadata=metadata, - add_electrical_series_kwargs=add_electrical_series_kwargs2_to_add_recording_to_nwbfile, ) # check that we have 2 groups self.assertEqual(len(self.nwbfile.electrode_groups), 2) @@ -2366,7 +2369,7 @@ def test_missing_electrode_group(self): """This tests that analyzer is correctly written even if the 'group' property is not available""" groups = self.single_segment_analyzer.recording.get_channel_groups() self.single_segment_analyzer.recording.delete_property("group") - write_sorting_analyzer_to_nwbfile( + add_sorting_analyzer_to_nwbfile( sorting_analyzer=self.single_segment_analyzer, nwbfile=self.nwbfile, ) @@ -2376,7 +2379,7 @@ def test_group_name_property(self): """This tests that the 'group_name' property is correctly used to instantiate electrode groups""" num_channels = len(self.single_segment_analyzer.recording.channel_ids) self.single_segment_analyzer.recording.set_property("group_name", ["my-fancy-group"] * num_channels) - write_sorting_analyzer_to_nwbfile( + add_sorting_analyzer_to_nwbfile( sorting_analyzer=self.single_segment_analyzer, nwbfile=self.nwbfile, ) @@ -2387,7 +2390,7 @@ def test_group_name_property(self): def test_units_table_name(self): """This tests the units naming exception""" with self.assertRaises(Exception) as context: - write_sorting_analyzer_to_nwbfile( + add_sorting_analyzer_to_nwbfile( sorting_analyzer=self.single_segment_analyzer, nwbfile=self.nwbfile, write_as="units", @@ -2396,11 +2399,14 @@ def test_units_table_name(self): def test_analyzer_channel_sliced(self): """This tests that the analyzer is written appropriately when the recording has been channel-sliced""" - write_sorting_analyzer_to_nwbfile( + add_recording_to_nwbfile( + recording=self.analyzer_rec_sliced, + nwbfile=self.nwbfile, + ) + add_sorting_analyzer_to_nwbfile( sorting_analyzer=self.analyzer_channel_sliced, nwbfile=self.nwbfile, recording=self.analyzer_rec_sliced, - write_electrical_series=True, ) self._test_analyzer_write(self.analyzer_channel_sliced, self.nwbfile, test_properties=True) # check unit electrodes are all in the sliced channels