Importing event markers into Brainstorm

We have formatted our data into a fieldtrip format which includes an 80 row matrix of data.

Our markers include those denoting the starts of trials('T') , start of accelerometer('D') and many more. We have a total of 216 markers. These are essential for us to do the next step of epoching in brainstorm.

HOWEVER, we were unable to determine how to add the markers into brainstorm. Originally, we stored the markers + Data in the fieldtrip format as shown below:

ft_data = [];
ft_data.fsample = s_SampRate;                             % Sampling rate scalar
ft_data.label = cll_AllChNames;                           % All channel names combined
ft_data.trial = { m_AllData };                            % 1x1 cell: channels x time
nSamples = size(m_AllData, 2);
ft_data.time = { (0:nSamples-1) / s_SampRate };           % Time vector in seconds


%%Storing the Markers below

 num_events = length(combined_idx_sorted);
 for i = 1:num_events
     ft_data.cfg.event(i).type = combined_names_sorted{i};   % Trigger label
     ft_data.cfg.event(i).sample = combined_idx_sorted(i);   % Trigger sample index
     ft_data.cfg.event(i).value = combined_names_sorted{i};  % Duplicate trigger label
 end

 %Save .mat for exportation to brainstorm

save('File_Name.mat', 'ft_data', '-v7.3');

This format allowed us to see the data and all the channels.
However there was no option in brainstorm to simply access the markers from this fieldtrip structure.

Is there a way by which brainstorm can read this fieldtrip structure to not only extract the data but ALSO the markers?

OR

Do we have to store the markers as a separate file and import it after importing our data?
If so what is the standard way to format the markers so they can be read by brainstorm?

Please advise.

Hi @AnishSingh27

Can you check this discussion and let us know if this helps to resolve your issue:

Thanks

Hi @tmedani
I referred to the discussion post, however it did not solve my problem.
The data I am importing is NOT epoched, unlike the data in the linked discussion.
This suggests that I need to epoch prior to importing the markers, however we need to visualize the entire data stream with markers prior to epoching to ensure proper data synchronization.

How can I import the markers into brainstorm prior to epoching?

Thanks!

Hi @AnishSingh27,

AFAIK, in FieldTrip the data and events are two separated structures.
So, reading this custom merged structure is not supported.

Yes, that will be the straight forward way to do it.

Brainstorm support multiple formats for events. See here.
Given that you have simple events (only label and time of occurrence), .csv is a good option:

fid = fopen('events.csv','w');
num_events = length(combined_idx_sorted);
for i = 1:num_events
  fprintf(fid, '%s, %g, 0\n', combined_names_sorted{i}, ft_data.time{1}(combined_idx_sorted(i)));     
end
fclose(fid);

Then you can import events from that file.

  • In the GUI:
    Record tab > (Event section) File > Add events from file

  • Or with a process:
    Events > Import from file

2 Likes