allensdk.brain_observatory.ecephys.ecephys_project_cache module

class allensdk.brain_observatory.ecephys.ecephys_project_cache.EcephysProjectCache(fetch_api: EcephysProjectApi | None = None, fetch_tries: int = 2, stream_writer: Callable | None = None, manifest: str | Path | None = None, version: str | None = None, cache: bool = True)[source]

Bases: Cache

CHANNELS_KEY = 'channels'
MANIFEST_VERSION = '0.3.0'
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(manifest_builder)[source]

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

classmethod fixed(manifest: str | Path | None = None, version: str | None = 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:
manifeststr or Path

full path to existing manifest json

versionstr

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: DbCredentials | None = None, scheme: str | None = None, host: str | None = None, asynchronous: bool = False, manifest: str | Path | None = None, version: str | None = 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_credentialsDbCredentials

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

schemestr

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

hoststr

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

asynchronousbool

Whether to fetch file asynchronously. Defaults to False.

manifeststr or Path

full path at which manifest json will be stored

versionstr

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_triesint

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: str | None = None, host: str | None = None, asynchronous: bool = False, manifest: str | Path | None = None, version: str | None = None, cache: bool = True, fetch_tries: int = 2, timeout: int = 1200)[source]

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

Parameters:
schemestr

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

hoststr

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

asynchronousbool

Whether to fetch file asynchronously. Defaults to False.

manifeststr or Path

full path at which manifest json will be stored

versionstr

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_triesint

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

timeoutint

Amount of time (in seconds) to wait on an HTTP request before raising an error. Increase this duration if you find that warehouse servers are not responding quickly. Defaults to 1200 seconds (20 minutes).

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

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

get_natural_movie_template(number)[source]
get_natural_scene_template(number)[source]
get_probes(suppress=None)[source]
get_session_data(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(suppress=None) DataFrame[source]
get_structure_acronyms(**channel_kwargs) List[str][source]
get_unit_analysis_metrics_by_session_type(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_typestr

identifies the session type for which to fetch analysis metrics.

annotatebool, optional

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

filter_by_validitybool, 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:
metricspd.DataFrame

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

get_unit_analysis_metrics_for_session(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_idint

identifies the session from which to fetch analysis metrics.

annotatebool, optional

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

filter_by_validitybool, 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:
metricspd.DataFrame

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

get_units(suppress: List[str] | None = None, filter_by_validity: bool = True, **unit_filter_kwargs) DataFrame[source]

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

Parameters:
suppressOptional[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_validitybool, 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) 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]