@@ -130,8 +130,7 @@ def extract_frame_times(self, save=True, frame_rate=None, display=False, **kwarg
130130 sync , chmap = load_timeline_sync_and_chmap (sync_path , timeline = self .timeline )
131131
132132 # Attempt to get the frame rate from the video file if not provided
133- video_file = next (self .session_path .joinpath (self .collection ).glob ('_sp_video.raw.*' ))
134- if video_file .exists ():
133+ if video_file := next (self .session_path .joinpath (self .collection ).glob ('_sp_video.raw.*' ), None ):
135134 video_meta = get_video_meta (video_file )
136135 if frame_rate is not None and frame_rate != video_meta .fps :
137136 _logger .warning (
@@ -258,7 +257,7 @@ def extract_frame_times(self, save=True, frame_rate=None, display=False, **kwarg
258257 plt .legend (markerfirst = False , title = 'repeat #' , loc = 'upper right' , facecolor = 'white' )
259258
260259 # Check the sync sequence from the video
261- if video_file . exists () :
260+ if video_file :
262261 observed = self .load_sync_sequence_from_video (video_file )
263262 _ , ax = plt .subplots (2 , 1 , sharex = True )
264263 ax [0 ].title .set_text ('generated sync square sequence' )
@@ -278,6 +277,7 @@ def extract_frame_times(self, save=True, frame_rate=None, display=False, **kwarg
278277
279278 if save :
280279 filename = self .session_path .joinpath (self .output_collection , '_sp_video.times.npy' )
280+ filename .parent .mkdir (exist_ok = True , parents = True )
281281 np .save (filename , frame_times )
282282 out_files = [filename ]
283283 else :
0 commit comments