allensdk.brain_observatory.nwb package

Module contents

allensdk.brain_observatory.nwb.add_average_image(nwbfile, average_image, image_api=None)[source]
allensdk.brain_observatory.nwb.add_cell_specimen_table(nwbfile: pynwb.file.NWBFile, cell_specimen_table: pandas.core.frame.DataFrame, session_metadata: dict)[source]

This function takes the cell specimen table and writes the ROIs contained within. It writes these to a new NWB imaging plane based off the previously supplied metadata

Parameters:
nwbfile: NWBFile

this is the in memory NWBFile currently being written to which ROI data is added

cell_specimen_table: pd.DataFrame

this is the DataFrame containing the cells segmented from a ophys experiment, stored in json file and loaded. example: /home/nicholasc/projects/allensdk/allensdk/test/

brain_observatory/behavior/cell_specimen_table_789359614.json

session_metadata: dict

Dictionary containing cell_specimen_table related metadata. Should include at minimum the following fields:

“emission_lambda”, “excitation_lambda”, “indicator”, “targeted_structure”, and ophys_frame_rate”

Returns:
nwbfile: NWBFile

The altered in memory NWBFile object that now has a specimen table

allensdk.brain_observatory.nwb.add_corrected_fluorescence_traces(nwbfile, corrected_fluorescence_traces)[source]
allensdk.brain_observatory.nwb.add_dff_traces(nwbfile, dff_traces, ophys_timestamps)[source]
allensdk.brain_observatory.nwb.add_eye_gaze_data_interfaces(pynwb_container: pynwb.core.NWBContainer, pupil_areas: pandas.core.series.Series, eye_areas: pandas.core.series.Series, screen_coordinates: pandas.core.frame.DataFrame, screen_coordinates_spherical: pandas.core.frame.DataFrame, synced_timestamps: pandas.core.series.Series) → pynwb.core.NWBContainer[source]
allensdk.brain_observatory.nwb.add_eye_gaze_mapping_data_to_nwbfile(nwbfile: pynwb.file.NWBFile, eye_gaze_data: dict) → pynwb.file.NWBFile[source]
allensdk.brain_observatory.nwb.add_eye_tracking_ellipse_fit_data_to_nwbfile(nwbfile: pynwb.file.NWBFile, eye_dlc_tracking_data: dict, synced_timestamps: pandas.core.series.Series) → pynwb.file.NWBFile[source]
allensdk.brain_observatory.nwb.add_image(nwbfile, image_data, image_name, module_name, module_description, image_api=None)[source]
allensdk.brain_observatory.nwb.add_invalid_times(nwbfile, epochs)[source]

Write invalid times to nwbfile if epochs are not empty Parameters ———- nwbfile: pynwb.NWBFile epochs: list of dicts

records of invalid epochs
Returns:
pynwb.NWBFile
allensdk.brain_observatory.nwb.add_licks(nwbfile, licks)[source]
allensdk.brain_observatory.nwb.add_max_projection(nwbfile, max_projection, image_api=None)[source]
allensdk.brain_observatory.nwb.add_metadata(nwbfile, metadata: dict, behavior_only: bool)[source]
allensdk.brain_observatory.nwb.add_motion_correction(nwbfile, motion_correction)[source]
allensdk.brain_observatory.nwb.add_rewards(nwbfile, rewards_df)[source]
allensdk.brain_observatory.nwb.add_running_acquisition_to_nwbfile(nwbfile, running_acquisition_df: pandas.core.frame.DataFrame)[source]
allensdk.brain_observatory.nwb.add_running_speed_to_nwbfile(nwbfile, running_speed, name='speed', unit='cm/s', from_dataframe=False)[source]

Adds running speed data to an NWBFile as a timeseries in acquisition

Parameters:
nwbfile : pynwb.NWBFile

File to which running speeds will be written

running_speed : Union[RunningSpeed, pd.DataFrame]

Either a RunningSpeed object or pandas DataFrame. Contains attributes ‘values’ and ‘timestamps’

name : str, optional

Used as name of timeseries object

unit : str, optional

SI units of running speed values

from_dataframe : bool, optional

Whether running_speed is a dataframe or not. Default is False.

Returns:
nwbfile : pynwb.NWBFile
allensdk.brain_observatory.nwb.add_segmentation_mask_image(nwbfile, segmentation_mask_image, image_api=None)[source]
allensdk.brain_observatory.nwb.add_stimulus_timestamps(nwbfile, stimulus_timestamps, module_name='stimulus')[source]
allensdk.brain_observatory.nwb.add_task_parameters(nwbfile, task_parameters)[source]
allensdk.brain_observatory.nwb.add_trials(nwbfile, trials, description_dict={})[source]
allensdk.brain_observatory.nwb.check_nwbfile_version(nwbfile_path: str, desired_minimum_version: str, warning_msg: str)[source]
allensdk.brain_observatory.nwb.create_eye_gaze_mapping_dataframe(eye_gaze_data: dict) → pandas.core.frame.DataFrame[source]
allensdk.brain_observatory.nwb.create_eye_tracking_nwb_processing_module(eye_dlc_tracking_data: dict, synced_timestamps: pandas.core.series.Series) → pynwb.base.ProcessingModule[source]
allensdk.brain_observatory.nwb.create_gaze_mapping_nwb_processing_modules(eye_gaze_data: dict)[source]
allensdk.brain_observatory.nwb.create_stimulus_presentation_time_interval(name: str, description: str, columns_to_add: Iterable) → pynwb.epoch.TimeIntervals[source]
allensdk.brain_observatory.nwb.eye_tracking_data_is_valid(eye_dlc_tracking_data: dict, synced_timestamps: pandas.core.series.Series) → bool[source]
allensdk.brain_observatory.nwb.read_eye_dlc_tracking_ellipses(input_path: pathlib.Path) → dict[source]

Reads eye tracking ellipse fit data from an h5 file.

Args:
input_path (Path): Path to eye tracking ellipse fit h5 file
Returns:
dict: Loaded h5 data. Each ‘params’ field contains dataframes with]
ellipse fit parameters. Dataframes contain 5 columns each consisting of: “center_x”, “center_y”, “height”, “phi”, “width”
allensdk.brain_observatory.nwb.read_eye_gaze_mappings(input_path: pathlib.Path) → dict[source]

Reads eye gaze mapping data from an h5 file.

Args:
input_path (Path): Path to eye gaze mapping h5 data file produced by
‘allensdk.brain_observatory.gaze_mapping’ module.
Returns:
dict: Loaded h5 data.

*_eye_areas: Area of eye (in pixels^2) over time *_pupil_areas: Area of pupil (in pixels^2) over time *_screen_coordinates: y, x screen coordinates (in cm) over time *_screen_coordinates_spherical: y, x screen coordinates (in deg)

over time
synced_frame_timestamps: synced timestamps for video frames
(in sec)
allensdk.brain_observatory.nwb.setup_table_for_epochs(table, timeseries, tag)[source]
allensdk.brain_observatory.nwb.setup_table_for_invalid_times(invalid_epochs)[source]

Create table with invalid times if invalid_epochs are present

Parameters:
invalid_epochs: list of dicts

of invalid epoch records

Returns:
pd.DataFrame of invalid times if epochs are not empty,
otherwise return None