Matlab Help Index Technical Documentation Index

write_label

NAME ^

ok = write_label(lindex, lxzy, lvals, labelfile, )

SYNOPSIS ^

function ok = write_label(lindex, lxyz, lvals, labelfile, subjid)

DESCRIPTION ^

 ok = write_label(lindex, lxzy, lvals, labelfile, <subjid>)

CROSS-REFERENCE INFORMATION ^

This function calls:

This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function ok = write_label(lindex, lxyz, lvals, labelfile, subjid)
0002 % ok = write_label(lindex, lxzy, lvals, labelfile, <subjid>)
0003 
0004 ok = 0;
0005 
0006 if(nargin ~= 4 & nargin ~= 5)
0007   fprintf('ok = write_label(lindex, lxzy, lvals, labelfile, <subjid>)\n');
0008   return;
0009 end
0010 
0011 if(exist('subid') ~= 1) subjid = ''; end
0012 
0013 if(isempty(lindex) & isempty(lxyz))
0014   %%fprintf('ERROR: both lindex and lxyz are empty.\n');
0015     oops(350);
0016   return;
0017 end
0018 
0019 if(~isempty(lindex) & ~isempty(lxyz))
0020   npoints1 = length(lindex); 
0021   npoints2 = length(lxyz); 
0022   if(npoints1 ~= npoints2)
0023     %%fprintf('ERROR: lindex and lxyz have different lengths.\n');
0024     oops(351);
0025     return;
0026   end
0027   npoints = npoints1;
0028 elseif(~isempty(lindex))
0029   npoints = length(lindex); 
0030   lxyz = zeros(npoints,3); 
0031 elseif(~isempty(lxyz))
0032   npoints = length(lxyz); 
0033   lindex = zeros(npoints,1); 
0034 end
0035 
0036 if(size(lxyz,2) ~= 3)
0037   %%fprintf('ERROR: lxyz does not have 3 columns\n');
0038     oops(352);
0039   return;
0040 end
0041 
0042 if(~isempty(lvals)) 
0043   if(npoints ~= length(lvals))
0044     %%fprintf('ERROR: length of lvals inconsistent\n');
0045     oops(353);
0046     return;
0047   end
0048 else
0049   lvals  = zeros(npoints,1); 
0050 end
0051 
0052 % open as an ascii file
0053 fid = fopen(labelfile, 'w') ;
0054 if(fid == -1)
0055   %%fprintf('ERROR: could not open %s\n',labelfile);
0056     oops(158);
0057   return;
0058 end
0059 
0060 fprintf(fid,'#!ascii label, from subject %s \n',subjid);
0061 fprintf(fid,'%d\n',npoints);
0062 
0063 % Make sure they are npoints by 1 %
0064 lindex = reshape(lindex,[npoints 1]);
0065 lxyz   = reshape(lxyz,[npoints 3]);
0066 lvals  = reshape(lvals,[npoints 1]);
0067 
0068 l = [lindex lxyz lvals];
0069 fprintf(fid,'%d %f %f %f %f\n',l') ;
0070 
0071 fclose(fid) ;
0072 
0073 ok = 1;
0074 
0075 return;

Generated at 19:47:41 15-Oct-2003 by m2html © 2003