Hello Brainstorm team!
I’ve been going through your tutorials and learning about all the core functions for the last couple of days. I really think you’ve created a wonderful freeware alternative to other expensive MEG/EEG suites!
I have one question for which which I couldn’t find an answer online: would it be possible to use Brainstorm for event-related synchronization and desynchronization analysis? After pre-processing, epoching, time-freq analysis, and averaging, is there a way to compute the ERS/ERD levels?
In essence, I would have the average time-freq during a reference (baseline) interval, and a test interval, and ERS/ERD would be defined as the percentage of a decrease or increase in a frequency-band power which occurs during the test interval as compared to the reference interval: ERD% = {[(freq power, reference interval) - (freq power, test interval)]/(freq power, reference interval)} X 100…
Best,
Nick
I take it’s not possible then?
Dear Nick,
Thanks for the compliments, it’s always nice to get enthusiastic feedback.
The operation you are asking is not available, but can be added as a new process very easily.
I would suggest another type of transformation, that is readily accessible with the process “Standardize > Compute z-score”.
It evaluates the mean m and standard deviation s over a baseline, for each sensor and each frequency band (if applicable), then centers (subtract m) and normalizes (divide by m) all the values in the file.
The result is expressed in “number of times the standard deviation” instead of a percentage.
You can run in on any file in the database that has some time information.
If you prefer your approach, you can make a copy of the z-score process (brainstorm3/toolbox/process/functions/process_zscore.m) to your personal process folder ($HOME/.brainstorm/process/process_your_function.m).
Then edit the last line of this file, and replace
A = bst_bsxfun(@rdivide, A, stdBaseline);
with:
A = bst_bsxfun(@rdivide, A, meanBaseline) .* 100;
Does that answer your question?
Cheers,
Francois
Hi Francois,
Thanks for the reply! It’s amazing how flexible this platform appears to be.
The modifications you suggest do sound very much like the thing I need. However, after trying to run this new function, the output I’m getting doesn’t seem to be what I expected. In fact, it looks to me almost identical to the one I’d get by simply averaging the TF plots of individual trials…
The output I aim for would look more alike to the two pictures attached below, with a negative value indicating a percentage decrease in power relative to reference (=suppression/desynchronization), and a positive value indicating an increase in power relative to reference…
Best,
Nikola
PS: could one select as the reference period a fixed time from a different trial? (say, a trial from a rest condition, as opposed to the baseline of an active trial)
I think what you describe is what you should be able to get with this method.
You should check a few things:
- Are you sure about the time intervals you selected?
- To identify properly your edited process in the list of available processes, you should change the line “sProcess.Comment” on top of the process function.
- Make sure the colormap is adapted for the values you want to display: you want to see both negative and positive values, hence you need to configure the colormap with the option “Absolute values” UNSELECTED.
Yes, you can pick a reference/baseline interval from a different file using the “Process2” tab instead.
Place the reference file on the left and the file to process on the right, then select the process
Maybe you can apply this transformation manually with one file, just to make sure that the process is doing what you expect:
- Right-click on the time-frequency file you want to edit > File > Export to Matlab > “mat”
- Modify the field mat.TF the way you want (dimensions: [nSensors x nTime x nFrequencies])
- Right-click on the FOLDER containing your initial file > File > Import from Matlab > “mat”, to create a new file with your modified values.
Then you can display it exactly the same way.
Please let me know if you need more help.
Francois
Hi Nikola:
Whenever you’re happy with your ERS/ERD process, would you be willing to share it and make it part of the Brainstorm distribution? We would be happy to acknowledge your contribution on the website and in the Matlab command window when it’s being used. What do you think?
Cheers,
Francois, changing these values worked! Thanks for the tip about the comment line as well.
Sylvain, I think it’s a great idea to include calculation of ERS/ERD as a default option. It is a very popular way to look at non phase locked power activity. I’m attaching the modified process file.
One issue I forgot to mention is the following: time-frequency maps produced with an averaged reference vs, for example, mastoid references can look very different, which becomes crucial for this type of analysis. As far as I understand, BrainStorm automatically opts for the averaged reference in all calculations. Crucially, is there any way to turn off this feature, and use a different reference?
Thanks again for such swift and effective help, both!
Thank you for sharing, Nikola: very much appreciated.
Francois is the most qualified to reply to your question re: reference.
Cheers,
Thanks Sylvain. I’ll wait for Francois’ reply then.
N
Hi Nikola,
Brainstorm converts all the recordings to average reference only for source estimation. This is done on the fly when calculating the sources and does not modify the imported the recordings.
The recordings are kept in the reference that they had in the imported files. If your files were saved with a mastoid reference, Brainstorm is not changing that, you can calculate the time-frequency decomposition of the original signals.
By default, the time series figures are in averaged reference, but this is a display option that you can easily turn off with the button “AVG REF” in the toolbar at the top of the main Brainstorm window.
Changing the reference to something different (other than original reference or average reference) is not possible yet, but we will work on adding those features later this year (summer or fall).
I will integrate the process you sent us in the Brainstorm distribution.
Thank you for your contribution!
Cheers,
Francois
Thank you Francois.
This solves my problem completely.
Thanks for your effort and maintaining such a great software!
N
I edited a bit your process, and called it “Event related perturbation (ERS/ERD)”, to make it a bit more general.
I removed the “spectral” word because the same operation can be applied to values other than time-frequency power maps.
I called the function process_ersd (just because process_erp would be too confusing).
Are you ok with this naming?
Also please let us know how you could like that we cite your contribution, ie name + affiliation.
cheers!
That all sounds good to me - looking forward to the update.
My affiliation is University of Cambridge, though I think calling this a “contribution” is a bit of an overstatement
It’s a procedure used in the field pretty widely.
Nikola
Thanks Nikola.
Small contribution then
Your name now appears in the header of the process_ersp.m file in the latest distribution (>> brainstorm update from the Matlab command line or corresponding GUI menu).
Cheers,
Brilliant! I’m sure future Brainstorm users will find the ERSP function useful in their analyses…