|
1 | 1 | class StreamSync:
|
2 |
| - def __init__(self): |
| 2 | + """Synchronize two data streams. |
| 3 | +
|
| 4 | + Inputs: `mne.io.Raw` files, audio files (TODO which formats?), |
| 5 | + and additional camera events. |
| 6 | +
|
| 7 | + Outputs: `mne.Annotations` object created from the camera events and |
| 8 | + time-warped to the timescale of the `Raw`. |
| 9 | + """ |
| 10 | + |
| 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 = [] |
| 15 | + |
| 16 | + def add_stream(self, stream, channel=None, events=None): |
| 17 | + """Add a new ``Raw`` or video stream, optionally with events. |
| 18 | +
|
| 19 | + stream : Raw | wav |
| 20 | + An audio or FIF stream. |
| 21 | + channel : str | int | None |
| 22 | + Which channel of `stream` contains the sync pulse sequence. |
| 23 | + events : array-like | None |
| 24 | + Events associated with the stream. TODO: should they be integer sample |
| 25 | + numbers? Timestamps? Do we support both? |
| 26 | + """ |
| 27 | + pulses = self._extract_pulse_sequence_from_stream(stream, channel=channel) |
| 28 | + self.streams.append(pulses) |
| 29 | + |
| 30 | + def _extract_pulse_sequence_from_stream(self, stream, channel): |
| 31 | + # TODO triage based on input type (e.g., if it's a Raw, pull out a stim chan, |
| 32 | + # if it's audio, just add it as-is) |
3 | 33 | pass
|
| 34 | + |
| 35 | + def do_syncing(self): |
| 36 | + """Synchronize all streams with the reference stream.""" |
| 37 | + # TODO (waves hands) do the hard part. |
| 38 | + # TODO spit out a report of correlation/association between all pairs of streams |
| 39 | + pass |
| 40 | + |
| 41 | + def plot_sync(self): |
| 42 | + pass |
| 43 | + |
| 44 | + |
| 45 | +def extract_audio_from_video(path_to_video, channel): |
| 46 | + """Path can be a regex or glob to allow batch processing.""" |
| 47 | + pass |
0 commit comments