From 91c6986e2bca7d4264c0bc3cd241ba443bc38100 Mon Sep 17 00:00:00 2001 From: Gabriel Rojas Bowe Date: Mon, 3 Aug 2026 16:05:43 -0700 Subject: [PATCH] Fix psychophysical kernel population Read the existing event-mapping table without declaring ephys tables inside DataJoint transactions, and emit one populate key per pooled fit. --- labdata_plugin/analysisschema.py | 3 ++- src/behavior_analyses/kernel_timing.py | 18 ++++++++---------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/labdata_plugin/analysisschema.py b/labdata_plugin/analysisschema.py index ccf96e8..301c88b 100644 --- a/labdata_plugin/analysisschema.py +++ b/labdata_plugin/analysisschema.py @@ -224,7 +224,8 @@ class PsychophysicalKernel(dj.Computed): def key_source(self): subject_conditions = ( dj.U("analysis_set_id", "subject_name", "trialset_description") - & BehaviorAnalysisSet.TrialSet() + .aggr(BehaviorAnalysisSet.TrialSet(), n_trialsets="count(*)") + .proj() ) return subject_conditions * PsychophysicalKernelFitConfig() diff --git a/src/behavior_analyses/kernel_timing.py b/src/behavior_analyses/kernel_timing.py index 1bf1087..a6a0aa4 100644 --- a/src/behavior_analyses/kernel_timing.py +++ b/src/behavior_analyses/kernel_timing.py @@ -1,6 +1,5 @@ from __future__ import annotations -from importlib import import_module from typing import Any import numpy as np @@ -339,18 +338,17 @@ def _fetch_chipmunk_trial_rows(dataset_key: dict[str, Any]) -> list[dict[str, An def _fetch_event_mapping_rows( session_key: dict[str, Any], ) -> list[dict[str, Any]]: - try: - import labdata + import datajoint as dj + import labdata + from labdata.schema import get_user_schema - labdata.plugins["gephys"].__file__ - module = import_module("gephys.analysisschema") + try: + labdata.plugins["gephys"] except KeyError: return [] - except ModuleNotFoundError as error: - if error.name in {"gephys", "gephys.analysisschema"}: - return [] - raise - return list((module.EventMapping() & session_key).fetch(as_dict=True)) + schema = get_user_schema() + table = dj.FreeTable(schema.connection, f"`{schema.database}`.`event_mapping`") + return list((table & session_key).fetch(as_dict=True)) def _fetch_mapped_digital_event_rows(