Back to the main page.

Bug 1871 - plotting fails for single precision data

Status CLOSED FIXED
Reported 2012-12-05 22:28:00 +0100
Modified 2014-02-24 10:56:23 +0100
Product: FieldTrip
Component: plotting
Version: unspecified
Hardware: PC
Operating System: Mac OS
Importance: P3 normal
Assigned to: Robert Oostenveld
URL:
Tags:
Depends on:
Blocks:
See also:

Robert Oostenveld - 2012-12-05 22:28:25 +0100

if you do cd fieldtrip/test load avgFIC.mat cfg = []; cfg.xlim = [0.3 0.5]; cfg.layout = 'CTF151.lay'; cfg.zlim = 'maxmin'; cfg.colorbar = 'yes'; ft_topoplotER(cfg,avgFIC) you get Error using builtin The first input, 'X', cannot be a single, complex or sparse matrix. 'X' must be a non-sparse real double matrix. Error in griddata>mergepoints2D (line 159) xyv = builtin('_mergesimpts', [y, x, v], [myepsy, myepsx, Inf], 'average'); Error in griddata>gdatav4 (line 286) [x, y, v] = mergepoints2D(x,y,v); Error in griddata (line 131) vq = gdatav4(x,y,v,xq,yq); Error in ft_plot_topo (line 200) [Xi,Yi,Zi] = griddata(chanX', chanY, dat, xi', yi, interpmethod); % interpolate the topographic data Error in ft_topoplotTFR (line 840) ft_plot_topo(chanX,chanY,datavector,'interpmethod',cfg.interpolation,... Error in ft_topoplotER (line 164) cfg = ft_topoplotTFR(cfg, varargin{:}); which is due to avgFIC being in single precision. This was detected in bug 1870, but is unrelated to that bug. TODO - make test script, not only for ft_topoplotER, but also multi- and singleplot, and both for ER and TFR. - use fieldtrip/utilities/struct2single on the inputs


Jan-Mathijs Schoffelen - 2012-12-06 08:34:40 +0100

TODO - make test script, not only for ft_topoplotER, but also multi- and singleplot, and both for ER and TFR. - use fieldtrip/utilities/struct2single on the inputs or better even: use struct2double instead ;-)


Robert Oostenveld - 2012-12-06 09:15:42 +0100

(In reply to comment #1) no, only the part that needs to be double should be double, not the whole struct. So struct2single for testing, and then double on the required items ;-P


Jan-Mathijs Schoffelen - 2012-12-06 10:00:46 +0100

why would we care. The data are only used within the function, so for my part all of the stuff can be temporarily converted into double.


Robert Oostenveld - 2012-12-06 10:12:25 +0100

(In reply to comment #3) why would we care -> because of memory. You are implying that the input struct to ft_xxxplot is converted with struct2double. That input can contain single trial data, since averaging will be done on the fly. So the input structure can be large, even at single precision, converting that to double will double (no pun intended) the RAM requirements. Also, the actual problem is in the ft_plot_xxx function in the plotting module, not in the main ft_xxxplot functions. The low-level ft_plot_xxx does not get structures as input, but only the arrays it needs to plot. So those arrays should be converted where needed and struct2double does not come into play there. Also, the ft_plot_xxx functions should be callable by the end user, and we don't expect the end user to be converting it.


Jim Herring - 2013-01-09 16:34:27 +0100

I think I can help solve this bug but as a fieldtrip-dev beginner would still like your opinion on my solution: It seems to be sufficient to add: 'dat = double(dat);' at the beginning of the ft_plot_xxx functions to convert to double if single (and do nothing if double). If this seems ok I can commit the change and create test scripts for the plotting functions.


Jim Herring - 2013-01-23 14:59:29 +0100

Bug is not reproducible anymore


Jim Herring - 2013-02-22 12:34:36 +0100

Bug seem to have reappeared. I have fixed the bug by converting dat structure to double in ft_plot_topo (rev. 7528) I've also created test scripts.


Jim Herring - 2013-02-25 16:40:02 +0100

channel position information (chanX and chanY) is now also converted to double as topo plotting occasionally crashed when channel position information was single (committed in rev. 7545).


Robert Oostenveld - 2013-11-19 12:37:58 +0100

there is a regression problem with the test script in revision 8811: Undefined function or variable "labelmeggrad". Error in ft_channelselection (line 407) if findmeggrad, channel = [channel; labelmeggrad]; end Error in topoplot_common (line 318) cfg.channel = ft_channelselection(cfg.channel, data.label); Error in ft_topoplotTFR (line 185) [cfg] = topoplot_common(cfg, varargin{:}); Error in test_bug1871 (line 33) ft_topoplotTFR(cfg, freq);


Robert Oostenveld - 2013-11-19 12:51:42 +0100

(In reply to comment #9) I looked at a longer list of dashboard log files, it started failing at http://code.google.com/p/fieldtrip/source/detail?r=8796


Robert Oostenveld - 2013-11-19 13:00:29 +0100

(In reply to comment #10) more precisely, it is due to ft_senstype failing on combined planar neuromag channels


Robert Oostenveld - 2013-11-19 13:46:16 +0100

(In reply to comment #11) .. actually not failing, but returning "unknown". It was due to ft_senslabel returning its output as a single 306x1 long vector rather than a 102x3 matrix. That is my fault in trying to address bug #1919. I thought it should be a vector but apparently not. I have fixed it: r8813 | roboos | 2013-11-19 13:13:18 +0100 (Tue, 19 Nov 2013) | 1 line r8812 | roboos | 2013-11-19 13:13:16 +0100 (Tue, 19 Nov 2013) | 2 lines


Robert Oostenveld - 2014-02-24 10:56:23 +0100

I closed several bugs at once that all have been resolved for some time. If you disagree, please reopen.