allensdk.core.brain_observatory_cache module

class allensdk.core.brain_observatory_cache.BrainObservatoryCache(cache=True, manifest_file='brain_observatory_manifest.json', base_uri=None, api=None)[source]

Bases: allensdk.api.cache.Cache

Cache class for storing and accessing data from the Brain Observatory. By default, this class will cache any downloaded metadata or files in well known locations defined in a manifest file. This behavior can be disabled.

Parameters:
cache: boolean

Whether the class should save results of API queries to locations specified in the manifest file. Queries for files (as opposed to metadata) must have a file location. If caching is disabled, those locations must be specified in the function call (e.g. get_ophys_experiment_data(file_name=’file.nwb’)).

manifest_file: string

File name of the manifest to be read. Default is “brain_observatory_manifest.json”.

Attributes:
api: BrainObservatoryApi instance

The object used for making API queries related to the Brain Observatory.

CELL_SPECIMENS_KEY = 'CELL_SPECIMENS'
EXPERIMENTS_KEY = 'EXPERIMENTS'
EXPERIMENT_CONTAINERS_KEY = 'EXPERIMENT_CONTAINERS'
EXPERIMENT_DATA_KEY = 'EXPERIMENT_DATA'
MANIFEST_VERSION = None
STIMULUS_MAPPINGS_KEY = 'STIMULUS_MAPPINGS'
build_manifest(file_name)[source]

Construct a manifest for this Cache class and save it in a file.

Parameters:
file_name: string

File location to save the manifest.

get_all_cre_lines()[source]

Return a list of all cre driver lines in the data set.

get_all_imaging_depths()[source]

Return a list of all imaging depths in the data set.

get_all_reporter_lines()[source]

Return a list of all reporter lines in the data set.

get_all_session_types()[source]

Return a list of all stimulus sessions in the data set.

get_all_stimuli()[source]

Return a list of all stimuli in the data set.

get_all_targeted_structures()[source]

Return a list of all targeted structures in the data set.

get_cell_specimens(file_name=None, ids=None, experiment_container_ids=None, include_failed=False, simple=True, filters=None)[source]

Return cell specimens that have certain properies.

Parameters:
file_name: string

File name to save/read the cell specimens. If file_name is None, the file_name will be pulled out of the manifest. If caching is disabled, no file will be saved. Default is None.

ids: list

List of cell specimen ids.

experiment_container_ids: list

List of experiment container ids.

include_failed: bool

Whether to include cells from failed experiment containers

simple: boolean

Whether or not to simplify the dictionary properties returned by this method to a more concise subset.

filters: list of dicts

List of filter dictionaries. The Allen Brain Observatory web site can generate filters in this format to reproduce a filtered set of cells found there. To see what these look like, visit http://observatory.brain-map.org/visualcoding, perform a cell search and apply some filters (e.g. find cells in a particular area), then click the “view these cells in the AllenSDK” link on the bottom-left of the search results page. This will take you to a page that contains a code sample you can use to apply those same filters via this argument. For more detail on the filter syntax, see BrainObservatoryApi.dataframe_query.

Returns:
list of dictionaries
get_experiment_containers(file_name=None, ids=None, targeted_structures=None, imaging_depths=None, cre_lines=None, transgenic_lines=None, include_failed=False, simple=True)[source]

Get a list of experiment containers matching certain criteria.

Parameters:
file_name: string

File name to save/read the experiment containers. If file_name is None, the file_name will be pulled out of the manifest. If caching is disabled, no file will be saved. Default is None.

ids: list

List of experiment container ids.

targeted_structures: list

List of structure acronyms. Must be in the list returned by BrainObservatoryCache.get_all_targeted_structures().

imaging_depths: list

List of imaging depths. Must be in the list returned by BrainObservatoryCache.get_all_imaging_depths().

cre_lines: list

List of cre lines. Must be in the list returned by BrainObservatoryCache.get_all_cre_lines().

transgenic_lines: list

List of transgenic lines. Must be in the list returned by BrainObservatoryCache.get_all_cre_lines() or. BrainObservatoryCache.get_all_reporter_lines().

include_failed: boolean

Whether or not to include failed experiment containers.

simple: boolean

Whether or not to simplify the dictionary properties returned by this method to a more concise subset.

Returns:
list of dictionaries
get_ophys_experiment_data(ophys_experiment_id, file_name=None)[source]

Download the NWB file for an ophys_experiment (if it hasn’t already been downloaded) and return a data accessor object.

Parameters:
file_name: string

File name to save/read the data set. If file_name is None, the file_name will be pulled out of the manifest. If caching is disabled, no file will be saved. Default is None.

ophys_experiment_id: integer

id of the ophys_experiment to retrieve

Returns:
BrainObservatoryNwbDataSet
get_ophys_experiment_stimuli(experiment_id)[source]

For a single experiment, return the list of stimuli present in that experiment.

get_ophys_experiments(file_name=None, ids=None, experiment_container_ids=None, targeted_structures=None, imaging_depths=None, cre_lines=None, transgenic_lines=None, stimuli=None, session_types=None, cell_specimen_ids=None, include_failed=False, require_eye_tracking=False, simple=True)[source]

Get a list of ophys experiments matching certain criteria.

Parameters:
file_name: string

File name to save/read the ophys experiments. If file_name is None, the file_name will be pulled out of the manifest. If caching is disabled, no file will be saved. Default is None.

ids: list

List of ophys experiment ids.

experiment_container_ids: list

List of experiment container ids.

targeted_structures: list

List of structure acronyms. Must be in the list returned by BrainObservatoryCache.get_all_targeted_structures().

imaging_depths: list

List of imaging depths. Must be in the list returned by BrainObservatoryCache.get_all_imaging_depths().

cre_lines: list

List of cre lines. Must be in the list returned by BrainObservatoryCache.get_all_cre_lines().

transgenic_lines: list

List of transgenic lines. Must be in the list returned by BrainObservatoryCache.get_all_cre_lines() or. BrainObservatoryCache.get_all_reporter_lines().

stimuli: list

List of stimulus names. Must be in the list returned by BrainObservatoryCache.get_all_stimuli().

session_types: list

List of stimulus session type names. Must be in the list returned by BrainObservatoryCache.get_all_session_types().

cell_specimen_ids: list

Only include experiments that contain cells with these ids.

include_failed: boolean

Whether or not to include experiments from failed experiment containers.

simple: boolean

Whether or not to simplify the dictionary properties returned by this method to a more concise subset.

require_eye_tracking: boolean

If True, only return experiments that have eye tracking results. Default: False.

Returns:
list of dictionaries