Skip to content

Commit f3fc5b3

Browse files
authored
Merge branch 'master' into import_pose
2 parents 6cf7627 + 202249f commit f3fc5b3

File tree

2 files changed

+10
-13
lines changed

2 files changed

+10
-13
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
- Spikesorting
2424
- Fix compatibility bug between v1 pipeline and `SortedSpikesGroup` unit
2525
filtering #1238
26-
26+
- Speedup `get_sorting` on `CurationV1` #1246
2727
- Behavior
2828
- Implement pipeline for keypoint-moseq extraction of behavior syllables #1056
2929

src/spyglass/spikesorting/v1/curation.py

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -203,25 +203,22 @@ def get_sorting(cls, key: dict) -> si.BaseSorting:
203203
analysis_file_abs_path = AnalysisNwbfile.get_abs_path(
204204
analysis_file_name
205205
)
206+
206207
with pynwb.NWBHDF5IO(
207208
analysis_file_abs_path, "r", load_namespaces=True
208209
) as io:
209210
nwbf = io.read()
210211
units = nwbf.units.to_dataframe()
211-
units_dict_list = [
212-
{
213-
unit_id: np.searchsorted(recording.get_times(), spike_times)
214-
for unit_id, spike_times in zip(
215-
units.index, units["spike_times"]
216-
)
217-
}
218-
]
219212

220-
sorting = si.NumpySorting.from_unit_dict(
221-
units_dict_list, sampling_frequency=sampling_frequency
222-
)
213+
recording_times = recording.get_times()
214+
units_dict = {
215+
unit.Index: np.searchsorted(recording_times, unit.spike_times)
216+
for unit in units.itertuples()
217+
}
223218

224-
return sorting
219+
return si.NumpySorting.from_unit_dict(
220+
[units_dict], sampling_frequency=sampling_frequency
221+
)
225222

226223
@classmethod
227224
def get_merged_sorting(cls, key: dict) -> si.BaseSorting:

0 commit comments

Comments
 (0)