Source code for allensdk.brain_observatory.behavior.behavior_project_cache.tables.experiments_table
from typing import Optional, List
import pandas as pd
from allensdk.brain_observatory.behavior.behavior_project_cache.tables\
.ophys_mixin import \
OphysMixin
from allensdk.brain_observatory.behavior.behavior_project_cache.tables\
.project_table import \
ProjectTable
from allensdk.brain_observatory.behavior.behavior_project_cache.tables\
.util.experiments_table_utils import (
add_experience_level_to_experiment_table,
add_passive_flag_to_ophys_experiment_table,
add_image_set_to_experiment_table)
[docs]class ExperimentsTable(ProjectTable, OphysMixin):
"""Class for storing and manipulating project-level data
at the behavior-ophys experiment level"""
def __init__(self, df: pd.DataFrame,
suppress: Optional[List[str]] = None,
passed_only: bool = True):
"""
Parameters
----------
df: pd.DataFrame
The behavior-ophys experiment-level data
suppress: Optional[List[str]]
columns to drop from table (default=None)
passed_only: bool
If True, only return experiments whose
exeriment_workflow_state is True
"""
self._passed_only = passed_only
ProjectTable.__init__(self, df=df, suppress=suppress)
OphysMixin.__init__(self)
self.final_processing()
[docs] def postprocess_base(self):
"""
It actually is possible for the same ophys_experiment_id
to map to more than one container, so we don't want to
eliminate duplicate instances of the index
"""
pass
[docs] def postprocess_additional(self):
pass
[docs] def final_processing(self):
# This method is necessary because self.post_process_additional()
# is called by the ProjectTable.__init__(), which is called
# before OphysMixin.__init__(). OphysMixin.__init__() joins
# some of the Behavior and Ophys columns into sigle, session-wide
# columns, which the functions below must access (specifically,
# OphysMixin.__init__() joins session_type_behavior and
# session_type_ophys into session_type, which is the column
# that add_image_set_to_experiment acts on. A future ticket
# should revisit the workflow of these classes to make it
# possible for the function calls below to be incorporated
# into post_process_additional
self._df = add_experience_level_to_experiment_table(self._df)
self._df = add_passive_flag_to_ophys_experiment_table(self._df)
self._df = add_image_set_to_experiment_table(self._df)
if self._passed_only:
self._df = self._df.query("experiment_workflow_state=='passed'")
self._df = self._df.query("container_workflow_state=='published'")