<div dir="ltr">Hi Alex,<div><br></div><div>Sorry for the late response. </div><div>With regards to the first question, all filtering frequencies should be specified in Hz. So, if you want a low pass at 10Hz, a high pass at 100Hz, and a band-stop between 59 and 61 Hz, you should specify (which likely fixes the error):</div>

<div><span style="font-family:arial,sans-serif;font-size:13px">cfg.lpfreq        = 100</span><br style="font-family:arial,sans-serif;font-size:13px"><span style="font-family:arial,sans-serif;font-size:13px">cfg.hpfreq        = 10</span><br style="font-family:arial,sans-serif;font-size:13px">

<span style="font-family:arial,sans-serif;font-size:13px">cfg.bsfreq        = [59 61]</span><br></div><div>Padding should be specified as the total number of seconds of each trial, and (200-30)/2 seconds on each side seems a bit rigorous for removing filtering artifacts ;). Unless you were intentionally using a low pass of 10/500 = 0.02 Hz. The longer the impulse response of the filter, the more padding is needed to remove edge artifacts. (A 4th order butt of a very low low-pass would have the IIR's filters version of an impulse response that is very very long). In general, when using the above suggested filtering frequencies and a 4th order butterworth and a sampling of 500Hz, a few seconds of padding on both sides of the trial will likely be enough to prevent edge artifacts.</div>

<div><br></div><div>However, when importing an unsupported data format, you cannot make use of data-padding, which is the most optimal one. You could opt for zero/mean/mirror padding, but they add transition artifacts, which might be even worse than your edge-artifacts. Don't use these unless it's really the only option, and be careful when doing so. My suggestion in your case would be to segment the data (during importing) with additional data, and remove this data after filtering, by hand (take care to adjust not only data.trial, but also data.time). So, if trial #2 would last from 30 to 60 seconds, segment it from 25 to 65, filter it, and remove the first 5 and the last 5 seconds. This will, of course, create issues if you want to use the first 5 seconds of data. </div>

<div><br></div><div><span style="font-family:arial,sans-serif;font-size:13px">With regards to your second question, the error suggests you used an improper cfg.pad option. I don't see this in your code though, are you absolutely sure you didn't include a cfg.pad? This should be specified in seconds, which is the total length of each trial + padding. If left out, this defaults to the length of the largest trial. Note though, this refers to zero padding for spectral interpolation. Also, the option cfg.tapsmofrq is only used if you specifiy cfg.taper = 'dpss'. It isn't used when using cfg.taper = 'hanning'.</span></div>

<div><span style="font-family:arial,sans-serif;font-size:13px"><br></span></div><div><span style="font-family:arial,sans-serif;font-size:13px">Cheers,<br>Roemer</span></div><div><span style="font-family:arial,sans-serif;font-size:13px"><br>

</span></div><div><span style="font-family:arial,sans-serif;font-size:13px"><br></span></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Sep 12, 2013 at 5:54 PM, Alexander Reyes <span dir="ltr"><<a href="mailto:reyesale@usc.edu" target="_blank">reyesale@usc.edu</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hello,<br><br>I am having some difficulty getting my data into a format that can be read by FieldTrip correctly. I apologize in advance for the length of this e mail. This is actually a two part question. <br>


<br>1. The data I am trying to analyze consists of electrocorticography (ECoG) data rather than EEG or MEG and was collected with a system not supported by FieldTrip. My raw data are segmented into 30 second trials (22 in total) and arranged into columns representing 76 ECoG and 8 EMG channels and sampled at 500 Hz. There are no markers or triggers in my data as of now since this is preliminary data. Additionally, I have not removed any artifacts from the data nor have I redefined any trials.<br>


<br>Following the FAQ for importing a generic data format, I have successfully created the following structure:<br><br>data.label =          subjectData.Labels;<br>data.fsample =     subjectData.Fs;<br>data.trial =         subjectData.TrialData;<br>


data.time =          subjectData.Ref;<br><br>I have fed this data into the ft_preprocessing.m function with the configuration shown below.  <br><br>cfg = [];<br>cfg.channel       = 'C*';<br>cfg.lpfilter      = 'yes';            <br>


cfg.hpfilter      = 'yes';            <br>cfg.bsfilter      = 'yes';            <br>cfg.lpfreq        = 100/data.fsample;          <br>cfg.hpfreq        = 10/data.fsample;           <br>cfg.bsfreq        = [59 61]/data.fsample;      <br>


cfg.lpfiltord     = 4;                <br>cfg.hpfiltord     = 4;                <br>cfg.bpfiltord     = 4;                <br>cfg.lpfilttype    = 'but';            <br>cfg.hpfilttype    = 'but';<br>ecog = ft_preprocessing(cfg,data);<br>


<br>The generated file filters the data correctly, but there are edge effects so I would like to pad the data. However, when I insert the two extra lines shown below and then run ft_preprocessing, I get the error that follows.  <br>


<br>cfg.padding       = 200;              <br>cfg.padtype       = 'data'; <br>       <br><br>Error using butter (line 83)<br>butter: critical frequencies must be in (0 1)<br><br>Error in ft_preproc_lowpassfilter (line 93)<br>


    [B, A] = butter(N, max(Flp)/Fn);<br><br>Error in preproc (line 297)<br>if strcmp(cfg.lpfilter, 'yes'),     dat = ft_preproc_lowpassfilter(dat, fsample, cfg.lpfreq, cfg.lpfiltord, cfg.lpfilttype,<br>cfg.lpfiltdir, cfg.lpinstabilityfix); end<br>


<br>Error in ft_preprocessing (line 323)<br>    [dataout.trial{i}, dataout.label, dataout.time{i}, cfg] = preproc(data.trial{i}(rawindx,:), data.label(rawindx),  data.time{i},<br>    cfg, begpadding, endpadding);<br><br>

I would appreciate some help as to why the padding does not work for my data set.<br>
<br>2. In an attempt to keep moving forward, I have bypassed the padding and tried to do a simple frequency analysis using the following configuration: <br><br>cfg = [];<br>cfg.method = 'mtmfft'; <br>cfg.output = 'pow';<br>


cfg.foi = [1:30];<br>cfg.taper = 'hanning';<br>cfg.t_ftimwin = 4./cfg.foi;   <br>cfg.toi = 0:0.5:30;         <br>cfg.tapsmofrq = 4;<br>freq = ft_freqanalysis (cfg,ecog);<br> <br>But I get the following error:<br>

<br>
Error using ft_specest_mtmfft (line 75)<br>the padding that you specified is shorter than the data<br><br>Error in ft_freqanalysis (line 503)<br>      [spectrum,ntaper,foi] = ft_specest_mtmfft(dat, time, 'taper', cfg.taper, options{:}, 'feedback', fbopt);<br>


<br>I was wondering if I could get some help decrypting this error message.<br><br>Thank you in advance.<br><br>Alex.<br><br><br></div>
<br>_______________________________________________<br>
fieldtrip mailing list<br>
<a href="mailto:fieldtrip@donders.ru.nl">fieldtrip@donders.ru.nl</a><br>
<a href="http://mailman.science.ru.nl/mailman/listinfo/fieldtrip" target="_blank">http://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a><br></blockquote></div><br></div><br clear="all"><div><br></div>-- <br><font size="3"><font color="darkblue"><font face="calibri">Roemer
            van der Meij M.Sc.<br>
            PhD Candidate<br>
            Donders Institute for Brain, Cognition and Behaviour<br>
            Centre for Cognition<br>
            P.O. Box 9104<br>
            6500 HE Nijmegen<br>
            The Netherlands<br>
            Tel: +31(0)24 3655932<br>
            E-mail: <a href="mailto:r.vandermeij@donders.ru.nl" target="_blank">r.vandermeij@donders.ru.nl</a></font></font></font><div style="padding:0px;margin-left:0px;margin-top:0px;overflow:hidden;word-wrap:break-word;color:black;font-size:10px;text-align:left;line-height:130%">

</div>