Import the HCP preprocessed MEG through scripts

Hi, brainstormers,

I am trying to load the HCP preprocessed MEG data into Brainstorm using a script because I want to load the data for all 89 subjects all at once. I used to import these files one by one through the GUI but now I would like to automate this process and transfer most of my work with the data to the cluster.

Here is the script that I generated from the process "run" box:

% Script generated by Brainstorm (12-Sep-2022)

% Input files
sFiles = [];
SubjectNames = {...
    '162935'};
RawFiles = {...
    'E:\files\data\162935\162935_MEG_Restin_preproc\162935\MEG\Restin\rmegpreproc\162935_MEG_3-Restin_rmegpreproc.mat'};

% Start a new report
bst_report('Start', sFiles);

% Process: Create link to raw file
sFiles = bst_process('CallProcess', 'process_import_data_raw', sFiles, [], ...
    'subjectname',    SubjectNames{1}, ...
    'datafile',       {RawFiles{1}, 'FT-TIMELOCK'}, ...
    'channelreplace', 1, ...
    'channelalign',   1, ...
    'evtmode',        'value');

% Save and display report
ReportFile = bst_report('Save', sFiles);
bst_report('Open', ReportFile);
% bst_report('Export', ReportFile, ExportDir);
% bst_report('Email', ReportFile, username, to, subject, isFullReport);

However, I am getting an error message when loading this script:

It seems like I should put in a different value in the 'datafile' parameter for the bst_process() function. Do you know what I should put in there for this type of data? I believe the HCP preprocessed data are in fieldtrip structure.

Also, is there a place where I can look for a more detailed description of each of the parameters for the process functions?

Thanks,
Andy

We worked on the import of the HCP datasets 5 years ago.
I think I remember there were many difficulties in reading the preprocessed files, as some data was missing and the structure were not standard.

We wrote a tutorial for downloading and importing the unprocessed data instead:
https://neuroimage.usc.edu/brainstorm/Tutorials/HCP-MEG

I tried to download the data again from the connectomeDB website, but it seems that something changed with the support of the Aspera plugin, I didn't manage to download the processed data for this subject.

Can you please share the processed .mat file that you are trying to import?
(upload it somewhere and post the download link here)
I'll see if I can do something simple to let you import this file in Brainstorm.
However, my general recommendation would be to work in Brainstorm starting from the unprocessed data.

Hi @Francois ,

Thank you for the quick response. Here is the link to the uploaded data. Here are the files for two subjects: data - Google Drive

There are 3 sessions for each subject. I can load these files individually into Brainstorm through the GUI but not sure how to do that through just scripts.

Let me know if it works.

Best,
Andy

Thank you for the example file.
These structures have very weird (if not incorrect) trialinfo structures, which are supposed to label the trials: one column with only NaN and one column with only zeros. The NaN were the cause of the import bug.

I fixed this bug in this commit:
https://github.com/brainstorm-tools/brainstorm3/commit/9393f8fe9df01f70f8efe7b91b421468f23ed01d

Please update Brainstorm and try again.
Make sure you use the process "Import MEG/EEG: Existing epochs".

Thank you. These are resting-state data, therefore there are no labels for each trial. This might be the cause of the problem.