Skip to content

Commit d9f53d0

Browse files
committed
Fix compute analyzer pipeline with tmp recording
1 parent f576da3 commit d9f53d0

2 files changed

Lines changed: 12 additions & 11 deletions

File tree

src/spikeinterface/core/sortinganalyzer.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ def __repr__(self) -> str:
230230
txt = f"{clsname}: {nchan} channels - {nunits} units - {nseg} segments - {self.format}"
231231
if self.is_sparse():
232232
txt += " - sparse"
233-
if self.has_recording():
233+
if self.has_recording() or self.has_temporary_recording():
234234
txt += " - has recording"
235235
ext_txt = f"Loaded {len(self.extensions)} extensions: " + ", ".join(self.extensions.keys())
236236
txt += "\n" + ext_txt
@@ -1355,7 +1355,9 @@ def compute_several_extensions(self, extensions, save=True, verbose=False, **job
13551355

13561356
for extension_name, extension_params in extensions_with_pipeline.items():
13571357
extension_class = get_extension_class(extension_name)
1358-
assert self.has_recording(), f"Extension {extension_name} need the recording"
1358+
assert (
1359+
self.has_recording() or self.has_temporary_recording()
1360+
), f"Extension {extension_name} need the recording"
13591361

13601362
for variable_name in extension_class.nodepipeline_variables:
13611363
result_routage.append((extension_name, variable_name))

src/spikeinterface/postprocessing/principal_component.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -359,12 +359,12 @@ def run_for_all_spikes(self, file_path=None, verbose=False, **job_kwargs):
359359

360360
job_kwargs = fix_job_kwargs(job_kwargs)
361361
p = self.params
362-
we = self.sorting_analyzer
363-
sorting = we.sorting
362+
sorting_analyzer = self.sorting_analyzer
363+
sorting = sorting_analyzer.sorting
364364
assert (
365-
we.has_recording()
366-
), "To compute PCA projections for all spikes, the waveform extractor needs the recording"
367-
recording = we.recording
365+
sorting_analyzer.has_recording() or sorting_analyzer.has_temporary_recording()
366+
), "To compute PCA projections for all spikes, the sorting analyzer needs the recording"
367+
recording = sorting_analyzer.recording
368368

369369
# assert sorting.get_num_segments() == 1
370370
assert p["mode"] in ("by_channel_local", "by_channel_global")
@@ -374,8 +374,9 @@ def run_for_all_spikes(self, file_path=None, verbose=False, **job_kwargs):
374374

375375
sparsity = self.sorting_analyzer.sparsity
376376
if sparsity is None:
377-
sparse_channels_indices = {unit_id: np.arange(we.get_num_channels()) for unit_id in we.unit_ids}
378-
max_channels_per_template = we.get_num_channels()
377+
num_channels = recording.get_num_channels()
378+
sparse_channels_indices = {unit_id: np.arange(num_channels) for unit_id in sorting_analyzer.unit_ids}
379+
max_channels_per_template = num_channels
379380
else:
380381
sparse_channels_indices = sparsity.unit_id_to_channel_indices
381382
max_channels_per_template = max([chan_inds.size for chan_inds in sparse_channels_indices.values()])
@@ -449,9 +450,7 @@ def _fit_by_channel_local(self, n_jobs, progress_bar):
449450
return pca_models
450451

451452
def _fit_by_channel_global(self, progress_bar):
452-
# we = self.sorting_analyzer
453453
p = self.params
454-
# unit_ids = we.unit_ids
455454
unit_ids = self.sorting_analyzer.unit_ids
456455

457456
# there is one unique PCA accross channels

0 commit comments

Comments
 (0)