allensdk.brain_observatory.behavior.session_apis.data_transforms.behavior_ophys_data_transforms module

class allensdk.brain_observatory.behavior.session_apis.data_transforms.behavior_ophys_data_transforms.BehaviorOphysDataTransforms(extractor: allensdk.brain_observatory.behavior.session_apis.abcs.data_extractor_base.behavior_ophys_data_extractor_base.BehaviorOphysDataExtractorBase, skip_eye_tracking: bool)[source]

Bases: allensdk.brain_observatory.behavior.session_apis.data_transforms.behavior_data_transforms.BehaviorDataTransforms, allensdk.brain_observatory.behavior.session_apis.abcs.session_base.behavior_ophys_base.BehaviorOphysBase

This class provides methods that transform data extracted from LIMS or JSON data sources into final data products necessary for populating a BehaviorOphysExperiment

get_average_projection(self, image_api=None)[source]

Get an image whose values are the average obtained values at each pixel of the ophys movie over time.

Returns:
allensdk.brain_observatory.behavior.image_api.Image:

Array-like interface to avg projection image data and metadata.

get_cell_roi_ids(self)[source]
get_cell_specimen_table(self)[source]

Get a cell specimen dataframe containing ROI information about cells identified in an ophys experiment.

Returns:
pd.DataFrame

Cell ROI information organized into a dataframe. Index is the cell ROI IDs.

get_corrected_fluorescence_traces(self)[source]

Get motion-corrected fluorescence traces.

Returns:
pd.DataFrame

Motion-corrected fluorescence traces organized into a dataframe. Index is the cell ROI IDs.

get_dff_traces(self)[source]

Get a table of delta fluorescence over fluorescence traces.

Returns:
pd.DataFrame

The traces of dff (normalized fluorescence) organized into a dataframe. Index is the cell ROI IDs.

get_events(self, filter_scale: float = 2, filter_n_time_steps: int = 20) → pandas.core.frame.DataFrame[source]

Returns events in dataframe format

Parameters:
filter_scale: float

See filter_events_array for description

filter_n_time_steps: int

See filter_events_array for description

See behavior_ophys_experiment.events for return type
get_eye_tracking(self, z_threshold: float = 3.0, dilation_frames: int = 2) → Union[pandas.core.frame.DataFrame, NoneType][source]

Gets corneal, eye, and pupil ellipse fit data

Parameters:
z_threshold : float, optional

The z-threshold when determining which frames likely contain outliers for eye or pupil areas. Influences which frames are considered ‘likely blinks’. By default 3.0

dilation_frames : int, optional

Determines the number of additional adjacent frames to mark as

‘likely_blink’, by default 2.

Returns:
Optional[pd.DataFrame]

*_area *_center_x *_center_y *_height *_phi *_width likely_blink

where “*” can be “corneal”, “pupil” or “eye”
Will return None if class attr _skip_eye_tracking is True.
get_eye_tracking_rig_geometry(self) → Union[dict, NoneType][source]

Get eye tracking rig metadata from behavior + ophys session.

Returns:
dict

Includes geometry of monitor, camera, LED

get_max_projection(self, image_api=None)[source]

Get an image whose values are the maximum obtained values at each pixel of the ophys movie over time.

Returns:
allensdk.brain_observatory.behavior.image_api.Image:

Array-like interface to max projection image data and metadata.

get_metadata(self) → allensdk.brain_observatory.behavior.metadata.behavior_ophys_metadata.BehaviorOphysMetadata[source]

Return metadata about the session. :rtype: BehaviorOphysMetadata

get_monitor_delay(self)[source]

Return the monitor delay (in seconds)

get_motion_correction(self)[source]

Get motion correction trace data.

Returns:
pd.DataFrame

A dataframe containing trace data used during motion correction computation.

get_ophys_experiment_id(self)[source]

Returns the ophys_experiment_id for the instantiated BehaviorOphys Session (or BehaviorOphys data fetcher) if applicable.

get_ophys_session_id(self)[source]

Returns the behavior + ophys_session_id associated with this experiment, if applicable.

get_ophys_timestamps(self)[source]

Get optical physiology frame timestamps.

Returns:
np.ndarray

Timestamps associated with frames captured by the microscope.

get_raw_dff_data(self)[source]
get_rewards(self)[source]

Get reward data from pkl file, based on pkl file timestamps (not sync file).

Returns:pd.DataFrame – A dataframe containing timestamps of delivered rewards.
get_roi_masks_by_cell_roi_id(self, cell_roi_ids: Union[int, Iterable[int], NoneType] = None)[source]

Obtains boolean masks indicating the location of one or more ROIs in this session.

Parameters:
cell_roi_ids : array-like of int, optional

ROI masks for these rois will be returned. The default behavior is to return masks for all rois.

Returns:
result : xr.DataArray
dimensions are:
  • roi_id : which roi is described by this mask?
  • row : index within the underlying image
  • column : index within the image

values are 1 where an ROI was present, otherwise 0.

Notes

This method helps Allen Institute scientists to look at sessions that have not yet had cell specimen ids assigned. You probably want to use get_roi_masks instead.

get_stimulus_timestamps(self)[source]

Return a numpy array of stimulus timestamps uncorrected for monitor delay (in seconds)

get_sync_data(self)[source]
get_sync_licks(self)[source]