Home > eeg > egis > scripts > get_interp_range.m

get_interp_range

PURPOSE ^

function [intmin, intmax]=get_interp_range(irows,icols,filenums,inroot);

SYNOPSIS ^

function [intmin, intmax]=get_interp_range(irows,icols,filenums,inroot);

DESCRIPTION ^

function [intmin, intmax]=get_interp_range(irows,icols,filenums,inroot);

Parameters:
    irows    - Total rows per image file
    icols    - Total cols per image file
    filenums    - vector of numbers appended to inroot to create
        input file names
    inroot    - Used with above to create input file names

This function scales images created with interp_by_samp.m using
the 's' header_flag parameter. Goes through the files specified by
a combination of the inroot with a filenumber appended, and returns
the minimum and maximum values found in those files in the output 
parameters.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [intmin, intmax]=get_interp_range(irows,icols,filenums,inroot);
0002 %function [intmin, intmax]=get_interp_range(irows,icols,filenums,inroot);
0003 %
0004 %Parameters:
0005 %    irows    - Total rows per image file
0006 %    icols    - Total cols per image file
0007 %    filenums    - vector of numbers appended to inroot to create
0008 %        input file names
0009 %    inroot    - Used with above to create input file names
0010 %
0011 %This function scales images created with interp_by_samp.m using
0012 %the 's' header_flag parameter. Goes through the files specified by
0013 %a combination of the inroot with a filenumber appended, and returns
0014 %the minimum and maximum values found in those files in the output
0015 %parameters.
0016 %
0017 
0018 %Created 3/20/96 by B. Rakitin
0019 %
0020 
0021 %disp(['Nargin = ' int2str(nargin) ', Nargout = ' int2str(nargout)]);
0022 
0023 if ~(nargin==4)
0024     error('get_interp_range requires four input params. See help.')
0025 end
0026 
0027 if ~((nargout==1)|(nargout==2))
0028     error('get_interp_range requires one or two output params. See help.')
0029 end
0030 
0031 n=length(filenums);
0032 if n==0
0033     error('Null vector passed as filenums param, asshole.');
0034 end
0035 
0036 tempdata=zeros((irows * icols),1);
0037 
0038 for f=1:n
0039     infilename=[inroot int2str(filenums(f))];
0040     disp(['Current File: ' infilename]);
0041     if exist(infilename)~=2
0042         disp(['Skipping non-existing file ' infilename ]);
0043     else
0044         infid=-1;msg='';
0045         [infid,msg]=fopen(infilename);
0046         if infid==-1
0047             disp([msg ': ' infilename]);
0048         else
0049             [tempdata, count]=fread(infid,size(tempdata),'float');
0050             if count~=(irows*icols)
0051                 fclose('all');
0052                 error(['Error reading file ' infilename]);
0053             end
0054             if f==1
0055                 disp('Initializing temp values.')
0056                 tempmax=max(tempdata);
0057                 tempmin=min(tempdata);
0058             else
0059                 if max(tempdata)>tempmax,tempmax=max(tempdata);end
0060                 if min(tempdata)<tempmin,tempmin=min(tempdata);end
0061             end
0062             fclose(infid);
0063             disp(['Current Max = ' int2str(tempmax) ', Current Min = ' int2str(tempmin)]);
0064         end    %if infid==-1
0065     end    %if exist(infilename)~=2
0066 end    %for f=1:n
0067 
0068 if nargout==2
0069     intmax=tempmax;
0070     intmin=tempmin;
0071 else
0072     if nargout==1
0073         intmin=zeros(1,2);
0074         intmin(1)=tempmax;
0075         intmin(2)=tempmin;
0076     end
0077 end
0078 
0079

Generated on Wed 20-Mar-2019 04:00:51 by m2html © 2003