[FieldTrip] layout file error after upgrading to the newest version

Schoffelen, J.M. (Jan Mathijs) jan.schoffelen at donders.ru.nl
Fri May 28 20:47:57 CEST 2021


Hi Marta,

Rather than just trying out more or less all kinds of possible solutions, I suggest to step back and think about what you want to achieve:

You seem to want to call ft_channelrepair and use the ’spline’ method to interpolate between non-bad channels, to get a modelled signal for the bad channels.

So far so good.

Now, in order to use the ’spline’ method, you need to supply a geometric description of the channels, a.k.a. an elec structure, which is a matlab structure that at least should specify the 3D positions of the electrodes. This is different from a layout, because a layout is a 2D schematic of the channel array that can be used for topographical visualization. Also, it could be that another method in ft_channelrepair does not require a set of 3D channel position, but only requires a definition of channel neighbours (without position information). So, you either need to supply ft_channelrepair with 3D channel position information for the ’spline’ interpolation, or you should consider using a different interpolation method.

What you should know, is that the information in the layout structure, pertaining to the channel positions, is stored in the field <name-of-the-variable>.pos, whereas in an elec structure, the channel positions should be represented as <name-of-the-variable>.chanpos, so your attempt in adding a column of zeros is not only wrong in the sense that it would have led to a distorted spline interpolation, it is also not going to work due to a difference in fieldnames.

Long story short, if you require ft_channelrepair to use a method that needs a sensor description, you need to pass a valid sensor description in the cfg, OR in the data argument.

Please consult the documentation

https://www.fieldtriptoolbox.org/faq/how_are_electrodes_magnetometers_or_gradiometers_described/

for a more detailed description of an elec-array.

Best wishes,
Jan-Mathijs


On 28 May 2021, at 15:59, Marta Topor via fieldtrip <fieldtrip at science.ru.nl<mailto:fieldtrip at science.ru.nl>> wrote:

Hi Tzvetan,

Thank you for your quick response, much appreciated!

I have spent a bit of time today trying to work this out.
If I do not include the cfg.elec line, I get another error:
Error using ft_fetch_sens (line 202)
no electrodes, gradiometers or optodes specified.

I have checked through my code and files thoroughly and I do not have a 3D layout file. I initially created my layout file from an image and it has always been in 2D. It seems that when I was running the code before, it worked OK with the 2D file.

Do you have any ideas for getting around this issue? I tried adding 0s throughout the layout structure to "pretend" it was 3D but it also did not work that way.

Thanks again and best wishes,

_________________________
Marta Topor
PhD Candidate

Room 07AC04
School of Psychology
University of Surrey

________________________________
From: fieldtrip <fieldtrip-bounces at science.ru.nl<mailto:fieldtrip-bounces at science.ru.nl>> on behalf of Tzvetan Popov <tzvetan.popov at uni-konstanz.de<mailto:tzvetan.popov at uni-konstanz.de>>
Sent: 28 May 2021 7:37 AM
To: FieldTrip discussion list <fieldtrip at science.ru.nl<mailto:fieldtrip at science.ru.nl>>
Subject: Re: [FieldTrip] layout file error after upgrading to the newest version

Dear Marta,

In your cfg.elec, a 3D description of electrodes positions is expected. Yet you have a 2D layout structure. I assume that your neighbours are also defined in this 2D plane.
Can you comment out the cfg.elec line and try again? Ft_read_sens is not supposed to work on 2D layout file, hence the error.

Good luck,
tzvetan


On 27 May 2021, at 22:24, Marta Topor <m.topor at surrey.ac.uk<mailto:m.topor at surrey.ac.uk>> wrote:

Dear colleagues,

I came across a surprising error and I am struggling to figure it out.
I wrote a few scripts last year in version fieldtrip-20200409. They all worked fine, last time I worked with those scripts in that version was January 2021. I had to take care of a few other tasks since then, so the project was on pause. I had my work laptop upgraded in the meantime which meant I had to upgrade to the newest Fieldtrip version.

I started working on that same project again, in version fieldtrip-20210525, and noticed layout file issues when interpolating channels.

For a bit of background,  I am using the Mobita water-based 32 EEG electrode system. I created my own layout file in the previous Fieldtrip version which worked without any issues in all scripts.
I now have an error using the ft_channelrepair() funtion and I think it relates to the ft_read_sens() funtion.

The cfg I used:
cfg = [];
cfg.method          = 'spline';
cfg.neighbours      = neighbours_EEG;
cfg.badchannel      = badchannels_train;
cfg.senstype        = 'EEG';
cfg.elec            = layout_file;
mydata_interpolated_train = ft_channelrepair(cfg, mydata_artrm_train);


The layout file fields are:
pos: [34×2 double]
label: {34×1 cell}
width: [34×1 double]
height: [34×1 double]
outline: {1×4 cell}
mask: {[101×2 double]}
cfg: [1×1 struct]

But I can only see these fields if I use the function importdata(). When I use the function ft_read_sens() and when I try to interpolate channels, I get the following error:

Error message:
Unrecognized function or variable 'lab'.

Error in channelposition (line 352)
n = size(lab,2);

Error in ft_datatype_sens (line 438)
        [chanpos, chanori, lab] = channelposition(sens);

Error in ft_datatype_sens (line 240)
    sens      = ft_datatype_sens(sens, new_argin{:});

Error in ft_datatype_sens (line 207)
    sens      = ft_datatype_sens(sens, new_argin{:});

Error in ft_datatype_sens (line 180)
    sens      = ft_datatype_sens(sens, new_argin{:});

Error in ft_read_sens (line 539)
sens = ft_datatype_sens(sens);


There are no errors when I plot the channels using the following code though and it all looks absolutely fine:
cfg = [];
cfg.layout = layout_m; %layout_m is imported from the layout_file using the importdata() function
cfg.channel = 'eeg';
ft_layoutplot(cfg, mydata_artrm_train);


Any ideas what could be the issue here and how I could get it solved?
Thanks for your help in advance!

_________________________
Marta Topor
PhD Candidate

Room 07AC04
School of Psychology
University of Surrey

_______________________________________________
fieldtrip mailing list
https://mailman.science.ru.nl/mailman/listinfo/fieldtrip<https://urldefense.com/v3/__https://eur02.safelinks.protection.outlook.com/?url=https*3A*2F*2Fmailman.science.ru.nl*2Fmailman*2Flistinfo*2Ffieldtrip&data=04*7C01*7Cm.topor*40surrey.ac.uk*7Cfb3553ce7a574f3d9e0808d921a46db2*7C6b902693107440aa9e21d89446a2ebb5*7C0*7C1*7C637577812370135929*7CUnknown*7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0*3D*7C1000&sdata=rJ92O3ReOOSatqdv0GD0Du6mOIzRHJr6jWSt*2FLtpBqs*3D&reserved=0__;JSUlJSUlJSUlJSUlJSUlJSUlJSU!!HJOPV4FYYWzcc1jazlU!pvAonQmJGzJN_sy6zvAvHw-KKKF04m43iS07XGmaYe6b2vLvG9g2DFKZhAwNlgv1It7TLNtT$>
https://doi.org/10.1371/journal.pcbi.1002202<https://urldefense.com/v3/__https://eur02.safelinks.protection.outlook.com/?url=https*3A*2F*2Fdoi.org*2F10.1371*2Fjournal.pcbi.1002202&data=04*7C01*7Cm.topor*40surrey.ac.uk*7Cfb3553ce7a574f3d9e0808d921a46db2*7C6b902693107440aa9e21d89446a2ebb5*7C0*7C1*7C637577812370135929*7CUnknown*7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0*3D*7C1000&sdata=Fumrt1UpioQgxcez701bgwQQRBGMziEmuqef9vM77Eg*3D&reserved=0__;JSUlJSUlJSUlJSUlJSUlJSUl!!HJOPV4FYYWzcc1jazlU!pvAonQmJGzJN_sy6zvAvHw-KKKF04m43iS07XGmaYe6b2vLvG9g2DFKZhAwNlgv1ItbH66Yt$>

_______________________________________________
fieldtrip mailing list
https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
https://urldefense.com/v3/__https://doi.org/10.1371/journal.pcbi.1002202__;!!HJOPV4FYYWzcc1jazlU!pvAonQmJGzJN_sy6zvAvHw-KKKF04m43iS07XGmaYe6b2vLvG9g2DFKZhAwNlgv1IkYZG7Q0$

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20210528/d8152499/attachment.htm>


More information about the fieldtrip mailing list