44import pathlib
55import re
66from decimal import Decimal
7-
7+ from typing import Any , Dict , List , Tuple
88import datajoint as dj
99import numpy as np
1010import pandas as pd
@@ -293,14 +293,28 @@ class EphysFile(dj.Part):
293293 file_path: varchar(255) # filepath relative to root data directory
294294 """
295295
296- def make (self , key ) :
297- """Populates table with electrophysiology recording information ."""
296+ def make_fetch (self , key : dict ) -> Tuple [ pathlib . Path , str , List [ str ], List [ str ]] :
297+ """Fetch required data from database for processing ."""
298298 session_dir = find_full_path (
299299 get_ephys_root_data_dir (), get_session_directory (key )
300300 )
301301 inserted_probe_serial_number = (ProbeInsertion * probe .Probe & key ).fetch1 (
302302 "probe"
303303 )
304+ supported_probe_types = list (probe .ProbeType .fetch ("probe_type" ))
305+ supported_acq_software = list (AcquisitionSoftware .fetch ("acq_software" ))
306+
307+ return session_dir , inserted_probe_serial_number , supported_probe_types , supported_acq_software
308+
309+ def make_compute (
310+ self ,
311+ key : dict ,
312+ session_dir : pathlib .Path ,
313+ inserted_probe_serial_number : str ,
314+ supported_probe_types : List [str ],
315+ supported_acq_software : List [str ],
316+ ) -> Tuple [Dict [str , Any ], List [Dict [str , Any ]], Dict [str , Any ], List [Dict [str , Any ]], List [Dict [str , Any ]]]:
317+ """Populates table with electrophysiology recording information."""
304318
305319 # Search session dir and determine acquisition software
306320 for ephys_pattern , ephys_acq_type in (
@@ -317,13 +331,11 @@ def make(self, key):
317331 "Neither SpikeGLX nor Open Ephys recording files found"
318332 )
319333
320- if acq_software not in AcquisitionSoftware . fetch ( "acq_software" ) :
334+ if acq_software not in supported_acq_software :
321335 raise NotImplementedError (
322336 f"Processing ephys files from acquisition software of type { acq_software } is not yet implemented."
323337 )
324338
325- supported_probe_types = probe .ProbeType .fetch ("probe_type" )
326-
327339 if acq_software == "SpikeGLX" :
328340 for meta_filepath in ephys_meta_filepaths :
329341 spikeglx_meta = spikeglx .SpikeGLXMeta (meta_filepath )
@@ -483,6 +495,18 @@ def make(self, key):
483495 f"Processing ephys files from acquisition software of type { acq_software } is not yet implemented."
484496 )
485497
498+ return econfig_entry , econfig_electrodes , ephys_recording_entry , ephys_file_entries , ephys_channel_entries
499+
500+ def make_insert (
501+ self ,
502+ key : dict ,
503+ econfig_entry : Dict [str , Any ],
504+ econfig_electrodes : List [Dict [str , Any ]],
505+ ephys_recording_entry : Dict [str , Any ],
506+ ephys_file_entries : List [Dict [str , Any ]],
507+ ephys_channel_entries : List [Dict [str , Any ]],
508+ ) -> None :
509+ """Insert computed data into database tables."""
486510 # Insert into probe.ElectrodeConfig (recording configuration)
487511 if not probe .ElectrodeConfig & {
488512 "electrode_config_hash" : econfig_entry ["electrode_config_hash" ]
0 commit comments