[FieldTrip] Computing ERFs from HCP MEG Motor Task
Fabio Strappazzon
fab.strappaz at gmail.com
Tue Jun 3 16:54:01 CEST 2025
Dear Julian and Stephan,
Thank you for your feedback.
Answering to Julian, no missing data are present that I'm aware of, at
least inspecting the data structures and checking for NaNs. So I'm assuming
that's not the problem.
Answering to Stephan:
The responses are locked to the EMG onset (so the motor response).
The interesting fact is that, when I extract the induced response by means
of subtracting the faulty "ERF", the sensorimotor responses can be observed
(sensorimotor alpha and lateralized beta ERD). The point is, I'm not sure
if I'm actually subtracting the evoked response (what I would like to do)
or just noise.
Moreover, in the figure outputs released by the HCP, the ERFs can be
observed around the first 200 ms, although they merged the two runs.
Also, inside each epoch, multiple EMG responses can be present but the
problem persists even after appropriately cropping the data and isolating a
single EMG response for epoch.
These are the sanity checks implemented:
%% Sanity checks suggested
allData = reshape([data_rh.trial{:}],
[length(data_rh.label),length(data_rh.time{1}),length(data_rh.trial)]);
any(isnan(allData(:)))
% Extracting the induced
for k = 1:numel(data_rh.trial)
data_rh.trial{k} = data_rh.trial{k} - avg_rh.avg;
end
% Cropping data (because of multiple EMG responses inside an epoch) -> step
from Chieti Workshop (2015)
cfg = [];
cfg.latency = [-.75 .75];
data_rh = ft_selectdata(cfg, data_rh); % fake data structure to save as
cropped
% Wavelet Averaging over trials (Avg TFR) keeping single trials
cfg = [];
cfg.channel = 'meg';
cfg.method = 'wavelet';
cfg.output = 'pow';
cfg.keeptrials = 'yes';
cfg.foi = 1:2:60; % freq range (linearly spaced)
cfg.toi = data_rh.time{1}(1:25:end); % every 25th timepoint, approximately
every 50 ms; time windows
tfr_rh = ft_freqanalysis(cfg, data_rh);
cfg = [];
tfr_rh_pow = ft_freqdescriptives(cfg, tfr_rh);
cfg = [];
cfg.baseline = [-3 0];
cfg.baselinetype = 'relchange';
cfg.showlabels = 'yes';
cfg.layout = '4d248_helmet.mat';
% cfg.zlim = [0 2];
figure('name', 'Right hand TFR responses')
ft_multiplotTFR(cfg, tfr_rh_pow);
Il giorno mar 3 giu 2025 alle ore 15:55 STEPHAN MORATTI via fieldtrip <
fieldtrip at science.ru.nl> ha scritto:
> Dear Fabio,
>
> Make sure that the trigger info is correct and precise. Motor
> responses usually are not phase locked to an external stimulus.
> You could calculate induced frequency activity and see if you get a
> contra-lateralized beta band desynchronization (that is not
> phase locked to the onset of your stimulus).
>
> best,
>
> Stephan
>
>
> El mar, 3 jun 2025 a las 13:56, Fabio Strappazzon via fieldtrip (<
> fieldtrip at science.ru.nl>) escribió:
>
>> 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.
>> _______________________________________________
>> fieldtrip mailing list
>> https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmailman.science.ru.nl%2Fmailman%2Flistinfo%2Ffieldtrip&data=05%7C02%7Cfieldtrip%40science.ru.nl%7Cd8c8bc3ca77e42ff461608dda2ae8323%7C084578d9400d4a5aa7c7e76ca47af400%7C1%7C0%7C638845592584541340%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=rI1FsbyhG4Z1%2BDwlvQEhsXEItmwSVk8XSNQSmqHPudg%3D&reserved=0
>> <https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmailman.science.ru.nl%2Fmailman%2Flistinfo%2Ffieldtrip&data=05%7C02%7Cfieldtrip%40science.ru.nl%7Cd8c8bc3ca77e42ff461608dda2ae8323%7C084578d9400d4a5aa7c7e76ca47af400%7C1%7C0%7C638845592584592225%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=UhsAsXggv7tCYVL68J7e2Y8gTL%2FasrIzc42IyA%2BPaLU%3D&reserved=0>
>> https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fdoi.org%2F10.1371%2Fjournal.pcbi.1002202&data=05%7C02%7Cfieldtrip%40science.ru.nl%7Cd8c8bc3ca77e42ff461608dda2ae8323%7C084578d9400d4a5aa7c7e76ca47af400%7C1%7C0%7C638845592584631927%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=aXLplYn2fBNADPKifM6G%2Bq4JVOqHub3TBY%2BTkTt19Ho%3D&reserved=0
>> <https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fdoi.org%2F10.1371%2Fjournal.pcbi.1002202&data=05%7C02%7Cfieldtrip%40science.ru.nl%7Cd8c8bc3ca77e42ff461608dda2ae8323%7C084578d9400d4a5aa7c7e76ca47af400%7C1%7C0%7C638845592584657460%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=GbWOx68kclokjuWlr8Ub3%2BAXPTQW0ygNFQXeV3rChnU%3D&reserved=0>
>>
>
>
> --
> Un cordial saludo,
>
>
> Stephan Moratti, PhD
> Profesor de Psicología Básica I
> Universidad Complutense de Madrid
> 91 394 3141
> smoratti at ucm.es
>
> La información contenida en este correo es CONFIDENCIAL, de uso exclusivo
> del destinatario/a arriba mencionado. Si ha recibido este mensaje por
> error, notifíquelo inmediatamente por esta misma vía y proceda a su
> eliminación, ya que ud. tiene totalmente prohibida cualquier utilización
> del mismo, en virtud de la legislación vigente.
>
> Los datos personales recogidos serán incorporados y tratados en el fichero
> 'Correoweb', bajo la titularidad del Vicerrectorado de Tecnologías de la
> Información, y en él el interesado/a podrá ejercer los derechos de acceso,
> rectificación, cancelación y oposición ante el mismo (artículo 5 de la Ley
> Orgánica 15/1999, de 13 de diciembre, de Protección de Datos de Carácter
> Personal).
>
> Antes de imprimir este correo piense si es necesario: el medio ambiente
> es cosa de todos.
>
> This message is private and confidential and it is intended exclusively
> for the addressee. If you receive this message by mistake, you should not
> disseminate, distribute or copy this e-mail. Please inform the sender and
> delete the message and attachments from your system, as it is completely
> forbidden for you to use this information, according to the current
> legislation. No confidentiality nor any privilege regarding the information
> is waived or lost by any mistransmission or malfunction.
>
> The personal data herein will be collected in the file “Correoweb”, under
> the ownership of the Vice-Rectorate for Information Technologies, in which
> those interested may exercise their right to access, rectify, cancel or
> protest the contents (article 5 of Organic Law 15/1999 dated 13 December,
> on the Protection of Personal data).
>
> Before printing this mail please consider whether it is really
> necessary: the environment is a concern for us all.
> _______________________________________________
> fieldtrip mailing list
> https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmailman.science.ru.nl%2Fmailman%2Flistinfo%2Ffieldtrip&data=05%7C02%7Cfieldtrip%40science.ru.nl%7Cd8c8bc3ca77e42ff461608dda2ae8323%7C084578d9400d4a5aa7c7e76ca47af400%7C1%7C0%7C638845592584679706%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=dlIlIu02OpyF0jfIGxBq3Ziw3P4OQM7NQnN90ZaUjvc%3D&reserved=0
> https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fdoi.org%2F10.1371%2Fjournal.pcbi.1002202&data=05%7C02%7Cfieldtrip%40science.ru.nl%7Cd8c8bc3ca77e42ff461608dda2ae8323%7C084578d9400d4a5aa7c7e76ca47af400%7C1%7C0%7C638845592584703126%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=IBaz9%2Fk%2BeOvKtrX8p9gWdqyLweC%2B6z30CeRKXQ0MGC8%3D&reserved=0
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20250603/7021833f/attachment.htm>
More information about the fieldtrip
mailing list