# [FieldTrip] Using FieldTrip for Plotting SPM Statistical Maps

Cecconi Benedetta Benedetta.Cecconi at uliege.be
Mon Mar 18 10:12:38 CET 2024

```Dear Mikkel,

thanks a lot for clarifying further and for your very detailed answer ??

I managed to plot topographies in Fieldtrip following your suggestions and modifying the SPM function "spm12/toolbox/MEEGtools/spm_eeg_img2maps.m". I attach the modified function here, with an example script for plotting multiple topographies, in case it might be useful to others...

Thanks again,

Benedetta
-----
Doctoral Candidate - FNRS ASP

Coma Science Group<https://www.coma.uliege.be/>   GIGA Consciousness
Centre du Cerveau²<http://www.chuliege.be/cerveau>      CHU de Liège

University of Liège, Belgium
11 Avenue de l'Hôpital, B34+2
4000-Liège (Sart Tilman)
Belgium
________________________________
From: mikkelcv at drcmr.dk <mikkelcv at drcmr.dk>
Sent: Friday, March 15, 2024 2:00 PM
To: Cecconi Benedetta <Benedetta.Cecconi at uliege.be>; FieldTrip discussion list <fieldtrip at science.ru.nl>
Subject: SV: Using FieldTrip for Plotting SPM Statistical Maps

Dear Benedetta

I see; if I understand correctly, SPM treats the data as a “volume”, with the first two dimensions being x and y coordinates and the 3rd dimension being time. To get this data into FieldTrip, you will probably need to specify it as a volume data structure (https://www.fieldtriptoolbox.org/faq/how_is_anatomical_functional_or_statistical_volume_data_described/).

Event though volumes in FieldTrip, in most instances, refer to MR data or source reconstructed EEG/MEG data, I think you can treat your t-maps as such for plotting. SPM kind of does this for statistics as it converts the EEG topographies over time into a volume with time as one side of the “volume”.

For plotting purposes, you can then use the FieldTrip functions for source plots (https://www.fieldtriptoolbox.org/tutorial/plotting/#plotting-data-at-the-source-level). With the cfg.method = ‘slice’ for ft_sourceplot, you could probably create some topoplot-looking figures.

Probably something like this could work:

volume.dim = [32, 32, 201].  % x, y, time

cfg = [];

cfg.method        = 'slice';

cfg.funparameter  = ’tscore’;

ft_sourceplot(cfg, volume);

You might need to play around a little with the cfg.funparameter and/or cfg.maskparameter to get it to work properly.

Best regards

Mikkel

Fra: Cecconi Benedetta <Benedetta.Cecconi at uliege.be>
Dato: fredag, 15. marts 2024 kl. 11.47
Til: mikkelcv at drcmr.dk <mikkelcv at drcmr.dk>, FieldTrip discussion list <fieldtrip at science.ru.nl>
Emne: Re: Using FieldTrip for Plotting SPM Statistical Maps

Dear Mikkel,

I'm not sure I can implement the solution you proposed as my T_maps/contrast maps (3D Sensor maps over time) are 32x32x201 double where 32x32 is the n of pixels and 201 the n of samples (here's a col of a contrast map):

[cid:6c6b3150-aa61-4789-8ec2-22d006dba4c1]

If I create a matrix Ch x time points, I do not know which values correspond to which channel (e.g., which channel a certain t-value belongs to)...

I am probably missing something of what you explained, is there any chance you could clarify further?

Benedetta

-----
Doctoral Candidate - FNRS ASP

Coma Science Group<https://www.coma.uliege.be/>   GIGA Consciousness
Centre du Cerveau²<http://www.chuliege.be/cerveau>      CHU de Liège

University of Liège, Belgium
11 Avenue de l'Hôpital, B34+2
4000-Liège (Sart Tilman)
Belgium

________________________________

From: mikkelcv at drcmr.dk <mikkelcv at drcmr.dk>
Sent: Friday, March 15, 2024 10:46 AM
To: FieldTrip discussion list <fieldtrip at science.ru.nl>
Cc: Cecconi Benedetta <Benedetta.Cecconi at uliege.be>
Subject: SV: Using FieldTrip for Plotting SPM Statistical Maps

Dear Benedetta

Depending on what level you have your t-maps (sensor level, source level, or something else), you can manually create the FieldTrip data structure. All you need is to arrange your t-map as NxM matrix, a vector with the N channel names, and a vector with the M dimension, usually time or frequency. Finally, you specify the “dimord” according to one of the datatypes, e.g., “chan_time” if the data is channelled by time points. The details on what you need and what the data fields should be named are explained here: https://www.fieldtriptoolbox.org/development/datastructure/

For example, if you have a single t-value per channel location in a standard EEG cap, you would export the N channels x 1 “t-map” and the channel names. Once you have arranged it according to the FieldTrip naming conventions, you can use ft_checkdata to see if the structure is “valid” in FieldTrips view or if something is still missing.

Best regards

Mikkel

Fra: fieldtrip <fieldtrip-bounces at science.ru.nl> på vegne af Cecconi Benedetta via fieldtrip <fieldtrip at science.ru.nl>
Dato: torsdag, 14. marts 2024 kl. 19.06
Til: fieldtrip at science.ru.nl <fieldtrip at science.ru.nl>
Cc: Cecconi Benedetta <Benedetta.Cecconi at uliege.be>
Emne: [FieldTrip] Using FieldTrip for Plotting SPM Statistical Maps

Hello everyone ??

I have contrast and t-maps generated in SPM-EEG, and I've been finding it challenging to plot these in SPM while allowing for some customization (even basic ones like adjusting the scale or plotting multiple time points).

Since there does not seem to be a simple solution to achieve this, I was considering using FieldTrip for plotting these statistical maps. I found the function spm2fieldtrip, but it only seems to handle the conversion of raw data. I was wondering if any of you have experience or insights on using FieldTrip for plotting SPM statistical maps directly, without the need to redo the entire analysis on FieldTrip.

Any tips or guidance would be greatly appreciated..

Best,

Benedetta

-----
Doctoral Candidate - FNRS ASP

Coma Science Group<https://www.coma.uliege.be/>   GIGA Consciousness
Centre du Cerveau²<http://www.chuliege.be/cerveau>      CHU de Liège

University of Liège, Belgium
11 Avenue de l'Hôpital, B34+2
4000-Liège (Sart Tilman)
Belgium
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20240318/b359dfa4/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 231591 bytes
Desc: image.png
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20240318/b359dfa4/attachment-0001.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: spm_eeg_img2maps.m
Type: application/octet-stream
Size: 4056 bytes
Desc: spm_eeg_img2maps.m
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20240318/b359dfa4/attachment-0002.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: topographies_SPM.m
Type: application/octet-stream
Size: 608 bytes
Desc: topographies_SPM.m
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20240318/b359dfa4/attachment-0003.obj>
```