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.

fsearch2_callback
function fsearch2_callback
%Version 4/3/09
%Assembles the variables and makes the command call to fret.m. After the AOIs are found it writes out the output files, and
%then it runs fupdate to update the black progress bar.

%close(gcf); 
%pause(.1);% helps close the Search window. Needs the pause or it will not close till after the computation.
global primary AOIshape maximumpeaks intensitylimit separation bringincr bringthick context toobright spotthreshold maxmovement
global strainname CFPspill CFPtagname YFPspill YFPtagname yfptype cfptype frettype
global initialdone culldone inspectdone finaldone culled
global initialfile culledfile inspectedfile finalfile
global sourcedirectory startdirectory inputdirectory outputdirectory 
global YFPFWHM FRETFWHM CFPFWHM YFPmono FRETmono CFPmono YFPs2b FRETs2b CFPs2b
global YFPFWHMcull FRETFWHMcull CFPFWHMcull YFPmonocull FRETmonocull CFPmonocull YFPs2bcull FRETs2bcull CFPs2bcull
global bitdepth Ysuffix Fsuffix Csuffix Dsuffix  bpfilter patchpixel
global error FileDirKnown dirsep progbarcol limit1 limit2

t = clock;
spotthreshold = 700; %originally put in for testing of patch pixel,but no longer used. Variable was left in code for easy creation of future flag.
fprintf( 1, 'sourcedirectory = %s\n', sourcedirectory );
fprintf( 1, 'startdirectory  = %s\n', startdirectory );
fprintf( 1, 'inputdirectory  = %s\n', inputdirectory );
fprintf( 1, 'outputdirectory = %s\n', outputdirectory );
finalfile = 'final.txt';

if yfptype == 1
    type = 'Y';
elseif cfptype == 1
    type = 'C';
elseif frettype == 1
    type = 'F';
end
cd( inputdirectory );
%    if( status == 1 )
command = sprintf( 'fret -f ''%s'' -Ys %5.3f -Cs %5.3f -dir %s -S %s -D %s -A %s -bi %d -bt %d -p %d -Yd %5.2f -Ym %5.2f -Yn %5.2f -Cd %5.2f -Cm %5.2f -Cn %5.2f -Fd %5.2f -Fm %5.2f -Fn %5.2f -s %d -li %5.2f -dots %d -P %d -c %d -T %5.2f -t %5.2f -bd %d -Yx %s -Fx %s -Cx %s -X %s -bp %d -bn %d -m %d -E %s -ls %d -lc %d',...
    strtrim(inputdirectory), YFPspill, CFPspill, strtrim(outputdirectory), strtrim(strainname), strtrim(CFPtagname), strtrim(YFPtagname), ...
    bringincr,bringthick,AOIshape,YFPFWHM,YFPmono,YFPs2b,CFPFWHM,CFPmono,CFPs2b,...
    FRETFWHM,FRETmono,FRETs2b ,separation, intensitylimit, maximumpeaks, primary, context, toobright, spotthreshold, bitdepth, strtrim(Ysuffix), strtrim(Fsuffix), strtrim(Csuffix), strtrim(Dsuffix),bpfilter,patchpixel,maxmovement,type,limit1,limit2);
fprintf( '%s\n', command );
try
    eval( command );
catch
    cd (sourcedirectory);
    rethrow(lasterror);
end;
if( error == 0 && FileDirKnown == 1 )
 %   cd( outputdirectory );%being in this directory really slowed down copyfile
    fprintf( 1, '\nCreating  4 output files......\n' );
    jmpfile = strcat( inputdirectory,dirsep,outputdirectory, dirsep, 'jmp.txt');
    initfile = strcat( inputdirectory,dirsep,outputdirectory, dirsep, 'initial.txt');
    cfile = strcat( inputdirectory,dirsep,outputdirectory, dirsep, 'culled.txt');
    ifile = strcat( inputdirectory,dirsep,outputdirectory, dirsep, 'inspected.txt');
    ffile = strcat( inputdirectory,dirsep,outputdirectory, dirsep, 'final.txt');
    %Matlab is very slow at overwriting a pre-existing file, so first
    %delete and then copy if the file is already there
if exist( initfile ,'file' ) == 1
    delete( initfile);
end
if exist( cfile ,'file' ) == 1
    delete( cfile);
end
if exist( ifile ,'file' ) == 1
    delete( ifile);
end
if exist( ffile ,'file' ) == 1
    delete( ffile);
end
[ status,message,messageid ] = copyfile(jmpfile,initfile);    
     if( status ~= 1 )
         fprintf( 1,'Couldn''t copy jmp.txt file to %s. %s,%s\n',initialfile,message,messageid );
     end;
  [ status,message,messageid ] =  copyfile( jmpfile,cfile );
     if( status ~= 1 )
         fprintf( 1,'Couldn''t copy jmp.txt file to %s. %s,%s\n',culledfile,message,messageid );
     end;
 [ status,message,messageid ] = copyfile( jmpfile,ifile );   
     if( status ~= 1 )
         fprintf( 1,'Couldn''t copy jmp.txt file to %s. %s,%s\n',inspectedfile,message,messageid );
     end; 
  [ status,message,messageid ] = copyfile( jmpfile,ffile );  
     if( status ~= 1 )
         fprintf( 1,'Couldn''t copy jmp.txt file to %s. %s,%s\n',finalfile,message,messageid );
     end;
    fprintf( 1, '\nComputing summary statistics for %s\n', initialfile );
    summarystats( initialfile );
    initialdone = 1; culldone = 0; inspectdone = 0; finaldone = 0;
    cd( startdirectory );
    if YFPFWHMcull > YFPFWHM
        YFPFWHMcull = YFPFWHM;
    end
    if FRETFWHMcull > FRETFWHM
        FRETFWHMcull = FRETFWHM;
    end
    if CFPFWHMcull > CFPFWHM
        CFPFWHMcull = CFPFWHM;
    end
    if YFPmonocull > YFPmono      
        YFPmonocull = YFPmono;
    end
    if FRETmonocull > FRETmono
        FRETmonocull = FRETmono;
    end
    if  CFPmonocull >  CFPmono
        CFPmonocull = CFPmono;
    end
    if YFPs2bcull < YFPs2b
        YFPs2bcull = YFPs2b;
    end
    if FRETs2bcull < FRETs2b
        FRETs2bcull = FRETs2b;
    end
    if CFPs2bcull < CFPs2b
   CFPs2bcull = CFPs2b;
    end
    if YFPFWHMcull ~= YFPFWHM || FRETFWHMcull ~= FRETFWHM ||YFPmonocull ~= YFPmono || ...
            FRETmonocull ~= FRETmono || YFPs2bcull ~= YFPs2b || FRETs2bcull ~= FRETs2b ||...
            CFPFWHMcull ~= CFPFWHM || CFPmonocull ~= CFPmono || CFPs2bcull ~= CFPs2b||...
            (limit1 == 1 && limit2 == 0)
        progbarcol = 'yellow';
    else 
        progbarcol = 'white';
    end  
    culled = 0;
    fupdate;
    fprintf(1,'%f minutes have elapsed since the start of the search.\n',(etime(clock,t))/60);
end

Contact us