Back to the main page.

Bug 2281 - headmodel localspheres gives an error

Status CLOSED FIXED
Reported 2013-09-09 18:31:00 +0200
Modified 2018-03-10 21:38:36 +0100
Product: FieldTrip
Component: forward
Version: unspecified
Hardware: PC
Operating System: Windows
Importance: P3 normal
Assigned to: Lilla Magyari
URL:
Tags:
Depends on:
Blocks:
See also:

Lilla Magyari - 2013-09-09 18:31:10 +0200

Hi, I run the test_ft_prepare_headmodel_new script from the test directory, and I got an error message when the localspeheres methods were applied: cfg=[]; cfg.grad=grad; cfg.method='localspheres'; vol67=ft_prepare_headmodel(cfg,seg2); single sphere, 3000 surface points, center = [19.3 1.2 54.6], radius = 70.3 channel = MLC11, 662 surface points, center = [16.4 -1.9 29.0], radius = 88.4 channel = MLC12, 654 surface points, center = [17.5 -4.4 36.1], radius = 82.9 channel = MLC13, 608 surface points, center = [17.9 -5.8 45.5], radius = 77.0 channel = MLC14, 623 surface points, center = [15.6 -5.0 51.2], radius = 74.2 channel = MLC15, 635 surface points, center = [13.2 -4.2 54.6], radius = 72.6 channel = MLC21, 685 surface points, center = [15.4 -1.6 35.9], radius = 82.9 channel = MLC22, 655 surface points, center = [16.3 -1.4 44.1], radius = 76.0 channel = MLC23, 610 surface points, center = [15.0 2.8 52.3], radius = 68.4 channe .... channel = MZP01, 457 surface points, center = [21.5 2.5 33.6], radius = 87.1 channel = MZP02, 411 surface points, center = [11.6 4.4 46.5], radius = 72.3 Undefined function or variable "hs". Error in ft_plot_mesh (line 210) set(hs, 'FaceColor', facecolor); Error in ft_headmodel_localspheres (line 165) ft_plot_mesh(geometry(shapesel,:), 'vertexcolor', 'g'); Error in ft_prepare_headmodel (line 339) vol = ft_headmodel_localspheres(geometry, cfg.grad, 'feedback', cfg.feedback, 'radius', cfg.radius, 'maxradius', cfg.maxradius, 'baseline', cfg.baseline, 'singlesphere', cfg.singlesphere); When the computation is running, a figure pops up and it starts to show the electrodes with some green patches (I guess the localsphere which belongs to 1 electrode ;). But it gives this error afterwards. The error is the same independently of the input (segmentation, headshape or mesh). Lilla Lilla


Robert Oostenveld - 2013-09-10 11:16:14 +0200

hs does not exist, which suggests that the section at line 190 if haspnt && ~isempty(pnt) if ~isempty(tri) hs = patch('Vertices', pnt, 'Faces', tri); elseif ~isempty(line) hs = patch('Vertices', pnt, 'Faces', line); else hs = patch('Vertices', pnt, 'Faces', []); end %set(hs, 'FaceColor', facecolor); set(hs, 'EdgeColor', edgecolor); set(hs, 'tag', tag); end was not executed. That indicates that pnt is empty, which may happen in this case when no surface points are selected. Is it not more appropriate to do if ~haspnt || isempty(pnt) hs = []; return end somewhere more to the beginning of the code? If there are no vertices, I don't think anything remains that can be plotted. All checks on pnt being present and non-empty further down in the code can then be removed.


Lilla Magyari - 2013-09-10 17:09:42 +0200

i have fixed it and also added a test script for ft_plot_mesh