diff --git a/element_array_ephys/ephys.py b/element_array_ephys/ephys.py index 60ffa9b5..f43aa620 100644 --- a/element_array_ephys/ephys.py +++ b/element_array_ephys/ephys.py @@ -4,7 +4,7 @@ import pathlib import re from decimal import Decimal - +from typing import Any, Dict, List, Tuple import datajoint as dj import numpy as np import pandas as pd @@ -293,14 +293,28 @@ class EphysFile(dj.Part): file_path: varchar(255) # filepath relative to root data directory """ - def make(self, key): - """Populates table with electrophysiology recording information.""" + def make_fetch(self, key: dict) -> Tuple[pathlib.Path, str, List[str], List[str]]: + """Fetch required data from database for processing.""" session_dir = find_full_path( get_ephys_root_data_dir(), get_session_directory(key) ) inserted_probe_serial_number = (ProbeInsertion * probe.Probe & key).fetch1( "probe" ) + supported_probe_types = list(probe.ProbeType.fetch("probe_type")) + supported_acq_software = list(AcquisitionSoftware.fetch("acq_software")) + + return session_dir, inserted_probe_serial_number, supported_probe_types, supported_acq_software + + def make_compute( + self, + key: dict, + session_dir: pathlib.Path, + inserted_probe_serial_number: str, + supported_probe_types: List[str], + supported_acq_software: List[str], + ) -> Tuple[Dict[str, Any], List[Dict[str, Any]], Dict[str, Any], List[Dict[str, Any]], List[Dict[str, Any]]]: + """Populates table with electrophysiology recording information.""" # Search session dir and determine acquisition software for ephys_pattern, ephys_acq_type in ( @@ -317,13 +331,11 @@ def make(self, key): "Neither SpikeGLX nor Open Ephys recording files found" ) - if acq_software not in AcquisitionSoftware.fetch("acq_software"): + if acq_software not in supported_acq_software: raise NotImplementedError( f"Processing ephys files from acquisition software of type {acq_software} is not yet implemented." ) - supported_probe_types = probe.ProbeType.fetch("probe_type") - if acq_software == "SpikeGLX": for meta_filepath in ephys_meta_filepaths: spikeglx_meta = spikeglx.SpikeGLXMeta(meta_filepath) @@ -483,6 +495,18 @@ def make(self, key): f"Processing ephys files from acquisition software of type {acq_software} is not yet implemented." ) + return econfig_entry, econfig_electrodes, ephys_recording_entry, ephys_file_entries, ephys_channel_entries + + def make_insert( + self, + key: dict, + econfig_entry: Dict[str, Any], + econfig_electrodes: List[Dict[str, Any]], + ephys_recording_entry: Dict[str, Any], + ephys_file_entries: List[Dict[str, Any]], + ephys_channel_entries: List[Dict[str, Any]], + ) -> None: + """Insert computed data into database tables.""" # Insert into probe.ElectrodeConfig (recording configuration) if not probe.ElectrodeConfig & { "electrode_config_hash": econfig_entry["electrode_config_hash"] diff --git a/element_array_ephys/readers/spikeglx.py b/element_array_ephys/readers/spikeglx.py index 214b70b9..1cdbd51f 100644 --- a/element_array_ephys/readers/spikeglx.py +++ b/element_array_ephys/readers/spikeglx.py @@ -281,7 +281,7 @@ def __init__(self, meta_filepath): elif probe_model == 24: self.probe_model = "neuropixels 2.0 - MS" else: - self.probe_model = str(probe_model) + self.probe_model = self.probe_PN # Get recording time self.recording_time = datetime.strptime( diff --git a/setup.py b/setup.py index 0a5846cb..14366465 100644 --- a/setup.py +++ b/setup.py @@ -35,7 +35,7 @@ "openpyxl", "plotly", "seaborn", - "spikeinterface", + "spikeinterface @ git+https://github.com/SpikeInterface/spikeinterface.git", "scikit-image>=0.20", "nbformat>=4.2.0", "pyopenephys>=1.1.6",