Multiple EEG-files to one spectrogram

6 次查看(过去 30 天)
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 个评论
Walter Roberson
Walter Roberson 2019-3-26
Concatenate the data together before calculating the spectrogram ?
Mikkel Mortensen
Mikkel Mortensen 2019-3-27
编辑:Mikkel Mortensen 2019-3-27
That might help, but what I wrote in the text was a thought example.
Our real problem is that we have multiple files that in total are recording EEG for a few months. These files are not necessary continous on the x-axis, but could jump some minuts.
What we want, is to plot all of this data from the files in the same spectrogram.
- If we as an example are missing one hour with data, we want it to plot this time as black or grey box (something like that)
Maybe the first step is to concatenate the files, but what will happen when the minuts(X-axis) jumps?

请先登录,再进行评论。

回答(1 个)

Bjorn Gustavsson
Bjorn Gustavsson 2019-3-27
编辑:Bjorn Gustavsson 2019-3-27
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 个评论
Bjorn Gustavsson
Bjorn Gustavsson 2019-3-27
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

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 EEG/MEG/ECoG 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by