Source code for allensdk.brain_observatory.behavior.utils.metadata_parsers

from typing import Optional

from allensdk.brain_observatory.ophys.project_constants import (
    NUM_DEPTHS_DICT, NUM_STRUCTURES_DICT)


############################
#
#     from session type
#
############################


[docs]def parse_behavior_context(session_type: str) -> str: """Return if session is passive or active. Parameters ---------- session_type : str String session type name. Returns ------- behavior_type : str Return string describing active or passive session. """ is_passive = "passive" in session_type and "OPHYS" in session_type if is_passive: behavior_type = "passive_viewing" else: behavior_type = "active_behavior" return behavior_type
[docs]def parse_stimulus_set(session_type: str) -> str: """Return the name of the image set or gratings. Parameters ---------- session_type : str String session type name. Returns ------- stim_set : str Name of stimulus set shown for session. """ session_type_split = session_type.split("_") stimulus_type = session_type_split[2] if stimulus_type == "images": image_set_letter = session_type_split[3] stim_set = f"{stimulus_type}_{image_set_letter}" elif stimulus_type == "gratings": stim_set = "gratings" else: raise ValueError( f"Session_type {session_type} not formatted as " "expected." ) return stim_set
############################ # # from project code # ############################
[docs]def parse_num_cortical_structures(project_code: str) -> Optional[str]: """Return the number of structures that were targeted for this session. Parameters ---------- project_code : str Full project name of the experiment. Returns ------- num_structures : int Number of structures targeted for the session. """ return NUM_STRUCTURES_DICT.get(project_code, None)
[docs]def parse_num_depths(project_code: str) -> Optional[str]: """Return the number of depths that were imaged for the session. Parameters ---------- project_code : str Full project name of the experiment. Returns ------- num_depths : int Number of depths imaged for the session. """ return NUM_DEPTHS_DICT.get(project_code, None)