Multiple EEG-files to one spectrogram
3 views (last 30 days)
Show older comments
Hi,
I am trying to plot multiple EEG-files in the SAME spectrogram in extension of eachother.
The files contain data from only one channel recording. The files are containing EEG from 6 hours in total, but they are seperated and are containing 3 hours each.
Now I want to plot them in extension of eachother in the same plot (spectrogram),
- Is this possible?
Thanks.
2 Comments
Answers (1)
Bjorn Gustavsson
on 27 Mar 2019
Edited: Bjorn Gustavsson
on 27 Mar 2019
If there is time-gaps in your data-sequence, just do the individual spectrograms as per usual, I'd use something like this:
data_files = dir('*.dataformatofyours');
WINDOW = 256; % Or Hamming/Bartlet/Kaiser/Whatever you use
NOVERLAP = 64; % ...
Fs = 25; %
for i_t = 1:numel(data_files),
[t{i_t},EEG{i_t}] = EEG_data_reader(data_files(i_t).name);
[S{i_t},F{i_t},T{i_t}] = spectrogram(EEG{i_t},WINDOW,NOVERLAP,[],Fs);
pcolor(T{i_t}+t{i_t}(1),F{i_t},log10(abs(S{i_t}))),shading flat
hold on
end
That should concatenate the plots, with some gaps where you have data-gaps. If you concatenate the data you will no longer have constant sampling-rate - which is what the spectrogram-function implicitly use, so if you concatenate data you will get "peculiar" features in your spectrogram across the seams.
HTH
3 Comments
Bjorn Gustavsson
on 27 Mar 2019
1, Well, how could I possibly know what data-format you have, and what your IO-function reading the, from my vantage-point unknown data-format? I simply assumed that you had a reading-function that gave you the EEG-data channel and the corresponding time-array.
2, Yes, I edited my reply.
3, the pcolor-call is intended to plot the log10 of the spectrogram amplitude as a function of time and frequency. The different data-chunks should shifted to the start-time of the corresponding data-chunk - here I've guessed that the time you get from your EEG-reading function gives you someting like a clock-time or serial time that you can use straight off. You might have to convert the time you get to something that's continuous in time, for example if you get data in [YYYY MM DD HH MM SS] format you might convert that into running days:
t_seq{i_t} = t{i_t}(:,3) + (t{i_t}(:,4) + t{i_t}(:,5)/60 + t{i_t}(:,6)/3600)/24;
Or whatever is suitable for your data.
HTH
See Also
Categories
Find more on EEG/MEG/ECoG in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!