Back to the main page.

Bug 1168 - ft_multiplotTFR dimensions not flexible

Reported 2011-11-18 10:30:00 +0100
Modified 2014-01-29 13:28:35 +0100
Product: FieldTrip
Component: core
Version: unspecified
Hardware: Other
Operating System: All
Importance: P3 normal
Assigned to: Eelke Spaak
Depends on:
See also:

Linsey Roijendijk - 2011-11-18 10:30:44 +0100

I was trying to make an 'imagesc' multiplot of 2-dimensional data by using ft_multiplotTFR: (stat = result of frequency statistics, method: montecarlo, statistic roc) cfg = []; cfg.parameter = 'stat'; stat.dimord = 'chan_empty_freq'; stat.empty = 0; stat.stat = reshape(stat.stat,[size(stat.stat,1) 1 size(stat.stat,2)]); ft_multiplotTFR(cfg,stat); However I noticed several problems: 1) I couldn't create a dimord with a name (in this example 'empty') not listed in the Fieldtrip code already. Error in ==> ft_multiplotTFR at 139 data = ft_checkdata(data, 'datatype', 'freq'); 152 error(sprintf('unexpected dimord "%s"', data.dimord)); 2) When I renamed 'empty' to 'time', the function couldn't handle that the 2nd dimension was time and the 3rd frequency. It implicitly assumed that the second dimension was freq and the third time, although it was different in the dimord. Error: ??? Index exceeds matrix dimensions. Error in ==> ft_multiplotTFR at 406 dat = dat(sellab, ymin:ymax, xmin:xmax); 3)Then as a work-around I tried to plot it as 'chan_freq_time' (in which I put the time-data/dimord in freq and empty in the 'freq' dimord). Then I got the error: ??? Error using ==> get There is no 'zdata' property in the 'image' class. Error in ==> objbounds at 64 zd = get(h(i), 'zdata'); Error in ==> axis>LocSetTight at 266 limits = objbounds(findall(ax)); Error in ==> axis at 102 LocSetTight(ax(j)); Error in ==> ft_multiplotTFR at 624 axis tight 64 zd = get(h(i), 'zdata'); What can I do next?

Robert Oostenveld - 2011-11-18 15:50:20 +0100

I created a test script and added it to svn. Note that it requires visual inspection to see some of the problems. Adding test/test_bug1168.m Transmitting file data . Committed revision 4773.

Boris Reuderink - 2012-01-03 13:51:37 +0100

Apparently, I get a different error when I run the script test/test_bug1168.m: --- the call to "ft_prepare_layout" took 0 seconds and an estimated 0 MB ??? Index exceeds matrix dimensions. Error in ==> ft_multiplotTFR at 406 dat = dat(sellab, ymin:ymax, xmin:xmax); Error in ==> test_bug1168 at 42 ft_multiplotTFR(cfg, freq) % this fails, visual inspection is needed to observe the problem --- Can anyone clarify, or find someone to assign this issue to? I can't understand the issue based on Linsey's description and Roberts script.

Jan-Mathijs Schoffelen - 2012-02-08 13:57:06 +0100

why not use ft_multiplotER? is the eventual problem the fact that singleton dimensions cannot be dealt with?

Linsey Roijendijk - 2012-02-08 14:03:39 +0100

(In reply to comment #2) The problem is that the dimensions in the .dimord are not taken into account. The functions seems to assume that the second dimension is time and the third frequency (and you cannot plot it the other way around). (In reply to comment #3) It is indeed possible to use a multiplotER, but by eye it is much easier to interpret the results when it is plotted as an image.

Jörn M. Horschig - 2012-02-22 10:18:24 +0100

1) It would be possible to make the function more generic by allowing cfg.yparam, cfg.xparam and cfg.paramenter to be set manually in the cfg. Right now, defaults are: if ~any(ismember(dimtok, 'time')) error('input data needs a time dimension'); else xparam = 'time'; yparam = 'freq'; cfg.parameter = ft_getopt(cfg, 'parameter', 'powspctrm'); end Everything else in the code already adheres to a generic programming style (e.g. data.(xparam) is accessed rather than data.time) 2) MATLAB cannot deal probably with a singleton dimension which is 'somewhere' in a matrix. Most operations on a Nx1xM matrix will squeeze the matrix to NxM. A workaround/hack is to just double the singleton dimension to Nx2xM (this is what I would do if I were you, Linsey). In theory, this could also be done by default in ft_multiplotTFR. The user would not notice that this is being done internally and yet give the desired result. 3) ft_multiplotTFR can now deal with dimords of any order (if there is no singleton dimension): % get dimord dimensions dims = textscan(data.dimord,'%s', 'Delimiter', '_'); dims = dims{1}; ydim = find(strcmp(yparam, dims)); xdim = find(strcmp(xparam, dims)); zdim = setdiff(1:ndims(dat), [ydim xdim]); % and permute dat = permute(dat, [zdim(:)' ydim xdim]); Sending ft_multiplotTFR.m Transmitting file data . Committed revision 5302. I need input on 1) and 2)

Jan-Mathijs Schoffelen - 2012-02-22 10:46:19 +0100

@1: Veto. The flexible functionality has been removed in the past. I would not put this back in again. @2: I don't understand. Can you remind me of the exact issue regarding the singleton?

Jörn M. Horschig - 2012-02-22 11:34:27 +0100

(In reply to comment #6) @1: ok, I can live with this (less work for me, hooray) @2: there was a bug in the testscript... so forget the singleton/squeeze stuff (this was caused by the wrong testscript) anyway, the problem still remains that if, e.g., the time-axis consists of a single sample, then ft_multiplotTFR does not plot anything. As a workaround/hack, I suggested to make it artificially two samples long, so that a colored stripe can be plotted.

Jörn M. Horschig - 2012-02-22 14:10:30 +0100

Hey Linsey, we just discussed this in the FT meeting. So, we won't change the function. However, for you to make it work, you can just repmat the time-dimension, so that a box can be drawn from min to max which has a finite dimension. Otherwise, you could still use ft_topoplotTFR and play around with interpolation, e.g. with cfg.interpolation set to 'nearest' and set to 'straight' or so

Jörn M. Horschig - 2012-08-23 14:02:03 +0200

bug closing time (

Johanna - 2012-10-19 13:18:03 +0200

Reopened because test_bug1168 fails. Fails on line 6, initTestSuite added by Boris recently does not exist on my path.

Jörn M. Horschig - 2012-10-19 14:37:38 +0200

assigned to boris cause his function is missing

Boris Reuderink - 2012-10-19 17:13:47 +0200

Please download and install MATLAB's xUnit: . I know that it is not very convenient to have to install another toolkit (maybe we should add it to external?), but it allows us to isolate test cases — which is needed to have meaningful test results.

Robert Oostenveld - 2012-10-20 08:33:34 +0200

I don't think we should add xUnit to fieldtrip/external; we don't want 20 people downloading it every day in the zip file. But we can add it to ft_hastoolbox, and then put it on home/common. Around line 356 in that function it checks whether the particular toolbox can be found on home/common, so thereby it could be auto-added.

Robert Oostenveld - 2012-10-20 11:12:13 +0200

I copied it to home/common roboos@mentat001> ll /home/common/matlab/xunit/ total 128 -rw-r--r-- 1 roboos mrphys 2620 Oct 20 11:01 assertElementsAlmostEqual.m -rw-r--r-- 1 roboos mrphys 1426 Oct 20 11:01 assertEqual.m ... and added it to ft_hastoolbox mac001> svn commit ft_hastoolbox.m Sending ft_hastoolbox.m Transmitting file data . Committed revision 6776.

Boris Reuderink - 2012-11-02 13:29:58 +0100

I am no longer working on FieldTrip. Hence, I donate all my bugs to the joint development user.

Eelke Spaak - 2012-12-18 13:55:32 +0100

Marking this bug as resolved, the test script runs successfully and the decision was explicitly made to not reintroduce cfg.xparam/yparam/zparam. If I am missing something here, please feel free to reopen.

Eelke Spaak - 2014-01-29 13:28:35 +0100

changing lots of bugs from resolved to closed.