Back to the main page.

Bug 2527 - ft_sourceplot does not plot color data

Status CLOSED FIXED
Reported 2014-04-07 09:29:00 +0200
Modified 2019-08-10 12:28:16 +0200
Product: FieldTrip
Component: plotting
Version: unspecified
Hardware: PC
Operating System: Windows
Importance: P5 major
Assigned to: Arjen Stolk
URL:
Tags:
Depends on:
Blocks:
See also:

Arjen Stolk - 2014-04-07 09:29:07 +0200

REPORT: Although a plot is generated, thus without error, a warning indicates that ft_sourceplot is not plotting correctly. Closer inspection reveals that the dimension of the 'color' variable at line 1001 in ft_sourceplot does not have the same size as 'surf.tri' and 'surf.pnt' when calling h1 = patch('Vertices', surf.pnt, 'Faces', surf.tri, 'FaceVertexCData', color , 'FaceColor', 'interp'); The 'color' variable is generated just above that line (lines 994 and down), according to: if isfield(surf, 'curv') % the curvature determines the color of gyri and sulci color = surf.curv(:) * cortex_light + (1-surf.curv(:)) * cortex_dark; else color = repmat(cortex_light, size(surf.pnt,1), 1); end And given that in our data (see simulation below), there is a curv field present, the dimension of 'color' is adjusted that of surf.curv, and not to that of surf.pnt. Removing the first part of the code solves the issue (i.e. defining 'color' according to: color = repmat(cortex_light, size(surf.pnt,1), 1); instead of surf.curv) But I guess the person who implemented this line, has better thoughts about the purpose of this line (e.g. support for MNE?). REPLICATION: The warning "Warning: Color Data is not set for Interpolated shading" can be generated using % simulate source interpolated data int.inside = logical(ones(91,109,91)); int.stat = randn(91,109,91); int.mask = int.inside; int.anatomy = int.inside; int.unit = 'mm'; int.transform = randn(4,4); int.dim = [91 109 91]; % source plot cfg = []; cfg.method = 'surface'; cfg.funcolormap = 'dutch'; cfg.projmethod = 'nearest'; cfg.surfdownsample = 10; cfg.camlight = 'yes'; cfg.funparameter = 'stat'; cfg.maskparameter = 'stat'; ft_sourceplot(cfg, int);


Jan-Mathijs Schoffelen - 2014-04-07 09:38:14 +0200

I think we should seize the opportunity to move the 'interpolation on the fly' in sourceplot to ft_sourceinterpolate. This sounds like a good assignment for Arjen.


Jan-Mathijs Schoffelen - 2014-04-07 09:50:30 +0200

To get Arjen started on fixing this bug: 1) in the simulation, please simulate a meaningful transformation matrix: the interpolation is done on the fly, and I am not sure what a randn(4,4) gives in the output 2) check whether the surf.curv is downsampled when cfg.surfdownsample is specified. I think that this is the key to the solution.


Jan-Mathijs Schoffelen - 2014-04-07 09:56:52 +0200

the fix should be implemented around line 903. reducepatch is used to downsample the surface. Arjen needs to build in some lines that identify the indices to the original vertices that are retained in the downsampled surface. These indices can then be used to downsample the curv and sulc as well.


Arjen Stolk - 2014-04-07 10:55:17 +0200

Yep, that might be the problem. I'm implementing a potential fix.


Arjen Stolk - 2014-04-07 11:22:45 +0200

[temp.tri, temp.pnt] = reducepatch(surf.tri, surf.pnt, 1/cfg.surfdownsample); % find indices of retained patch faces [~, idx] = ismember(temp.pnt, surf.pnt, 'rows'); surf.tri = temp.tri; surf.pnt = temp.pnt; clear temp % downsample other fields if isfield(surf, 'curv') surf.curv = surf.curv(idx); end if isfield(surf, 'sulc') surf.sulc = surf.sulc(idx); end if isfield(surf, 'hemisphere') surf.hemisphere = surf.hemisphere(idx); end


Arjen Stolk - 2014-04-07 11:23:33 +0200

the curv, sulc, and hemisphere fields are now adjusted/downsampled as well (when present)


Robert Oostenveld - 2019-08-10 12:28:16 +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 describing the issue on https://github.com/fieldtrip/fieldtrip/issues.