allensdk.brain_observatory.behavior.data_files.stimulus_file module¶
- class allensdk.brain_observatory.behavior.data_files.stimulus_file.BehaviorStimulusFile(filepath: str | Path)[source]¶
Bases:
_StimulusFile- property behavior_session_uuid: UUID | None¶
Return the behavior session UUID either from the uuid field or foraging_id field.
- property date_of_acquisition: datetime¶
Return the date_of_acquisition as a datetime.datetime.
This will be read from self.data[‘start_time’]
- classmethod file_path_key() str[source]¶
The key in the dict_repr that maps to the path to this StimulusFile’s pickle file on disk.
- classmethod from_lims(db: PostgresQueryMixin, behavior_session_id: int | str) BehaviorStimulusFile[source]¶
Populate a DataFile from an internal database (likely LIMS)
- Returns:
- DataFile:
An instantiated DataFile which has data and filepath properties
- property mouse_id: str¶
Retrieve the mouse_id value from the stimulus pickle file.
This can be read either from:
data[‘items’][‘behavior’][‘params’][‘stage’] or data[‘items’][‘behavior’][‘cl_params’][‘stage’]
if both are present and they disagree, raise an exception.
- property num_frames: int¶
Return the number of frames associated with this StimulusFile
- property session_duration: float¶
Gets session duration in seconds
- Returns:
- session duration in seconds
- property session_type: str¶
Return the session type as read from the pickle file. This can be read either from
data[‘items’][‘behavior’][‘params’][‘stage’] or data[‘items’][‘behavior’][‘cl_params’][‘stage’]
if both are present and they disagree, raise an exception
- property stimuli: Dict[str, Tuple[str, str | int, int, int]]¶
Stimuli shown during session
- Returns:
- stimuli:
- (stimulus type (‘Image’ or ‘Grating’),
- stimulus descriptor (image_name or orientation of grating in
degrees),
nonsynced time of display, display frame (frame that stimuli was displayed))
- property stimulus_name: str¶
Get the image stimulus name by parsing the file path of the image set.
If no image set, check for gratings and return “behavior” if not found.
- Parameters:
- stimulus_fileBehaviorStimulusFile
Stimulus pickle file to parse.
- Returns:
- stimulus_namestr
Name of the image stimulus from the image file path set shown to the mouse.
- validate() BehaviorStimulusFile[source]¶
- exception allensdk.brain_observatory.behavior.data_files.stimulus_file.MalformedStimulusFileError[source]¶
Bases:
RuntimeErrorMalformed stimulus file
- class allensdk.brain_observatory.behavior.data_files.stimulus_file.MappingStimulusFile(filepath: str | Path)[source]¶
Bases:
_StimulusFile
- class allensdk.brain_observatory.behavior.data_files.stimulus_file.ReplayStimulusFile(filepath: str | Path)[source]¶
Bases:
_StimulusFile
- class allensdk.brain_observatory.behavior.data_files.stimulus_file.StimulusFileLookup[source]¶
Bases:
objectA container class to carry around the StimulusFile(s) associated with a BehaviorSession
- property behavior_stimulus_file: BehaviorStimulusFile¶
- property mapping_stimulus_file: MappingStimulusFile¶
- property replay_stimulus_file: ReplayStimulusFile¶
- class allensdk.brain_observatory.behavior.data_files.stimulus_file.StimulusFileReadableInterface[source]¶
Bases:
ABCMarks a data object as readable from stimulus file
- abstractmethod classmethod from_stimulus_file(stimulus_file: BehaviorStimulusFile) DataObject[source]¶
Populate a DataObject from the stimulus file
- Returns:
- DataObject:
An instantiated DataObject which has name and value properties
- allensdk.brain_observatory.behavior.data_files.stimulus_file.from_json_cache_key(cls, stimulus_file_path: str)[source]¶
- allensdk.brain_observatory.behavior.data_files.stimulus_file.from_lims_cache_key(cls, db, behavior_session_id: int)[source]¶
- allensdk.brain_observatory.behavior.data_files.stimulus_file.stimulus_lookup_from_json(dict_repr: dict) StimulusFileLookup[source]¶
Load a lookup table of the stimulus files associated with a BehaviorSession from the dict representation of that session’s session_data