Home > eeg > egis > meg_code > make_meg_power_image.m

make_meg_power_image

PURPOSE ^

status = make_a_image(data,bad_chan,plot_res,image_rows,image_columns

SYNOPSIS ^

function image_binary = make_meg_image(data,bad_chan,plot_res,image_rows,image_columns,out_root);

DESCRIPTION ^

status = make_a_image(data,bad_chan,plot_res,image_rows,image_columns
,out_root)
data = arbitrary number of rows Nchan columns. 
bad_chan = bad_Chans list e.g [6 7 9]; (optional)
plot_Res = image size e.g 100 (optional) defaults to 100
e.g.
make_a_image(cor_by_obs([1 4],:),[37 68],100)
other optional parameters
image_rows (default is 1)
image_columns (default is size(data,1))
out_root (default is gui) generates file out_root.img

note: thisis the lowest level imaging software, there is probably a higher
level script you should be using

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function image_binary = make_meg_image(data,bad_chan,plot_res,image_rows,image_columns,out_root);
0002 %status = make_a_image(data,bad_chan,plot_res,image_rows,image_columns
0003 %,out_root)
0004 %data = arbitrary number of rows Nchan columns.
0005 %bad_chan = bad_Chans list e.g [6 7 9]; (optional)
0006 %plot_Res = image size e.g 100 (optional) defaults to 100
0007 %e.g.
0008 %make_a_image(cor_by_obs([1 4],:),[37 68],100)
0009 %other optional parameters
0010 %image_rows (default is 1)
0011 %image_columns (default is size(data,1))
0012 %out_root (default is gui) generates file out_root.img
0013 %
0014 %note: thisis the lowest level imaging software, there is probably a higher
0015 %level script you should be using
0016 if ~ (nargin ==1|nargin ==2|nargin == 3|nargin == 5|nargin == 6)
0017     error('inappropriate number of input arguments');
0018 end;
0019  
0020 if nargin < 2
0021     bad_chan = [];
0022     plot_res = 100;
0023 end
0024 if nargin < 3
0025     plot_res= 100;
0026 end;
0027 if nargin <  4
0028 image_binary = zeros(plot_res,plot_res*size(data,1));
0029 image_rows = 1;
0030 image_columns = size(data,1);
0031 else
0032 image_binary = zeros(plot_res*image_rows,plot_res*image_columns);
0033 end;
0034 
0035 [xelec,yelec,zelec] = sensors(148);
0036 xelec(1)
0037 good_chan_mask = ones(1,size(data,2));
0038 ruu = sqrt(xelec(1).^2+yelec(1).^2+zelec(1).^2);
0039 [xs,ys,zs] = polgrid_meg(plot_res,ruu);
0040 if ~isempty(bad_chan)    
0041 good_chan_mask(1,bad_chan) = zeros(1,size(bad_chan,2));
0042 end;
0043 good_chan = find(good_chan_mask(1,:));
0044 x = zeros(1,size(good_chan,2));
0045 y = zeros(1,size(good_chan,2));
0046 z = zeros(1,size(good_chan,2));
0047 x = xelec(good_chan);
0048 y = yelec(good_chan);
0049 z = zelec(good_chan);
0050 elec = xyz2tp(x,y,z);
0051 max_mask = 120;
0052 welec = 1;
0053 icount = 1;
0054 [k,kinv,a,ainv,e] = k_and_e(welec,x,y,z);
0055 for i = 1:image_rows
0056     for j = 1:image_columns
0057                w = data(icount,:);
0058                v = zeros(1,size(good_chan,2));
0059         v = w(good_chan);
0060         icount = icount+1;
0061         [p,q,error_check]= mateqs(welec,x,y,z,v,k,kinv,a,ainv,e);
0062         image_3d= interp_3d(welec,x,y,z,xs,ys,zs,p,q);    
0063 %        imagemat = image_3d;
0064         imagemat= mask_meg_power(xs,ys,zs,image_3d,max_mask); 
0065         imagemat = flipud(imagemat);
0066         image_binary(plot_res*(i-1)+1:plot_res*(i-1)+plot_res,plot_res*(j-1)+1:plot_res*j)= imagemat;
0067 end;
0068 end;
0069 if (nargin == 6)
0070     if ~isempty(out_root)
0071         out_fname = [out_root '.img'];
0072         fid = fopen(out_fname,'wb');
0073         if fid < 0
0074             error('couldnt open output file')
0075         end
0076     else
0077         fid = -1;
0078     end
0079 elseif nargin < 6
0080     fid = put_fid('wb');
0081     if fid < 0
0082         error('couldnt open output file')
0083     end
0084 end;
0085 if fid ~= -1
0086     size(image_binary);
0087     num_written = fwrite(fid, size(image_binary), 'float');
0088     if num_written ~= 2
0089             error('Failed to write header info');
0090     end 
0091     fwrite(fid,plot_res,'float');
0092     num_written = fwrite(fid,image_binary','float');
0093     if num_written ~= size(image_binary,1)*size(image_binary,2)
0094         error('write-out filed')
0095     end;
0096     fclose(fid);
0097 end;
0098 
0099 
0100 
0101 
0102 
0103 
0104 
0105 
0106 
0107

Generated on Sat 25-May-2019 04:00:51 by m2html © 2003