resampledata

Robert Oostenveld roberto at SMI.AUC.DK
Tue Nov 2 17:56:18 CET 2004


Hi Teresa

Reading through your screen output, I notice that you are reusing the
same variable name. I.e. you are doing

cfg = something
datatest = preprocessing, no problem
datatest_filtered = resampledata, also works fine

then you do

cfg = something else, including resamplefs
datatest_filtered = preprocessing -> gives error

Subsequently you appear supprised that datatest_filtered exists, but it
was the result of the first call to resampledata, and not to the second
call to preprocessing. The 2nd preprocessing gave an error and did not
overwrite the variable.

In the old days, resampling used to be done inside preprocessing, but
it actually was a separate function right from its initial
implementation. Conceptually it makes sense to think of
resampling/downsampling as part of the preprocessing, but it never was
implemented optimally in preprocessing. Therefore it was taken out of
the preprocessing. To ensure that people with old configurations do not
incorrectly assume that their preprocessed data is downsampled, it
gives an error if you try to resample/downsample with the preprocessing
function. Instead you should call preprocessing, and then call
resampledata like

cfgpre = something
data = preprocessing(cfgpre);
cfgdwn = []
cfgdwn.resamplefs = something
datadwn = resampledata(cfgdwn, data);
clear data

or in one line as

cfgpre = something
cfgdwn.resamplefs = something
datadwn = resampledata(cfgdwn, preprocessing(cfgpre));

Another hint: if you want to check what configuration was really used
in any fieldtrip analysis step, you should look at the configuration
that is contained in the output data. I will try to implement a more
thorough warning/error system for configuration fields that are not
being used by a specific function.

> I am skipping cfg.detrend ='yes' because it is the default.

The default (of any fieldtrip function) is not neccesary what you want.
Please think about what you want and specify it. Also remember that
defaults can change between versions. For ERPs you probably do not want
to detrend the data prior to downsampling (but you do want to
baselinecorrect with the proper baseline window), for TFRs it does not
really matter too much and it might be advantageous to detrend.
Actually, I don't think that in this case the default is the best
option in general.

> Should I use cfg.downsample=X; instead of resampledata?

No, that is not an option for preprocessing, nor for resampledata.

> The file resampledata.m does not appear in the reference documentation
> list
> of the FieldTrip webpage.

I'll add it in a future version of the documentation. Thanks for
letting me know.

You get the most up to date documentation of any fieldtrip function by
typing "help functionname". You will see from the documentation that
cfg.resamplefs is NOT an option for preprocessing, and also that
cfg.lpfreq is not an option for resampledata (you specified it
incorerctly in the cfg in your mail).

best regards,
Robert

PS Attached you will find the most recent version of resampledata, a
small bug in the re-computation of the time axis has been fixed. Also
the help has been updated.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: resampledata.m
Type: application/octet-stream
Size: 2567 bytes
Desc: not available
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20041102/05af7875/attachment-0003.obj>
-------------- next part --------------



On 2 Nov 2004, at 16:54, Montez, T. wrote:

> Hi,
>
> Using the code:
>
>
> addpath E:\Matlab\fieldtrip-0.9.2
>
> % READING THE DATA
>
> hdr =
> read_fcdc_header('E:\Matlab\Data\A012-4channels.ds\A012
> -4channels.res4');
> dat =
> read_fcdc_data('E:\Matlab\Data\A012-4channels.ds\A012-4channels.meg4',
> hdr, 1, 4096);
>
> cfg = [];
>
> cfg.dataset = 'E:\Matlab\Data\A012-4channels.ds'
> cfg.trl=[1 4096 0]
>
> cfg.channel='MEG'
>
> datatest = preprocessing(cfg)
> save ('E:\Matlab\Data\Test\datatest')
>
> % FILTERING AND RESAMPLE
>
> cfg.lpfreq = 13
>
> cfg.resamplefs = 250
> datatest_filtered = resampledata(cfg, datatest)
>
> cfg.hpfreq = 8
>
> datatest_filtered = preprocessing(cfg)
> save ('E:\Matlab\Data\Test\datatest_filtered')
>
>
> I get the error:
>
>
> % ??? Error using ==> preprocessing
> % resampling is not supported any more, see RESAMPLEDATA
>
>
>
> However it seem to work:
>
>
>>> datatest_filtered
>
> datatest_filtered =
>
>             cfg: [1x1 struct]
>             hdr: [1x1 struct]
>           label: {4x1 cell}
>           trial: {[4x1639 double]}
>          offset: 0
>            time: {[1x1639 double]}
>         fsample: 250
>            grad: [1x1 struct]
>     origfsample: 625
>      origoffset: 0
>        origtime: {[1x4096 double]}
>
>>> cfg
>
> cfg =
>
>        dataset: 'E:\Matlab\Data\A012-4channels.ds'
>            trl: [1 4096 0]
>        channel: 'MEG'
>         lpfreq: 13
>     resamplefs: 250
>         hpfreq: 8
>
>
> I am skipping cfg.detrend ='yes' because it is the default.
>
> Should I use cfg.downsample=X; instead of resampledata?
>
> The file resampledata.m does not appear in the reference documentation
> list
> of the FieldTrip webpage.
>
>
> Thanks,
> Teresa Montez
>
----------------------------------------------------------------------
Robert Oostenveld, PhD
Center for Sensory-Motor Interaction (SMI)
Aalborg University, Denmark

and

F.C. Donders Centre for Cognitive Neuroimaging
University Nijmegen
P.O. Box 9101
NL-6500 AH Nijmegen
The Netherlands

Tel: +31 (0)24 3619695
Fax: +31 (0)24 3610989
----------------------------------------------------------------------
N.B. Starting from 1 September 2004, the University of Nijmegen has
changed its name to Radboud University Nijmegen. All web- and
email-addresses ending in ".kun.nl" should therefore be changed into
".ru.nl". Please update your address book and links.


More information about the fieldtrip mailing list