Code covered by the BSD License  

Highlights from
FRETSCAL

image thumbnail

FRETSCAL

by

 

For the FRET analysis of images of yeast cells labeled with YFP and CFP.

walkthru_callback
function walkthru_callback
%Version 4/3/09
%Function opens up culled.txt, goes through and sends it to guts, writes out inspected.txt during the walk through
%Gets called by Fretscal>Inspection>Walkthrough AOIs
global  toprocess accepted rejected
global AOIshape 
global filenamebase inspectdone finaldone
global culledfile inspectedfile finalfile inspectionfile 
global quest_ans  
global inputdirectory outputdirectory dirsep homedirectory  

dir = strcat( inputdirectory, dirsep, outputdirectory );

rindex = (AOIshape - 1)/2;
%   if( AOIshape == 1 )
%     rindex = 0;
%   elseif( AOIshape == 3 )
%     rindex = 1;
%   elseif(AOIshape == 5)
%     rindex = 2;
%   elseif(AOIshape == 7)
%     rindex = 3;
%   elseif(AOIshape == 9)
%     rindex = 4;
%   elseif(AOIshape == 11)
%     rindex = 5;
%   elseif(AOIshape == 13)
%     rindex = 6;
%   elseif(AOIshape == 15)
%     rindex = 7;
%   elseif(AOIshape == 17)
%     rindex = 8;    
%   elseif(AOIshape == 19)
%     rindex = 9;
%   elseif(AOIshape == 21)
%     rindex = 10;
%   elseif(AOIshape == 25)
%     rindex = 12;
%   elseif(AOIshape == 37)
%     rindex = 18;
%   elseif(AOIshape == 49)
%     rindex = 24;
%   elseif(AOIshape == 75)
%     rindex = 37;
%   elseif(AOIshape == 99)
%     rindex = 49;
%   elseif (AOIshape) == 149
%     rindex = 74;
%   end;
  accepted = 0;
  rejected = 0;
  fin = fopen( strcat( dir, dirsep, culledfile ), 'r' );
  %strcat( dir, dirsep, culledfile );
  toprocess = 0;
  while( feof( fin ) ~= 1 )
    linearray{ toprocess+1 } = fgetl( fin );
    toprocess = toprocess + 1;
  end; 
  toprocess = toprocess - 2; % subtract two header lines
  fprintf( 1, 'Culled file has %d records to process\n', toprocess );
  fseek( fin, 0, -1 );   % rewind
  line1 = fgetl( fin );  % first header line will be copied into inspectedfile
  line2 = fgetl( fin );  %% skip second header line
  processed = 0;
  fout = fopen( strcat( dir, dirsep, inspectedfile ), 'w' );
  fprintf( fout, '%s\n', line1 );
  fwriteline2cull( fout ); % writes the second header line
  while( processed < toprocess )
    [ filenamebase, count ] = fscanf( fin, '%s', 1 );
    if( count > 0 )
      [ yfpfocus, yfps2b, fretfocus, frets2b, cfpfocus, cfps2b ] = walkthru_guts( fin, processed, rindex );
      if( quest_ans >= 0 )
        if( quest_ans == 1 )
          accepted = accepted + 1;
          fprintf( fout, '%s\n', linearray{ processed+3 } );
        else
          rejected = rejected + 1;
          fprintf( 1, 'discarded %s\n', inspectionfile );
        end;
      else
        processed = 100000;   % just something to end the loop when quit
      end;
    end;
    processed = processed + 1;
  end; % all lines in culled.txt
  fclose( fin );
  fclose( fout );
  inspectdone = 1;
  finaldone = 0;
  string1 = sprintf( '%s%s%s%s%s', inputdirectory, dirsep, outputdirectory, dirsep, inspectedfile );
  string2 = sprintf( '%s%s%s%s%s', inputdirectory, dirsep, outputdirectory, dirsep, 'final.txt' );
  copyfile( string1, string2 );
  finalfile = 'final.txt';
  fprintf( 1, 'AOIs to process = %d, accepted AOIs = %d\n', toprocess, accepted );
  cd(homedirectory);
  summarystats( inspectedfile );

Contact us