Source estimation on already processed dataset from EEGlab

Hi Brainstorm community,

I have an already processed dataset from EEGLAB and exported to Matlab in the form of (channels x time x trials) in the .mat format. I don’ have .set files now. I need to do source estimation and need the output matrix in the form of (Number of Dipoles x time x trials) again in the .mat format. I created a new protocol and I am using the default anatomy. Can you tell me how do I import my (channels x time x trials) .mat file in brainstorm and do the source estimation. Also, I have a .txt/excel file for channel x, y and z coordinates and labels for 64 channels if I need to input that also. It would be of great help if can list me the steps to do it.

Thanks,
Harshit

Hi Guys,

In addition to my previous query. I am able to export source file to Matlab. So I have the data in the form of struct which has a ImagingKernel variable in the form of (dipoles channels). I need to get the (dipoles * time) format. How do I get this. And please answer both my queries because I don’t know if I correctly got the sources. Also I got Time variable as 00 double. I dont know why??

Hi Harsit, Brainstorm is able to import .set data, and if you have different event type, it automatically groups epochs of different events in separate folders. If you are more confortable with your .mat file, when you import data matrix brainstorm asks the matrix stucture, and you just need to select ChannelxTime, if you organized in this way your data. Personally I find easier the automatic import of .set file, I use it as a routine in my data analysis. Which EEG cap did you use to record your data?
brainstorm has several montage, and maybe there is the one you need. Otherwise, if you have electrodes position different for each subject you could create a matlab matrix and then importing for each subject the channel position. Although, when you import the .set file, brainstorm should be able to read the channel position that will be named ‘EEGLAB channel (numbers of channel)’.
All the steps to peform source analysis are well explained in the tutorial, it’s a long process to explain in the forum. I can list you the step just to give a general idea:
import data
import anatomy, if you don’t have subject anatomy use the default
channel montage (very important for your forward problem)
generate the forward model you prefer (BEM, 3-shells). If you use default anatomy and EEGpostion, you can do it just one time and then copying it to all the subjects
create you noise covariance
and finally create source estimation.
if you need the source for each trial, I suggest to solve the inverse problem just for your forward model, and then it should automatically create link source for all of your trials, otherwise if you have a lot of trials and you create a full matrix for all of them the protocol could be very heavy.
I Hope it helped a bit

1 Like

Yes, In am able to do the source estimation from the tutorials and your answer is also very helpful! But what I did is I had (channels * time * trial) matrix and I transformed in (channels* time) matrix by concatenating the trails. I finally exported the source matrix from matlab and I got ImagingKernel as one variable which is (No of sources* Channels). I need the (No. of sources * time) matrix which I can later transform in (sources* time*trial) later. If you can answer this question it would be very helpful to my research. Thanks !!

Sorry for the response delay…

At the end of the source estimation tutorial, you have a suggestion for reconstructing the full ImageGridAmp matrix using in_bst_results(): https://neuroimage.usc.edu/brainstorm/Tutorials/SourceEstimation#Useful_functions

To get the list of all your files, so that you can create a script that loops on them and reads them one by one with in_bst_results: drop them all in Process1, select “process sources”, select any available process and generate the corresponding Matlab script. Or use the process “File > Select files: Sources”.