File tree Expand file tree Collapse file tree 1 file changed +9
-12
lines changed
src/spyglass/spikesorting/v1 Expand file tree Collapse file tree 1 file changed +9
-12
lines changed Original file line number Diff line number Diff 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 :
You can’t perform that action at this time.
0 commit comments