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: iread.m
    path of file: ./repos/fieldtrip/external/biosig/private
    
    the code of the file until where you have to start completion: function [data,HDR] = iread(HDR,CHAN,StartPos)
% IREAD reads image data 
%
% [S,HDR] = iread(HDR)
%
% See also: fread, SREAD, SWRITE, SCLOSE, SSEEK, SREWIND, STELL, SEOF

% This program 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.

%	$Id$
%	(C) 2005,2006,2008 by Alois Schloegl <a.schloegl@ieee.org>	
%    	This is part of the BIOSIG-toolbox http://biosig.sf.net/

    
function [data,HDR] = iread(HDR,CHAN,StartPos)
% IREAD reads image data 
%
% [S,HDR] = iread(HDR)
%
% See also: fread, SREAD, SWRITE, SCLOSE, SSEEK, SREWIND, STELL, SEOF

% This program 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.

%	$Id$
%	(C) 2005,2006,2008 by Alois Schloegl <a.schloegl@ieee.org>	
%    	This is part of the BIOSIG-toolbox http://biosig.sf.net/


if 0, 


elseif strcmp(HDR.TYPE,'IMAGE:BMP'),
        fseek(HDR.FILE.FID,HDR.HeadLen,'bof');
        nc = ceil((HDR.bits*HDR.IMAGE.Size(1))/32)*4;
        
        if (HDR.bits==1)
                [data,c] = fread(HDR.FILE.FID,[nc,HDR.IMAGE.Size(2)*8],'ubit1');
                %[data,c] = fread(HDR.FILE.FID,HDR.IMAGE.Size([2,1]),'ubit1');
size(data),
%                data = reshape(data(1:nc,:)',HDR.IMAGE.Size);
                
        elseif (HDR.bits==4)
                palr   = [  0,128,  0,128,  0,128,  0,192,128,255,  0,255,  0,255,  0,255]; 
                palg   = [  0,  0,128,128,  0,  0,128,192,128,  0,255,255,  0,  0,255,255]; 
                palb   = [  0,  0,  0,  0,128,128,128,192,128,  0,  0,  0,255,255,255,255]; 
                tmp    = uint8(fread(HDR.FILE.FID,[nc,HDR.IMAGE.Size(2)*2],'ubit4'));
                data        = palr(tmp(1:HDR.IMAGE.Size(1),:)'+1);
                data(:,:,2) = palg(tmp(1:HDR.IMAGE.Size(1),:)'+1);
                data(:,:,3) = palb(tmp(1:HDR.IMAGE.Size(1),:)'+1);
                data = data(HDR.IMAGE.Size(2):-1:1,:,:);
                
        elseif (HDR.bits==8)
                pal = uint8(colormap*256);
                tmp = fread(HDR.FILE.FID,[nc,HDR.IMAGE.Size(2)],'uint8');
                data        = pal(tmp(1:HDR.IMAGE.Size(1),:)'+1,1);
                data(:,:,2) = pal(tmp(1:HDR.IMAGE.Size(1),:)'+1,2);
                data(:,:,3) = pal(tmp(1:HDR.IMAGE.Size(1),:)'+1,3);
                data = reshape(data,[HDR.IMAGE.Size([2,1]),3]);
                data = data(HDR.IMAGE.Size(2):-1:1,:,:);
                
        elseif (HDR.bits==24)
                data   = uint8(fread(HDR.FILE.FID,[nc,HDR.IMAGE.Size(2)],'uint8'));
                HDR.BMP.Red   = data((1:HDR.IMAGE.Size(1))*3,:)';
                HDR.BMP.Green = data((1:HDR.IMAGE.Size(1))*3-1,:)';
                HDR.BMP.Blue  = data((1:HDR.IMAGE.Size(1))*3-2,:)';
                data = HDR.BMP.Red;
                data(:,:,2) = HDR.BMP.Green;
                data(:,:,3) = HDR.BMP.Blue;
                data = data(HDR.IMAGE.Size(2):-1:1,:,:);
        else
                
        end