How would I create a 3D matrix with channels, epoch time-series data, and trials as the dimensions?

I am looking for a way to create a data matrix to use for our analysis. I need to write a script that creates a matrix containing this information:

[ 
    [ 
         % trial 1
         epoch 1 time-series for channel 1, 
         epoch 1 time-series for channel 2,
         epoch 1 time-series for channel 3,
         ....
         ....
         ....
     ],
     [  
         % trial 2
         epoch 2 time-series for channel 1, 
         epoch 2 time-series for channel 2,
         epoch 2 time-series for channel 3,
         ....
         ....
         ....
     ],
     ....
     ....
     % for all 810 trials
]

I have already preprocessed the data and created the epochs in brainstorm so those epoch files are in a folder in the database on my computer. Is there a way to create the above matrix in MATLAB?

Thank you for any help!

I think this is what the process example "process_example_customavg.m" does:
Tutorials/TutUserProcess - Brainstorm

If you are not familiar with Brainstorm scripting yet, starting with the Scripting tutorial would probably help:
https://neuroimage.usc.edu/brainstorm/Tutorials/Scripting

1 Like

Hi James,

Not quite sure exactly what you want your array to look like but it seems like you are looking to generate something like the below figure.

To generate a multidimensional array like this you should visit the following.

image

1 Like

This seems like exactly what I need! Thanks so much.

Hello, I got your solution to work which included using the "files to process" box to generate a selection of files with the tag of my event name. This opened a matlab file and at the top it had

sFiles = {Subject01/...... , 
          Subject02/...... , 
          etc. for 800+ epochs}

which lists all of the epoch files that don't contain bad segments of data.

I need to do this for multiple subjects though so I was wondering if there is a way to produce this list of good trials without first using the "files to process" box.

Is there a way to write a script to get the same epochs that are present in sFiles using only a script?

You can start from an empty Process1 box, and start your script with the file selection, with the processes Files > Select files: *.