| Algorithm 1. Reading XLtek EEG Data Algorithm. | |||||
| Input: An EEG signal and the size of window in seconds | |||||
| Output: Array of EEG data samples that constitute the epochs | |||||
| 1 | FUNCTION get_epoch(s, min_secs = 10) | ||||
| 2 | // Extracting signal start time, sample rate, channel names, and number of samples | ||||
| 3 | start_time, s_rate, ch_names, n_samples ← s.return_hdr() | ||||
| 4 | s_rate ← int(round(s_rate)) | ||||
| 5 | // Extracting the creation time for the erd file that holds the raw data | ||||
| 6 | erd_time ← s.return_hdr() [−1][‘creation_time’] | ||||
| 7 | // Excluding samples between the start time of recording and the actual acquisition | ||||
| 8 | stc_erd_diff ← (erd_time–start_time). total_seconds() | ||||
| 9 | // Computing the number of samples required from each channel | ||||
| 10 | stride ← min_secs ∗ s_rate | ||||
| 11 | start_index ← int(stc_erd_diff) ∗ s_rate | ||||
| 12 | end_index ← start_index + stride | ||||
| 13 | findings ← [ ] | ||||
| 14 | WHILE end_index ≤ n_samples DO | ||||
| 15 | t ← s.return_dat ([1], start_index, end_index) | ||||
| 16 | // Excluding the epochs that may contain NaN values | ||||
| 17 | IF ! np.any(np.isnan(t), axis = 1) THEN | ||||
| 18 | data ← s.return_dat(range(len(ch_names)), start_index, end_index) | ||||
| 19 | IF s_rate > 256 THEN | ||||
| 20 | data ← decimate(data, q = 2) | ||||
| 21 | ENDIF | ||||
| 22 | // Converting numpy array to a pandas data frame | ||||
| 23 | df ← pd.DataFrame(data = data.T, columns = ch_names) | ||||
| 24 | findings.append(montage(df, model_modified_channels)) | ||||
| 25 | ENDIF | ||||
| 26 | start_index ← start_index + stride | ||||
| 27 | end_index ← end_index + stride | ||||
| 28 | ENDWHILE | ||||
| 29 | return findings | ||||
| 30 | ENDFUNCTION | ||||