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: spm_eeg_mask2channels.m
    path of file: ./repos/bspm/thirdparty/spm12
    
    the code of the file until where you have to start completion: function chanind = spm_eeg_mask2channels(D, mask)
% Make a list of channel labels based on scalp mask
% FORMAT chanind = spm_eeg_firstlevel(D, mask)
%
% D - M/EEG object (or filename)
% mask - mask (numeric array, nifti object or image file name)

    
function chanind = spm_eeg_mask2channels(D, mask)
% Make a list of channel labels based on scalp mask
% FORMAT chanind = spm_eeg_firstlevel(D, mask)
%
% D - M/EEG object (or filename)
% mask - mask (numeric array, nifti object or image file name)
%        if the mask is 3D channels in all the blobs will be returned
%
% Output:
% chanind - indices of channels in D which correspond to blobs in the mask
%__________________________________________________________________________
% Copyright (C) 2009 Wellcome Trust Centre for Neuroimaging

% Vladimir Litvak
% $Id: spm_eeg_mask2channels.m 5640 2013-09-18 12:02:29Z vladimir $

%-Check inputs
%--------------------------------------------------------------------------

if nargin < 2
    error('At least two inputs are required.');
end