Home > eeg > egis > petr_dirtier > interp_no_egis.m

interp_no_egis

PURPOSE ^

function img_stack = interp_no_egis(data,bad_chan,interp_type,plot_res,outfile,header_flag, stack);

SYNOPSIS ^

function img_stack = interp_no_egis(data,bad_chan,interp_type,plot_res,outfile,header_flag,stack)

DESCRIPTION ^

 function img_stack = interp_no_egis(data,bad_chan,interp_type,plot_res,outfile,header_flag, stack);

 Calls interpolation routines but doesn't rely on EGIS file for
 the data

 Adapted from existing interpolation routines written by RS

 img_stack is size plot_res,plot_res,size(data,1)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function img_stack = interp_no_egis(data,bad_chan,interp_type,plot_res,outfile,header_flag,stack)
0002 % function img_stack = interp_no_egis(data,bad_chan,interp_type,plot_res,outfile,header_flag, stack);
0003 %
0004 % Calls interpolation routines but doesn't rely on EGIS file for
0005 % the data
0006 %
0007 % Adapted from existing interpolation routines written by RS
0008 %
0009 % img_stack is size plot_res,plot_res,size(data,1)
0010 
0011 % Modification history:
0012 % 11/30/96 PJ Started script
0013 % 06/05/00 PJ Modified further so that if output file arguments aren't passed,
0014 %             routine simply returns data in img_stack.
0015 %
0016 
0017 write_images = 1;
0018 
0019 if nargin < 1
0020   disp(['Not enough input arguments to interp_no_egis'])
0021   return
0022 elseif nargin < 2
0023   bad_chan = [];
0024   interp_type = '3d';
0025   plot_res = 40;
0026   outfile = 'interp.out';
0027   header_flag = 'h';
0028   stack = 1;
0029 elseif nargin < 3
0030   interp_type = '3d';
0031   plot_res = 40;
0032   outfile = 'interp.out';
0033   header_flag = 'h';
0034   stack = 1;
0035 elseif nargin < 4
0036   plot_res = 40;
0037   outfile = 'interp.out';
0038   header_flag = 'h';
0039   stack = 1;
0040 elseif nargin < 5
0041   write_images = 0;
0042 elseif nargin < 6
0043   header_flag = 'h';
0044   stack = 1;
0045 elseif nargin < 7
0046   stack = 1;
0047 end
0048 
0049 if write_images & ~stack
0050   disp(['Only supporting stacked output at this time'])
0051   return
0052 end
0053 
0054 if any(size(data) == 1)
0055   nsamps = 1;
0056 else
0057   nsamps = size(data,1);
0058 end
0059 
0060 good_chan = ones(1,size(data,2));
0061 if ~isempty(bad_chan)
0062   good_chan(bad_chan) = zeros(size(bad_chan));
0063 end
0064 
0065 good_chan = find(good_chan);
0066 
0067 [xelec,yelec,zelec] = electrodes(129);
0068 
0069   v = zeros(1,size(good_chan,2));
0070   x = zeros(1,size(good_chan,2));
0071   y = zeros(1,size(good_chan,2));
0072   z = zeros(1,size(good_chan,2));
0073 
0074   x = xelec(good_chan);
0075   y = yelec(good_chan);
0076   z = zelec(good_chan);
0077 
0078 welec = 1;
0079 
0080 [k, kinv, a, ainv, e] = k_and_e(welec,x,y,z);
0081 
0082 img_stack = zeros(plot_res,plot_res,nsamps);
0083 
0084 for isamp = 1:nsamps
0085 
0086   disp(['  samp: ' int2str(isamp)])
0087 
0088   w = data(isamp,:);
0089   v = w(good_chan);
0090 
0091   [p,q]= mateqs(welec,x,y,z,v,k,kinv,a,ainv,e);
0092 %  disp('plot is being made as a 2d image')
0093   ruu = sqrt(x(1).^2+y(1).^2+z(1).^2);
0094   [xs,ys,zs] = polgrid(plot_res,ruu);    
0095   image_3d= interp_3d(welec,x,y,z,xs,ys,zs,p,q);    
0096   imagemat= mask(xs,ys,zs,image_3d,120); 
0097 
0098   img_stack(:,:,isamp) = imagemat;
0099   
0100   if write_images
0101     if isamp == 1
0102       outfname = [outfile '_s' int2str(isamp) '_s' int2str(nsamps)];
0103       outfid = fopen(outfname,'wb','ieee-be');
0104       
0105       if header_flag == 'h'    
0106     num_written = fwrite(outfid, size(imagemat), 'float');
0107     if num_written ~= 2, error('Failed to write header info'), end
0108     fwrite(outfid, plot_res, 'float');
0109       end
0110     end
0111     
0112     num_written = fwrite(outfid,imagemat','float');
0113     if num_written ~= size(imagemat,1)*size(imagemat,2), error('write-out failed'), end
0114   end
0115   
0116 end % for isamp=
0117 
0118 if write_images
0119   fclose(outfid);
0120 end
0121 
0122 return
0123 
0124 
0125 
0126 
0127

Generated on Wed 20-Sep-2023 04:00:50 by m2html © 2003