From 184e8cb656692cd6a743d6bd370901939bd600a4 Mon Sep 17 00:00:00 2001 From: ftadel Date: Sat, 8 Jan 2022 11:36:11 +0100 Subject: [PATCH] Bugfix: Surface processing: No reducepatch if Nvertices too low --- toolbox/anatomy/tess_fillholes.m | 6 ++++-- toolbox/anatomy/tess_isohead.m | 8 +++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/toolbox/anatomy/tess_fillholes.m b/toolbox/anatomy/tess_fillholes.m index 85993c978..006ee402b 100644 --- a/toolbox/anatomy/tess_fillholes.m +++ b/toolbox/anatomy/tess_fillholes.m @@ -84,8 +84,10 @@ VertConn = tess_vertconn(Vertices, Faces); Vertices = tess_smooth(Vertices, 1, 10, VertConn, 0); % Downsampling isosurface -bst_progress('text', 'Fill: Downsampling surface...'); -[Faces, Vertices] = reducepatch(Faces, Vertices, nVertices ./ length(Vertices)); +if (length(Vertices) > nVertices) + bst_progress('text', 'Fill: Downsampling surface...'); + [Faces, Vertices] = reducepatch(Faces, Vertices, nVertices ./ length(Vertices)); +end % Remove small components bst_progress('text', 'Fill: Removing small components...'); [Vertices, Faces] = tess_remove_small(Vertices, Faces); diff --git a/toolbox/anatomy/tess_isohead.m b/toolbox/anatomy/tess_isohead.m index 8467adf8d..812078ea6 100644 --- a/toolbox/anatomy/tess_isohead.m +++ b/toolbox/anatomy/tess_isohead.m @@ -134,9 +134,11 @@ bst_progress('inc', 10); % Downsampling isosurface -bst_progress('text', 'Downsampling surface...'); -[sHead.Faces, sHead.Vertices] = reducepatch(sHead.Faces, sHead.Vertices, nVertices./length(sHead.Vertices)); -bst_progress('inc', 10); +if (length(sHead.Vertices) > nVertices) + bst_progress('text', 'Downsampling surface...'); + [sHead.Faces, sHead.Vertices] = reducepatch(sHead.Faces, sHead.Vertices, nVertices./length(sHead.Vertices)); + bst_progress('inc', 10); +end % Convert to millimeters sHead.Vertices = sHead.Vertices(:,[2,1,3]); sHead.Faces = sHead.Faces(:,[2,1,3]);