[FieldTrip] more on artfifact rejection
jan-mathijs schoffelen
jan.schoffelen at donders.ru.nl
Wed Jan 26 11:45:23 CET 2011
Dear Michael and the rest of the world,
I updated the documentation page on artifact rejection with a more
explicit statement that specifying the padding only works with data on
disk (and removed the second input arguments in the code examples).
I'll discuss the other issue with the rest soon.
Best
JM
On Jan 24, 2011, at 6:27 PM, Michael Wibral wrote:
> Hi Jan-Mathijs,
>
> this is basically what we do at the moment, i.e. fooling
> artifcat_zvalue by removing the one field it complains about amnd
> using rejetartefact only at the very last.
> See the attched code - I really do not want to post this code on the
> tutorial website as I am not fully sure what I am doing :-).
>
> Michael
>
> %% CODE
> ft_defaults;
> Datapath='/data/MEGArchive/data/meg/CTF_Data/NewMooney.proc/
> DATASETS/';
> Design={
> 'DMG13_NewMooney_20110120_0', [2 3],
> 'mytrialfun_New_MooneyMEEG_StandardButtons2',[4 5 6 7 8];
> }
>
>
> for ss=1:size(Design,1) % over subjects
> for cc=1:length(Design{ss,4}) % over conditions
> for ff=1:length(Design{ss,2}) % over .ds datasets/runs
>
> FullFileName=strcat(Datapath,Design{ss,1},num2str(Design{ss,2}(ff)),
> '.ds')
> FullHeaderFile=FullFileName; %strcat(FullFileName,'/',)
> % core data reading
> cfg=[];
> cfg.dataset=FullFileName;
> cfg.headerformat = 'ctf_ds'; % for you to check whether still
> necessary
> ctf.dataformat = 'ctf_ds';
> cfg.cond=Design{ss,4}(cc)
> cfg.continuous='yes';
>
> cfg.channel={'MEG','EEG','-MLP12', '-MRC14', '-MLT41', '-MRC25', '-
> MRP56', '-MRT21', '-MLO21', '-MRO44', '-MRT47'}; % add bad channels ?
> cfg.trialfun=Design{ss,3};
> cfg=ft_definetrial(cfg);
> cfg.trl(end,:)=[];
> trl=cfg.trl; % keep track of the trials
>
> padding=0.75 % 750 ms
>
>
> %%%%%%%%% artifact rejection section
> %%% jump
> % cutoff and padding
> cfg.artfctdef.zvalue.channel = 'MEG';
> cfg.artfctdef.zvalue.cutoff = 35;
> cfg.artfctdef.zvalue.trlpadding = 0.5*padding;
> cfg.artfctdef.zvalue.artpadding = 0.5*padding;
> cfg.artfctdef.zvalue.fltpadding = 0;
>
> % algorithmic parameters
> cfg.artfctdef.zvalue.medianfilter = 'yes';
> cfg.artfctdef.zvalue.medianfiltord = 9; % in samples
> cfg.artfctdef.zvalue.absdiff = 'yes';
>
> % feedback
> cfg.artfctdef.zvalue.feedback = 'no';
> cfg.artfctdef.reject = 'jump';
> [cfg, artifact_jump] = ft_artifact_zvalue(cfg); %, Data);
> % cfg.artfctdef.jump.artifact = artifact_jump;
> % cfg = ft_rejectartifact(cfg);
>
> %%% muscle
> cfg.artfctdef.zvalue=rmfield(cfg.artfctdef.zvalue, 'artifact'); %
> remove field from structure otherwise this won't run ??
> % cutoff and padding
> cfg.artfctdef.zvalue.channel = 'MEG';
> cfg.artfctdef.zvalue.cutoff = 15;
> cfg.artfctdef.zvalue.trlpadding = 0.1;
> cfg.artfctdef.zvalue.fltpadding = 0.1;
> cfg.artfctdef.zvalue.artpadding = 0.1;
>
> % algorithmic parameters
> cfg.artfctdef.zvalue.bpfilter = 'yes';
> cfg.artfctdef.zvalue.bpfreq = [110 140];
> cfg.artfctdef.zvalue.bpfiltord = 6;
> cfg.artfctdef.zvalue.bpfilttype = 'but';
> cfg.artfctdef.zvalue.hilbert = 'yes';
> cfg.artfctdef.zvalue.boxcar = 0.2;
>
> % feedback
> cfg.artfctdef.zvalue.feedback = 'no';
> cfg.artfctdef.reject = 'muscle';
> [cfg, artifact_muscle] = ft_artifact_zvalue(cfg);
> cfg.artfctdef.muscle.artifact = artifact_muscle;
> cfg = ft_rejectartifact(cfg);
>
> %%% EOG
>
>
> cfg.artfctdef.zvalue=rmfield(cfg.artfctdef.zvalue, 'artifact');
> % cutoff and padding
> cfg.artfctdef.zvalue.channel = 'MRT41';
> cfg.artfctdef.zvalue.cutoff = 10;
> cfg.artfctdef.zvalue.trlpadding = 0.5;
> cfg.artfctdef.zvalue.artpadding = 0.1;
> cfg.artfctdef.zvalue.fltpadding = 0.1;
> % algorithmic parameters
> cfg.artfctdef.zvalue.bpfilter = 'yes';
> cfg.artfctdef.zvalue.bpfilttype = 'but';
> cfg.artfctdef.zvalue.bpfreq = [1 15];
> cfg.artfctdef.zvalue.bpfiltord = 3;
> cfg.artfctdef.zvalue.hilbert = 'yes';
>
> % feedback
> cfg.artfctdef.zvalue.feedback = 'no';
> cfg.artfctdef.reject = 'EOG';
> [cfg, artifact_EOG] = ft_artifact_zvalue(cfg); % Data);
>
> cfg.trl=trl;
> cfg.artfctdef.reject = 'complete'; % this rejects complete trials,
> use 'partial' if you want to do partial artifact rejection
> % collect all the info about the artifacts that were found
> cfg.artfctdef.eog.artifact =artifact_EOG;
> cfg.artfctdef.jump.artifact = artifact_jump;
> cfg.artfctdef.muscle.artifact = artifact_muscle;
> cfg = ft_rejectartifact(cfg);
>
> Data_no_artifacts=ft_preprocessing(cfg);
>
> % some additional filtering for DC removal and detrending
> cfg=[];
> cfg.detrend='yes'
> cfg.hpfilt='yes'
> cfg.hpfreq=1;
> TrialData{ff}=ft_preprocessing(cfg,Data_no_artifacts);
> clear Data_no_artifacts;
>
> end
> ...
> ...
> end
> end
>
>
>
>
>
> -----Ursprüngliche Nachricht-----
> Von: "jan-mathijs schoffelen" <jan.schoffelen at donders.ru.nl>
> Gesendet: Jan 24, 2011 4:41:09 PM
> An: "Email discussion list for the FieldTrip project" <fieldtrip at donders.ru.nl
> >
> Betreff: Re: [FieldTrip] more on artfifact rejection
>
>> Hmmm, apparently this approach needs to be ironed out a bit (also
>> from
>> our side). For now, I'd say that it should work if you keep per type
>> of artifact the artifact field in the output configuration, and just
>> concatenate these prior to calling ft_rejectartifact. I will moreover
>> CC this e-mail to the people involved in creating the first version
>> of
>> the renewed tutorial, and will bring up the issue in this week's
>> FieldTrip developers meeting.
>>
>> Best,
>>
>> JM
>>
>> On Jan 24, 2011, at 1:51 PM, Michael Wibral wrote:
>>
>>> Hi Jan mathijs,
>>>
>>> I tried to get option1 running, stumbled over the following little
>>> obstacle however:
>>>
>>> I tried to keep one cfg throughout the steps ft_definetrial;
>>> ft_artifact_zvalue, ft_rejectartifcat (with option complete and some
>>> tracking of where artfecats were found), ft_preprocessing (cutting
>>> out the clean trials from the cont. data). IMHO this used to be the
>>> way most people did this kind of procesing a while ago.
>>>
>>> However, I can't get ft_artifact_zvalue to run with different
>>> settings one after another for jump/musvle/EOG. FT claims after the
>>> first run of ft_artifact_zvalue that the z-value thing has been
>>> performed and refuse to detect other artifacts with new settings.
>>>
>>>> From here I only see two alternative: specifying a really lengthy
>>>> cfg every time a new (also struggling with the cfg.dataset versus
>>>> cfg.datafile issue) and do the bookkeeping of cfg.trl and related
>>>> things myself or manually removing the cfg.artdef.zvalue.artifct
>>>> field to get the z-value based detection to run again. This seems a
>>>> bit odd to me.
>>>
>>> Any suggestions?
>>>
>>> Michael
>>>
>>>
>>>
>>>
>>> -----Ursprüngliche Nachricht-----
>>> Von: "jan-mathijs schoffelen" <jan.schoffelen at donders.ru.nl>
>>> Gesendet: Jan 24, 2011 12:12:57 PM
>>> An: "Email discussion list for the FieldTrip project" <fieldtrip at donders.ru.nl
>>>>
>>> Betreff: Re: [FieldTrip] more on artfifact rejection
>>>
>>>> Dear Michael,
>>>>
>>>> I agree. The tutorial should be 'de'-confused by sketching option
>>>> 1,
>>>> and another one should be describing option 2, or the original
>>>> should
>>>> be clearly making the distinction.
>>>>
>>>> Best,
>>>>
>>>> JM
>>>>
>>>>
>>>> On Jan 24, 2011, at 11:48 AM, Michael Wibral wrote:
>>>>
>>>>> Hi Jan-Mathijs,
>>>>>
>>>>> I am a bit unsure how to proceed:
>>>>>
>>>>> (1) sketch the artifact correction way like this
>>>>> ft-definetrial -> artifact.XXX.YYY -> ft_rejectartifact ->
>>>>> ft_preprocessing
>>>>> OR
>>>>> (2) ft-definetrial -> ft_preprocessing (with cfg.padding) ->
>>>>> artifact.XXX.YYY -> ft_rejectartifact(cfg, data) ->
>>>>> ft_preprocessing.
>>>>>
>>>>> I think I should go for option (1) as this seems to be the
>>>>> standard
>>>>> use on continuous data. Sometime in the futrure one should then
>>>>> add
>>>>> a tutorial for those that have data in trials to start with.
>>>>>
>>>>> Michael
>>>>>
>>>>> -----Ursprüngliche Nachricht-----
>>>>> Von: "jan-mathijs schoffelen" <jan.schoffelen at donders.ru.nl>
>>>>> Gesendet: Jan 21, 2011 9:55:48 AM
>>>>> An: "Email discussion list for the FieldTrip project" <fieldtrip at donders.ru.nl
>>>>>>
>>>>> Betreff: Re: [FieldTrip] more on artfifact rejection
>>>>>
>>>>>> Dear Michael,
>>>>>>
>>>>>> Yes, I agree with you here as well. In principle the
>>>>>> ft_artifact_zvalue supports data as a second input argument,
>>>>>> but in
>>>>>> such case the different types of padding in the cfg do not make
>>>>>> sense.
>>>>>> I would indeed remove the second input arguments in the example
>>>>>> code
>>>>>> snippets. Could I ask you to take care of that?
>>>>>>
>>>>>> Thanks,
>>>>>>
>>>>>> JM
>>>>>>
>>>>>>
>>>>>> On Jan 20, 2011, at 10:51 AM, Michael Wibral wrote:
>>>>>>
>>>>>>> Deal Fieldtrip users,
>>>>>>>
>>>>>>> there is something else I do not understand in the tutorial: if
>>>>>>> you
>>>>>>> read in the data in trials (as it is done) how can you do
>>>>>>> padding
>>>>>>> later as it is suggested. I tried to run the example code on teh
>>>>>>> website reading in the data such that it contains trials. If I
>>>>>>> then
>>>>>>> try to search for muscle artifacts I get the 'subscript indices
>>>>>>> must
>>>>>>> be positive or logical ... values', indicating that the code
>>>>>>> tries
>>>>>>> to access data that aren't there. If I set the padding to zero
>>>>>>> (instead of 0.1) it works. So I am wondering wether somehow one
>>>>>>> should actually run these things on continuous data (contrary to
>>>>>>> what is indicated in the tutorial)?
>>>>>>>
>>>>>>> Michael
>>>>>>> <Michael Wibral.vcf><Michael
>>>>>>> Wibral.vcf>_______________________________________________
>>>>>>> fieldtrip mailing list
>>>>>>> fieldtrip at donders.ru.nl
>>>>>>> http://mailman.science.ru.nl/mailman/listinfo/fieldtrip
>>>>>>
>>>>>> Dr. J.M. (Jan-Mathijs) Schoffelen
>>>>>> Donders Institute for Brain, Cognition and Behaviour,
>>>>>> Centre for Cognitive Neuroimaging,
>>>>>> Radboud University Nijmegen, The Netherlands
>>>>>> J.Schoffelen at donders.ru.nl
>>>>>> Telephone: 0031-24-3614793
>>>>>>
>>>>>> _______________________________________________
>>>>>> fieldtrip mailing list
>>>>>> fieldtrip at donders.ru.nl
>>>>>> http://mailman.science.ru.nl/mailman/listinfo/fieldtrip
>>>>> <Michael
>>>>> Wibral.vcf>_______________________________________________
>>>>> fieldtrip mailing list
>>>>> fieldtrip at donders.ru.nl
>>>>> http://mailman.science.ru.nl/mailman/listinfo/fieldtrip
>>>>
>>>> Dr. J.M. (Jan-Mathijs) Schoffelen
>>>> Donders Institute for Brain, Cognition and Behaviour,
>>>> Centre for Cognitive Neuroimaging,
>>>> Radboud University Nijmegen, The Netherlands
>>>> J.Schoffelen at donders.ru.nl
>>>> Telephone: 0031-24-3614793
>>>>
>>>>
>>>> _______________________________________________
>>>> fieldtrip mailing list
>>>> fieldtrip at donders.ru.nl
>>>> http://mailman.science.ru.nl/mailman/listinfo/fieldtrip
>>> <Michael Wibral.vcf>_______________________________________________
>>> fieldtrip mailing list
>>> fieldtrip at donders.ru.nl
>>> http://mailman.science.ru.nl/mailman/listinfo/fieldtrip
>>
>> Dr. J.M. (Jan-Mathijs) Schoffelen
>> Donders Institute for Brain, Cognition and Behaviour,
>> Centre for Cognitive Neuroimaging,
>> Radboud University Nijmegen, The Netherlands
>> J.Schoffelen at donders.ru.nl
>> Telephone: 0031-24-3614793
>>
>>
>> _______________________________________________
>> fieldtrip mailing list
>> fieldtrip at donders.ru.nl
>> http://mailman.science.ru.nl/mailman/listinfo/fieldtrip
> <Michael Wibral.vcf>_______________________________________________
> fieldtrip mailing list
> fieldtrip at donders.ru.nl
> http://mailman.science.ru.nl/mailman/listinfo/fieldtrip
Dr. J.M. (Jan-Mathijs) Schoffelen
Donders Institute for Brain, Cognition and Behaviour,
Centre for Cognitive Neuroimaging,
Radboud University Nijmegen, The Netherlands
J.Schoffelen at donders.ru.nl
Telephone: 0031-24-3614793
More information about the fieldtrip
mailing list