I changed and add some info in coil_def.dat, then I edit the channel file (by export it to matlab and load it again) I am not sure if the channel file ,now will understand that will take the new info updated in coil_def.dat; It is ?
please any explanation?
If you are not reading from a .fif or a .res4 file, you would need to create your own function for adding the coil_def.dat information into your channel file. You can find some inspiration in the functions above.
1-I am reading from fif file from the tutorial in BST: mind004_050924_median01_raw.fif
2-Then I modify the coil_def.f.dat
3- I export the channel file to matlab, I modify it, then I import it from matlab
4-I compute the leadfield
------------due to your answer this leadfield is not corresponding to the correct one because as you said (the information from the file coil_def.dat is integrated in the channel file when loading data from Elekta .fif files).
This what I expected, for this I think to export the file to fif then load it again so that the integration happen, is this thinking right? but as I remember I did not succeed to export the file as fif, as I remember I exported to edf mind004_050924_median01_raw.edf
it could be exported to .fif?
You said:
If you are not reading from a .fif or a .res4 file, you would need to create your own function for adding the coil_def.dat information into your channel file. You can find some inspiration in the functions above.
can you please clarify more, so in my steps above 1,2, 3, at 3 I should create the function but how? I am beginner in BST I used it as user friendly interface, not coding, but I do not have problem to learn how to code on it.
This what I expected, for this I think to export the file to fif then load it again so that the integration happen, is this thinking right? but as I remember I did not succeed to export the file as fif, as I remember I exported to edf mind004_050924_median01_raw.edf
it could be exported to .fif?
can you please clarify more, so in my steps above 1,2, 3, at 3 I should create the function but how? I am beginner in BST I used it as user friendly interface, not coding, but I do not have problem to learn how to code on it.
What you are doing is beyond the current scope of Brainstorm, I'm sorry we won't be able to provide much support for this. Beyond what you can find in Brainstorm, you'll have to code everything by yourself in Matlab.
To get started with the data structures, read the Scripting tutorial (https://neuroimage.usc.edu/brainstorm/Tutorials/Scripting). For the rest, you'll have to go directly through the code.
If you decide to create a new file format, you'll need to write readers in Brainstorm (in_fopen_yourformat / in_fread_yourformat).
If you decide to use the .fif format, you'll need to write your own "acquisition" software, independent from Brainstorm, which creates the .fif file.
Thank you Francois,
At instance the BST integrate the info in coil_def.dat to the acquisition channel file just if we load the fif file ( or .res4 may be we can export res4 after update it and import it again? or BST also cannot write BST?)
So what I should think about it is:
instead of integrate the info in coil_def.dat just when loading the fif file, for example to make the integration upon computing the LF matrix... so here I should understand where in the code you make the integration, and where you compute the LF, I will try, I hope I can arrive to a solution,
The easiest for you would be to write your own function that modifies the channel file by adding the integration points you want. You don't even need the coil_def.dat for that at the moment (not until you produce an MEG system and file format that other people start using).
Just edit the channel file from a Matlab script in a similar way as what ctf_add_coil_defs.m do.
You'll lose less time than trying to write these complicated CTF or FIF files...
please if someone did it before please help me:
the idea is I load the fif file and I have the 2 file as you see in the attached image raw and channel, if I export them to matlab it seems to be its extension name .edf and .pos respectively
the idea is to make them again as .fif file
I am interesting to load the fif file so that the info in the coil_def.dat can be integrated after I made the changes in the channel file
Thanks in advance
As explained before, you need to learn how to use the writing functions of the MNE-Matlab toolbox. This will be done 100% outside of Brainstorm, unfortunately we won't be able to help you with this task.
Otherwise, you can ask the MNE-Python community, they might have easier solutions for you.
Just edit the channel file from a Matlab script in a similar way as what ctf_add_coil_defs.m do.
Edit the .Loc and .Orient fields of the channel file from a Matlab script in order to integrate the geometry of each MEG sensor.
There is nothing that can do this for you with a single function call in Brainstorm or in any other Matlab tool I know of. The only advice I can give you is to read the existing functions that does it for the CTF and FIF file, and get some inspiration to write your own code.
This is not trivial. If you are not confident with your Matlab coding abilities, you might want to start with a generic Matlab programming training.
Sorry I have another question,
If I write just the channel file (exported from BST to .pos file) in fiff file and then I load it again, does the info in coil_def.dat will integrated now?
or I need to write both the channel and raw file into fif file? because when I loaded an example from BST mind004_050924_median01_raw.fif as you see in the attached image both the raw and channel file appear
for this I think to save the both again in fif format, but may be it is enough just to save the channel file, and this will be more easy i think?
If think you can read only the channel information from the FIF file with the Brainstorm function.
However, it could be easier to have all your data (sensors information + data) in the same file format.
Or even easier, if you don't really need to have the data written in .fif (for processing in MNE-python for instance), then simple write your own code to integrate the sensor geometry directly in a Brainstorm channel file.
1)there is a lot of write fif script in matlab script, which one I should used?
@Francois you said above:( If you are not reading from a .fif or a .res4 file, you would need to create your own function for adding the coil_def.dat information into your channel file).
And you shared a matlab script. My question, I did not see in the script you shared where you integrate the information in the coil_def.dat in channel file when loadin electa.fif files, where exactly I want to change in the script to integrate the information even if I load the .pos file if it is difficult to convert the channel file .fif file?
If you are developing your own sensors and if you are planning to use Brainstom for estimating foward models, you might be interested in finding ways to integrate the geometry of your sensors in the channel file in your Brainstorm database.
If you know the position of the center of the sensor and its geometry, you can write a script to decompose each sensor into multiple integration points.