function summarystats( statsfile )
%Version 4/3/09
%Writes the summary statistics of the various files, depending on the value
%of statsfile.
global toprocess accepted
global frettype cfptype yfptype
global filenamebase inputdirectory outputdirectory dirsep homedirectory
dir = strcat( inputdirectory, dirsep, outputdirectory );
cd (dir);
fin = fopen( statsfile, 'r' );
toprocess = 0;
while( feof( fin ) ~= 1 )
linearray{ toprocess+1 } = fgetl( fin );
toprocess = toprocess + 1;
end;
testfinal = isstrprop(statsfile,'digit');
if testfinal(6)==1
toprocess = toprocess - 1;%in the final written file the parameters are stored in a separate file, and there is only one header line
fprintf( 1, '\n%s has %d records\n', statsfile, toprocess );
fseek( fin, 0, -1 ); % rewind
line1 = fgetl( fin ); %%// skip first header line
else
toprocess = toprocess - 2; % subtract two header lines
fprintf( 1, '\n%s has %d records\n', statsfile, toprocess );
fseek( fin, 0, -1 ); % rewind
line1 = fgetl( fin ); %%// skip first header line
line2 = fgetl( fin ); %%// skip second header line
end
processed = 0;
fsumfocus = 0; ysumfocus = 0; csumfocus = 0;
fsums2b = 0; ysums2b = 0; csums2b = 0;
ysumsMono = -10000; fsumsMono = -10000; csumsMono = -10000; % low number to initialize. Old code.
accepted = 0;
while( processed < toprocess )
[ filenamebase, count ] = fscanf( fin, '%s', 1 );
processed = processed + 1;
if( count > 0 )
[ strain ] = fscanf( fin, '%s', 1 );
[ donor ] = fscanf( fin, '%s', 1 );
[ acceptor ] = fscanf( fin, '%s', 1 );
[ dot ] = fscanf( fin, '%d ', 1 );
[ yfpsig ] = fscanf( fin, '%f', 1 );
[ yfpbak ] = fscanf( fin, '%f', 1 );
[ fretsig ] = fscanf( fin, '%f', 1 );
[ fretbak ] = fscanf( fin, '%f', 1 );
[ cfpsig ] = fscanf( fin, '%f', 1 );
[ cfpbak ] = fscanf( fin, '%f', 1 );
[ adjustYFP ] = fscanf( fin, '%f', 1 );
[ adjustFRET ] = fscanf( fin, '%f', 1 );
[ adjustCFP ] = fscanf( fin, '%f', 1 );
[ den ] = fscanf( fin, '%f', 1 );
[ fretr ] = fscanf( fin, '%f', 1 );
[ yfpfocus ] = fscanf( fin, '%f', 1 );
[ yfps2b ] = fscanf( fin, '%f', 1 );
[YFPMono] = fscanf( fin, '%f', 1 );
[YFP_X] = fscanf( fin, '%d', 1 );
[YFP_Y] = fscanf( fin, '%d', 1 );
[ fretfocus ] = fscanf( fin, '%f', 1 );
[ frets2b ] = fscanf( fin, '%f', 1 );
[FRETMono] = fscanf( fin, '%f', 1 );
[FRET_X] = fscanf( fin, '%d', 1 );
[FRET_Y] = fscanf( fin, '%d', 1 );
[ cfpfocus ] = fscanf( fin, '%f', 1 );
[cfps2b] = fscanf( fin, '%f', 1 );
[CFPMono] = fscanf( fin, '%f', 1 );
[CFP_X] = fscanf( fin, '%d', 1 );
[CFP_Y] = fscanf( fin, '%d', 1 );
accepted = accepted + 1;
ysumfocus = ysumfocus + yfpfocus;
ysums2b = ysums2b + yfps2b;
fsumfocus = fsumfocus + fretfocus;
fsums2b = fsums2b + frets2b;
csumfocus = csumfocus + cfpfocus;
csums2b = csums2b + cfps2b;
if ysumsMono < YFPMono
ysumsMono = YFPMono;
end
if csumsMono < CFPMono
csumsMono = CFPMono;
end
if fsumsMono < FRETMono
fsumsMono = FRETMono;
end
end;
end;
cd (homedirectory);
fclose( fin );
if( accepted > 0 )
if( yfptype == 1 || frettype == 1 )
fprintf( 1, 'Average YFP signal to background = %5.2f\n', ysums2b / accepted );
fprintf( 1, 'Average YFP signal width at half max = %5.2f pixels\n', ysumfocus / accepted );
fprintf( 1, 'YFP monotocity tolerance minimum to pass= %5.2f\n', ysumsMono );
end;
fprintf( 1, 'Average FRET signal to background = %5.2f\n', fsums2b / accepted );
fprintf( 1, 'Average FRET signal width at half max = %5.2f pixels\n', fsumfocus / accepted );
fprintf( 1, 'FRET monotocity tolerance minimum to pass= %5.2f\n', fsumsMono);
if( cfptype == 1 || frettype == 1 )
fprintf( 1, 'Average CFP signal to background = %5.2f\n', csums2b / accepted );
fprintf( 1, 'Average CFP signal width at half max = %5.2f pixels\n', csumfocus / accepted );
fprintf( 1, 'CFP monotocity tolerance minimum to pass = %5.2f\n', csumsMono);
end;
end;