<div dir="ltr">Dear Fabio,<div><br></div><div>some sanity checks I would suggest:</div><div>* Are there NANs in the data somewhere (e.g. any(isnan(data(:)))</div><div>* Are the time-axes aliges between all trials?</div><div>* Are the channel labels the same in all trials?</div><div><br></div><div>Any of these things can lead to omitted data, and given enough trials will lead to empty data.</div><div><br></div><div>Hope this helps,</div><div><br></div><div>Julian</div></div><br><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">On Tue, Jun 3, 2025 at 2:26 PM Fabio Strappazzon via fieldtrip <<a href="mailto:fieldtrip@science.ru.nl">fieldtrip@science.ru.nl</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Dear all,<br>
<br>
I'm trying to extract ERFs from HCP MEG minimally preprocessed data<br>
from the motor task (right hand trials) and before doing the trial<br>
averaging I'm computing very simple operations (trial selection,<br>
0.5-60 Hz bandpass filtering and demeaning).<br>
I'm considering each run as independent, giving the fact that the<br>
sensor information is different across the two runs and this might<br>
affect the future source reconstruction.<br>
However, when I then compute the trial average, the evoked activity is<br>
not evident.<br>
Am I missing something?<br>
<br>
This is the script:<br>
<br>
clear all<br>
close all<br>
clc<br>
<br>
filesystem_dir % retrieves directories<br>
ft_init<br>
cd(scriptsdir)<br>
mySub = '177746';<br>
preprocdir = [datadir,mySub,'\MEG\Motort\tmegpreproc']; % preprocessed data dir<br>
subj_resdir = [resdir,mySub]; % results directory<br>
irun = 10;<br>
<br>
% loads minimally preprocessed data and trialinfo<br>
cd(preprocdir)<br>
load(sprintf([mySub,'_MEG_%d-Motort_tmegpreproc_TEMG.mat'],irun)) %<br>
run 1 (t0 is the EMG onset)<br>
load(sprintf([mySub,'_MEG_%d-Motort_tmegpreproc_trialinfo.mat'],irun))<br>
% WARNING: First columns are for EMG onsets, seconds for flash<br>
stimulus onset<br>
<br>
% selecting only right hand data<br>
cfg = [];<br>
cfg.channel = {'MEG'}; % read all MEG channels except EMG channels<br>
cfg.trials = find(data.trialinfo(:, 2) == 4); % select only right hand trials<br>
data_rh = ft_selectdata(cfg, data);<br>
<br>
% Wide-band BP filtering (prior to baseline correction):<br>
cfg = [];<br>
cfg.hpfilter = 'yes';<br>
cfg.hpfreq = .5;<br>
fdata_temp = ft_preprocessing(cfg, data_rh);<br>
<br>
cfg = [];<br>
cfg.lpfilter = 'yes';<br>
cfg.lpfreq = 60;<br>
fdata_rh = ft_preprocessing(cfg, fdata_temp);<br>
<br>
% Baseline correcting epochs;<br>
cfg = [];<br>
cfg.demean = 'yes';<br>
cfg.baselinewindow = [-0.3 0]; % -300 ms to 0 (chosen by HCP)<br>
fdata2avg = ft_preprocessing(cfg, fdata_rh);<br>
<br>
% ERF (avg across bsln corrected trials)<br>
cfg = [];<br>
avg_rh = ft_timelockanalysis(cfg, fdata2avg);<br>
<br>
% Plot<br>
cfg = [];<br>
cfg.showlabels = 'yes';<br>
cfg.fontsize = 6;<br>
cfg.layout = '4d248_helmet.mat';<br>
cfg.ylim = [-3e-13 3e-13]; % problem is present also when the scale is adjusted<br>
ft_multiplotER(cfg, avg_rh);<br>
<br>
Thanks in advance.<br>
Best regards,<br>
<br>
Fabio.<br>
_______________________________________________<br>
fieldtrip mailing list<br>
<a href="https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmailman.science.ru.nl%2Fmailman%2Flistinfo%2Ffieldtrip&data=05%7C02%7Cfieldtrip%40science.ru.nl%7C9c039cc120b64a7279ba08dda2a0e63d%7C084578d9400d4a5aa7c7e76ca47af400%7C1%7C0%7C638845534151135669%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=y64Wi3T6DyqI5fSg5GpWSLVdWrabI5qjT1VTWZ7fNWc%3D&reserved=0" originalSrc="https://mailman.science.ru.nl/mailman/listinfo/fieldtrip" rel="noreferrer" target="_blank">https://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a><br>
<a href="https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fdoi.org%2F10.1371%2Fjournal.pcbi.1002202&data=05%7C02%7Cfieldtrip%40science.ru.nl%7C9c039cc120b64a7279ba08dda2a0e63d%7C084578d9400d4a5aa7c7e76ca47af400%7C1%7C0%7C638845534151150493%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=quo6jJ9r0lORBoP%2B1%2BjQbdBGXVzN9HKDlk82vOSd5LE%3D&reserved=0" originalSrc="https://doi.org/10.1371/journal.pcbi.1002202" rel="noreferrer" target="_blank">https://doi.org/10.1371/journal.pcbi.1002202</a><br>
</blockquote></div>