[FieldTrip] Plot classifier weights' topography

Barnett, Benjy benjy.barnett.20 at ucl.ac.uk
Wed Mar 10 11:45:57 CET 2021


Thanks Jan-Mathijs,

I am getting the following error when I try this.

Error using ft_checkdata (line 528)
This function requires 'comp', 'timelock' or 'freq' data as input, see ft_datatype_comp, ft_datatype_timelock or ft_datatype_freq.

My code is this:

data = [];
data.avg =weights';
data.labels = labels;
data.time = 1;
data.dimord = 'chan_time';



cfg = [];
cfg.xlim ='maxmin';
cfg.zlim = 'maxmin';
cfg.layout = 'neuromag306all.lay';
cfg.channel = 'MEG';
cfg.parameter = 'weights'; % the default 'avg' is not present in the data
figure; ft_topoplotER(cfg,data); colorbar


And my data structure is this:

data.weights = 306x1 double
 data.labels, = 321 x1cell
data.time=1
data.dimord=‘chan_time’

I’m believe I have all the necessary fields for it to pass as time lock data (time, dimord, and label), so I’m not sure why it is not working. I have tried preselecting only the correct 306 labels and using those in the structure but this does not help either. I can try the ft_plot_topo method, but since I had some other questions I thought I’d see if you could help me with the higher level function. My other questions are simply, in the neuromag layout files, are the first two columns X and Y coordinates respectively? And secondly, I understand that plotting magnetometers and gradiometers together is not such a good idea because of the difference in their scales, but why do you say that using only gradiometers will not result in a nice topography? Does that mean my only option is to plot magnetometers alone? Also, thanks for the reference to that paper, indeed I was using the forward mixing weights after having read that very paper!

Thanks a lot!
Benjy


On Mar 5, 2021, at 3:02 PM, Schoffelen, J.M. (Jan Mathijs) <jan.schoffelen at donders.ru.nl<mailto:jan.schoffelen at donders.ru.nl>> wrote:

Dear Benjy,

It looks as if you are almost there.

That is, I don’t know what your data structure looks like, but if you create it sufficiently lean, and internally consistent, it should work.
Something like:

data = [];
data.weights = weights;
data.label = <list-of-labels>;
data.time = 0; % just give it a value
data.dimord = ‘chan_time’;

Alternatively, you can use the lower-level function ft_plot_topo (it’s in fieldtrip/plotting): this function requires also ‘low-level’ input arguments, i.e. two vectors of x and y coordinates of the sensor positions, the vector with the to-be-plotted values, and some additional options for aesthetics. I think the help documentation of this function explains it well enough.

Two points of caution:
1) with the 306 mixed gradiometer/magnetometer system it probably does not make sense to visualize a topogrophy of the gradiometers and magnetometers mixed, and also, using the gradiometers only it probably will probably not result in a nice topography.
2) it could be that it is more informative to look at the ‘forward mixing weights’, rather than the unmixing weights that drop out of your classifier. An exceptionally good read about this issue is provided in: https://doi.org/10.1016/j.neuroimage.2013.10.067<https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fdoi.org%2F10.1016%2Fj.neuroimage.2013.10.067&data=04%7C01%7C%7C2d001b0f96d040c256bc08d8dfebe8ea%7C1faf88fea9984c5b93c9210a11d9a5c2%7C0%7C0%7C637505551608497405%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=iGUmFxRtA2u8iXvHksxNY%2BaqwNY6Vx8efqB%2FH6%2BKp6k%3D&reserved=0>

Best wishes,
Jan-Mathijs


On 5 Mar 2021, at 15:18, Barnett, Benjy <benjy.barnett.20 at ucl.ac.uk<mailto:benjy.barnett.20 at ucl.ac.uk>> wrote:

Hi!

I am trying to plot the topography of my LDA weights, but am having some trouble. I am using my own script to calculate the weights rather than any packages (e.g. DMLT, or MVPA-light), so the tutorials on the fieldtrip site haven’t been able to help me. So far, I’ve simply tried adding the weights (a 306x1 length vector) as a field to my data structure. And trying this code:


data.weights = weights;
cfg = [];
cfg.xlim ='maxmin';
cfg.zlim = 'maxmin';
cfg.layout = 'neuromag306all.lay';
cfg.channel = 'MEG';
cfg.parameter = 'weights';
figure; ft_topoplotER(cfg,data); colorbar

Unsurprisingly, this doesn’t work. It results in the error 'field “weights" not present in data’. I assume because the weights field is not interpretable by the fieldtrip code. I guessed the lack of a dimord field for the weights might be underlying its lack of interpretability, but playing around with that has not worked either. I’ve tried adding a ‘weightsdimord’ field with the [306x1] dimensions, but this also - unsurprisingly - didn’t work.

Is there a way around this? Will I need to use lower level functions than ft_topoplotER? If so, can anyone advise on how I might implement this?

Many thanks for your time,
Benjy
_______________________________________________
fieldtrip mailing list
https://mailman.science.ru.nl/mailman/listinfo/fieldtrip<https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmailman.science.ru.nl%2Fmailman%2Flistinfo%2Ffieldtrip&data=04%7C01%7C%7C2d001b0f96d040c256bc08d8dfebe8ea%7C1faf88fea9984c5b93c9210a11d9a5c2%7C0%7C0%7C637505551608507361%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=4M%2BiFWZXL7byRW8DF7%2F6YUD4jTU0JBbgkvEQeTCaxKE%3D&reserved=0>
https://doi.org/10.1371/journal.pcbi.1002202

_______________________________________________
fieldtrip mailing list
https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
https://doi.org/10.1371/journal.pcbi.1002202

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20210310/053d2861/attachment-0001.htm>


More information about the fieldtrip mailing list