Multiple EEG-files to one spectrogram

조회 수: 6 (최근 30일)
Mikkel Mortensen
Mikkel Mortensen 2019년 3월 26일
댓글: Walter Roberson 2019년 3월 27일
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