[FieldTrip] Trial by Trial Source Reconstruction for Decoding

Barnett, Benjy benjy.barnett.20 at ucl.ac.uk
Tue Apr 25 14:32:46 CEST 2023


Sorry for multiple posting, please ignore - I have just noticed the cfg.rawtrials option in ft_sourceanalysis, which makes this much simpler.

Thank you

On Apr 25, 2023, at 1:12 PM, Barnett, Benjy via fieldtrip <fieldtrip at science.ru.nl<mailto:fieldtrip at science.ru.nl>> wrote:


⚠ Caution: External sender

Hi all,

I’m trying to implement some MVPA decoding analyses in source space using MEG data collected on a CTF system. I have gone through different tutorials to perform the source reconstruction (namely https://urldefense.com/v3/__https://www.fieldtriptoolbox.org/workshop/aarhus/beamformingerf/__;!!HJOPV4FYYWzcc1jazlU!4HiCPnTY4ZHLBQO-35S-qTzf4nEOOD1IKhyJGLDYrHsrcjodns47ZrpV1HfVBgHidCK45KCLe79g6tzsGhQWqnFMt5BoIWV1xA$ <https://urldefense.com/v3/__https://www.fieldtriptoolbox.org/workshop/aarhus/beamformingerf/__;!!HJOPV4FYYWzcc1jazlU!6dJY9xn9eTEqqGoXULa_OMBzAvS3Cl7jDWxpxhESR-a61x1hEJWt38h4sKsVfLMoG9DIkPTj6qamNi18fKgf9dtYDIaRLfHvTw$>; https://urldefense.com/v3/__https://www.fieldtriptoolbox.org/workshop/paris2019/handson_sourceanalysis/__;!!HJOPV4FYYWzcc1jazlU!4HiCPnTY4ZHLBQO-35S-qTzf4nEOOD1IKhyJGLDYrHsrcjodns47ZrpV1HfVBgHidCK45KCLe79g6tzsGhQWqnFMt5DgySA0Xg$ <https://urldefense.com/v3/__https://www.fieldtriptoolbox.org/workshop/paris2019/handson_sourceanalysis/__;!!HJOPV4FYYWzcc1jazlU!6dJY9xn9eTEqqGoXULa_OMBzAvS3Cl7jDWxpxhESR-a61x1hEJWt38h4sKsVfLMoG9DIkPTj6qamNi18fKgf9dtYDIZKqhJFug$>).

To train my decoder, I will obviously need trial by trial activity estimates for each of the virtual channels. The issue is that these tutorials, and most other information I can find, only go into how to extract condition-level source estimates. I have an idea of how to do this for individual trials, but it’s such a shift from the tutorials I wondered if I could check whether my plan will work conceptually and technically.

My current code (to obtain condition level estimates) is as follows:

    % Compute Covariance Matrix
    cfg = [];
    cfg.covariance = 'yes';
    avg = ft_timelockanalysis(cfg,meg_data); %meg_data = datazero + datanotzero;

    cfg.keeptrials = 'yes';
    avgzero = ft_timelockanalysis(cfg,datazero); %condition 1 = ‘zero'
    avgnotzero = ft_timelockanalysis(cfg,datanotzero); %condition 2 = ’not zero'

    %Calculate spatial filter for each voxel over all data
    cfg = [];
    cfg.method = 'lcmv';
    cfg.sourcemodel = sourcemodel_new;
    cfg.headmodel = headmodel_new;
    cfg.lcmv.keepfilter = 'yes';
    cfg.lcmv.lambda = '5%';
    cfg.lcmv.weightnorm = 'unitnoisegain';
    cfg.lcmv.fixedori = 'yes';
    cfg.channel = {'MEG'};
    cfg.senstype = 'MEG';
    sourceavg = ft_sourceanalysis(cfg, avg); %compute filters over all trials

    %Now apply this filter to zero and not-zero data separately
    cfg = [];
    cfg.method = 'lcmv';
    cfg.sourcemodel = sourcemodel_new;
    cfg.sourcemodel.filter = sourceavg.avg.filter;
    cfg.headmodel = headmodel_new;
    sourcezero = ft_sourceanalysis(cfg, avgzero);
    sourcenotzero = ft_sourceanalysis(cfg, avgnotzero);

Would I be correct to simply alter this pipeline so that I perform the call to ft_timelockanalysis and estimate the covariance matrix for each trial individually, rather than each condition? Then I was planning to simply run the ft_sourceanalysis function on each of these trials individually, keeping track of which trial belongs to which condition for later use in decoding. I can then go into the source output from the sourceanalysis and extract the .mom field to get the virtual channel data per trial, which I plan to then enter into the decoder.

Does this make sense conceptually? It seems a logical step from the beamforming of condition level signals, but I’ve come to learn it’s rarely that simple!

I hope that all makes sense,

Benjy
_______________________________________________
fieldtrip mailing list
https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
https://urldefense.com/v3/__https://doi.org/10.1371/journal.pcbi.1002202__;!!HJOPV4FYYWzcc1jazlU!4HiCPnTY4ZHLBQO-35S-qTzf4nEOOD1IKhyJGLDYrHsrcjodns47ZrpV1HfVBgHidCK45KCLe79g6tzsGhQWqnFMt5BvVIyIiw$ 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20230425/97c003ef/attachment.htm>


More information about the fieldtrip mailing list