Skip to content

Commit 5226fd8

Browse files
authored
Merge branch 'main' into main
2 parents 4c0dd64 + 790715c commit 5226fd8

18 files changed

Lines changed: 134 additions & 72 deletions

src/spikeinterface/core/analyzer_extension_core.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,8 @@ class ComputeRandomSpikes(AnalyzerExtension):
4949
use_nodepipeline = False
5050
need_job_kwargs = False
5151

52-
def _run(
53-
self,
54-
):
52+
def _run(self, verbose=False):
53+
5554
self.data["random_spikes_indices"] = random_spikes_selection(
5655
self.sorting_analyzer.sorting,
5756
num_samples=self.sorting_analyzer.rec_attributes["num_samples"],
@@ -145,7 +144,7 @@ def nbefore(self):
145144
def nafter(self):
146145
return int(self.params["ms_after"] * self.sorting_analyzer.sampling_frequency / 1000.0)
147146

148-
def _run(self, **job_kwargs):
147+
def _run(self, verbose=False, **job_kwargs):
149148
self.data.clear()
150149

151150
recording = self.sorting_analyzer.recording
@@ -183,6 +182,7 @@ def _run(self, **job_kwargs):
183182
sparsity_mask=sparsity_mask,
184183
copy=copy,
185184
job_name="compute_waveforms",
185+
verbose=verbose,
186186
**job_kwargs,
187187
)
188188

@@ -311,7 +311,7 @@ def _set_params(self, ms_before: float = 1.0, ms_after: float = 2.0, operators=N
311311
)
312312
return params
313313

314-
def _run(self, **job_kwargs):
314+
def _run(self, verbose=False, **job_kwargs):
315315
self.data.clear()
316316

317317
if self.sorting_analyzer.has_extension("waveforms"):
@@ -339,6 +339,7 @@ def _run(self, **job_kwargs):
339339
self.nafter,
340340
return_scaled=return_scaled,
341341
return_std=return_std,
342+
verbose=verbose,
342343
**job_kwargs,
343344
)
344345

@@ -581,7 +582,7 @@ def _select_extension_data(self, unit_ids):
581582
# this do not depend on units
582583
return self.data
583584

584-
def _run(self):
585+
def _run(self, verbose=False):
585586
self.data["noise_levels"] = get_noise_levels(
586587
self.sorting_analyzer.recording, return_scaled=self.sorting_analyzer.return_scaled, **self.params
587588
)

src/spikeinterface/core/node_pipeline.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,7 @@ def run_node_pipeline(
473473
squeeze_output=True,
474474
folder=None,
475475
names=None,
476+
verbose=False,
476477
):
477478
"""
478479
Common function to run pipeline with peak detector or already detected peak.
@@ -499,6 +500,7 @@ def run_node_pipeline(
499500
init_args,
500501
gather_func=gather_func,
501502
job_name=job_name,
503+
verbose=verbose,
502504
**job_kwargs,
503505
)
504506

src/spikeinterface/core/sortinganalyzer.py

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -835,7 +835,7 @@ def get_num_units(self) -> int:
835835
return self.sorting.get_num_units()
836836

837837
## extensions zone
838-
def compute(self, input, save=True, extension_params=None, **kwargs):
838+
def compute(self, input, save=True, extension_params=None, verbose=False, **kwargs):
839839
"""
840840
Compute one extension or several extensiosn.
841841
Internally calls compute_one_extension() or compute_several_extensions() depending on the input type.
@@ -883,11 +883,11 @@ def compute(self, input, save=True, extension_params=None, **kwargs):
883883
)
884884
"""
885885
if isinstance(input, str):
886-
return self.compute_one_extension(extension_name=input, save=save, **kwargs)
886+
return self.compute_one_extension(extension_name=input, save=save, verbose=verbose, **kwargs)
887887
elif isinstance(input, dict):
888888
params_, job_kwargs = split_job_kwargs(kwargs)
889889
assert len(params_) == 0, "Too many arguments for SortingAnalyzer.compute_several_extensions()"
890-
self.compute_several_extensions(extensions=input, save=save, **job_kwargs)
890+
self.compute_several_extensions(extensions=input, save=save, verbose=verbose, **job_kwargs)
891891
elif isinstance(input, list):
892892
params_, job_kwargs = split_job_kwargs(kwargs)
893893
assert len(params_) == 0, "Too many arguments for SortingAnalyzer.compute_several_extensions()"
@@ -898,11 +898,11 @@ def compute(self, input, save=True, extension_params=None, **kwargs):
898898
ext_name in input
899899
), f"SortingAnalyzer.compute(): Parameters specified for {ext_name}, which is not in the specified {input}"
900900
extensions[ext_name] = ext_params
901-
self.compute_several_extensions(extensions=extensions, save=save, **job_kwargs)
901+
self.compute_several_extensions(extensions=extensions, save=save, verbose=verbose, **job_kwargs)
902902
else:
903903
raise ValueError("SortingAnalyzer.compute() need str, dict or list")
904904

905-
def compute_one_extension(self, extension_name, save=True, **kwargs):
905+
def compute_one_extension(self, extension_name, save=True, verbose=False, **kwargs):
906906
"""
907907
Compute one extension.
908908
@@ -925,7 +925,7 @@ def compute_one_extension(self, extension_name, save=True, **kwargs):
925925
Returns
926926
-------
927927
result_extension: AnalyzerExtension
928-
Return the extension instance.
928+
Return the extension instance
929929
930930
Examples
931931
--------
@@ -961,13 +961,16 @@ def compute_one_extension(self, extension_name, save=True, **kwargs):
961961

962962
extension_instance = extension_class(self)
963963
extension_instance.set_params(save=save, **params)
964-
extension_instance.run(save=save, **job_kwargs)
964+
if extension_class.need_job_kwargs:
965+
extension_instance.run(save=save, verbose=verbose, **job_kwargs)
966+
else:
967+
extension_instance.run(save=save, verbose=verbose)
965968

966969
self.extensions[extension_name] = extension_instance
967970

968971
return extension_instance
969972

970-
def compute_several_extensions(self, extensions, save=True, **job_kwargs):
973+
def compute_several_extensions(self, extensions, save=True, verbose=False, **job_kwargs):
971974
"""
972975
Compute several extensions
973976
@@ -1021,9 +1024,9 @@ def compute_several_extensions(self, extensions, save=True, **job_kwargs):
10211024
for extension_name, extension_params in extensions_without_pipeline.items():
10221025
extension_class = get_extension_class(extension_name)
10231026
if extension_class.need_job_kwargs:
1024-
self.compute_one_extension(extension_name, save=save, **extension_params, **job_kwargs)
1027+
self.compute_one_extension(extension_name, save=save, verbose=verbose, **extension_params, **job_kwargs)
10251028
else:
1026-
self.compute_one_extension(extension_name, save=save, **extension_params)
1029+
self.compute_one_extension(extension_name, save=save, verbose=verbose, **extension_params)
10271030
# then extensions with pipeline
10281031
if len(extensions_with_pipeline) > 0:
10291032
all_nodes = []
@@ -1053,6 +1056,7 @@ def compute_several_extensions(self, extensions, save=True, **job_kwargs):
10531056
job_name=job_name,
10541057
gather_mode="memory",
10551058
squeeze_output=False,
1059+
verbose=verbose,
10561060
)
10571061

10581062
for r, result in enumerate(results):
@@ -1071,9 +1075,9 @@ def compute_several_extensions(self, extensions, save=True, **job_kwargs):
10711075
for extension_name, extension_params in extensions_post_pipeline.items():
10721076
extension_class = get_extension_class(extension_name)
10731077
if extension_class.need_job_kwargs:
1074-
self.compute_one_extension(extension_name, save=save, **extension_params, **job_kwargs)
1078+
self.compute_one_extension(extension_name, save=save, verbose=verbose, **extension_params, **job_kwargs)
10751079
else:
1076-
self.compute_one_extension(extension_name, save=save, **extension_params)
1080+
self.compute_one_extension(extension_name, save=save, verbose=verbose, **extension_params)
10771081

10781082
def get_saved_extension_names(self):
10791083
"""

src/spikeinterface/core/waveform_tools.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ def distribute_waveforms_to_buffers(
221221
mode="memmap",
222222
sparsity_mask=None,
223223
job_name=None,
224+
verbose=False,
224225
**job_kwargs,
225226
):
226227
"""
@@ -281,7 +282,9 @@ def distribute_waveforms_to_buffers(
281282
)
282283
if job_name is None:
283284
job_name = f"extract waveforms {mode} multi buffer"
284-
processor = ChunkRecordingExecutor(recording, func, init_func, init_args, job_name=job_name, **job_kwargs)
285+
processor = ChunkRecordingExecutor(
286+
recording, func, init_func, init_args, job_name=job_name, verbose=verbose, **job_kwargs
287+
)
285288
processor.run()
286289

287290

@@ -410,6 +413,7 @@ def extract_waveforms_to_single_buffer(
410413
sparsity_mask=None,
411414
copy=True,
412415
job_name=None,
416+
verbose=False,
413417
**job_kwargs,
414418
):
415419
"""
@@ -523,7 +527,9 @@ def extract_waveforms_to_single_buffer(
523527
if job_name is None:
524528
job_name = f"extract waveforms {mode} mono buffer"
525529

526-
processor = ChunkRecordingExecutor(recording, func, init_func, init_args, job_name=job_name, **job_kwargs)
530+
processor = ChunkRecordingExecutor(
531+
recording, func, init_func, init_args, job_name=job_name, verbose=verbose, **job_kwargs
532+
)
527533
processor.run()
528534

529535
if mode == "memmap":
@@ -783,6 +789,7 @@ def estimate_templates_with_accumulator(
783789
return_scaled: bool = True,
784790
job_name=None,
785791
return_std: bool = False,
792+
verbose: bool = False,
786793
**job_kwargs,
787794
):
788795
"""
@@ -861,7 +868,9 @@ def estimate_templates_with_accumulator(
861868

862869
if job_name is None:
863870
job_name = "estimate_templates_with_accumulator"
864-
processor = ChunkRecordingExecutor(recording, func, init_func, init_args, job_name=job_name, **job_kwargs)
871+
processor = ChunkRecordingExecutor(
872+
recording, func, init_func, init_args, job_name=job_name, verbose=verbose, **job_kwargs
873+
)
865874
processor.run()
866875

867876
# average

src/spikeinterface/extractors/nwbextractors.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,8 @@ class NwbRecordingExtractor(BaseRecording):
440440
stream_cache_path: str, Path, or None, default: None
441441
Specifies the local path for caching the file. Relevant only if `cache` is True.
442442
storage_options: dict | None = None,
443-
Additional parameters for the storage backend (e.g. AWS credentials) used for "zarr" stream_mode.
443+
These are the additional kwargs (e.g. AWS credentials) that are passed to the zarr.open convenience function.
444+
This is only used on the "zarr" stream_mode.
444445
use_pynwb: bool, default: False
445446
Uses the pynwb library to read the NWB file. Setting this to False, the default, uses h5py
446447
to read the file. Using h5py can improve performance by bypassing some of the PyNWB validations.
@@ -861,8 +862,10 @@ def _fetch_main_properties_backend(self):
861862

862863
@staticmethod
863864
def fetch_available_electrical_series_paths(
864-
file_path: str | Path, stream_mode: Optional[Literal["fsspec", "remfile", "zarr"]] = None
865-
) -> List[str]:
865+
file_path: str | Path,
866+
stream_mode: Optional[Literal["fsspec", "remfile", "zarr"]] = None,
867+
storage_options: dict | None = None,
868+
) -> list[str]:
866869
"""
867870
Retrieves the paths to all ElectricalSeries objects within a neurodata file.
868871
@@ -873,7 +876,9 @@ def fetch_available_electrical_series_paths(
873876
stream_mode : "fsspec" | "remfile" | "zarr" | None, optional
874877
Determines the streaming mode for reading the file. Use this for optimized reading from
875878
different sources, such as local disk or remote servers.
876-
879+
storage_options: dict | None = None,
880+
These are the additional kwargs (e.g. AWS credentials) that are passed to the zarr.open convenience function.
881+
This is only used on the "zarr" stream_mode.
877882
Returns
878883
-------
879884
list of str
@@ -901,6 +906,7 @@ def fetch_available_electrical_series_paths(
901906
file_handle = read_file_from_backend(
902907
file_path=file_path,
903908
stream_mode=stream_mode,
909+
storage_options=storage_options,
904910
)
905911

906912
electrical_series_paths = _find_neurodata_type_from_backend(
@@ -988,7 +994,8 @@ class NwbSortingExtractor(BaseSorting):
988994
If True, the file is cached in the file passed to stream_cache_path
989995
if False, the file is not cached.
990996
storage_options: dict | None = None,
991-
Additional parameters for the storage backend (e.g. AWS credentials) used for "zarr" stream_mode.
997+
These are the additional kwargs (e.g. AWS credentials) that are passed to the zarr.open convenience function.
998+
This is only used on the "zarr" stream_mode.
992999
use_pynwb: bool, default: False
9931000
Uses the pynwb library to read the NWB file. Setting this to False, the default, uses h5py
9941001
to read the file. Using h5py can improve performance by bypassing some of the PyNWB validations.

src/spikeinterface/postprocessing/amplitude_scalings.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ def _get_pipeline_nodes(self):
181181
nodes = [spike_retriever_node, amplitude_scalings_node]
182182
return nodes
183183

184-
def _run(self, **job_kwargs):
184+
def _run(self, verbose=False, **job_kwargs):
185185
job_kwargs = fix_job_kwargs(job_kwargs)
186186
nodes = self.get_pipeline_nodes()
187187
amp_scalings, collision_mask = run_node_pipeline(
@@ -190,6 +190,7 @@ def _run(self, **job_kwargs):
190190
job_kwargs=job_kwargs,
191191
job_name="amplitude_scalings",
192192
gather_mode="memory",
193+
verbose=verbose,
193194
)
194195
self.data["amplitude_scalings"] = amp_scalings
195196
if self.params["handle_collisions"]:

src/spikeinterface/postprocessing/correlograms.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def _select_extension_data(self, unit_ids):
7070
new_data = dict(ccgs=new_ccgs, bins=new_bins)
7171
return new_data
7272

73-
def _run(self):
73+
def _run(self, verbose=False):
7474
ccgs, bins = compute_correlograms_on_sorting(self.sorting_analyzer.sorting, **self.params)
7575
self.data["ccgs"] = ccgs
7676
self.data["bins"] = bins

src/spikeinterface/postprocessing/isi.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def _select_extension_data(self, unit_ids):
5656
new_extension_data = dict(isi_histograms=new_isi_hists, bins=new_bins)
5757
return new_extension_data
5858

59-
def _run(self):
59+
def _run(self, verbose=False):
6060
isi_histograms, bins = _compute_isi_histograms(self.sorting_analyzer.sorting, **self.params)
6161
self.data["isi_histograms"] = isi_histograms
6262
self.data["bins"] = bins

src/spikeinterface/postprocessing/principal_component.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ def project_new(self, new_spikes, new_waveforms, progress_bar=True):
256256
new_projections = self._transform_waveforms(new_spikes, new_waveforms, pca_model, progress_bar=progress_bar)
257257
return new_projections
258258

259-
def _run(self, **job_kwargs):
259+
def _run(self, verbose=False, **job_kwargs):
260260
"""
261261
Compute the PCs on waveforms extacted within the by ComputeWaveforms.
262262
Projections are computed only on the waveforms sampled by the SortingAnalyzer.
@@ -295,7 +295,7 @@ def _run(self, **job_kwargs):
295295
def _get_data(self):
296296
return self.data["pca_projection"]
297297

298-
def run_for_all_spikes(self, file_path=None, **job_kwargs):
298+
def run_for_all_spikes(self, file_path=None, verbose=False, **job_kwargs):
299299
"""
300300
Project all spikes from the sorting on the PCA model.
301301
This is a long computation because waveform need to be extracted from each spikes.
@@ -359,7 +359,9 @@ def run_for_all_spikes(self, file_path=None, **job_kwargs):
359359
unit_channels,
360360
pca_model,
361361
)
362-
processor = ChunkRecordingExecutor(recording, func, init_func, init_args, job_name="extract PCs", **job_kwargs)
362+
processor = ChunkRecordingExecutor(
363+
recording, func, init_func, init_args, job_name="extract PCs", verbose=verbose, **job_kwargs
364+
)
363365
processor.run()
364366

365367
def _fit_by_channel_local(self, n_jobs, progress_bar):

src/spikeinterface/postprocessing/spike_amplitudes.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def _get_pipeline_nodes(self):
107107
nodes = [spike_retriever_node, spike_amplitudes_node]
108108
return nodes
109109

110-
def _run(self, **job_kwargs):
110+
def _run(self, verbose=False, **job_kwargs):
111111
job_kwargs = fix_job_kwargs(job_kwargs)
112112
nodes = self.get_pipeline_nodes()
113113
amps = run_node_pipeline(
@@ -116,6 +116,7 @@ def _run(self, **job_kwargs):
116116
job_kwargs=job_kwargs,
117117
job_name="spike_amplitudes",
118118
gather_mode="memory",
119+
verbose=False,
119120
)
120121
self.data["amplitudes"] = amps
121122

0 commit comments

Comments
 (0)