allensdk.brain_observatory.behavior.data_objects.stimuli.stimulus_templates module¶
- class allensdk.brain_observatory.behavior.data_objects.stimuli.stimulus_templates.StimulusImage(warped: ndarray, unwarped: ndarray, name: str)[source]¶
Bases:
objectContainer class for image stimuli
- property name¶
- class allensdk.brain_observatory.behavior.data_objects.stimuli.stimulus_templates.StimulusImageFactory[source]¶
Bases:
objectFactory for StimulusImage
- static from_processed(warped: ndarray, unwarped: ndarray, name: str) StimulusImage[source]¶
Creates a StimulusImage from processed input (usually nwb). Image has already been warped and preprocessed
- from_unprocessed(input_array: ndarray, name: str) StimulusImage[source]¶
Creates a StimulusImage from unprocessed input (usually pkl). Image needs to be warped and preprocessed
- class allensdk.brain_observatory.behavior.data_objects.stimuli.stimulus_templates.StimulusMovieFrameFactory[source]¶
Bases:
StimulusImageFactory
- class allensdk.brain_observatory.behavior.data_objects.stimuli.stimulus_templates.StimulusMovieTemplateFactory[source]¶
Bases:
StimulusTemplateFactoryModified stimulus template factory to read a natural movie.
- static from_unprocessed(movie_name: str, movie_frames: List[ndarray], n_workers: int | None = None) StimulusTemplate[source]¶
Create StimulusTemplate from pkl or unprocessed input. Stimulus templates created this way need to be processed to acquire unwarped versions of the movie frames presented.
NOTE: Warped movie frames display what was seen on a monitor by a subject. Unwarped images display a ‘diagnostic’ version of the stimuli to be presented.
- Parameters:
- movie_namestr
- The name of the image set. Example:
Natural_Images_Lum_Matched_set_TRAINING_2017.07.14
- movie_framesList[np.ndarray]
A list of image arrays
- n_workersint, Optional
Number of processes to spawn to warp movie frames. Defaults to os.cpu_count if not specified.
- Returns:
- StimulusTemplate
A StimulusTemplate object
- class allensdk.brain_observatory.behavior.data_objects.stimuli.stimulus_templates.StimulusTemplate(image_set_name: str, images: List[StimulusImage])[source]¶
Bases:
objectContainer class for a collection of image stimuli
- property image_names: List[str]¶
- property image_set_name: str¶
- property images: List[StimulusImage]¶
- to_dataframe(index_name: str = 'image_name', index_type: str = 'str') DataFrame[source]¶
Convert the collection of stimulus templates to a dataframe.
- Parameters:
- index_namestr
Name apply to the index column of the data frame to return. Defaults to “image_name”.
- index_typestr
Type of the index of the dataframe to set. Defaults to ‘str’.
- Returns:
- dfpandas.DataFrame
Dataframe containing an index and two columns: warped, unwarped. (un)warped columns return as a list of lists representing the displayed image/frame.
- class allensdk.brain_observatory.behavior.data_objects.stimuli.stimulus_templates.StimulusTemplateFactory[source]¶
Bases:
objectFactory for StimulusTemplate
- static from_processed(image_set_name: str, image_attributes: List[dict], unwarped: List[ndarray], warped: List[ndarray]) StimulusTemplate[source]¶
Create StimulusTemplate from nwb or other processed input. Stimulus templates created this way DO NOT need to be processed to acquire unwarped versions of the images presented.
NOTE: The ordering of image_attributes, unwarped, and warped matter!
NOTE: Warped images display what was seen on a monitor by a subject. Unwarped images display a ‘diagnostic’ version of the stimuli to be presented.
- Parameters:
- image_set_namestr
- The name of the image set. Example:
Natural_Images_Lum_Matched_set_TRAINING_2017.07.14
- image_attributesList[dict]
A list of dictionaries containing image metadata. Must at least contain the key:
image_name
- But will usually also contain:
image_category, orientation, phase, spatial_frequency, image_index
- unwarpedList[np.ndarray]
A list of unwarped image arrays
- warpedList[np.ndarray]
A list of warped image arrays
- Returns:
- StimulusTemplate
A StimulusTemplate object
- static from_unprocessed(image_set_name: str, image_attributes: List[dict], images: List[ndarray]) StimulusTemplate[source]¶
Create StimulusTemplate from pkl or unprocessed input. Stimulus templates created this way need to be processed to acquire unwarped versions of the images presented.
NOTE: The ordering of image_attributes and images matter!
NOTE: Warped images display what was seen on a monitor by a subject. Unwarped images display a ‘diagnostic’ version of the stimuli to be presented.
- Parameters:
- image_set_namestr
- The name of the image set. Example:
Natural_Images_Lum_Matched_set_TRAINING_2017.07.14
- image_attributesList[dict]
A list of dictionaries containing image metadata. Must at least contain the key:
image_name
- But will usually also contain:
image_category, orientation, phase, spatial_frequency, image_index
- imagesList[np.ndarray]
A list of image arrays
- Returns:
- StimulusTemplate
A StimulusTemplate object