[FieldTrip] Computing ERFs from HCP MEG Motor Task

Fabio Strappazzon fab.strappaz at gmail.com
Tue Jun 3 13:44:57 CEST 2025


Dear all,

I'm trying to extract ERFs from HCP MEG minimally preprocessed data
from the motor task (right hand trials) and before doing the trial
averaging I'm computing very simple operations (trial selection,
0.5-60 Hz bandpass filtering and demeaning).
I'm considering each run as independent, giving the fact that the
sensor information is different across the two runs and this might
affect the future source reconstruction.
However, when I then compute the trial average, the evoked activity is
not evident.
Am I missing something?

This is the script:

clear all
close all
clc

filesystem_dir % retrieves directories
ft_init
cd(scriptsdir)
mySub = '177746';
preprocdir = [datadir,mySub,'\MEG\Motort\tmegpreproc']; % preprocessed data dir
subj_resdir = [resdir,mySub]; % results directory
irun = 10;

% loads minimally preprocessed data and trialinfo
cd(preprocdir)
load(sprintf([mySub,'_MEG_%d-Motort_tmegpreproc_TEMG.mat'],irun)) %
run 1 (t0 is the EMG onset)
load(sprintf([mySub,'_MEG_%d-Motort_tmegpreproc_trialinfo.mat'],irun))
% WARNING: First columns are for EMG onsets, seconds for flash
stimulus onset

% selecting only right hand data
cfg = [];
cfg.channel = {'MEG'}; % read all MEG channels except EMG channels
cfg.trials = find(data.trialinfo(:, 2) == 4); % select only right hand trials
data_rh = ft_selectdata(cfg, data);

% Wide-band BP filtering (prior to baseline correction):
cfg = [];
cfg.hpfilter = 'yes';
cfg.hpfreq = .5;
fdata_temp = ft_preprocessing(cfg, data_rh);

cfg = [];
cfg.lpfilter = 'yes';
cfg.lpfreq = 60;
fdata_rh = ft_preprocessing(cfg, fdata_temp);

% Baseline correcting epochs;
cfg = [];
cfg.demean = 'yes';
cfg.baselinewindow = [-0.3 0]; % -300 ms to 0 (chosen by HCP)
fdata2avg = ft_preprocessing(cfg, fdata_rh);

% ERF (avg across bsln corrected trials)
cfg = [];
avg_rh = ft_timelockanalysis(cfg, fdata2avg);

% Plot
cfg = [];
cfg.showlabels = 'yes';
cfg.fontsize = 6;
cfg.layout = '4d248_helmet.mat';
cfg.ylim = [-3e-13 3e-13]; % problem is present also when the scale is adjusted
ft_multiplotER(cfg, avg_rh);

Thanks in advance.
Best regards,

Fabio.


More information about the fieldtrip mailing list