Closed behinger closed 4 years ago
Good find! Seems I forgot compensate for MATLAB's one-based indexing.
Testing this with a peak of a single sample, we see that an ERP at 1000 Hz with a 1-ms-wide peak at 100 ms has this peak at index 100:
[~, i] = max(erp_generate_signal(100, 1, 1, 1000, 1000))
i =
100
But indeed we tend to start counting at 0 when dealing with epochs, so this should be 101.
Therefore, I moved the ERP latency over one sample in erp_generate_signal
on line 59:
peakLatency = (peakLatency/1000)*srate + 1;
That should fix the issue.
The burst latency of the ERSP had the same issue, so I applied the same fix in ersp_generate_signal
on line 156.
[~, i] = max(ersp_generate_signal(1, 1, 0, 1000, 1000, 'modulation', 'burst', 'modLatency', 250, 'modWidth', 1))
I believe those are the only scripts that were affected by this.
Thanks for the report -- the issue is significant enough to make a new release out of the current code. If you found anything else, now would be a good time to let me know. :D
great :-) No, this is the only thing I found
Still, great toolbox. But the timing is off by one sample I think.
Reproducible code:
Output:
That is, I would expect to see a peak at 100ms.
I find a peak at the second data entry
But the second data entry is 50 not 100ms. It seems there is a mistake here
Best, Bene
EDIT: I noticed there might be jitter in the p1, but I don't think the jitter has influence on the problem