Skip to content
Open
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions dlc2nwb/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,16 @@ def get_movie_timestamps(movie_file, VARIABILITYBOUND=1000, infer_timestamps=Tru

reader = cv2.VideoCapture(movie_file)
timestamps = []
for _ in range(len(reader)):
n_frames = int(reader.get(cv2.CAP_PROP_FRAME_COUNT))
fps = reader.get(cv2.CAP_PROP_FPS)

for _ in range(n_frames):
_ = reader.read()
timestamps.append(reader.get(cv2.CAP_PROP_POS_MSEC))

timestamps = np.array(timestamps) / 1000 # Convert to seconds

if np.nanvar(np.diff(timestamps)) < 1.0 / reader.fps * 1.0 / VARIABILITYBOUND:
if np.nanvar(np.diff(timestamps)) < 1.0 / fps * 1.0 / VARIABILITYBOUND:
warnings.warn(
"Variability of timestamps suspiciously small. See: https://github.com/DeepLabCut/DLC2NWB/issues/1"
)
Expand Down Expand Up @@ -195,6 +198,7 @@ def _write_pes_to_nwbfile(
paf_graph,
timestamps,
exclude_nans,
**optional_kwargs,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
**optional_kwargs,
**optional_container_kwargs,

or optional_pose_estimation_kwargs to distinguish these from ones you would pass to individual series

Also might just be better to make it fully explicit with pose_estimation_container_kwargs: Optional[dict] = None

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, fixed!

):
pose_estimation_series = []
for kpt, xyp in df_animal.groupby(level="bodyparts", axis=1, sort=False):
Expand Down Expand Up @@ -230,6 +234,7 @@ def _write_pes_to_nwbfile(
source_software_version=deeplabcut_version,
nodes=[pes.name for pes in pose_estimation_series],
edges=paf_graph if paf_graph else None,
**optional_kwargs,
)
if 'behavior' in nwbfile.processing:
behavior_pm = nwbfile.processing["behavior"]
Expand Down