Hello Brainstorm community, I have created a simple process for linear regression of single-trial data. It works with sensors, sources, timefreq, and matrix datatypes, and can be used in batch to process many subjects. The process uses the process2 tab - the user enters data for all trials in FilesA, and matrix files containing the trial-by-trial regressors in FilesB, with one matrix file for each study entered in FilesA. The matrix file should contain one trial per row, and one column per regressor + a trial rejection column at the end. The first column should be all ones for the intercept, if it is to be included in the model and the last column should be all zeros, unless you want to reject trials based on, for example, trial type or behavior. I would be happy to share this code if it is of interest to others.
process_CNRL_regression.m (43.6 KB)
1 Like
Hi @bcoffman234,
This is amazing contribution! If ok with it, we'd love show case the user of such a process in a tutorial page (something similar to the tutorial on decoding), it will be a great resource for other users.
Can you share an example dataset to such tutorial?
Also, you’re also very welcome to contribute directly on the tutorial writing if you’re interested — even a draft or outline would be a great starting point.
Let us know what you think
Sure, I would be happy to contribute.
CNRLregression_tutorial.zip
The above link sources a Neuromag MEG data obtained during variable intensity AEF/AEP task (passive) from a single subject from our recently published work in this area. Continuous data are provided as well as low pass filtered data (55Hz) and segmented/baseline corrected trials (Tone; 50 ms duration, 10ms rise/fall). The regressor matrix used the attached plugin to pull regressor values from trial data (notice that all ‘Tone’ trials also have another event characterizing their intensity (75, 80, or 85 dB). The function takes trial data as input alongside descriptions/titles of regressors (comma-separated, one for each event contained in all trials - all trials must have same number of events, and this number must match the number of values entered here) and there is a checkbox for including the intercept.
These trials can be used in FilesA, and this matrix in FilesB of the process2 menu for use in the CNRL regression plugin. Let me know if you have any further questions!
process_CNRL_getRegressors.m (5.8 KB)