How to build a MEG file by myself

I am a new user of the toolbox “Brainstorm”. I would like to calculate reverse problems with this toolbox based on my own measured magnetic field data on the brain surface.

However, according to “tutorial 3: Importing MEG Recording”, I can not find how to build a MEG recording file for the toolbox with my own data. Can anyone give a detail tutorial about this?

Furthermore, in sample “TutorialCTF”, the items Loc (1).(2)… and Orient (1).(2)… mean the locations and orientations of different integration points. What does integration point mean, and what is its weight ?

By the way, I would like to find other users of this toolbox to have some communications. Anybody interested in this can contact me. I am in China. Email: cmeehuli@zju.eud.cn. MSN: zju_lianghu@hotmail.com.

Hello,

thank you for trying BST.

what is the format of your MEG data: Elekta, CTF, 4D,… ? If this is another type of format, it’s still possible to import your data as binaries or even after ASCII conversion. If you do have some Matlab script to read out your data and you are ready to share it, we’d be happy to include it into our BST import filters.

The integration points of MEG coils are locations where the pick up of the magnetic field is modeled. MEG magnetometers have generally a round or square shape which can be approximated with their centroid for instance. That’s an integration point. These coils are also oriented with respect to the head surface, which is not important to model in EEG, but is crucial in MEG.

Hope this helps.

Thank you very much for your response.

We got the MEG data through an experimental setup designed by ourselves. Its format is a .txt file containing following contents:
Sensor 1: Value: 1.41378, Position: (-1,0,0.5)
Sensor 2: Value: 1.41378, Position: (-0.9,0,5.1)

Furthermore, in our research, some sensors are located on the surface of the skull, but others are located departing from the skull surface with distances (1mm~20mm). I doubt whether this location method will affect the calculation result of “brainstorm”.

Is there a tutorial about how to import my own data as binaries or even after ASCII conversion through Matlab scipt?

BST can read out from simple ASCII data files. I recommend you save your data in two separate files:

1 containing the channel locations
1 containing the data (in a sensor x time array for instance)

If this is MEG, you also need a separate file specifying the sensor orientations.

Then proceed by importing the data as:
http://neuroimage.usc.edu/brainstorm/Tutorials/TutImportRecordings?highlight=(import)

Having sensors at different distances from the scalp does not matter for modeling, as long as their position and orientation are properly informed.

Hope this helps,

Thanks.
You said three seperating .txt files are required, i.e., 1 containing the channel locations. ), 1 containing the orientation, 1 containing the data (in a sensor x time array for instance.
Can you give more explanatinos about the required format of the data in the .txt file?
Maybe you can take the CTF example in your tutorial as an illustation. It will be very grateful if you can give the .txt files for the locations, orientations and data of this example respectively, and illustrate how to import them into the Brainstorm.

The format is simple:

each file needs to be an ASCII array:

  • locations: sensors x [X Y Z]
  • orientations: sensors x [X Y Z]
  • data: sensors x time

let me know how it goes

Hi,
I think that the quickest way for you would be to import the data from the CTF tutorial, and then to replace some part of the data with your own structure.

  1. Go until the end of tutorial 3.
  2. Edit the channel information:
  • Right-click on the channel file > File > Export to Matlab > ChannelMat
  • ChannelMat.MegRefCoef = [];
  • Create a ChannelMat.Channel structure that has as many entries as the number of rows in your recordings files (nSensors), and set the fields as following:
    – Loc: [3x1], location in space, in CTF coordinates (http://neuroimage.usc.edu/brainstorm/CoordinateSystems) in meters
    – Orient: [3x1], orientation of the coils (normal to the coil’s plane)
    – Comment: ‘’
    – Weigth: 1
    – Type: ‘MEG’
    – Name: channel’s name
  • Then import back this structure ChannelMat in the brainstorm database by right-clicking again on the channel file > File > Import from Matlab > ChannelMat
  1. Edit the data file:
  • Right-click on the recordings > File > Export to Matlab > DataMat
  • DataMat.F = your data matrix [nSensors x nTime]
  • DataMat.Time = time vector [1 x nTime]
  • DataMat.ChannelFlag = ones(nSensors, 1)
  • DataMat.Comment = whatever you want…
  • Re-import this structure in the DB: right-click on recordings > File > Import from Matlab > DataMat

You will probably run into a lot of trouble to adjust your coordinates system to what is required by Brainstorm… You have to compute a 3D transformation (rotation+translation) from your CS to Brainstorm CS (=SCS, for Subject Coordinate System). You can find some inspiration in the file mri2scs, that computes the conversion from MRI coordinates to SCS.

Have fun…
Francois

Thank you very much. I will have a try.

Thank you very much for your help over the past.
Another question is why 38 matrix are required to specify the location and orientation of each channel. In my opinion, a 31 array [x,y,z] is enough to illustrate the location. Furthermore, what does the “weight” mean accordingly?

you can use a 1x3 vector for x y z if you assume the coil can be simplified as a single point where the magnetic field is computed (this is OK). If you want to be more sophisticated in the modeling, you may include more integration points (see message above). For a gradiometer made of 2 square coils for instance, this corresponds to 8 points (one per square vertex).