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: readroiim.m
    path of file: ./repos/diplib/dipimage
    
    the code of the file until where you have to start completion: %READROIIM   Read ROI of an image from file
%
% This function is useful for large image files, if only a smaller region is
% needed for processing, or to extract a thumbnail from it.
%
% SYNOPSIS:
%  [image,metadata] = readroiim(filename,spacing,origin,sizes,format)
%
% PARAMETERS:
%  filename: string with name of file, optionally with path and extension.
%  spacing:  step size for reading a down-sampled ROI.
%  origin:   coordinates for the first pixel to read.
%  sizes:    size of the ROI to read.
%  format:   either 'ICS' or 'TIFF', or an empty string, which will cause
%            the function to search for the correct type.
%
% DEFAULTS:
%  filename = 'erika.ics'
%  spacing = 4
%  origin = []
%  sizes = []
%  format = ''
%
% EXAMPLE:
%  out = readroiim('erika',[2 2],[64 64],[128 128])
%
% NOTE:
%  For TIFF files, only the first image in the file is read. To control
%  which image directory to read, use the READTIFF function directly.

% (c)2018, Cris Luengo.
% Based on original DIPimage code: (c)1999-2014, Delft University of Technology.
%
% Licensed under the Apache License, Version 2.0 (the "License");
% you may not use this file except in compliance with the 
    
function is useful for large image files, if only a smaller region is
% needed for processing, or to extract a thumbnail from it.
%
% SYNOPSIS:
%  [image,metadata] = readroiim(filename,spacing,origin,sizes,format)
%
% PARAMETERS:
%  filename: string with name of file, optionally with path and extension.
%  spacing:  step size for reading a down-sampled ROI.
%  origin:   coordinates for the first pixel to read.
%  sizes:    size of the ROI to read.
%  format:   either 'ICS' or 'TIFF', or an empty string, which will cause
%            the function to search for the correct type.
%
% DEFAULTS:
%  filename = 'erika.ics'
%  spacing = 4
%  origin = []
%  sizes = []
%  format = ''
%
% EXAMPLE:
%  out = readroiim('erika',[2 2],[64 64],[128 128])
%
% NOTE:
%  For TIFF files, only the first image in the file is read. To control
%  which image directory to read, use the READTIFF function directly.

% (c)2018, Cris Luengo.
% Based on original DIPimage code: (c)1999-2014, Delft University of Technology.
%
% Licensed under the Apache License, Version 2.0 (the "License");
% you may not use this file except in compliance with the License.
% You may obtain a copy of the License at
%
%    http://www.apache.org/licenses/LICENSE-2.0
%
% Unless required by applicable law or agreed to in writing, software
% distributed under the License is distributed on an "AS IS" BASIS,
% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
% See the License for the specific language governing permissions and
% limitations under the License.

function [image,file_info] = readroiim(filename,spacing,origin,sizes,format)

if nargin < 1
   filename = 'erika.ics';
end