[FieldTrip] Appending data.grad, after using D.ftraw(0)

smoratti at psi.ucm.es smoratti at psi.ucm.es
Mon Sep 10 15:55:26 CEST 2012

Dear George,

Your approach was right, and it would have worked with older versions of field trip. Now in field trip the grad field contents have changed a little bit.

Now it contains

balance: [1x1 struct]
     chanori: [306x3 double]
     chanpos: [306x3 double]
    chantype: {306x1 cell}
    chanunit: {306x1 cell}
     coilori: [510x3 double]
     coilpos: [510x3 double]
       label: {306x1 cell}
         tra: [306x510 double]
        unit: 'cm'

so the field put would be chanpos, ori would be chanori (or coilpos/ coilori depending on your MEG system).

So check this out and you can easily adapt the structure. I think SPM does not go with the últimate field trip version.

I hope this helps,



Stephan Moratti, PhD

see also: http://web.me.com/smoratti/

Universidad Complutense de Madrid
Facultad de Psicología
Departamento de Psicología Básica I
Campus de Somosaguas
28223 Pozuelo de Alarcón (Madrid)


Center for Biomedical Technology
Laboratory for Cognitive and Computational Neuroscience
Parque Científico y Tecnológico de la Universidad Politecnica de Madrid
Campus Montegancedo
28223 Pozuelo de Alarcón (Madrid)

email: smoratti at psi.ucm.es
Tel.:    +34 679219982

El 10/09/2012, a las 14:22, George Wallis escribió:

> Dear fieldtrippers,
> if anyone can help me with this I'd be very grateful!
> I have a bunch of preprocessed and epoched data files in SPM format, and I'm converting them to fieldtrip format using the following:
> D  = spm_eeg_load(fn);
> data = D.ftraw(0);
> ...which results in...
> data = 
>     fsample: 250
>       label: {350x1 cell}
>       trial: {1x360 cell}
>        time: {1x360 cell}
> Comparing this to data structures generated using fieldtrip alone, field like data.grad are missing.
> I can create something like a grad field by doing:
> D.sensors('MEG')
> ans = 
>       pnt: [510x3 double]
>       ori: [510x3 double]
>       tra: [306x510 double]
>      unit: 'mm'
>     label: {306x1 cell}
> If I then append this to the data:
> data.grad = D.sensors('MEG');
> I get an error:
> --- 
> Error using ft_chantype (line 56)
> the input that was provided to this function cannot be deciphered
> Error in ft_datatype_sens (line 128)
>         sens.chantype = ft_chantype(sens);
> Error in ft_datatype_raw (line 99)
>       data.grad = ft_datatype_sens(data.grad);
> Error in ft_checkdata (line 177)
>   data = ft_datatype_raw(data, 'hassampleinfo', hassampleinfo);
> Error in ft_timelockanalysis (line 134)
> data = ft_checkdata(data, 'datatype', {'raw', 'comp'}, 'feedback', 'yes', 'hassampleinfo',
> 'yes');
> Error in ft_SENS_ERF_grRep (line 82)
>             avdat = ft_timelockanalysis(cfg,raw);
> ---
> ...when I try to do timelockanalysis on this data.  If I leave the grad field off (i.e. not append it to the output of ftraw(0)) there's no problem, and the analysis runs fine.  However, because I want to do spatial neighbour cluster analysis later, I think I need the .grad field, so I might as well get it incorporated at this stage.
> Going a bit further into the error messages above, the function ft_datatype_sens appears to convert the old format .ori, .pnt into the newer .coilori, .coilpos ... etc.  But the next function in the chain, ft_chantype, looks for .pnt and .ori when doing:
> isgrad   = isa(input, 'struct') && isfield(input, 'pnt') && isfield(input, 'ori');
> I'm wondering if this could be the problem?
> Sorry for the long message!  I'd be very grateful if anyone can help out.
> Best wishes,
> George
> _______________________________________________
> fieldtrip mailing list
> fieldtrip at donders.ru.nl
> http://mailman.science.ru.nl/mailman/listinfo/fieldtrip

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20120910/444962f9/attachment-0002.html>

More information about the fieldtrip mailing list