Back to the main page.

Bug 3088 - ft_volumerealign shuts down Matlab when f key is pressed

Status CLOSED WONTFIX
Reported 2016-03-04 16:59:00 +0100
Modified 2019-08-10 12:32:22 +0200
Product: FieldTrip
Component: inverse
Version: unspecified
Hardware: PC
Operating System: Windows
Importance: P5 normal
Assigned to:
URL:
Tags:
Depends on:
Blocks:
See also:

Juan - 2016-03-04 16:59:06 +0100

During normal use of the function with 'intereactive' method, after a few clicks within the mri itself, if 'f' key is pressed, Matlab terminates abruptly. I've reproduced this behaviour with different mri. For instance, it happens with the standard mri given in the /template/headmodel folder. load standard_mri.mat cfg=[]; cfg.method='interactive'; cfg.coordsys='ctf'; mri2=ft_volumerealign(cfg,mri), % 'q', 'l', 'r' or 'n' keypresses work ok, but whenever 'f' key is pressed, matlab is just terminated. h2h Juan


Robert Oostenveld - 2016-03-05 15:41:16 +0100

this sounds like a bug in MATLAB (i.e. MATLAB crashing), not a bug in FieldTrip. Which MATLAB version are you using on which operating system?


Juan - 2016-03-07 10:39:37 +0100

Hi, I don't know if its Matlab is terminated because of a bug in FT or in one of Matlab's components. The fact is that it only crashes during normal execution of a fieldtrip function (i.e. ft_volumerealign). Windows 8.1 x64 matlab R2014a (x64) Hope this helps.


Robert Oostenveld - 2016-03-07 11:26:26 +0100

(In reply to Juan from comment #2) I don’t have a windows computer myself to reproduce. On my Mac (OSX 10.9.5 and R2015b) your code example runs just fine and I can toggle fiducionals with 'f' without a crash. At the donders we use windows 7, which also don't seem to have problems with crashing (otherwise my colleagues would have complained with me). Do you have another MATLAB version on that computer? If so, does it also crash with that version? Could you add (with the MATLAB debugger) breakpoints at various locations in the code? Just ad a whole bunch and then run the code once more, making large steps. This should allow you to identify where (which line) the code is problematic. Probably the relevant parts to check are the sub functions dealing with the GUI callbacks that you find at the end, like cb_redraw and cb_keyboard.


Juan - 2016-03-07 12:12:16 +0100

Hi, Sure I can (side note: I've been learning FT for a couple of months now and I feel very grateful for all this work). Ok. Various things: - This problem occurs on the latest FT version (as of last friday) as well as in a FT downloaded on mid February. (sorry I don't have other versions available). - I will download a copy of Matlab 2015b and install it and update this thread with results. - On the debugging(windows 8.1x64-matlab r2014a): Inside ft_volumerealign there is a callback function called cb_redraw defined in line:1376 (yes, as you pointed out). Everything seems to work fine until this fcn. Almost at the end (line#:1589) if opt.viewresult is false there is a for statement which runs once for each opt.fidlabel (4 times on my tests). **on 4th iteration in my case ** and percisely while executing line# 1602 it is where the exception is thrown and a "Matlab System Error" pops up and Matlab is closed. Here's the code (noted exactly the actual line). if ~opt.viewresult for i=1:length(opt.fidlabel) pos = opt.fiducial.(opt.fidlabel{i}); % if any(isnan(pos)) % continue % end posi = pos(1); posj = pos(2); posk = pos(3); subplot(h1); hold on opt.handlesmarker(i,1) = plot3(posi, 1, posk, 'marker', 'o', 'color', markercolor{i}); % -> ERROR POPS HERE! (WHEN i=4) hold off subplot(h2); hold on opt.handlesmarker(i,2) = plot3(opt.dim(1), posj, posk, 'marker', 'o', 'color', markercolor{i}); hold off subplot(h3); hold on opt.handlesmarker(i,3) = plot3(posi, posj, opt.dim(3), 'marker', 'o', 'color', markercolor{i}); hold off end % for each fiducial end


Robert Oostenveld - 2016-03-07 13:25:07 +0100

(In reply to Juan from comment #4) technically speaking there is nothing wrong with the MATLAB code around those lines. So it is really a core MATLAB error, which probably relates to how MATLAB builds up the figure. You could also try to change the MATLAB figure renderer, as it might be an OpenGL or Direct3D issue. Please try out playing with set(gcf, 'renderer', ...) somewhere in the code, with painters and zbuffer.


Juan - 2016-03-07 14:56:47 +0100

Hi, You're right. With 'painters' renderer there is no crash (though the image is weird). How should this be managed? Maybe some kind of warning? 'Warning: Under some setups in windows 'f' key-press produces unstable behavior.' Could be better to leave it alone, as it is some kind of matlab related issue. Though it can be annoying to lose unsaved script modifications.


Robert Oostenveld - 2016-03-07 18:37:10 +0100

(In reply to Juan from comment #6) I don't think that FieldTrip should be giving warnings about specific MATLAB errors for specific versions on specific OSes.


Robert Oostenveld - 2019-08-10 12:32:22 +0200

This closes a whole series of bugs that have been resolved (either FIXED/WONTFIX/INVALID) for quite some time. If you disagree, please file a new issue on https://github.com/fieldtrip/fieldtrip/issues.