Closed luozhy88 closed 1 year ago
Hmm, interesting idea. I guess the only way to do this would be to manually create the events.
Here's an example.
For continuous data, the events table has three columns: event_onset
(in samples), event_time
(in seconds), and event_type
.
Suppose you want to insert an event 4 seconds after the start. You recorded data at 512 Hz, so 512 samples per second. 4 seconds thus equals 2048 samples. An event that took place at time 0 would be sample 1, so sample 2048 would actually be just short of 4 seconds - in our example, it'd be ~3.998 - so if you wanted to place an event at exactly 4 seconds from 0, you'd place it at sample 2049.
Now suppose you have 200 seconds worth of data. That's 102400 samples. The code below generates a table with events every 4 seconds.
Once you've done that, you can modify the event table of your data directly, then create epochs around those events as you describe. You could either do events(your_data) <- new_events
or your_data$events <- new_events
sampling_rate <- 512
time_period <- 4
epoch_samples <- sampling_rate * time_period
event_sample_onsets <- seq(epoch_samples + 1, 102400, epoch_samples)
new_events <- data.frame(event_onset = event_sample_onsets,
event_time = (event_sample_onsets - 1) * (1/sampling_rate),
event_type = 100)
new_events
#> event_onset event_time event_type
#> 1 2049 4 100
#> 2 4097 8 100
#> 3 6145 12 100
#> 4 8193 16 100
#> 5 10241 20 100
#> 6 12289 24 100
#> 7 14337 28 100
#> 8 16385 32 100
#> 9 18433 36 100
#> 10 20481 40 100
#> 11 22529 44 100
#> 12 24577 48 100
#> 13 26625 52 100
#> 14 28673 56 100
#> 15 30721 60 100
#> 16 32769 64 100
#> 17 34817 68 100
#> 18 36865 72 100
#> 19 38913 76 100
#> 20 40961 80 100
#> 21 43009 84 100
#> 22 45057 88 100
#> 23 47105 92 100
#> 24 49153 96 100
#> 25 51201 100 100
#> 26 53249 104 100
#> 27 55297 108 100
#> 28 57345 112 100
#> 29 59393 116 100
#> 30 61441 120 100
#> 31 63489 124 100
#> 32 65537 128 100
#> 33 67585 132 100
#> 34 69633 136 100
#> 35 71681 140 100
#> 36 73729 144 100
#> 37 75777 148 100
#> 38 77825 152 100
#> 39 79873 156 100
#> 40 81921 160 100
#> 41 83969 164 100
#> 42 86017 168 100
#> 43 88065 172 100
#> 44 90113 176 100
#> 45 92161 180 100
#> 46 94209 184 100
#> 47 96257 188 100
#> 48 98305 192 100
#> 49 100353 196 100
Created on 2023-03-30 with reprex v2.0.2
Closing as no further response
Thank you very much for having such a great tool .
If my data doesn't have an event, how can I divide it by time? My request is: Create epoch: 1 Data is divided in 8 seconds and overlapped in 4 seconds. 2 extract the middle 50 epoch. 3 average these 50 epoch.