NWBAlignment#
- class ethograph.io.nwb_alignment.NWBAlignment(nwb_path)[source]#
Bases:
objectSession metadata backed by an NWB file.
All external media (video, audio, pose) are stored as ImageSeries in acquisition with
{stream}_{device}naming. Timing comes fromrateortimestampson the ImageSeries.Methods
close()devices(stream)Discover devices from trials table columns AND acquisition items.
Discover ElectricalSeries in acquisition.
file_time_spans(stream[, device])Return [(filepath, t_start, t_end), ...] for each external file in the stream.
from_nwb_object(nwb_obj)Create alignment from an already-opened pynwb NWBFile object.
get_media(trial, stream[, device])get_stream_rate(stream[, device])Read the sampling rate for a stream from its acquisition ImageSeries.
print_session()resolve_media_path(trial, stream[, device, ...])Resolve the full path for a media file.
restrict(obj, trial)set_stream_rate(rate, stream[, device])start_time(trial)stop_time(trial)stream_offset_for_trial(trial, stream[, device])Trial-relative time of sample 0 for a stream's file.
Return
{acq_name: (starting_time, rate)}for all acquisition streams.trial_epoch(trial)- devices(stream)[source]#
Discover devices from trials table columns AND acquisition items.
Three sources, checked in order:
Trials table columns (
video_cam_1-> devicecam_1).Acquisition ImageSeries following
{stream}_{device}naming.Acquisition ImageSeries whose
external_fileextensions match known media types (e.g..mp4-> video,.wav-> audio).
- electrical_series()[source]#
Discover ElectricalSeries in acquisition. Returns list of {name, path, n_channels, rate}.
- file_time_spans(stream, device=None)[source]#
Return [(filepath, t_start, t_end), …] for each external file in the stream.
Handles both NWB timing schemes (
timestampsandrate). Files with unresolvable timing are silently skipped.
- classmethod from_nwb_object(nwb_obj)[source]#
Create alignment from an already-opened pynwb NWBFile object.
- Return type:
- get_stream_rate(stream, device=None)[source]#
Read the sampling rate for a stream from its acquisition ImageSeries.
- property has_real_timing: bool#
Whether the trials table has meaningful start/stop times.
Returns False when all trials have identical placeholder timing (e.g. start=0.0, stop=1.0 for every row), which indicates the NWB was generated without real session timing.
- resolve_media_path(trial, stream, device=None, fallback_folder=None)[source]#
Resolve the full path for a media file.
Try the ImageSeries
external_filepath for this trial (if on disk).Fallback: trial table filename +
fallback_folder.Returns
Noneif unresolvable.
- stream_offset_for_trial(trial, stream, device=None)[source]#
Trial-relative time of sample 0 for a stream’s file.
For per-trial aligned media returns 0.0. For session-wide media returns the file’s start relative to the trial. Reads timing from the acquisition ImageSeries.
- Return type:
- stream_rates()[source]#
Return
{acq_name: (starting_time, rate)}for all acquisition streams.Only returns rate and starting_time from NWB ImageSeries metadata. Does not compute duration — external files must be probed for that.
- property trials_ep#
Pynapple IntervalSet built from the NWB trials table.