[FieldTrip] ft_sourcemovie

Debora Desideri deb.desideri at gmail.com
Wed Jul 13 12:01:26 CEST 2016


Dear Hassan,
to my knowledge ft_sourcemovie works only with sources estimated using MNE.
What you can do is exctrating the source time course (for example using
ft_sourcedescriptives) and then plot each frame and create your own movie
using the matlab function getframe.

Here is a sample code:

%%% Extract source timecourse with ft_sourcedescriptives

%%% source is the output of ft_sourceanalysis with method lcmv

cfg = [];
cfg.projectmom         = 'yes';
cfg.fixedori           = 'over_trials';
source_timecourse         = ft_sourcedescriptives(cfg,source);


Npos = size(source.pos,1);
Ntime = length(source.time);

source_timecourse.avg.momint = nan(Npos,Ntime);


idx = find(source_timecourse.inside);

for i = 1:length(idx)
    index = idx(i);
    source_timecourse.avg.momint(index,:) =
source_timecourse.avg.mom{index};

end

%% Interpolate each time point of interest

 for tt = 1:length(source_timecourse.time) % full trial length or you can
select a time window of interest


    src = source_timecourse;
    src.time = source_timecourse.time(:,tt);

    src.avg.momint = source_tc.avg.momint(:,tt);  % here you may just leave
the time course as it is, or square it or normalize it by a baseline etc etc



    cfg = [];
    cfg.parameter         = 'momint';
    sourceInt{tt}        = ft_sourceinterpolate(cfg, src, mri); % mri is
the mri of your subject or a template mri

    clear src
end



%% Plot on surface ( if you want you can set the colorlimt to be the same
in each frames so you will be able to see changes in the "amplitude" as
well)


for tt = 1:length(sourceInt{tt})


    cfg = [];
    cfg.method            = 'surface';
    cfg.funparameter      = 'momint';
    cfg.funcolormap = 'hot';
    ft_sourceplot(cfg, sourceInt{tt})
    drawnow
    Frames(tt) = getframe; % get the current frame and store it



end

%% Show movie
figure
movie(Frames,1)


%% Save movie (frames) in AVI format

writerObj = VideoWriter('Movie.avi'); % Name it.
%writerObj.FrameRate = 60; % How many frames per second.
open(writerObj);

for tt=1:size(Frames,2)

    writeVideo(writerObj, Frames(tt));
    %end

end
hold off
close(writerObj); % Saves the movie.


Hope this helps :)
Best,
Debora


On Tue, Jul 12, 2016 at 6:35 PM, Hassan Aleem <ha438 at georgetown.edu> wrote:

> Does anyone have an example of how to use ft_sourcemovie to look at source
> localization across time with the 'lcmv' method. would be greatly
> appreciated. Thanks!
>
> _______________________________________________
> fieldtrip mailing list
> fieldtrip at donders.ru.nl
> https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
>



-- 

Debora Desideri, PhD Student
BNP Lab - Neurology Department
University Hospital Tübingen
Eberhard Karls University Tübingen
Hoppe-Seyler Str. 3
D-72076 Tübingen
Tel: +49 7071/29 80478
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20160713/34d7a00b/attachment-0002.html>


More information about the fieldtrip mailing list