You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: validate_seg.m
    path of file: ./repos/bspm/thirdparty/spm12/external/fieldtrip/private
    
    the code of the file until where you have to start completion: function [tissue1, tissue2, tissue3] = validate_seg(tissue1, tissue2, tissue3)

% VALIDATE_SEG ensures that the segmentation represents tissue types in a cumulative than exclusive 
% manner. 
%
% Use as
%   [tissue1, tissue2, tissue3] = validate_segmentation(tissue1, tissue2, tissue3)
% where the second two input (and output) arguments are optional. In case of more than one input 
% argument the tissue-types should follow eachother from inside towards outside (e.g. tissue1 = brain,
% tissue2 = skull, tissue = scalp). 
%
% The output will consist of one or more boolean segmentations without empty spaces inside. 
% In such way, more than one tissue-types will be represented in an overlapping manner. If
% the input is invalid and cannot be converted to overlapping segmentations, this function will give
% an error.
%
% This function makes use of functions from the MATLAB Signal Processing Toolbox.
%
% See also TRIANGULATE_SEG, PREPARE_MESH_SEGMENTATION

% Copyright (C) 2012, Robert Oostenveld
%
% This file is part of FieldTrip, see http://www.fieldtriptoolbox.org
% for the documentation and details.
%
%    FieldTrip is free software: you can redistribute it and/or modify
%    it under the terms of the GNU General Public License as published by
%    the Free Software Foundation, either version 3 of the License, or
%    (at your option) any later version.
%
%    FieldTrip is distributed in the hope that it will be useful,
%    but WITHOUT ANY WARRANTY; without even the implied warranty of
%    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
%    GNU General Public License for more details.
%

    
function [tissue1, tissue2, tissue3] = validate_seg(tissue1, tissue2, tissue3)

% VALIDATE_SEG ensures that the segmentation represents tissue types in a cumulative than exclusive 
% manner. 
%
% Use as
%   [tissue1, tissue2, tissue3] = validate_segmentation(tissue1, tissue2, tissue3)
% where the second two input (and output) arguments are optional. In case of more than one input 
% argument the tissue-types should follow eachother from inside towards outside (e.g. tissue1 = brain,
% tissue2 = skull, tissue = scalp). 
%
% The output will consist of one or more boolean segmentations without empty spaces inside. 
% In such way, more than one tissue-types will be represented in an overlapping manner. If
% the input is invalid and cannot be converted to overlapping segmentations, this function will give
% an error.
%
% This function makes use of functions from the MATLAB Signal Processing Toolbox.
%
% See also TRIANGULATE_SEG, PREPARE_MESH_SEGMENTATION

% Copyright (C) 2012, Robert Oostenveld
%
% This file is part of FieldTrip, see http://www.fieldtriptoolbox.org
% for the documentation and details.
%
%    FieldTrip is free software: you can redistribute it and/or modify
%    it under the terms of the GNU General Public License as published by
%    the Free Software Foundation, either version 3 of the License, or
%    (at your option) any later version.
%
%    FieldTrip is distributed in the hope that it will be useful,
%    but WITHOUT ANY WARRANTY; without even the implied warranty of
%    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
%    GNU General Public License for more details.
%
%    You should have received a copy of the GNU General Public License
%    along with FieldTrip. If not, see <http://www.gnu.org/licenses/>.
%
% $Id$

% the boundaries for surface extraction should be at
% t = sort(unique(brain+skull+2*scalp))
% t = (t(1:end