allensdk.api.queries.brain_observatory_api module¶
-
class
allensdk.api.queries.brain_observatory_api.
BrainObservatoryApi
(base_uri=None, datacube_uri=None)[source]¶ Bases:
allensdk.api.queries.rma_template.RmaTemplate
-
CELL_MAPPING_ID
= 590985414¶
-
NWB_FILE_TYPE
= 'NWBOphys'¶
-
dataframe_query
(data, filters, primary_key)[source]¶ Given a list of dictionary records and a list of filter dictionaries, filter the records using Pandas and return the filtered set of records.
Parameters: - data: list of dicts
List of dictionaries
- filters: list of dicts
Each dictionary describes a filtering operation on a field in the dictionary. The general form is { ‘field’: <field>, ‘op’: <operation>, ‘value’: <filter_value(s)> }. For example, you can apply a threshold on the “osi_dg” column with something like this: { ‘field’: ‘osi_dg’, ‘op’: ‘>’, ‘value’: 1.0 }. See _QUERY_TEMPLATES for a full list of operators.
-
dataframe_query_string
(filters)[source]¶ Convert a list of cell metric filter dictionaries into a Pandas query string.
-
filter_cell_specimens
(cell_specimens, ids=None, experiment_container_ids=None, include_failed=False, filters=None)[source]¶ Filter a list of cell specimen records returned from the get_cell_metrics method according some of their properties.
Parameters: - cell_specimens: list of dicts
List of records returned by the get_cell_metrics method.
- ids: list of integers
Return only records for cells with cell specimen ids in this list
- experiment_container_ids: list of integers
Return only records for cells that belong to experiment container ids in this list
- include_failed: bool
Whether to include cells from failed experiment containers
- filters: list of dicts
Custom query used to reproduce filter sets created in the Allen Brain Observatory web application. The general form is a list of dictionaries each of which describes a filtering operation based on a metric. For more information, see dataframe_query.
-
filter_experiment_containers
(containers, ids=None, targeted_structures=None, imaging_depths=None, transgenic_lines=None, include_failed=False)[source]¶
-
filter_ophys_experiments
(experiments, ids=None, experiment_container_ids=None, targeted_structures=None, imaging_depths=None, transgenic_lines=None, stimuli=None, session_types=None, include_failed=False, require_eye_tracking=False)[source]¶
-
get_cell_metrics
(**kwargs)[source]¶ Get cell metrics by id
Parameters: - cell_metrics_ids : integer or list of integers, optional
only select specific cell metric records.
Returns: - dict : cell metric metadata
-
get_cell_specimen_id_mapping
(file_name, mapping_table_id=None)[source]¶ Download mapping table from old to new cell specimen IDs.
The mapping table is a CSV file that maps cell specimen ids that have changed between processing runs of the Brain Observatory pipeline.
Parameters: - file_name : string
Filename to save locally.
- mapping_table_id : integer
ID of the mapping table file. Defaults to the most recent mapping table.
Returns: - pandas.DataFrame
Mapping table as a DataFrame.
-
get_column_definitions
(api_class_name=None)[source]¶ Get column definitions
Parameters: - api_class_names : string or list of strings, optional
only select specific column definition records.
Returns: - dict : column definition metadata
-
get_experiment_container_metrics
(experiment_container_metric_ids=None)[source]¶ Get experiment container metrics by id
Parameters: - isi_experiment_ids : integer or list of integers, optional
only select specific experiments.
Returns: - dict : isi experiment metadata
-
get_experiment_containers
(**kwargs)[source]¶ Get experiment container by id
Parameters: - experiment_container_ids : integer or list of integers, optional
only select specific experiment containers.
Returns: - dict : experiment container metadata
-
get_isi_experiments
(isi_experiment_ids=None)[source]¶ Get ISI Experiments by id
Parameters: - isi_experiment_ids : integer or list of integers, optional
only select specific experiments.
Returns: - dict : isi experiment metadata
-
get_ophys_experiments
(**kwargs)[source]¶ Get OPhys Experiments by id
Parameters: - ophys_experiment_ids : integer or list of integers, optional
only select specific experiments.
Returns: - dict : ophys experiment metadata
-
get_stimulus_mappings
(**kwargs)[source]¶ Get stimulus mappings by id
Parameters: - stimulus_mapping_ids : integer or list of integers, optional
only select specific stimulus mapping records.
Returns: - dict : stimulus mapping metadata
-
list_column_definition_class_names
()[source]¶ Get column definitions
Returns: - list : api class name strings
-
list_isi_experiments
(isi_ids=None)[source]¶ List ISI experiments available through the Allen Institute API
Parameters: - neuronal_model_ids : integer or list of integers, optional
only select specific isi experiments.
Returns: - dict : neuronal model metadata
-
rma_templates
= {'brain_observatory_queries': [{'count': False, 'name': 'list_isi_experiments', 'criteria_params': [], 'num_rows': 'all', 'model': 'IsiExperiment', 'description': 'see name'}, {'count': False, 'criteria_params': ['isi_experiment_ids'], 'name': 'isi_experiment_by_ids', 'criteria': '[id$in{{ isi_experiment_ids }}]', 'num_rows': 'all', 'model': 'IsiExperiment', 'include': 'experiment_container(ophys_experiments,targeted_structure)', 'description': 'see name'}, {'count': False, 'criteria_params': ['ophys_experiment_ids'], 'name': 'ophys_experiment_by_ids', 'criteria': '{% if ophys_experiment_ids is defined %}[id$in{{ ophys_experiment_ids }}]{%endif%}', 'num_rows': 'all', 'model': 'OphysExperiment', 'include': 'experiment_container,well_known_files(well_known_file_type),targeted_structure,specimen(donor(age,transgenic_lines))', 'description': 'see name'}, {'count': False, 'name': 'ophys_experiment_data', 'criteria_params': ['ophys_experiment_id'], 'criteria': '[attachable_id$eq{{ ophys_experiment_id }}],well_known_file_type[name$eqNWBOphys]', 'num_rows': 'all', 'model': 'WellKnownFile', 'description': 'see name'}, {'count': False, 'name': 'column_definitions', 'criteria_params': ['api_class_name'], 'criteria': '[api_class_name$eq{{ api_class_name }}]', 'num_rows': 'all', 'model': 'ApiColumnDefinition', 'description': 'see name'}, {'count': False, 'name': 'column_definition_class_names', 'only': ['api_class_name'], 'num_rows': 'all', 'model': 'ApiColumnDefinition', 'description': 'see name'}, {'count': False, 'name': 'stimulus_mapping', 'criteria_params': ['stimulus_mapping_ids'], 'criteria': '{% if stimulus_mapping_ids is defined %}[id$in{{ stimulus_mapping_ids }}]{%endif%}', 'num_rows': 'all', 'model': 'ApiCamStimulusMapping', 'description': 'see name'}, {'count': False, 'criteria_params': ['experiment_container_ids'], 'name': 'experiment_container', 'criteria': '{% if experiment_container_ids is defined %}[id$in{{ experiment_container_ids }}]{%endif%}', 'num_rows': 'all', 'model': 'ExperimentContainer', 'include': 'ophys_experiments,isi_experiment,specimen(donor(conditions,age,transgenic_lines)),targeted_structure', 'description': 'see name'}, {'count': False, 'name': 'experiment_container_metric', 'criteria_params': ['experiment_container_metric_ids'], 'criteria': '{% if experiment_container_metric_ids is defined %}[id$in{{ experiment_container_metric_ids }}]{%endif%}', 'num_rows': 'all', 'model': 'ApiCamExperimentContainerMetric', 'description': 'see name'}, {'model': 'ApiCamCellMetric', 'criteria': '{% if cell_specimen_ids is defined %}[cell_specimen_id$in{{ cell_specimen_ids }}]{%endif%}', 'name': 'cell_metric', 'criteria_params': ['cell_specimen_ids'], 'description': 'see name'}, {'count': False, 'name': 'cell_specimen_id_mapping_table', 'criteria_params': ['mapping_table_id'], 'criteria': '[id$eq{{ mapping_table_id }}],well_known_file_type[name$eqOphysCellSpecimenIdMapping]', 'num_rows': 'all', 'model': 'WellKnownFile', 'description': 'see name'}]}¶
-