function p = getBlockMaskParameters(idMdl)
   % Mask initialization for GP predictor
   
   % Copyright 2023 The MathWorks, Inc.
   if ~isa(idMdl,'idGaussianProcess') && ~isa(idMdl,'idNeuralNetwork')
      p.inputPortSize = [];
      p.linIndex = [];
      p.nlIndex = [];
      p.coeflin = [];
      p.lct = [];
      p.outOffset = [];
      p.nlLct = [];
      return;
   end

   % Linear Component
   lct = idMdl.LinearFcn.InputProjection;
   coeflin = idMdl.LinearFcn.Value(:);
   if ~idMdl.LinearFcn.Use      
      coeflin = zeros(size(coeflin));
   end
   linIndex = getIndices(idMdl.Inputs,idMdl.LinearFcn.Inputs);

   % For Offset
   if idMdl.Offset.Use
      outoffset = idMdl.Offset.Value;
   else
      outoffset = 0;
   end

   % For Nonlinear component
   if isa(idMdl,'idGaussianProcess') 
      prop = 'Kernel';
   elseif isa(idMdl,'idNeuralNetwork')
      prop = 'Network';
   end
     
   nlIndex = getIndices(idMdl.Inputs,idMdl.(prop).Inputs);

   % Create mask parameter
   p.inputPortSize = length(idMdl.Inputs);
   p.linIndex = linIndex;
   p.nlIndex = nlIndex;
   p.coeflin = coeflin;
   p.lct = lct;
   p.nlLct = idMdl.(prop).Parameters.InputProjection;
   p.outOffset = outoffset;
end

function indices = getIndices(allInputs, partInputs)
   indices = [];
   if iscell(partInputs)
      for i = 1:length(allInputs)
         for j = 1:length(partInputs)
            if strcmpi(allInputs{i}, partInputs{j})
               indices = [indices i];
            end
         end         
      end
   else
      for i = 1:length(allInputs)
         if any(strcmpi(allInputs{i},partInputs))
            indices = [indices i]; %#ok<*AGROW> 
         end
      end
   end
end