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(