An easy-to-use platform for EEG experimentation in the classroom
at main 28 lines 1.0 kB view raw
1/** 2 * Functions for writing EEG data to disk. 3 * The actual write stream lives in the main process; the renderer 4 * communicates via the IPC bridge in window.electronAPI. 5 */ 6 7import { EEGData } from '../../constants/interfaces'; 8 9// Creates an EEG write stream in the main process and returns a stream ID 10export const createEEGWriteStream = ( 11 title: string, 12 subject: string, 13 group: string, 14 session: number 15): Promise<string> => 16 window.electronAPI.createEEGWriteStream(title, subject, group, session); 17 18// Writes the CSV header row to the stream identified by streamId 19export const writeHeader = (streamId: string, channels: string[]): void => 20 window.electronAPI.writeEEGHeader(streamId, channels); 21 22// Writes a single EEG data row (fire-and-forget for performance) 23export const writeEEGData = (streamId: string, eegData: EEGData): void => 24 window.electronAPI.writeEEGData(streamId, eegData); 25 26// Closes the write stream 27export const closeEEGStream = (streamId: string): Promise<void> => 28 window.electronAPI.closeEEGStream(streamId);