Pynapple IO#

Loaders and augmenters for pynapple-backed data (NWB files and .npz pynapple folders). These are the pynapple counterparts of the xarray builders in Dataset.


Loading#

ethograph.io.pynapple.load_nap_data(path)[source]#

Load pynapple data from a file or folder.

Supports .nwb, .npz, or a directory (pynapple folder). When loading a single .npz, sibling files in the same directory are also loaded (e.g. trials.npz alongside speed.npz).

Return type:

tuple[dict, nap.IntervalSet | None]

Returns:

  • data (dict) – Loaded pynapple objects keyed by name.

  • trials_ep (IntervalSet or None) – Trial intervals if found in the data.

ethograph.io.pynapple.detect_trials(data)[source]#

Find a trials IntervalSet in a loaded pynapple data dict.

Return type:

nap.IntervalSet | None

ethograph.io.pynapple.flatten_nap_folder(data, load_metadata=False)[source]#
Return type:

dict[str, dict]

ethograph.io.pynapple.get_metadata(obj)[source]#
Return type:

dict

ethograph.io.pynapple.parse_nwb_types(nwb)[source]#
Return type:

dict[str, type]


Building#

ethograph.io.pynapple.add_changepoints_to_nap(data, target_feature, changepoint_func, **func_kwargs)[source]#
Return type:

nap.TsGroup

ethograph.io.pynapple.add_angle_rgb_to_nap(tsdframe, smoothing_params, position_key='position', xy_columns=['x', 'y'])[source]#
Return type:

TsdFrame


NWB import probes#

These helpers inspect an NWB file to discover what is available for import (trials, behavioural series, electrical series, label sources).

ethograph.io.nwb_import.read_trials_table(nwb)[source]#
Return type:

DataFrame

ethograph.io.nwb_import.probe_electrical_series(nwb)[source]#

List all ElectricalSeries in nwb.acquisition.

Return type:

list[dict]

ethograph.io.nwb_import.probe_label_sources(nwb)[source]#

List all potential interval label sources in the NWB file.

Return type:

list[dict]