[FieldTrip] Plot classifier weights' topography

Schoffelen, J.M. (Jan Mathijs) jan.schoffelen at donders.ru.nl
Fri Mar 5 16:02:41 CET 2021


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

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://doi.org/10.1371/journal.pcbi.1002202

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


More information about the fieldtrip mailing list