Dear Brainstorm-Experts,
I used brainstorm to import the MRI and the CT of a patient and placed all the implanted sEEG electrodes which works very well.
I now want to export the MNI coordinates of those electrodes to matlab to perform anatomical labeling etc.
How can I export them as MNI and not SCS coordinates and second if I click on “MNI” does it perform a normalization and if so how?
Thank you in advance!
Best Johannes
… after trying it several times…
- exporting the patients MRI additionally to the electrodes makes the cs_convert function working…
Still the second part of the question remains open:
“if I click on “MNI” does it perform a normalization and if so how?”
Have a nice weekend and best, Johannes
Dear Johannes,
Your question corresponds to something I’ve been wanting to add for a while, so I took the occasion to implement it. I added the possibility to export directly a channel file in the Brainstorm database to a text file in MNI coordinates, without having to do any manual conversion with cs_convert.
Update Brainstorm, then try using the file formats “EEG: ASCII: Name,XYZ_MNI” or “EEG: ASCII: XYZ_MNI,Name” when exporting your channel file (right-click on the channel file > File > Export to file).
Double-check that the MNI coordinates you obtain in the output text file make sense… this was developed just now and not tested much, so expect all sorts of bugs.
Note that you need to compute the MNI transformation from the MRI viewer first. This corresponds to a 4x4 affine transformation computed with SPM, so it is less accurate than the SPM non-linear MNI registration that some other programs use.
https://neuroimage.usc.edu/brainstorm/CoordinateSystems#MNI_coordinates
Cheers,
Francois
1 Like
Dear Francois,
thanks for updating! I’ll check this and report bugs, if I find them.
One bug I already reported, when I export the file see: Labels of electrodes are not updated when exported
Thanks and best, Johannes
Dear Francois,
I tested the new export and now the order of the labels and the coordinates look fine. But the MNI coordinates seem to be in cm instead of mm?
Thanks and best, Johannes
It was like this to be more similar to the other EEG files formats (EEGLAB, BESA, Curry, EGI NetStation…)
But I do prefer have these files in mm as well, and there are the other file formats available to export in cm anyway.
So I modified again the function to export mm instead (I hope it won’t disrupt anybody’s work).
Update Brainstorm again to get this modification.
Thanks for the fast update!
Did you change the delimiter on purpose? Before it was space and now it is tab. For me both is fine. I just needed to adapt the importdata function to read the text file in matlab.
Yes, I modified this on purpose.
A tab delimiter makes it possible to have spaces in electrode names for instance. And I think most files readers would process tabs as separators.
I hope this won’t disrupt anybody’s work…
Dear Francois,
after a while I wanted to extract the MNI coordinates of some new patients. Unfortunately, when using the latest version, the following error is displayed:
** Error: Line 91: out_channel_ascii (line 91)
** Cannot open file
**
** Call stack:
** >out_channel_ascii.m at 91
** >export_channel.m at 166
** >bst_call.m at 28
** >tree_callbacks.m>@(h,ev)bst_call(@export_channel,filenameFull) at 960
**
Do you have an idea how to solve this?
Thanks and best regards,
Johannes
The error you reported is generated here:
https://github.com/brainstorm-tools/brainstorm3/blob/master/toolbox/io/out_channel_ascii.m
This means that the file you are trying to create can't be opened for writing.
Maybe you don't have the rights to save the file in this folder.
If you are working on Windows and can't understand why you Matlab refuses to write in the target folder: try starting Matlab as an administrator (right-click on the Matlab icon > Run as administrator) or simply try creating the file somewhere else (outside of the C:\Program Files or C:\Users folders).