allensdk.brain_observatory.ecephys.ecephys_project_cache module

class allensdk.brain_observatory.ecephys.ecephys_project_cache.EcephysProjectCache(fetch_api: allensdk.brain_observatory.ecephys.ecephys_project_api.ecephys_project_api.EcephysProjectApi = <allensdk.brain_observatory.ecephys.ecephys_project_api.ecephys_project_warehouse_api.EcephysProjectWarehouseApi object>, fetch_tries: int = 2, stream_writer: Callable = <function write_from_stream>, manifest: Union[str, pathlib.Path, None] = None, version: Optional[str] = None, cache: bool = True)[source]

Bases: allensdk.api.cache.Cache

CHANNELS_KEY = 'channels'
MANIFEST_VERSION = '0.2.1'
NATURAL_MOVIE_DIR_KEY = 'movie_dir'
NATURAL_MOVIE_KEY = 'natural_movie'
NATURAL_SCENE_DIR_KEY = 'natural_scene_dir'
NATURAL_SCENE_KEY = 'natural_scene'
PROBES_KEY = 'probes'
PROBE_LFP_NWB_KEY = 'probe_lfp_nwb'
SESSIONS_KEY = 'sessions'
SESSION_ANALYSIS_METRICS_KEY = 'session_analysis_metrics'
SESSION_DIR_KEY = 'session_data'
SESSION_NWB_KEY = 'session_nwb'
SUPPRESS_FROM_CHANNELS = ('air_channel_index', 'surface_channel_index', 'name', 'date_of_acquisition', 'published_at', 'specimen_id', 'session_type', 'isi_experiment_id', 'age_in_days', 'sex', 'genotype', 'has_nwb', 'lfp_temporal_subsampling_factor')
SUPPRESS_FROM_PROBES = ('air_channel_index', 'surface_channel_index', 'date_of_acquisition', 'published_at', 'specimen_id', 'session_type', 'isi_experiment_id', 'age_in_days', 'sex', 'genotype', 'has_nwb', 'lfp_temporal_subsampling_factor')
SUPPRESS_FROM_SESSION_TABLE = ('has_nwb', 'isi_experiment_id', 'date_of_acquisition')
SUPPRESS_FROM_UNITS = ('air_channel_index', 'surface_channel_index', 'has_nwb', 'lfp_temporal_subsampling_factor', 'epoch_name_quality_metrics', 'epoch_name_waveform_metrics', 'isi_experiment_id')
TYPEWISE_ANALYSIS_METRICS_KEY = 'typewise_analysis_metrics'
UNITS_KEY = 'units'
add_manifest_paths(self, manifest_builder)[source]

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

classmethod fixed(manifest=None, version=None)[source]

Creates a EcephysProjectCache that refuses to fetch any data - only the existing local cache is accessible. Useful if you want to settle on a fixed dataset for analysis.

Parameters:
manifest : str or Path

full path to existing manifest json

version : str

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

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

Create an instance of EcephysProjectCache with an EcephysProjectLimsApi. Retrieves bleeding-edge data stored locally on Allen Institute servers. Only available for use on-site at the Allen Institute or through a vpn. Requires Allen Institute database credentials.

Parameters:
lims_credentials : DbCredentials

Credentials to access LIMS database. If not provided will attempt to find credentials in environment variables.

scheme : str

URI scheme, such as “http”. Defaults to EcephysProjectLimsApi.default value if unspecified. Will not be used unless host is also specified.

host : str

Web host. Defaults to EcephysProjectLimsApi.default value if unspecified. Will not be used unless scheme is also specified.

asynchronous : bool

Whether to fetch file asynchronously. Defaults to True.

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 (default=True)

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

classmethod from_warehouse(scheme: Union[str, NoneType] = None, host: Union[str, NoneType] = None, asynchronous: bool = True, manifest: Union[str, pathlib.Path, NoneType] = None, version: Union[str, NoneType] = None, cache: bool = True, fetch_tries: int = 2)[source]

Create an instance of EcephysProjectCache with an EcephysProjectWarehouseApi. Retrieves released data stored in the warehouse.

Parameters:
scheme : str

URI scheme, such as “http”. Defaults to EcephysProjectWarehouseAPI.default value if unspecified. Will not be used unless host is also specified.

host : str

Web host. Defaults to EcephysProjectWarehouseApi.default value if unspecified. Will not be used unless scheme is also specified.

asynchronous : bool

Whether to fetch file asynchronously. Defaults to True.

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 (default=True)

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

get_all_ages(self, **session_kwargs)[source]
get_all_full_genotypes(self, **session_kwargs)[source]
get_all_session_types(self, **session_kwargs)[source]
get_all_sexes(self, **session_kwargs)[source]
get_channels(self, suppress=None)[source]

Load (potentially downloading and caching) a table whose rows are individual channels.

get_natural_movie_template(self, number)[source]
get_natural_scene_template(self, number)[source]
get_probes(self, suppress=None)[source]
get_session_data(self, session_id: int, filter_by_validity: bool = True, **unit_filter_kwargs)[source]

Obtain an EcephysSession object containing detailed data for a single session

get_session_table(self, suppress=None) → pandas.core.frame.DataFrame[source]
get_structure_acronyms(self, **channel_kwargs) → List[str][source]
get_unit_analysis_metrics_by_session_type(self, session_type, annotate: bool = True, filter_by_validity: bool = True, **unit_filter_kwargs)[source]

Cache and return a table of analysis metrics calculated on each unit from a specified session type. See get_all_session_types for a list of session types.

Parameters:
session_type : str

identifies the session type for which to fetch analysis metrics.

annotate : bool, optional

if True, information from the annotated units table will be merged onto the outputs

filter_by_validity : bool, optional

Filter units used by analysis so that only ‘valid’ units are returned, by default True

**unit_filter_kwargs :

Additional keyword arguments that can be used to filter units (for power users).

Returns:
metrics : pd.DataFrame

Each row corresponds to a single unit, describing a set of analysis metrics calculated on that unit.

get_unit_analysis_metrics_for_session(self, session_id, annotate: bool = True, filter_by_validity: bool = True, **unit_filter_kwargs)[source]

Cache and return a table of analysis metrics calculated on each unit from a specified session. See get_session_table for a list of sessions.

Parameters:
session_id : int

identifies the session from which to fetch analysis metrics.

annotate : bool, optional

if True, information from the annotated units table will be merged onto the outputs

filter_by_validity : bool, optional

Filter units used by analysis so that only ‘valid’ units are returned, by default True

**unit_filter_kwargs :

Additional keyword arguments that can be used to filter units (for power users).

Returns:
metrics : pd.DataFrame

Each row corresponds to a single unit, describing a set of analysis metrics calculated on that unit.

get_units(self, suppress: Union[List[str], NoneType] = None, filter_by_validity: bool = True, **unit_filter_kwargs) → pandas.core.frame.DataFrame[source]

Reports a table consisting of all sorted units across the entire extracellular electrophysiology project.

Parameters:
suppress : Optional[List[str]], optional

A list of dataframe column names to hide, by default None (None will hide dataframe columns specified in: SUPPRESS_FROM_UNITS)

filter_by_validity : bool, optional

Filter units so that only ‘valid’ units are returned, by default True

**unit_filter_kwargs :

Additional keyword arguments that can be used to filter units (for power users).

Returns:
pd.DataFrame

A table consisting of sorted units across the entire extracellular electrophysiology project

allensdk.brain_observatory.ecephys.ecephys_project_cache.count_owned(this, other, foreign_key, count_key, inplace=False)[source]
allensdk.brain_observatory.ecephys.ecephys_project_cache.get_grouped_uniques(this, other, foreign_key, field_key, unique_key, inplace=False)[source]
allensdk.brain_observatory.ecephys.ecephys_project_cache.read_csv(path) → pandas.core.frame.DataFrame[source]
allensdk.brain_observatory.ecephys.ecephys_project_cache.read_metrics_csv(path)[source]
allensdk.brain_observatory.ecephys.ecephys_project_cache.read_movie(path)[source]
allensdk.brain_observatory.ecephys.ecephys_project_cache.read_nwb(path)[source]
allensdk.brain_observatory.ecephys.ecephys_project_cache.read_scene(path)[source]
allensdk.brain_observatory.ecephys.ecephys_project_cache.write_csv(path, df)[source]
allensdk.brain_observatory.ecephys.ecephys_project_cache.write_metrics_csv(path, df)[source]