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: ImageType.m
    path of file: ./repos/CS_MoCo_LAB/reconstruction/matlab/CS_LAB_matlab/utils/utils_elastix
    
    the code of the file until where you have to start completion: classdef ImageType < handle
%IMAGETYPE  Base class to handle nD images
%    This class provides basic functionality and structure for medical images, inspired by the Insight Toolkit (www.itk.org). It provides means to handle origin, spacing, orientation, etc.
%
%    Most of the functionality is adapted to n-D images, and has been tested for 2D, 3D and 4D images.
%
%   Example:
%
%     img = ImageType(size,origin,spacing,orientation);
%     img.data = rand(size);
%     img.GetPosition([1 2 1]'); % retrieve the world coordinates of voxel with index [1 2 1]'
%
%   See also ECHOIMAGETYPE, VECTORIMAGETYPE, MESHTYPE.

%   Written by Alberto Gomez 2011
%   King's College London
%   OpenSource code under the BSD-2 lic
    
function [P, I] = GetBounds(obj,th,addBorder)
            % get the limits in x, y and z, in world coordinates (P) and in voxel coordinates (I)
            % Arguments 'th' , and 'addBorder' are optional. If th is specified, data below that threshold is ignored when calculating the bounds.
            % addBorder is a boolean which allows to add a 1 voxel border around the bounds.
            if (nargin==1)
                P = zeros(2*ndims(obj.data),1);

                
                c = zeros(ndims(obj.data),2^ndims(obj.data));
                
                  str1 = '';
                  str2 = '';
                  str3 = '';
                  intervals=[];
                  for i = 1:ndims(obj.data)
                        str1 = [str1 '[1 obj.size('  num2str(i) ')],'];
                        str2 = [str2 'i' num2str(i) ' '];
                        str3 = [str3 'i' num2str(i) '(:) '];
                  end