<div dir="ltr">














<p class="" style="text-autospace:none"><span style="font-family:Courier">Hi all,</span></p>

<p class="" style="text-autospace:none"><span style="font-family:Courier"> </span></p>

<p class="" style="text-autospace:none"><span style="font-family:Courier">I am a fieldtrip starter working on an EEG data
set. I have a question conce</span><span style="font-family:Courier">rning the </span><span style="font-family:Courier">muscle artifact detection function and I
was hoping that you could help me with this.   </span></p>

<p class="" style="text-autospace:none"><span style="font-family:Courier">I am calling the function </span></p>

<p class="" style="text-autospace:none"><span style="font-family:Courier">[cfg,artifact_muscle]  =
ft_artifact_muscle(cfg,ref_data)  as explained in the manual (settings
suggested) and get the following error message (see code + error):</span></p>

<p class="" style="text-autospace:none"><span style="font-family:Courier">________________________________________________________________________________________________</span></p>

<p class="" style="text-autospace:none"><span style="font-family:Courier">> %detect the MUSCLE artifacts</span></p>

<p class="" style="text-autospace:none"><span style="font-family:Courier">> cfg                              =
[];</span></p>

<p class="" style="text-autospace:none"><span style="font-family:Courier">> cfg.continuous                   =
'yes';</span></p>

<p class="" style="text-autospace:none"><span style="font-family:Courier">> % define trial first</span></p>

<p class="" style="text-autospace:none"><span style="font-family:Courier">> cfg.dataset                      =
'xx’;</span></p>

<p class="" style="text-autospace:none"><span style="font-family:Courier">> cfg.trialfun                     ='trialfun_general';</span></p>

<p class="" style="text-autospace:none"><span style="font-family:Courier">> cfg.trialdef.triallength         =1;                  
% creates 1-second data segments </span></p>

<p class="" style="text-autospace:none"><span style="font-family:Courier">> cfg.trialdef.ntrials    <span style>     </span><span style>     </span><span style>     </span>=  
inf;   </span></p>

<p class="" style="text-autospace:none"><span style="font-family:Courier"><span style>     </span><span style>     </span><span style>     </span><span style>     </span><span style>     </span>% i.e. the complete
file</span></p>

<p class="" style="text-autospace:none"><span style="font-family:Courier">> cfg                          
= ft_definetrial(cfg);</span></p>

<p class="" style="text-autospace:none"><span style="font-family:Courier">> </span></p>

<p class="" style="text-autospace:none"><span style="font-family:Courier">> % cutoff</span></p>

<p class="" style="text-autospace:none"><span style="font-family:Courier">>
cfg.artfctdef.muscle.channel      = 'all';</span></p>

<p class="" style="text-autospace:none"><span style="font-family:Courier">>
cfg.artfctdef.muscle.cutoff         = 4;</span></p>

<p class="" style="text-autospace:none"><span style="font-family:Courier">>   </span></p>

<p class="" style="text-autospace:none"><span style="font-family:Courier">> % algorithmic parameters</span></p>

<p class="" style="text-autospace:none"><span style="font-family:Courier">>
cfg.artfctdef.muscle.bpfilter        =
'yes';</span></p>

<p class="" style="text-autospace:none"><span style="font-family:Courier">>
cfg.artfctdef.muscle.bpfreq         
= [110 140];</span></p>

<p class="" style="text-autospace:none"><span style="font-family:Courier">>
cfg.artfctdef.muscle.bpfiltord       = 9;</span></p>

<p class="" style="text-autospace:none"><span style="font-family:Courier">>
cfg.artfctdef.muscle.bpfilttype      = 'but';</span></p>

<p class="" style="text-autospace:none"><span style="font-family:Courier">> cfg.artfctdef.muscle.hilbert          
= 'yes';</span></p>

<p class="" style="text-autospace:none"><span style="font-family:Courier">>
cfg.artfctdef.muscle.boxcar          
= 0.2;</span></p>

<p class="" style="text-autospace:none"><span style="font-family:Courier">>   </span></p>

<p class="" style="text-autospace:none"><span style="font-family:Courier">> % feedback</span></p>

<p class="" style="text-autospace:none"><span style="font-family:Courier">>
%cfg.artfctdef.muscle.interactive   = 'yes'; % to adjust cutoff
zvalue if needed</span></p>

<p class="" style="text-autospace:none"><span style="font-family:Courier">>    </span></p>

<p class="" style="text-autospace:none"><span style="font-family:Courier">> [cfg, artifact_muscle] =
ft_artifact_muscle(cfg,ref_data);</span></p>

<p class="" style="text-autospace:none"><span style="font-family:Courier">> </span></p>

<p class="" style="text-autospace:none"><span style="font-family:Courier">> </span></p>

<p class="" style="text-autospace:none"><span style="font-family:Courier">> </span></p>

<p class="" style="text-autospace:none"><span style="font-family:Courier">> </span></p>

<p class="" style="text-autospace:none"><span style="font-family:Courier">> ERROR:</span></p>

<p class="" style="text-autospace:none"><span style="font-family:Courier">> Subscript indices must either be real
positive integers or logicals.</span></p>

<p class="" style="text-autospace:none"><span style="font-family:Courier">> </span></p>

<p class="" style="text-autospace:none"><span style="font-family:Courier">> Error in ft_fetch_data (line 123)</span></p>

<p class="" style="text-autospace:none"><span style="font-family:Courier">>       
count     = count(begsample:endsample);</span></p>

<p class="" style="text-autospace:none"><span style="font-family:Courier">> </span></p>

<p class="" style="text-autospace:none"><span style="font-family:Courier">> Error in ft_artifact_zvalue (line 195)</span></p>

<p class="" style="text-autospace:none"><span style="font-family:Courier">>         
dat{trlop} = ft_fetch_data(data,       
'header', hdr, 'begsample', trl(trlop,1)-fltpadding, 'endsample',
trl(trlop,2)+fltpadding, 'chanindx',</span></p>

<p class="" style="text-autospace:none"><span style="font-family:Courier">>         
sgnind, 'checkboundary', strcmp(cfg.continuous,'</span></p>

<p class="" style="text-autospace:none"><span style="font-family:Courier">> Error in ft_artifact_muscle (line 156)</span></p>

<p class="" style="text-autospace:none"><span style="font-family:Courier">>      [tmpcfg,
artifact] = ft_artifact_zvalue(tmpcfg, data);</span></p>

<p class="" style="text-autospace:none"><span style="font-family:Courier">>
_______________________________________________________</span></p>

<p class="" style="text-autospace:none"><span style="font-family:Courier"> </span></p>

<p class="" style="text-autospace:none"><span style="font-family:Courier"> </span></p>

<p class="" style="text-autospace:none"><span style="font-family:Courier">However, I only get the error message with the
default/suggested values. </span></p>

<p class="" style="text-autospace:none"><span style="font-family:Courier">When I use:</span></p>

<p class="" style="text-autospace:none"><span style="font-family:Courier">cfg.artfctdef.muscle.bpfreq = [110 120]; and
cfg.artfctdef.muscle.bpfiltord  = 7; </span></p>

<p class="" style="text-autospace:none"><span style="font-family:Courier">I don't get the error message and the script runs
properly. Does anyone happen to know what could have let to this problem?</span></p>

<p class="" style="text-autospace:none"><span style="font-family:Courier"> </span></p>

<p class="" style="text-autospace:none"><span style="font-family:Courier">Thanks a lot in advance!</span></p>

<p class=""><span style="font-family:Courier">Best, Leonie</span></p>

</div>