allensdk.brain_observatory.behavior.behavior_project_cache module

class allensdk.brain_observatory.behavior.behavior_project_cache.BehaviorProjectCache(fetch_api: Optional[Type[allensdk.brain_observatory.behavior.internal.behavior_project_base.BehaviorProjectBase]] = None, fetch_tries: int = 2, manifest: Union[str, pathlib.Path, None] = None, version: Optional[str] = None, cache: bool = True)[source]

Bases: allensdk.api.cache.Cache

BEHAVIOR_ANALYSIS_LOG_KEY = 'behavior_analysis_log'
BEHAVIOR_SESSIONS_KEY = 'behavior_sessions'
MANIFEST_CONFIG = {'behavior_analysis_log': {'parent_key': 'BASEDIR', 'spec': 'behavior_analysis_log.csv', 'typename': 'file'}, 'behavior_sessions': {'parent_key': 'BASEDIR', 'spec': 'behavior_sessions.csv', 'typename': 'file'}, 'ophys_analysis_log': {'parent_key': 'BASEDIR', 'spec': 'ophys_analysis_log.csv', 'typename': 'file'}, 'ophys_experiments': {'parent_key': 'BASEDIR', 'spec': 'ophys_experiments.csv', 'typename': 'file'}, 'ophys_sessions': {'parent_key': 'BASEDIR', 'spec': 'ophys_sessions.csv', 'typename': 'file'}}
MANIFEST_VERSION = '0.0.1-alpha'
OPHYS_ANALYSIS_LOG_KEY = 'ophys_analysis_log'
OPHYS_EXPERIMENTS_KEY = 'ophys_experiments'
OPHYS_SESSIONS_KEY = 'ophys_sessions'
add_manifest_paths(self, manifest_builder)[source]

Add cache-class specific paths to the manifest. In derived classes, should call super.

classmethod from_lims(manifest: Union[str, pathlib.Path, NoneType] = None, version: Union[str, NoneType] = None, cache: bool = True, fetch_tries: int = 2, lims_credentials: Union[allensdk.core.authentication.DbCredentials, NoneType] = None, mtrain_credentials: Union[allensdk.core.authentication.DbCredentials, NoneType] = None, host: Union[str, NoneType] = None, scheme: Union[str, NoneType] = None, asynchronous: bool = True) → 'BehaviorProjectCache'[source]

Construct a BehaviorProjectCache with a lims api. Use this method to create a BehaviorProjectCache instance rather than calling BehaviorProjectCache directly.

Parameters:
manifest : str or Path

full path at which manifest json will be stored

version : str

version of manifest file. If this mismatches the version recorded in the file at manifest, an error will be raised.

cache : bool

Whether to write to the cache

fetch_tries : int

Maximum number of times to attempt a download before giving up and raising an exception. Note that this is total tries, not retries

lims_credentials : DbCredentials

Optional credentials to access LIMS database. If not set, will look for credentials in environment variables.

mtrain_credentials: DbCredentials

Optional credentials to access mtrain database. If not set, will look for credentials in environment variables.

host : str

Web host for the app_engine. Currently unused. This argument is included for consistency with EcephysProjectCache.from_lims.

scheme : str

URI scheme, such as “http”. Currently unused. This argument is included for consistency with EcephysProjectCache.from_lims.

asynchronous : bool

Whether to fetch from web asynchronously. Currently unused.

Returns
=======
BehaviorProjectCache

BehaviorProjectCache instance with a LIMS fetch API

get_behavior_session_data(self, behavior_session_id: int, fixed: bool = False)[source]

Note – This method mocks the behavior of a cache. No files are actually downloaded for local access. Instead, it adds the session id to a csv log. If the “fixed” parameter is true, then the API will first check to ensure that the log is present in the record before pulling the data.

get_behavior_session_table(self, suppress: Union[List[str], NoneType] = None) → pandas.core.frame.DataFrame[source]

Return summary table of all behavior_session_ids in the database. :param suppress: optional list of columns to drop from the resulting

dataframe.
Return type:pd.DataFrame
get_experiment_table(self, suppress: Union[List[str], NoneType] = None) → pandas.core.frame.DataFrame[source]

Return summary table of all ophys_experiment_ids in the database. :param suppress: optional list of columns to drop from the resulting

dataframe.
Return type:pd.DataFrame
get_session_data(self, ophys_experiment_id: int, fixed: bool = False)[source]

Note – This method mocks the behavior of a cache. No files are actually downloaded for local access. Instead, it adds the session id to a csv log. If the “fixed” parameter is true, then the API will first check to ensure that the log is present in the record before pulling the data.

get_session_table(self, suppress: Union[List[str], NoneType] = None, by: str = 'ophys_session_id') → pandas.core.frame.DataFrame[source]

Return summary table of all ophys_session_ids in the database. :param suppress: optional list of columns to drop from the resulting

dataframe.
Parameters:by (str) – (default=”ophys_session_id”). Column to index on, either “ophys_session_id” or “ophys_experiment_id”. If by=”ophys_experiment_id”, then each row will only have one experiment id, of type int (vs. an array of 1>more).
Return type:pd.DataFrame