Back to the main page.

Bug 2474 - Crash in ft_compute_leadfield because of number types

Status CLOSED FIXED
Reported 2014-02-17 15:25:00 +0100
Modified 2014-02-24 10:56:27 +0100
Product: FieldTrip
Component: forward
Version: unspecified
Hardware: PC
Operating System: Windows
Importance: P5 major
Assigned to: Robert Oostenveld
URL:
Tags:
Depends on:
Blocks:
See also:

Vladimir Litvak - 2014-02-17 15:25:46 +0100

I recently started seeing a new crash: Error using * MTIMES is not supported for one sparse input and one single input. In file "C:\spm12\external\fieldtrip\forward\ft_compute_leadfield.m" (v9183), function "ft_compute_leadfield" at line 247. The line is: lf = sens.tra * lf; and the crash happens because lf is single and sens.tra is sparse double. Converting lf to double fixes it but I'm not sure where the correct place for the fix is. I'll provide an example.


Vladimir Litvak - 2014-02-17 15:34:00 +0100

Created attachment 594 Data example ft_compute_leadfield(pos, sens, vol, 'reducerank', 2, 'dipoleunit', 'nA*m', 'chanunit', chanunits);


Vladimir Litvak - 2014-02-17 15:36:32 +0100

(In reply to Vladimir Litvak from comment #1) I also chased how sens.tra becomes sparse and that happens in ft_prepare_vol_sens


Robert Oostenveld - 2014-02-18 09:39:47 +0100

(In reply to Vladimir Litvak from comment #2) I can confirm the bug. There is a reason for tra being sparse (computational speed), but not a reason for something being single. I see that pos is single precision, and also this: >> vol.bnd ans = tri: [5120x3 double] pnt: [2562x3 single] nrm: [2562x3 double]


Robert Oostenveld - 2014-02-18 09:40:27 +0100

(In reply to Robert Oostenveld from comment #3) furthermore, sens also contains single precision fields >> sens sens = balance: [1x1 struct] chanori: [280x3 double] chanpos: [280x3 single] chantype: {280x1 cell} chanunit: {280x1 cell} coilori: [464x3 double] coilpos: [464x3 single] coordsys: 'neuromag' label: {280x1 cell} labelorg: {306x1 cell} tra: [280x464 double] type: 'neuromag306' unit: 'm'


Robert Oostenveld - 2014-02-18 10:01:47 +0100

mac001> svn commit utilities/ forward/private/ test/test_bug2474.m Sending forward/private/ft_datatype_headmodel.m Sending forward/private/ft_datatype_sens.m Adding test/test_bug2474.m Sending utilities/ft_struct2double.m Sending utilities/ft_struct2single.m Transmitting file data ..... Committed revision 9208. I changed it such that ft_datatype_headmodel and ft_datatype_sens force the conversion of single precision into double precision. These two will be called in ft_prepare_vol_sens, which should hence happen prior to ft_compute_leadfield. It would be inefficient to do the conversion inside each call to ft_compute_leadfield. The test script now works. Note that it requires version='upcoming' for the sens. How to document and communicate that to the users is still an open issue.


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

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