Skip to content

Commit

Permalink
Bugfix: Labels of the Structures when importing volatlas as surfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
ftadel committed Apr 6, 2023
1 parent dca0ad2 commit b5584ae
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 11 deletions.
2 changes: 1 addition & 1 deletion doc/license.html
Expand Up @@ -5,7 +5,7 @@
<body alink="#fff000" link="#fff000" vlink="#fff000">
<h4><span style="font-family: Arial Black; color: #ffffff;"><strong>THERE IS NO UNDO BUTTON!<BR>SET UP A <FONT color=red>BACKUP</FONT> OF YOUR DATABASE</strong></span></h4>
<HR>
<!-- LICENCE_START -->Version: 3.230405 (05-Apr-2023)<br>
<!-- LICENCE_START -->Version: 3.230406 (06-Apr-2023)<br>
<span style="font-style: italic;">COPYRIGHT &copy; 2000-2023
USC &amp; McGill University.<br>
</span>
Expand Down
2 changes: 1 addition & 1 deletion doc/version.txt
@@ -1,2 +1,2 @@
% Brainstorm
% v. 3.230405 (05-Apr-2023)
% v. 3.230406 (06-Apr-2023)
31 changes: 23 additions & 8 deletions toolbox/anatomy/tess_concatenate.m
@@ -1,14 +1,16 @@
function [NewTessFile, iSurface] = tess_concatenate( TessFiles, NewComment, fileType, Labels)
function [NewTessFile, iSurface] = tess_concatenate( TessFiles, NewComment, fileType, Labels, isKeepLabels)
% TESS_CONCATENATE: Concatenate various surface files into one new file.
%
% USAGE: [NewTessFile, iSurface] = tess_concatenate(TessFiles, NewComment='New surface', fileType='Other', Labels)
% [NewTessMat, iSurface] = tess_concatenate(TessMats, NewComment='New surface', fileType='Other', Labels)
% USAGE: [NewTessFile, iSurface] = tess_concatenate(TessFiles, NewComment='New surface', fileType='Other', Labels=[], isKeepLabels=0)
% [NewTessMat, iSurface] = tess_concatenate(TessMats, NewComment='New surface', fileType='Other', Labels=[], isKeepLabels=0)
%
% INPUT:
% - TessFiles : Cell-array of paths to surfaces files to concatenate
% - TessMats : Array of loaded surface structures
% - NewComment : Name of the output surface
% - fileType : File type for the new file {'Cortex', 'InnerSkull', 'OuterSkull', 'Scalp', 'Other'}
% - Labels : Labels for anatomical parcellations, Nx3 cell-array, each row={index, label, color}
% - isKeepLabels: If 1, keep the original comments of the input surfaces as the labels of the Structure atlas
% OUTPUT:
% - NewTessFile : Filename of the newly created file
% - iSurface : Index of the new surface file
Expand All @@ -31,9 +33,12 @@
% For more information type "brainstorm license" at command prompt.
% =============================================================================@
%
% Authors: Francois Tadel, 2008-2022
% Authors: Francois Tadel, 2008-2023

% Parse inputs
if (nargin < 5) || isempty(isKeepLabels)
isKeepLabels = 0;
end
if (nargin < 4) || isempty(Labels)
Labels = [];
end
Expand Down Expand Up @@ -70,16 +75,26 @@
isSave = 0;
end
% Detect if right/left hemisphere
if ~isempty(strfind(oldTess.Comment, 'lh.')) || ~isempty(strfind(oldTess.Comment, 'Lhemi')) || ~isempty(strfind(oldTess.Comment, 'Lwhite')) || ~isempty(strfind(oldTess.Comment, 'left'))
if ~isempty(strfind(oldTess.Comment, 'lh.')) || ~isempty(strfind(oldTess.Comment, 'Lhemi')) || ~isempty(strfind(oldTess.Comment, 'Lwhite')) || ~isempty(strfind(lower(oldTess.Comment), 'left'))
isLeft = 1;
scoutTag = ' L';
scoutHemi = 'L';
scoutComment = 'Cortex';
elseif ~isempty(strfind(oldTess.Comment, 'rh.')) || ~isempty(strfind(oldTess.Comment, 'Rhemi')) || ~isempty(strfind(oldTess.Comment, 'Rwhite')) || ~isempty(strfind(oldTess.Comment, 'right'))
if isKeepLabels
scoutComment = strrep(oldTess.Comment, 'left', '');
scoutComment = strrep(scoutComment, 'Left', '');
else
scoutComment = 'Cortex';
end
elseif ~isempty(strfind(oldTess.Comment, 'rh.')) || ~isempty(strfind(oldTess.Comment, 'Rhemi')) || ~isempty(strfind(oldTess.Comment, 'Rwhite')) || ~isempty(strfind(lower(oldTess.Comment), 'right'))
isRight = 1;
scoutTag = ' R';
scoutHemi = 'R';
scoutComment = 'Cortex';
if isKeepLabels
scoutComment = strrep(oldTess.Comment, 'right', '');
scoutComment = strrep(scoutComment, 'Right', '');
else
scoutComment = 'Cortex';
end
% Detect based on comment (tag ' L' or ' R' already present)
elseif (length(oldTess.Comment) > 2) && strcmpi(oldTess.Comment(end-1:end), ' L')
scoutTag = ' L';
Expand Down
3 changes: 2 additions & 1 deletion toolbox/io/import_surfaces.m
Expand Up @@ -179,7 +179,8 @@
% Multiple surfaces
else
[Tess(:).Atlas] = deal(db_template('Atlas'));
NewTess = tess_concatenate(Tess, [], [], Labels);
isKeepLabels = 1;
NewTess = tess_concatenate(Tess, [], [], Labels, isKeepLabels);
NewTess.iAtlas = find(strcmpi({NewTess.Atlas.Name}, 'Structures'));
NewTess.Comment = importedBaseName;
end
Expand Down

0 comments on commit b5584ae

Please sign in to comment.