Skip to content

Commit fa6180a

Browse files
authored
Merge pull request #227 from dj-sciops/main
Implement three-part-make for the `EphysRecording` table
2 parents 7dc76e8 + aaa6e1a commit fa6180a

File tree

3 files changed

+32
-8
lines changed

3 files changed

+32
-8
lines changed

element_array_ephys/ephys.py

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import pathlib
55
import re
66
from decimal import Decimal
7-
7+
from typing import Any, Dict, List, Tuple
88
import datajoint as dj
99
import numpy as np
1010
import 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"]

element_array_ephys/readers/spikeglx.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ def __init__(self, meta_filepath):
281281
elif probe_model == 24:
282282
self.probe_model = "neuropixels 2.0 - MS"
283283
else:
284-
self.probe_model = str(probe_model)
284+
self.probe_model = self.probe_PN
285285

286286
# Get recording time
287287
self.recording_time = datetime.strptime(

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
"openpyxl",
3636
"plotly",
3737
"seaborn",
38-
"spikeinterface",
38+
"spikeinterface @ git+https://github.com/SpikeInterface/spikeinterface.git",
3939
"scikit-image>=0.20",
4040
"nbformat>=4.2.0",
4141
"pyopenephys>=1.1.6",

0 commit comments

Comments
 (0)