[FieldTrip] Issue with visualising EEG Spectrogram

Schoffelen, J.M. (Jan Mathijs) jan.schoffelen at donders.ru.nl
Wed Jun 19 11:24:23 CEST 2019


Hi Daniel,

May I suggest you to do 4 things, rather than trying to really understand why no apparent baselining seems to have been applied.

1 a). You can run ft_freqanalysis for all channels at once (without the for-loop)
1 b). You may want to use cfg.method = ‘wltconvol’ for ft_freqanalysis, rather than ‘wavelet’ , since it’s much faster with equivalent results.
2). Next, you can call ft_freqbaseline (again: only once, and perhaps use ‘relchange’ as a method) to ‘baseline correct' the spectrograms.
3). Next, you can use ft_multiplotTFR on the baseline corrected variable, using a cfg.layout = ‘ordered’, and don’t specify any baseline correction options here.

Best wishes,
Jan-Mathijs



On 18 Jun 2019, at 20:12, Daniel Campoy (CMP - Student) <D.Campoy at uea.ac.uk<mailto:D.Campoy at uea.ac.uk>> wrote:

Hello,

I have been stuck trying to understand the results I’m seeing so please forgive me as my background is not in neuroscience. I’m a Masters student working with EEG data for a classification project using Matlab 2017b.

I have been successful at visualising the data of a test subject for a specific trigger and plot all channels (dataset has 8 channels) from the trigger (image stimuli) using ft_singleplotTFR. Thus creating a 2x4 plot of images for all 8 channels.  However I’m stuck trying understand my results when I plot an EEG spectrogram using ft_singleplotTFR for each channel across all triggers (T=1 in my dataset) the data does not show what I’ve seen for separate channels. It displays a plot of 8 images filled blue and a fine yellow/green bar across the bottom.  The only thing I’ve changed is supplying all the trials instead of one at a time using a for loop to iterate through each trial for 8 channels. I’ve removed the for loop outside of the for loop of channels since I’m supplying all trials. Below is my code and process. Any insight would be much appreciated and if you need further information please let me know.  I’ve attached an image of the results of each channel across all triggers.


My first step is to load the .mat file I’ve saved containing all the defined trials. After this is complete, the below code is used to extract all the trigger events where the value in cfg.events is T=1.  I run the ft_preprocessingagain but for the defined trials I’m looking for T=1.

trigger = extractfield(cfg.event,'value');
channels = EEG_Data.cfg.channel;
trigger_idx = find(startsWith(trigger,'T=1'));
cfg.trials       = trigger_idx; %index location for all T=1 stimuli triggers
EEG_Data_Trial = ft_preprocessing(cfg,EEG_Data);


After completion the next block of code is ran for each channel. You may have noticed the cdat variable is in the output, this is me modifying the ft_singleplotTFR function to return the EEG spectrogram matrix I use for later analysis.


figure %used to create a figure of EEG Spectrograms

for z = 1:length(channels) %Collect the measurements from each channel for a given trigger
                    Img_idx = 1 + Img_idx;
                    cfg              = [];
                    cfg.output       = 'pow'; %return power spectra
                    cfg.channel      = channels{z};
                    cfg.method       = 'wavelet'; %use wavelet function
                    %cfg.trials       = trigger_idx; %specify index location to find event in EEG_Data_Trial.trial
                    cfg.width        = 1; % 3 has shown some promise for results
                    cfg.gwidth       = 4; %decreasing this has shown to fill out are of the figure
                    cfg.pad          = 20; %increases resolution as the value goes up
                    cfg.foilim       = [1 30]; %1 to 30 Hz range
                    %cfg.toi          = -.10:0.0001:.35; %produced a full image time window from -100 ms to 350ms in 0.1ms steps
                    cfg.toi          = -.05:0.00001:.250; %time window from -50 ms to 250ms in 0.01ms steps

                    TFRwavelet = ft_freqanalysis(cfg, EEG_Data_Trial);
                    fprintf('\n Time-Freq wavelet for trigger index %u channel %s and processed %u trigger(s)\n',trigger_idx(i),channels{z},i)
                    %Create Image of EEG Spectrogram to output cdat matrix
                    cfg = [];
                    cfg.baselinetype = 'absolute';
                    cfg.maskstyle = 'saturation';
                    cfg.zlim         =  'maxmin';
                    subplot(2,4,z)%used to create figures of plotted channels
                    [EEG_Spec,cdat] = ft_singleplotTFR(cfg, TFRwavelet);
                    subplot(2,4,z)%used to create figures of plotted channels
end

Thank you and kind regards,

Daniel C.
<OneSub_acrossTrails_T1.png>_______________________________________________
fieldtrip mailing list
https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
https://doi.org/10.1371/journal.pcbi.1002202

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20190619/0d8c1a97/attachment-0002.html>
-------------- next part --------------
_______________________________________________
fieldtrip mailing list
https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
https://doi.org/10.1371/journal.pcbi.1002202


More information about the fieldtrip mailing list