allensdk.brain_observatory.nwb package¶
Submodules¶
Module contents¶
-
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_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 epochsReturns: - pynwb.NWBFile
-
allensdk.brain_observatory.nwb.
add_running_data_df_to_nwbfile
(nwbfile, running_data_df, unit_dict, index_key='timestamps')[source]¶ Adds running speed data to an NWBFile as timeseries in acquisition and processing
Parameters: - nwbfile : pynwb.NWBFile
File to which runnign speeds will be written
- running_speed : pandas.DataFrame
Contains ‘speed’ and ‘times’, ‘v_in’, ‘vsig’, ‘dx’
- unit : str, optional
SI units of running speed values
Returns: - nwbfile : pynwb.NWBFile
-
allensdk.brain_observatory.nwb.
add_running_speed_to_nwbfile
(nwbfile, running_speed, name='speed', unit='cm/s')[source]¶ Adds running speed data to an NWBFile as a timeseries in acquisition
Parameters: - nwbfile : pynwb.NWBFile
File to which runnign speeds will be written
- running_speed : RunningSpeed
Contains attributes ‘values’ and ‘timestamps’
- name : str, optional
used as name of timeseries object
- unit : str, optional
SI units of running speed values
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_presentations
(nwbfile, stimulus_table, tag='stimulus_time_interval')[source]¶ Adds a stimulus table (defining stimulus characteristics for each time point in a session) to an nwbfile as TimeIntervals.
Parameters: - nwbfile : pynwb.NWBFile
- stimulus_table: pd.DataFrame
Each row corresponds to an interval of time. Columns define the interval (start and stop time) and its characteristics. Nans in columns with string data will be replaced with the empty strings. Required columns are:
start_time :: the time at which this interval started stop_time :: the time at which this interval ended
- tag : str, optional
Each interval in an nwb file has one or more tags. This string will be applied as a tag to all TimeIntervals created here
Returns: - nwbfile : pynwb.NWBFile
-
allensdk.brain_observatory.nwb.
add_stimulus_timestamps
(nwbfile, stimulus_timestamps, module_name='stimulus')[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_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