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.

cull_callback2
function cull_callback2
%Version 4/3/09
%Gets called by cull_callback when the user hits the start culling button.
%Does all the work of setting up the new variables for the culling.
%Performs the culling, displaying the results in the progress bar.

global CFPspill YFPspill primary
global frettype cfptype yfptype culldone inspectdone finaldone
global initialfile culledfile inspectedfile finalfile
global culls inspects finals toprocess accepted culled
global inputdirectory outputdirectory dirsep
global string1 string2 progbarcol limit2
global YFPFWHMcull FRETFWHMcull CFPFWHMcull YFPmonocull FRETmonocull CFPmonocull YFPs2bcull FRETs2bcull CFPs2bcull
culled = 1;
dir = strcat( inputdirectory, dirsep, outputdirectory );
finalfile = 'final.txt';
accepted = 0;
reject = 0;
culls = 0;
fin = fopen( strcat( dir, dirsep, initialfile ), 'r' );
toprocess = 0;
while( feof( fin ) ~= 1 )
    linearray{ toprocess + 1 } = fgetl( fin );
    toprocess = toprocess + 1;
end;
fprintf( 1, '\nInitial file has %d records\n', toprocess-2 );
fseek( fin, 0, -1 );   % rewind
line1 = fgetl( fin );  %%// skip first header line
line2 = fgetl( fin );  %%// skip second header line
processed = 2;
fout = fopen( strcat( dir, dirsep, culledfile ), 'w' );
fprintf( fout, '%s\n', line1 );
fwriteline2cull( fout );
while( processed < toprocess )
    [ j1, count ] = fscanf( fin, '%s', 1 );
    if( count > 0 )
        [ j2, count ]  = fscanf( fin, '%s %s %s %d ', 4 );
        [ yfpsig,  count ] = fscanf( fin, '%f', 1 );
        [ yfpbak,  count ] = fscanf( fin, '%f', 1 );
        [ fretsig, count ] = fscanf( fin, '%f', 1 );
        [ fretbak, count ] = fscanf( fin, '%f', 1 );
        [ cfpsig,  count ] = fscanf( fin, '%f', 1 );
        [ cfpbak,  count ] = fscanf( fin, '%f', 1 );
        adjustYFPrc  = yfpsig  - yfpbak;
        adjustFRETrc = fretsig - fretbak;
        adjustCFPrc  = cfpsig  - cfpbak;
        den        = YFPspill * adjustYFPrc + CFPspill * adjustCFPrc;
        fretrc     = adjustFRETrc / den;
        [ 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 );
        if limit2 == 0
            if( frettype == 1 )
                if( cfps2b >= CFPs2bcull )
                    if( yfps2b >= YFPs2bcull )
                        if( frets2b >= FRETs2bcull )
                            if( CFPMono <= CFPmonocull )
                                if( YFPMono <= YFPmonocull )
                                    if( FRETMono <= FRETmonocull )
                                        if( cfpfocus <= CFPFWHMcull )
                                            if( yfpfocus <= YFPFWHMcull )
                                                if( fretfocus <= FRETFWHMcull )
                                                    accepted = accepted + 1;
                                                    fprintf( fout, '%s\n', linearray{ processed+1 } );
                                                    culls = culls + 1;
                                                end;
                                            end;
                                        end;
                                    end;
                                end;
                            end;
                        end;
                    end;
                end;
            elseif( cfptype == 1 )
                if( cfps2b >= CFPs2bcull )
                    if( frets2b >= FRETs2bcull )
                        if( CFPMono <= CFPmonocull )
                            if( FRETMono <= FRETmonocull )
                                if( cfpfocus <= CFPFWHMcull )
                                    if( fretfocus <= FRETFWHMcull )
                                        accepted = accepted + 1;
                                        fprintf( fout, '%s\n', linearray{ processed+1 } );
                                        culls = culls + 1;
                                    end;
                                end;
                            end;
                        end;
                    end;
                end;
            elseif( yfptype == 1 )
                if( yfps2b >= YFPs2bcull )
                    if( frets2b >= FRETs2bcull )
                        if( YFPMono <= YFPmonocull )
                            if( FRETMono <= FRETmonocull )
                                if( yfpfocus <= YFPFWHMcull )
                                    if( fretfocus <= FRETFWHMcull )
                                        accepted = accepted + 1;
                                        fprintf( fout, '%s\n', linearray{ processed+1 } );
                                        culls = culls + 1;
                                    end;
                                end;
                            end;
                        end;
                    end;
                end;
            else
                fprintf( 1, 'problem with type\n' );
            end;
        else
            if primary == 1                
                if yfps2b >= YFPs2bcull                                        
                    if YFPMono <= YFPmonocull                 
                        if yfpfocus <= YFPFWHMcull                      
                            accepted = accepted + 1;
                            fprintf( fout, '%s\n', linearray{ processed+1 } );
                            culls = culls + 1;
                        end;
                    end;
                end;
            elseif primary == 2
                if frets2b >= FRETs2bcull
                    if FRETMono <= FRETmonocull
                        if fretfocus <= FRETFWHMcull 
                            accepted = accepted + 1;
                            fprintf( fout, '%s\n', linearray{ processed+1 } );
                            culls = culls + 1;
                        end;
                    end;
                end;
            elseif primary == 3
                if cfps2b >= CFPs2bcull 
                    if CFPMono <= CFPmonocull 
                        if cfpfocus <= CFPFWHMcull
                            accepted = accepted + 1;
                            fprintf( fout, '%s\n', linearray{ processed+1 } );
                            culls = culls + 1;
                        end;
                    end;
                end;
            else
                fprintf( 1, 'problem with type\n' );
            end;
        end
    else
        break;
    end;
    processed = processed + 1;
end; % all lines in jmp.txt
fclose( fin );
fclose( fout );
string1 = sprintf( '%s%s%s%s%s', inputdirectory, dirsep, outputdirectory, dirsep, culledfile );
string2 = sprintf( '%s%s%s%s%s', inputdirectory, dirsep, outputdirectory, dirsep, inspectedfile );
copyfile( string1, string2 );
string2 = sprintf( '%s%s%s%s%s', inputdirectory, dirsep, outputdirectory, dirsep, finalfile );
copyfile( string1, string2 );
culls = accepted;
fprintf( 1, 'culled AOIs = %d\n', culls );
progbarcol = 'white';
culldone = 1; % update with rewritten files
inspectdone = 0; finaldone = 0 ;
%inspects = 0; finals = 0;
summarystats( finalfile );


Contact us