[FieldTrip] TFR with mtmconvol

Jonathan Schubert jonathan.schubert at uni-hamburg.de
Fri Oct 19 16:20:46 CEST 2012


Hi Roemer,

I did the preprocessing with eeglab. I'm going to include the eeglab
commands at the end of this mail.
So first the fieldtrip commands only:

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% reading in the data from eeglab

[data]=eeglab2fieldtrip(EEG, 'preprocessing', 'none');

% This step is from the fieldtrip wiki
cfg = [];
cfg.demean = 'yes';
data = ft_preprocessing(cfg, data);

% frequency analysis
cfg = [];
cfg.channel    = 'all';
cfg.output     = 'pow';
cfg.method     = 'mtmconvol';
cfg.taper      = 'hanning';
cfg.foi        = 40:1:100;
cfg.toi        = -1.0:0.02:1.0;
cfg.t_ftimwin  = 7./cfg.foi;
cfg.tapsmofrq  = cfg.foi*0.4;
cfg.pad        = 'maxperlen';
cfg.keeptrials = 'no';
freq      = ft_freqanalysis(cfg, data);

% baseline correction -300 to -100 ms

base = freq;
bix = find(freq.time < -0.1 & freq.time >-0.3);
totalbase    =
repmat(nanmean(freq.powspctrm(:,:,bix),3),[1,1,length(freq.time)]);
freq.powspctrm = 100 * ((freq.powspctrm-totalbase)./totalbase);

% plotting the results
lay = ft_prepare_layout(freq);

figure
cfg = [];
cfg.layout  = lay;
cfg.interactive = 'yes';
cfg.marker = 'labels';
cfg.channel = {'M_4'};
cfg.xparam  = 'time';
cfg.yparam = 'freq';
cfg.zparam  = 'powspctrm';
cfg.xlim  = [-0.3 1.0];
cfg.zlim  = 'maxabs' ;
ft_singleplotTFR (cfg, freq);






%%%%%%%%%%%%%%%%%%%%%%%%%
% So here is what I did with eeglab, before calling the eeglab2fieldtrip

% reading in data
EEG = pop_loadset('filename',[setname, '.set'],'filepath', pathname);
[ALLEEG EEG CURRENTSET] = pop_newset(ALLEEG, EEG, CURRENTSET, 'setname',
setname);

% edit channels and reading in their locations and set reference
EEG=pop_chanedit(EEG,
'load',{'E:\\E176_data\\TF_Matlab_scripts\\electrode_pos61.elp' 'filetype'
'autodetect'},'append',64,'changefield',{65 'labels'
'ref_right_ear'},'setref',{'1:64' 'ref_right_ear'});

[ALLEEG EEG] = eeg_store(ALLEEG, EEG, CURRENTSET);
EEG = eeg_checkset( EEG );

% lowpass filter
EEG = pop_eegfilt( EEG, 0, 110, [], [0]);
[ALLEEG EEG CURRENTSET] = eeg_store(ALLEEG, EEG, CURRENTSET);

% change sampling rate to 250Hz
EEG = pop_resample( EEG, 250);
[ALLEEG EEG CURRENTSET] = eeg_store(ALLEEG, EEG, CURRENTSET);

% highpass filter
EEG = pop_eegfilt( EEG, 0.3, 0, [], [0]);
[ALLEEG EEG CURRENTSET] = eeg_store(ALLEEG, EEG, CURRENTSET);

% re-referencing to linked earlobe reference
EEG = pop_reref( EEG,
[],'refloc',struct('type',{''},'labels',{'ref_ear_right'},'radius',{0.65556},'sph_theta',{-90},'sph_phi',{-28},'theta',{90},'sph_radius',{1},'X',{5.4065e-017},'Y',{-0.88295},'Z',{-0.46947},'ref',{''},'urchan',{65}));
EEG = pop_reref( EEG, [62 65] );

% run ICA
EEG = pop_runica(EEG, 'extended',1,'chanind',
[1:61],'stop',1e-007,'maxsteps',600);
% Identification of components reflecting eyeblinks and -movements,
% heartbeat, noise is done by hand

% get rid of artifact components
artcomp = sort([EEG.artifact.eyeblink, EEG.artifact.noise,
EEG.artifact.heyem, EEG.artifact.ecg]);
EEG = pop_subcomp(EEG, artcomp, 0);
EEG = pop_saveset(EEG, savename, pathname);
[ALLEEG EEG] = eeg_store(ALLEEG, EEG, CURRENTSET);

%notch filter to take out the electrical
%current at 50 HZ and 100 Hz
EEG = pop_eegfilt( EEG, 49, 51, [], [1]);
[ALLEEG EEG CURRENTSET] = eeg_store(ALLEEG, EEG, CURRENTSET);
EEG = pop_eegfilt( EEG, 99, 101, [], [1]);
[ALLEEG EEG CURRENTSET] = eeg_store(ALLEEG, EEG, CURRENTSET);

% epoching the data and removing
thresh = 100;
condition = {'111'};
for j=1:length(condition)
    EEG = pop_loadset('filename', savename,'filepath', pathname);
    EEG = pop_epoch( EEG, {condition{j}}, [-1.0  1.2], 'newname', ['L'
subject{i},' resampled pruned with ICA epochs'], 'epochinfo', 'yes');
    EEG = pop_rmbase( EEG, [-100  0]);
    [EEG, Ind1] = pop_eegthresh( EEG, 1, [1:61], -thresh, thresh, -0.5,
0.5, 0, 1); % get rid of artifacts
end

% re-referencing to avg reference: do not use EOG channels for average
reference
EEG = pop_select( EEG, 'nochannel',[62 63]);
% re-reference to average reference
EEG = pop_reref(EEG, []);


Best,
Jonathan


2012/10/19 Roemer van der Meij <r.vandermeij at donders.ru.nl>

> Hi Jonathan,
>
> This indeed looks like a bleeding in of the 0Hz component. How did you
> exactly follow the help on the wiki? Could you post your entire analysis
> pipeline? (i.e. your call to ft_preprocessing, your call to
> ft_singleplotTFR, baselining that you do, etc.). That would help in
> diagnosing the problem.
>
> All the best,
> Roemer
>
>
> On Fri, Oct 19, 2012 at 1:23 PM, Jonathan Schubert <
> jonathan.schubert at uni-hamburg.de> wrote:
>
>> Dear all,
>>
>> I have a question regarding frequency analysis using the multitaper
>> approach. I transformed my data using the following code:
>>
>>         cfg = [];
>>         cfg.channel    = 'all';
>>         cfg.output     = 'pow';
>>         cfg.method     = 'mtmconvol';
>>         cfg.foi        = 40:1:100;
>>         cfg.toi        = -1.0:0.02:1.0;
>>         cfg.t_ftimwin  = 7./cfg.foi;
>>         cfg.tapsmofrq  = cfg.foi*0.4;
>>         cfg.pad        = 'maxperlen';
>>         cfg.keeptrials = 'no';
>>         freq      = ft_freqanalysis(cfg, data);
>>
>> When I plot the TFR it looks strange in a similiar way to what I found on
>> the fieldtrip homepage:
>> http://fieldtrip.fcdonders.nl/faq/why_does_my_tfr_look_strange
>> Following the help on the homepage did not improve the outcome. I
>> attached an example of my TFR.
>>
>> What can I do to improve the outcome of the frequency analysis?
>>
>> Best,
>> Jonathan
>>
>>
>> _______________________________________________
>> fieldtrip mailing list
>> fieldtrip at donders.ru.nl
>> http://mailman.science.ru.nl/mailman/listinfo/fieldtrip
>>
>
>
>
> --
> Roemer van der Meij M.Sc.
> PhD Candidate
> Donders Institute for Brain, Cognition and Behaviour
> Centre for Cognition
> P.O. Box 9104
> 6500 HE Nijmegen
> The Netherlands
> Tel: +31(0)24 3655932
> E-mail: r.vandermeij at donders.ru.nl
>
>
> _______________________________________________
> fieldtrip mailing list
> fieldtrip at donders.ru.nl
> http://mailman.science.ru.nl/mailman/listinfo/fieldtrip
>



-- 

Dipl.-Psych. Jonathan Schubert
University of Hamburg
Biological Psychology and Neuropsychology
Von-Melle-Park 11, Room 301
D-20146 Hamburg
Germany
-
Phone: (49) 40 - 42838 7626
Fax:   (49) 40 - 42838 6591
jonathan.schubert at uni-hamburg.de
www.bpn.uni-hamburg.de <http://www.epb.uni-hamburg.de/de/personen/schubert>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20121019/df7e13b8/attachment-0002.html>


More information about the fieldtrip mailing list