Importing fieldtrip data

Dear Francois,

I have fieldtrip dataset that contains sensor MEG data, virtual sensors from MEG and EEG data. I would like to review raw data of all modalities in brainstorm using the fieldtrip data importer. So far it loads the MEG channels as 'MEG' separate from EEG and virtual channels, which are loaded as 'OTHER'. Do you have a suggestion how to include the virtual channels here? Can I share with you an example dataset?

Best regards,
Marcel

Hi Marcel,

You can change the type of the sensors easily: Right-click on the channel file > Edit channel file.
https://neuroimage.usc.edu/brainstorm/Tutorials/Epilepsy#Prepare_the_channel_file

Best,
Francois

Thanks, Francois! This is really a simple solution of my request.

Hi Francois,

There is another question related to the data set from fieldtrip. When I am trying to display the MEG channel topography I get the following error:

image

I can display the channel positions without any problem:

You can download an example dataset from here:
https://bwsyncandshare.kit.edu/s/ytfa2okF3fNNm2m

Thanks for looking into this!
Marcel

Hi Marcel,

There was some sort of bug in the Brainstorm code, that led the MEG magnetic extrapolation (smoothing of the MEG topography) not working when there are different numbers of coils among the sensors.
This is something I fixed here: Inverse: MEG channel extrap robust to different number of coils · brainstorm-tools/brainstorm3@676d77b · GitHub

However, there is also another problem with the file you shared. The Brainstorm functions do not seem completely equipped to read it... If you look in the Matlab command line after reading the file, you'd see:

Error: Wrong number of coils for channel MRT41: Cannot import this file correctly...
Error: Wrong number of coils for channel MRT51: Cannot import this file correctly...
Error: Wrong number of coils for channel MRT52: Cannot import this file correctly...
Error: Wrong number of coils for channel MRT53: Cannot import this file correctly...

The positions of these sensors are defined in an unusual way. I'll need to ask the FieldTrip team what this can possibly mean, to know if we should get rid of these of these sensors, or handle them in a different way. I'll get back to you on this when I get an answer.

Update:

Right now, I think you can update Brainstorm and safely link again this file to your database.
I'll post further updates here if any (depending of the answer on the FieldTrip side)

Thank you Francois, it seems to work now!

Just one more comment: For me it looks like there is currently no clear definition whether negative or positive deflections of traces point upwards or downwards when reviewing MEG/EEG data. Considerung also the amplitude maps it looks like you start with positive amplitudes upwards initially which you can flip using "flip y-axes". The clinical standard is that negative amplitudes point upwards. Can you use this as standard setting for MEG/EEG traces and can you note somewhere in the traces window which definition is currently chosen? This will be very helpful for reviewing of epilepsy data sets.

Thank you Francois, it seems to work now!

It works for your file, but my work is not exactly finished, as I still need to understand if I can improve the heuristic I'm using to connect channels and coils...

You removed the file too soon for the FieldTrip developers to be able to download and test your file with my code. See: Getting the coil-channel correspondence from grad.tra · Issue #2040 · fieldtrip/fieldtrip · GitHub
Can you please share it again?

I won't use the reverse Y axis as this specific to clinical EEG and SEEG. It would be too confusing for other users. But I will add something to indicate graphically the direction of the Y axis.

Can you use this as standard setting for MEG/EEG traces and can you note somewhere in the traces window which definition is currently chosen?

I added a button that indicates which is the direction of the Y axis in the figure.
If you click on it, it flips the Y axis.

image image

Please update Brainstorm and let me know if it matches your request.

Can you please share it again?

Waiting for you to share the file again for the FieldTrip developers - thanks.

Hi Francois,

thank you for adding this button!

I uploaded the dataset again. You can find it here:
https://bwsyncandshare.kit.edu/s/faA7smobMdxsZtg

Best regards,
Marcel

Hi Francois,

I am having problems importing fieldtrip structures, which I could import before. I get the following error messesage. I can share example data using a private link.

image

Thanks for your help!
Marcel

The function ft_datatype_sens.m, which is supposed to be in folder fieldtrip/utilities, is missing on your computer or is not in your path. Your installation of FieldTrip seems to be broken.

Either restore it manually, or install/update FieldTrip as a Brainstorm plugin:
https://neuroimage.usc.edu/brainstorm/Tutorials/Plugins

You were right. I just needed to reinstall fieltrip. Now it works!

Thanks a lot!
Marcel

Hi Francois,

when importing fieldtrip.mat files into brainstorm, I get an outlier in the MEG channel topography. This outlier is not present in the initial fieldtrip file. Do you have an idea what might cause this error? I can share with you an example data set through a private linke. Thanks for your help!
Marcel


... In addition to this one wrong sensor position, I get the following error:
Error: Wrong number of coils for channel MLF12: Cannot import this file correctly...
Error: Wrong number of coils for channel MLF13: Cannot import this file correctly...
Error: Wrong number of coils for channel MLF14: Cannot import this file correctly...
Error: Wrong number of coils for channel MLF25: Cannot import this file correctly...
Error: Wrong number of coils for channel MLO53: Cannot import this file correctly...
Error: Wrong number of coils for channel MLT21: Cannot import this file correctly...
Error: Wrong number of coils for channel MLT31: Cannot import this file correctly...
Error: Wrong number of coils for channel MLT32: Cannot import this file correctly...
Error: Wrong number of coils for channel MLT41: Cannot import this file correctly...
Error: Wrong number of coils for channel MLT47: Cannot import this file correctly...
Error: Wrong number of coils for channel MLT57: Cannot import this file correctly...
Error: Wrong number of coils for channel MRF12: Cannot import this file correctly...
Error: Wrong number of coils for channel MRF13: Cannot import this file correctly...
Error: Wrong number of coils for channel MRF14: Cannot import this file correctly...
Error: Wrong number of coils for channel MRT21: Cannot import this file correctly...
Error: Wrong number of coils for channel MRT31: Cannot import this file correctly...
Error: Wrong number of coils for channel MRT41: Cannot import this file correctly...
Error: Wrong number of coils for channel MRT51: Cannot import this file correctly...
Error: Wrong number of coils for channel MRT53: Cannot import this file correctly...

... and the channel file shows gaps like this:

Is it possible that you have a look at this problem, Francois?

Thanks in advance!
Marcel

Hi Marcel,

Could you share the a sample file that causes the issue, to understand what is going on?
Upload the file somewhere and post the download links here.

Best,
Raymundo

Thank you for offering your help, Raymundo!

You can find an example file here: https://bwsyncandshare.kit.edu/s/qwpnGFgaHjNH3xt

Marcel

Hi Marcel,

After looking at the data, the issues (outlier and blanks in channel file) have the origin:

Rebuilding the coil-channel matrix, since the 'reject' step essentially removed one (or a few) components from the data, so these cannot be anymore recovered. Here are detailed explanation:

To fix this issue an heuristic fix was implemented and worked for the previously shared data (Jun 2022). However, the newest shared data is a case where it fails. This is well reported in: Importing fieldtrip data - #6 by Francois

Details:

  • Outlier (MLF33). In this case, in the (imperfect) rebuild the coil-channel matrix, channel MLF33 is defined by two coils, but they are the two reference coils (in red)

  • Blanks in channel file In these cases, in the rebuild the coil-channel matrix, those channels are defined by more than 2 coils, thus the position is obtained from the channel position and not from the coils that comprise the channels.
    How are electrodes, magnetometers or gradiometers described? - FieldTrip toolbox


@Francois, it seems an improved heuristic is needed at rebuilding the coil-channel matrix

Hi Francois,
will you have time to look into this? There seem to be problems importing the MEG channel positions from Fieldtrip into brainstorm.

Best regards,
Marcel

As Francois seems to be unavailable: Is there anyone else who is able to reorganize the import of fieldtrip data into brainstorm so that it doesn't change the positions of the MEG sensors?

Many thanks in advance!