11from pathlib import Path
22from shutil import rmtree as shutil_rmtree
3+ from typing import List , Tuple
34
45import datajoint as dj
56import numpy as np
@@ -312,7 +313,6 @@ class SpikeSortingRecordingSelection(SpyglassMixin, dj.Manual):
312313
313314@schema
314315class SpikeSortingRecording (SpyglassMixin , dj .Computed ):
315-
316316 definition = """
317317 -> SpikeSortingRecordingSelection
318318 ---
@@ -322,34 +322,68 @@ class SpikeSortingRecording(SpyglassMixin, dj.Computed):
322322 """
323323
324324 _parallel_make = True
325- _use_transaction , _allow_insert = False , True
326-
327- def make (self , key ):
328- """Populates the SpikeSortingRecording table with the recording data.
329-
330- 1. Fetches ...
331- - Sort interval and parameters from SpikeSortingRecordingSelection
332- and SpikeSortingPreprocessingParameters
333- - Channel IDs and reference electrode from SortGroup, filtered by
334- filtereing parameters
335- 2. Saves the recording data to the recording directory
336- 3. Inserts the path to the recording data into SpikeSortingRecording
325+
326+ def make_fetch (self , key : dict ) -> List [Interval ]:
327+ """Fetch times for compute.
328+
329+ Parameters
330+ ----------
331+ key: dict
332+ Key of SpikeSortingRecordingSelection table
333+
334+ Returns
335+ -------
336+ List[Interval]
337+ Sort Interval object, as a list of length 1
337338 """
338- rec_info = self ._make_file (key )
339+ # make decomposes passed obj, so make it a list if only one item
340+ return [self ._get_sort_interval_valid_times (key )]
341+
342+ def make_compute (
343+ self , key : dict , sort_interval_valid_times : Interval
344+ ) -> Tuple [dict , Interval ]:
345+ """Run computation. Generate the file, set Interval key, prep insert.
346+
347+ Parameters
348+ ----------
349+ key: dict
350+ Key of SpikeSortingRecordingSelection table
351+ sort_interval_valid_times, sort
352+ Interval object of the sort
339353
340- sort_interval_valid_times = self ._get_sort_interval_valid_times (key )
354+ Returns
355+ -------
356+ Tuple[dict, Interval]
357+ Dictionary of self-insert, and updated Interval object
358+ """
359+ rec_info = self ._make_file (key )
341360 sort_interval_valid_times .set_key (
342361 nwb_file_name = key ["nwb_file_name" ],
343362 interval_list_name = rec_info ["name" ],
344363 pipeline = "spikesorting_recording_v0" ,
345364 )
346- IntervalList .insert1 (sort_interval_valid_times .as_dict , replace = True )
347-
348365 self_insert = dict (
349366 key ,
350367 sort_interval_list_name = rec_info ["name" ],
351368 recording_path = rec_info ["path" ],
352369 )
370+ return self_insert , sort_interval_valid_times
371+
372+ def make_insert (
373+ self , key : dict , self_insert : dict , sort_interval_valid_times : Interval
374+ ) -> None :
375+ """Insert into self and IntervalList, document environment.
376+
377+ Parameters
378+ ----------
379+ key: dict
380+ Key of SpikeSortingRecordingSelection table
381+ self_insert: dict
382+ Dict of keys for this table
383+ sort_interval_valid_times: sort
384+ Interval object of the sort
385+ """
386+ IntervalList .insert1 (sort_interval_valid_times .as_dict , replace = True )
353387 self .insert1 (self_insert )
354388 self ._record_environment (self_insert )
355389
0 commit comments