Back to the main page.

Bug 3261 - ft_multiplotTFR with maskstyle = 'saturation' with non-evenly spaced frequency bands shows incorrect axis labels

Status CLOSED FIXED
Reported 2017-03-01 14:32:00 +0100
Modified 2017-11-20 20:09:21 +0100
Product: FieldTrip
Component: plotting
Version: unspecified
Hardware: PC
Operating System: Mac OS
Importance: P5 major
Assigned to: Jan-Mathijs Schoffelen
URL:
Tags:
Depends on:
Blocks:
See also:

nno - 2017-03-01 14:32:34 +0100

Greetings, we (Luca Ronconi and I) encountered an issue when plotting data in ft_multiplotTFR: data with axes non-evenly spaced is displayed wrongly when using maskstyle='saturation'. In the code below, artificial signal is created in the range ~ 7 - 13Hz. When plotting the data without mask, or with maskstyle = 'opacity', axis labels in freq x time plots are correct. When using maskstyle='saturation' and viewing a freq x time plot, the plots seems to show signal in the range ~ 14 - 22 Hz, which is incorrect behaviour. Note that all layout plots (with a time x freq plot for each sensor) puts the data as if data is linearly spaced (but without axis labels), consistent with FieldTrip's warning: "Warning: (one of the) axis is/are not evenly spaced, but plots are made as if axis are linear > In ft_multiplotTFR (line 409) " However this is a separate issue - and we would argue, a bug - as FT displays the wrong labels on the frequency axis. This could lead to wrong inferences about which frequencies show a significant effect. A search on bugzilla found this issue: http://bugzilla.fieldtriptoolbox.org/show_bug.cgi?id=3252. We were unable to run the code in comment #2 ("Error using builtin - No tolerance can be NaN.") therefore we don't know if the issue is related or not. System information: OSX 10.12, Matlab 2015a, FT commit 73dac6550219e5482813308d10f9a5f7ce3aa1a1. To reproduce the issue: close all; % close plots cfg=struct(); cfg.layout='biosemi64.lay'; layout=ft_prepare_layout(cfg); s=struct(); s.freq=3*1.05.^(0:50); % non-linear s.label=layout.label(1:(end-2)); s.time=-.5+.02*(0:100); s.dimord='chan_freq_time'; % create signal in particular time and frequency range freq_idxs=20:30; time_idxs=40:60; s.powspctrm=zeros(64,51,101); s.powspctrm(:,freq_idxs,time_idxs)=4; % plot I: without mask, correct frequency cfg = struct(); cfg.interactive = 'yes'; cfg.showlabels = 'yes'; cfg.layout=layout; cfg.rotate=90; cfg.showlabels = 'yes'; cfg.parameter='powspctrm'; figure; ft_multiplotTFR(cfg, s); % apply mask s.mask=s.powspctrm>0; % plot II: with opacity mask, correct frequency cfg.maskstyle = 'opacity'; figure; ft_multiplotTFR(cfg, s); % plot III: with saturation mask, incorrect frequency cfg.maskstyle = 'saturation'; figure; ft_multiplotTFR(cfg, s); expected_freqs=s.freq(freq_idxs); expected_freq_range=[min(expected_freqs), max(expected_freqs)]; fprintf('Expected freq range: %.3f ... %.3f\n',expected_freq_range); % to see the differences in the last two plots, select the FP1 sensor % in each of them and click on the selection to open a freq x time % plot. The 'opacity' plot shows significant effects in the expected % frequency range (7.581 ... 12.348 Hz). The 'saturation' plot shows % significant effects in the wrong frequency range, about 14 .. 22 Hz.


Jan-Mathijs Schoffelen - 2017-03-02 09:50:11 +0100

ft_plot_matrix seems to use uimagesc when highlightstyle is opacity, and imagesc when highlightstyle is saturation. Feel free to fix :o)


nno - 2017-03-02 18:12:48 +0100

(In reply to Jan-Mathijs Schoffelen from comment #1) > ft_plot_matrix seems to use uimagesc when highlightstyle is opacity, and imagesc when > highlightstyle is saturation. Feel free to fix :o) Thanks, that seems to solve the issue indeed. Any idea why? For a fix, is it possible to put a test in place (that fails with current code and passes with code that fixes the issue)? As far as I understand FieldTrip's architecture and testing methodology I assume the answer is no, but I just want to make sure.


Jan-Mathijs Schoffelen - 2017-03-02 19:08:10 +0100

well, I guess that in this case, the label 'failure' requires somebody to look at the result. So indeed, an automatic test without human intervention will not work. uimagesc works because it was specifically designed for imagesc-like functionality with unequal axes sampling.


nno - 2017-03-03 17:05:09 +0100

(In reply to Jan-Mathijs Schoffelen from comment #3) > well, I guess that in this case, the label 'failure' requires somebody to look at the result. So indeed, an automatic test without human intervention will not work. Thanks for the clarification. Indeed I meant an automated test. I sent a PR: https://github.com/fieldtrip/fieldtrip/pull/355 > uimagesc works because it was specifically designed for imagesc-like functionality with unequal axes sampling. I see, thanks. Follow up message about using that function is here: http://bugzilla.fieldtriptoolbox.org/show_bug.cgi?id=3262


Jan-Mathijs Schoffelen - 2017-07-04 15:18:35 +0200

This seems fixed, thanks to nic