1+ from __future__ import annotations
2+
3+ import os
4+
5+ import matplotlib .pyplot as plt
6+ import mne
7+ import numpy as np
8+ from numpy .typing import ArrayLike
9+
10+ type Stream = mne .io .BaseRaw | ArrayLike
11+ type Channel = str | int
12+ type PathLike = str | bytes | os .PathLike
13+
14+
115class StreamSync :
216 """Synchronize two data streams.
317
@@ -8,12 +22,20 @@ class StreamSync:
822 time-warped to the timescale of the `Raw`.
923 """
1024
11- def __init__ (self , reference_object , pulse_channel ):
12- self .ref_stream = reference_object .get_chan (pulse_channel )
13- self .sfreq = reference_object .info ["sfreq" ] # Hz
14- self .streams = []
25+ def __init__ (self , reference_object : Stream , pulse_channel : Channel ) -> None :
26+ self .ref_stream : ArrayLike = reference_object .get_chan (pulse_channel )
27+ self .sfreq : float = reference_object .info ["sfreq" ] # Hz
28+ self .streams : list [Stream ] = []
29+
30+ def add_camera_events (self , events : ArrayLike ) -> mne .Annotations : # noqa: ARG002
31+ return mne .Annotations ([], [], [])
1532
16- def add_stream (self , stream , channel = None , events = None ): # noqa ARG002
33+ def add_stream (
34+ self ,
35+ stream : Stream ,
36+ channel : Channel ,
37+ events : ArrayLike | None = None , # noqa: ARG002
38+ ) -> StreamSync :
1739 """Add a new ``Raw`` or video stream, optionally with events.
1840
1941 stream : Raw | wav
@@ -26,22 +48,27 @@ def add_stream(self, stream, channel=None, events=None): # noqa ARG002
2648 """
2749 pulses = self ._extract_pulse_sequence_from_stream (stream , channel = channel )
2850 self .streams .append (pulses )
51+ return self
2952
30- def _extract_pulse_sequence_from_stream (self , stream , channel ):
53+ def _extract_pulse_sequence_from_stream (
54+ self ,
55+ stream : Stream , # noqa: ARG002
56+ channel : Channel , # noqa: ARG002
57+ ) -> ArrayLike :
3158 # TODO triage based on input type (e.g., if it's a Raw, pull out a stim chan,
3259 # if it's audio, just add it as-is)
33- pass
60+ return np . array ([]) # fake return
3461
35- def do_syncing (self ):
62+ def do_syncing (self ) -> float :
3663 """Synchronize all streams with the reference stream."""
3764 # TODO (waves hands) do the hard part.
3865 # TODO spit out a report of correlation/association between all pairs of streams
39- pass
66+ return 0.0
4067
41- def plot_sync (self ):
42- pass
68+ def plot_sync (self ) -> plt . figure . Figure :
69+ return plt . figure . Figure ()
4370
4471
45- def extract_audio_from_video (path_to_video , channel ) : # noqa ARG001
72+ def extract_audio_from_video (path_to_video : PathLike , channel : Channel ) -> ArrayLike : # noqa: ARG001
4673 """Path can be a regex or glob to allow batch processing."""
47- pass
74+ return np . array ([]) # fake return
0 commit comments