File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1212
1313### Fixed
1414- Development checkouts now report a development version with a Git commit suffix.
15+ - Template datasets without waveform templates can be reloaded after cluster assignments change.
1516
1617## [ 2.7.0] 2025-12-10
1718
Original file line number Diff line number Diff line change @@ -414,16 +414,16 @@ def _load_data(self):
414414 self .n_channels_loc = 0
415415
416416 # Clusters waveforms
417- if not np .all (self .spike_clusters == self .spike_templates ) and \
417+ clusters_changed = not np .array_equal (self .spike_clusters , self .spike_templates )
418+ if clusters_changed and self .sparse_templates is not None and \
418419 self .sparse_templates .cols is None :
419420 self .merge_map , self .nan_idx = self .get_merge_map ()
420421 self .sparse_clusters = self .cluster_waveforms ()
421- self .n_clusters = self .spike_clusters .max () + 1
422422 else :
423423 self .merge_map = {}
424424 self .nan_idx = []
425425 self .sparse_clusters = self .sparse_templates
426- self .n_clusters = self .spike_templates .max () + 1
426+ self .n_clusters = self .spike_clusters .max () + 1
427427
428428 # Spike waveforms (optional, otherwise fetched from raw data as needed).
429429 self .spike_waveforms = self ._load_spike_waveforms ()
Original file line number Diff line number Diff line change @@ -135,6 +135,26 @@ def test_model_save(template_model_full):
135135 m .save_spike_clusters (m .spike_clusters )
136136
137137
138+ def test_model_reload_curated_dataset_without_templates (template_path ):
139+ (template_path .parent / 'templates.npy' ).unlink ()
140+
141+ model = load_model (template_path )
142+ assert model .sparse_templates is None
143+ spike_clusters = model .spike_clusters .copy ()
144+ spike_clusters [spike_clusters == spike_clusters [0 ]] = spike_clusters .max () + 1
145+ model .save_spike_clusters (spike_clusters )
146+ model .close ()
147+
148+ model = load_model (template_path )
149+ try :
150+ ae (model .spike_clusters , spike_clusters )
151+ assert model .sparse_templates is None
152+ assert model .sparse_clusters is None
153+ assert model .n_clusters == spike_clusters .max () + 1
154+ finally :
155+ model .close ()
156+
157+
138158def test_model_spike_waveforms (template_path_full ):
139159 model = load_model (template_path_full )
140160
You can’t perform that action at this time.
0 commit comments