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.

getculllimits
function getculllimits
%Version 4/3/09 Loads the window where one inputs the limits for culling
%after one has run a search.
global bigincr smlincr fontpics darkgreen AOIshape bringincr
global slider1 slider2 slider3 slider4 slider5 slider6 slider7 slider8 slider9
global sliderw valuew labelw primary limit2
global start1 start2 start3 start4 start5 start6 start7 start8 start9
global string1c string2c string3c string4c string5c string6c string7c string8c string9c
global txt1 txt2 txt3 txt4 txt5 txt6 txt7 txt8 txt9 h_getlimits
global YFPFWHM CFPFWHM FRETFWHM YFPmono FRETmono CFPmono YFPs2b CFPs2b FRETs2b
global YFPFWHMcull FRETFWHMcull CFPFWHMcull YFPmonocull FRETmonocull CFPmonocull YFPs2bcull FRETs2bcull CFPs2bcull


x = .1; y = .5; w = .8; h = .3; spacing = .048;
sliderw = w/2;
valuew  = w/10;
labelw  = 4*w/10;
bigincr = zeros(1,9);

smin(1)= YFPs2b;smax(1)=10.0;start1=YFPs2bcull;
smin(4)= FRETs2b;smax(4)=10.0;start4=FRETs2bcull; 
smin(7)= CFPs2b;smax(7)=10.0;start7=CFPs2bcull;  
smin(2)= -.5;smax(2)=YFPmono;start2=YFPmonocull;  
smin(5)= -.5;smax(5)=FRETmono;start5=FRETmonocull; 
smin(8)= -.5;smax(8)=CFPmono;start8=CFPmonocull; 
smin(3)= 1.0;smax(3)=YFPFWHM;start3=YFPFWHMcull;
smin(6)= 1.0;smax(6)=FRETFWHM;start6=FRETFWHMcull;
smin(9)= 1.0;smax(9)=CFPFWHM;start9=CFPFWHMcull; 

string1c = sprintf( 'YFP  signal to background  [%5.2f,%5.2f]', smin( 1 ), smax( 1 ) );
string4c = sprintf( 'FRET signal to background  [%5.2f,%5.2f]', smin( 4 ), smax( 4 ) );
string7c = sprintf( 'CFP  signal to background  [%5.2f,%5.2f]', smin( 7 ), smax( 7 ) );
string2c = sprintf( 'YFP  monotonicity tolerance [%5.2f,%5.2f]', smin( 2 ), smax( 2 ) );
string5c = sprintf( 'FRET monotonicity tolerance [%5.2f,%5.2f]', smin( 5 ), smax( 5 ) );
string8c = sprintf( 'CFP  monotonicity tolerance [%5.2f,%5.2f]', smin( 8 ), smax( 8 ) );
string3c = sprintf( 'YFP  signal''s full width at half max [%5.2f,%5.2f]', smin( 3 ), smax( 3 ) );
string6c = sprintf( 'FRET signal''s full width at half max  [%5.2f,%5.2f]', smin( 6 ), smax( 6 ) );
string9c = sprintf( 'CFP  signal''s full width at half max  [%5.2f,%5.2f]', smin( 9 ), smax( 9 ) );

for i = 1:9
    if smin(i)== smax(i)
        bigincr(i)= 0;
        smlincr(i)=0;
        fprintf(1, 'Can not cull when search limits are at maximum stringency');
    else
        bigincr(i)=.1/(smax(i)-smin(i));smlincr(i)=.01/(smax(i)-smin(i));
    end
end
%change start positions if not within the limits
if YFPs2b > YFPs2bcull
    start1 = YFPs2b;
end
if FRETs2b > FRETs2bcull
    start2 = FRETs2b;
end
if CFPs2b > CFPs2bcull
    start3 = CFPs2b;
end
if YFPmono < YFPmonocull
    start4 = YFPmono;
end
if FRETmono < FRETmonocull
    start5 = FRETmono;
end
if CFPmono < CFPmonocull
    start6 = CFPmono;
end

if YFPFWHM > AOIshape + bringincr
    start7 = AOIshape + bringincr;
end
if YFPFWHM < YFPFWHMcull
    start7 = YFPFWHM;
end
if FRETFWHM > AOIshape + bringincr
    start8 = AOIshape + bringincr;
end
if FRETFWHM < FRETFWHMcull
    start8 = FRETFWHM;
end
if CFPFWHM > AOIshape + bringincr
    start9 = AOIshape + bringincr;
end
if CFPFWHM < CFPFWHMcull
    start9 = CFPFWHM;
end
if CFPFWHMcull > AOIshape + bringincr
    CFPFWHMcull = AOIshape + bringincr;
end
if YFPFWHMcull > AOIshape + bringincr
    YFPFWHMcull = AOIshape + bringincr;
end
if FRETFWHMcull > AOIshape + bringincr
    FRETFWHMcull = AOIshape + bringincr;
end
if FRETFWHMcull < 1
    FRETFWHMcull = 1;
end
if CFPFWHMcull < 1
    CFPFWHMcull = 1;
end
if YFPFWHMcull < 1
    YFPFWHMcull = 1;
end
    


h_getlimits.fig = figure('Color', darkgreen, 'units','normalized','name','Culling Parameters','ToolBar','none','NumberTitle','off','menubar','none','position',[ .1 .4 .8 .5 ], 'name', 'Culling Limits' );
uicontrol( 'units', 'normalized', 'style', 'text', 'string', 'Culling limits', 'position',[ .35 .85 .3 .1 ], 'background','black','fore','white','fontsize', fontpics );

i = 1;
txt1    = uicontrol(h_getlimits.fig, 'style','text','string',sprintf('%4.2f',start1 ), ...
    'background','white','units','normalized', 'position', [ x+sliderw y+h-i*spacing valuew spacing ], 'fontsize', fontpics );
name1   = uicontrol(h_getlimits.fig, 'style','text','string',string1c, 'HorizontalAlignment', 'left', ...
    'background','white','units','normalized', 'position', [ x+sliderw+valuew y+h-i*spacing  labelw spacing ], 'fontsize', fontpics );
slider1 = uicontrol(h_getlimits.fig, 'style','slider','units','normalized','background','white', ...
    'position', [ x y+h-i*spacing sliderw spacing ], 'min',smin(i),'max',smax(i),'value',start1, ...
    'sliderstep',[  smlincr(i), bigincr(i) ],'userdata',txt1, 'callback',{@getlimits_callback, slider1, i }, 'fontsize', fontpics );
i = 2;
txt2    = uicontrol(h_getlimits.fig, 'style','text','string',sprintf('%4.2f',start2 ), ...
    'background','white','units','normalized', 'position', [ x+sliderw y+h-i*spacing valuew spacing ], 'fontsize', fontpics );
name2   = uicontrol(h_getlimits.fig, 'style','text','string',string2c, 'HorizontalAlignment', 'left', ...
    'background','white','units','normalized', 'position', [ x+sliderw+valuew y+h-i*spacing  labelw spacing ], 'fontsize', fontpics );
slider2 = uicontrol(h_getlimits.fig, 'style','slider','units','normalized','background','white', ...
    'position', [ x y+h-i*spacing sliderw spacing ], 'min',smin(i),'max',smax(i),'value',start2, ...
    'sliderstep',[  smlincr(i), bigincr(i) ],'userdata',txt2, 'callback',{@getlimits_callback, slider2, i }, 'fontsize', fontpics );
i = 3;
txt3    = uicontrol(h_getlimits.fig, 'style','text','string',sprintf('%4.2f',start3 ), ...
    'background','white','units','normalized', 'position', [ x+sliderw y+h-i*spacing valuew spacing ], 'fontsize', fontpics );
name3   = uicontrol(h_getlimits.fig, 'style','text','string',string3c, 'HorizontalAlignment', 'left', ...
    'background','white','units','normalized', 'position', [ x+sliderw+valuew y+h-i*spacing  labelw spacing ], 'fontsize', fontpics );
slider3 = uicontrol(h_getlimits.fig, 'style','slider','units','normalized','background','white', ...
    'position', [ x y+h-i*spacing sliderw spacing ], 'min',smin(i),'max',smax(i),'value',start3, ...
    'sliderstep',[  smlincr(i), bigincr(i) ],'userdata',txt3, 'callback',{@getlimits_callback, slider3, i }, 'fontsize', fontpics );
i = 4;
txt4    = uicontrol(h_getlimits.fig, 'style','text','string',sprintf('%4.2f',start4 ), ...
    'background','white','units','normalized', 'position', [ x+sliderw y+h-i*spacing valuew spacing ], 'fontsize', fontpics );
name4   = uicontrol(h_getlimits.fig, 'style','text','string',string4c, 'HorizontalAlignment', 'left', ...
    'background','white','units','normalized', 'position', [ x+sliderw+valuew y+h-i*spacing  labelw spacing ], 'fontsize', fontpics );
slider4 = uicontrol(h_getlimits.fig, 'style','slider','units','normalized','background','white', ...
    'position', [ x y+h-i*spacing sliderw spacing ], 'min',smin(i),'max',smax(i),'value',start4, ...
    'sliderstep',[  smlincr(i), bigincr(i) ],'userdata',txt4, 'callback',{@getlimits_callback, slider4, i }, 'fontsize', fontpics );
i = 5;
txt5    = uicontrol(h_getlimits.fig, 'style','text','string',sprintf('%4.2f',start5 ), ...
    'background','white','units','normalized', 'position', [ x+sliderw y+h-i*spacing valuew spacing ], 'fontsize', fontpics );
name5   = uicontrol(h_getlimits.fig, 'style','text','string',string5c, 'HorizontalAlignment', 'left', ...
    'background','white','units','normalized', 'position', [ x+sliderw+valuew y+h-i*spacing  labelw spacing ], 'fontsize', fontpics );
slider5 = uicontrol(h_getlimits.fig, 'style','slider','units','normalized','background','white', ...
    'position', [ x y+h-i*spacing sliderw spacing ], 'min',smin(i),'max',smax(i),'value',start5, ...
    'sliderstep',[  smlincr(i), bigincr(i) ],'userdata',txt5, 'callback',{@getlimits_callback, slider5, i }, 'fontsize', fontpics );
i = 6;
txt6    = uicontrol(h_getlimits.fig, 'style','text','string',sprintf('%4.2f',start6 ), ...
    'background','white','units','normalized', 'position', [ x+sliderw y+h-i*spacing valuew spacing ], 'fontsize', fontpics );
name6   = uicontrol(h_getlimits.fig, 'style','text','string',string6c, 'HorizontalAlignment', 'left', ...
    'background','white','units','normalized', 'position', [ x+sliderw+valuew y+h-i*spacing  labelw spacing ], 'fontsize', fontpics );
slider6 = uicontrol(h_getlimits.fig, 'style','slider','units','normalized','background','white', ...
    'position', [ x y+h-i*spacing sliderw spacing ], 'min',smin(i),'max',smax(i),'value',start6, ...
    'sliderstep',[  smlincr(i), bigincr(i) ],'userdata',txt6, 'callback',{@getlimits_callback, slider6, i }, 'fontsize', fontpics );
i = 7;
txt7    = uicontrol(h_getlimits.fig, 'style','text','string',sprintf('%4.2f',start7 ), ...
    'background','white','units','normalized', 'position', [ x+sliderw y+h-i*spacing valuew spacing ], 'fontsize', fontpics );
name7   = uicontrol(h_getlimits.fig, 'style','text','string',string7c, 'HorizontalAlignment', 'left', ...
    'background','white','units','normalized', 'position', [ x+sliderw+valuew y+h-i*spacing  labelw spacing ], 'fontsize', fontpics );
slider7 = uicontrol(h_getlimits.fig, 'style','slider','units','normalized','background','white', ...
    'position', [ x y+h-i*spacing sliderw spacing ], 'min',smin(i),'max',smax(i),'value',start7, ...
    'sliderstep',[  smlincr(i), bigincr(i) ],'userdata',txt7, 'callback',{@getlimits_callback, slider7, i }, 'fontsize', fontpics );
i = 8;
txt8    = uicontrol(h_getlimits.fig, 'style','text','string',sprintf('%4.2f',start8 ), ...
    'background','white','units','normalized', 'position', [ x+sliderw y+h-i*spacing valuew spacing ], 'fontsize', fontpics );
name8   = uicontrol(h_getlimits.fig, 'style','text','string',string8c, 'HorizontalAlignment', 'left', ...
    'background','white','units','normalized', 'position', [ x+sliderw+valuew y+h-i*spacing  labelw spacing ], 'fontsize', fontpics );
slider8 = uicontrol(h_getlimits.fig, 'style','slider','units','normalized','background','white', ...
    'position', [ x y+h-i*spacing sliderw spacing ], 'min',smin(i),'max',smax(i),'value',start8, ...
    'sliderstep',[  smlincr(i), bigincr(i) ],'userdata',txt8, 'callback',{@getlimits_callback, slider8, i }, 'fontsize', fontpics );
i = 9;
txt9    = uicontrol(h_getlimits.fig, 'style','text','string',sprintf('%4.2f',start9 ), ...
    'background','white','units','normalized', 'position', [ x+sliderw y+h-i*spacing valuew spacing ], 'fontsize', fontpics );
name9   = uicontrol(h_getlimits.fig, 'style','text','string',string9c, 'HorizontalAlignment', 'left', ...
    'background','white','units','normalized', 'position', [ x+sliderw+valuew y+h-i*spacing  labelw spacing ], 'fontsize', fontpics );
slider9 = uicontrol(h_getlimits.fig, 'style','slider','units','normalized','background','white', ...
    'position', [ x y+h-i*spacing sliderw spacing ], 'min',smin(i),'max',smax(i),'value',start9, ...
    'sliderstep',[  smlincr(i), bigincr(i) ],'userdata',txt9, 'callback',{@getlimits_callback, slider9, i }, 'fontsize', fontpics );

if primary == 1
    primarys = 'YFP';
elseif primary == 2
    primarys = 'FRET';
elseif primary == 3
    primarys = 'CFP';
end
limitstring = sprintf('Apply cull ONLY on primary, %s, channel. Ignore other channel settings.',primarys);
h_limit2.u0 = uicontrol( 'units', 'normalized', 'style', 'radiobutton', 'string', limitstring, ...
            'position', [ 2.25/10 .25 5.5/10 1/12 ], 'background','red','fore','white','fontsize', fontpics ); 
h_limit2.u1 = uicontrol( 'units', 'normalized', 'style', 'radiobutton', 'string', 'Apply cull on ALL channels.', ...
            'position', [ 2.25/10 .15 5.5/10 1/12 ], 'background','red','fore','white','fontsize', fontpics );

set( h_limit2.u0, 'callback', {@limit2_callback, h_limit2, 1 } );
set( h_limit2.u1, 'callback', {@limit2_callback, h_limit2, 2 } );
if limit2 == 1
    set(h_limit2.u0,'value',1);
    set(h_limit2.u1,'value',0);    
elseif limit2 == 0
    set(h_limit2.u0,'value',0);
    set(h_limit2.u1,'value',1); 
end

uicontrol( 'style','pushbutton', 'units', 'normalized',  'string','Done',...
    'position',[ .45 .02 .1 .1], 'callback','close(gcf);fupdate','fontsize', fontpics);
end


function getlimits_callback( gcf, eventdata, handles, index )

global initialdone culldone inspectdone finaldone fontpics
global slider1 slider2 slider3 slider4 slider5 slider6 slider7 slider8 slider9
global sliderw valuew labelw progbarcol
global start1 start2 start3 start4 start5 start6 start7 start8 start9
global string1c string2c string3c string4c string5c string6c string7c string8c string9c
global txt1 txt2 txt3 txt4 txt5 txt6 txt7 txt8 txt9 h_getlimits
global YFPFWHM FRETFWHM CFPFWHM YFPmono FRETmono CFPmono YFPs2b FRETs2b CFPs2b
global YFPFWHMcull FRETFWHMcull CFPFWHMcull YFPmonocull FRETmonocull CFPmonocull YFPs2bcull FRETs2bcull CFPs2bcull

x = .1; y = .5; w = .8; h = .3; spacing = .048;
if strcmp(progbarcol,'white') == 1
    progbarcol = 'yellow';
end
start1 = get(slider1,'value');
start1 = (round(start1*100))/100;
start2 = get(slider2,'value');
start2 = (round(start2*100))/100;
start3 = get(slider3,'value');
start3 = (round(start3*100))/100;
start4 = get(slider4,'value');
start4 = (round(start4*100))/100;
start5 = get(slider5,'value');
start5 = (round(start5*100))/100;
start6 = get(slider6,'value');
start6 = (round(start6*100))/100;
start7 = get(slider7,'value');
start7 = (round(start7*100))/100;
start8 = get(slider8,'value');
start8 = (round(start8*100))/100;
start9 = get(slider9,'value');
start9 = (round(start9*100))/100;

switch index
    case 1
        txt1  = uicontrol(h_getlimits.fig, 'style','text','string',sprintf('%4.2f',start1 ), ...
            'background','white','units','normalized', 'position', [ x+sliderw y+h-index*spacing   valuew spacing ], 'fontsize', fontpics );
        name1 = uicontrol(h_getlimits.fig, 'style','text','string',string1c, 'HorizontalAlignment', 'left', ...
            'background','white','units','normalized', 'position', [ x+sliderw+valuew y+h-index*spacing  labelw spacing ] , 'fontsize', fontpics);
    case 2
        txt2  = uicontrol(h_getlimits.fig, 'style','text','string',sprintf('%4.2f',start2 ), ...
            'background','white','units','normalized', 'position', [ x+sliderw y+h-index*spacing   valuew spacing ], 'fontsize', fontpics );
        name2 = uicontrol(h_getlimits.fig, 'style','text','string',string2c, 'HorizontalAlignment', 'left', ...
            'background','white','units','normalized', 'position', [ x+sliderw+valuew y+h-index*spacing  labelw spacing ], 'fontsize', fontpics );  
    case 3
        txt3  = uicontrol(h_getlimits.fig, 'style','text','string',sprintf('%4.2f',start3 ), ...
            'background','white','units','normalized', 'position', [ x+sliderw y+h-index*spacing   valuew spacing ], 'fontsize', fontpics );
        name3 = uicontrol(h_getlimits.fig, 'style','text','string',string3c, 'HorizontalAlignment', 'left', ...
            'background','white','units','normalized', 'position', [ x+sliderw+valuew y+h-index*spacing  labelw spacing ] , 'fontsize', fontpics);
    case 4
        txt4  = uicontrol(h_getlimits.fig, 'style','text','string',sprintf('%4.2f',start4 ), ...
            'background','white','units','normalized', 'position', [ x+sliderw y+h-index*spacing   valuew spacing ], 'fontsize', fontpics );
        name4 = uicontrol(h_getlimits.fig, 'style','text','string',string4c, 'HorizontalAlignment', 'left', ...
            'background','white','units','normalized', 'position', [ x+sliderw+valuew y+h-index*spacing  labelw spacing ] , 'fontsize', fontpics);
    case 5
        txt5  = uicontrol(h_getlimits.fig, 'style','text','string',sprintf('%4.2f',start5 ), ...
            'background','white','units','normalized', 'position', [ x+sliderw y+h-index*spacing   valuew spacing ], 'fontsize', fontpics );
        name5 = uicontrol(h_getlimits.fig, 'style','text','string',string5c, 'HorizontalAlignment', 'left', ...
            'background','white','units','normalized', 'position', [ x+sliderw+valuew y+h-index*spacing  labelw spacing ] , 'fontsize', fontpics);  
    case 6
        txt6  = uicontrol(h_getlimits.fig, 'style','text','string',sprintf('%4.2f',start6 ), ...
            'background','white','units','normalized', 'position', [ x+sliderw y+h-index*spacing   valuew spacing ], 'fontsize', fontpics );
        name6 = uicontrol(h_getlimits.fig, 'style','text','string',string6c, 'HorizontalAlignment', 'left', ...
            'background','white','units','normalized', 'position', [ x+sliderw+valuew y+h-index*spacing  labelw spacing ] , 'fontsize', fontpics);
    case 7
        txt7  = uicontrol(h_getlimits.fig, 'style','text','string',sprintf('%4.2f',start7 ), ...
            'background','white','units','normalized', 'position', [ x+sliderw y+h-index*spacing   valuew spacing ], 'fontsize', fontpics );
        name7 = uicontrol(h_getlimits.fig, 'style','text','string',string7c, 'HorizontalAlignment', 'left', ...
            'background','white','units','normalized', 'position', [ x+sliderw+valuew y+h-index*spacing  labelw spacing ] , 'fontsize', fontpics);
        case 8
        txt8  = uicontrol(h_getlimits.fig, 'style','text','string',sprintf('%4.2f',start8 ), ...
            'background','white','units','normalized', 'position', [ x+sliderw y+h-index*spacing   valuew spacing ], 'fontsize', fontpics );
        name8 = uicontrol(h_getlimits.fig, 'style','text','string',string8c, 'HorizontalAlignment', 'left', ...
            'background','white','units','normalized', 'position', [ x+sliderw+valuew y+h-index*spacing  labelw spacing ], 'fontsize', fontpics );
    case 9
        txt9  = uicontrol(h_getlimits.fig, 'style','text','string',sprintf('%4.2f',start9 ), ...
            'background','white','units','normalized', 'position', [ x+sliderw y+h-index*spacing   valuew spacing ], 'fontsize', fontpics );
        name9 = uicontrol(h_getlimits.fig, 'style','text','string',string9c, 'HorizontalAlignment', 'left', ...
            'background','white','units','normalized', 'position', [ x+sliderw+valuew y+h-index*spacing  labelw spacing ], 'fontsize', fontpics );
end;
if( start1 >= YFPs2b )
    YFPs2bcull	= start1;
else
    fprintf( 1, 'YFP signal to background can''t make limit less strict\n' );
    start1 = YFPs2bcull;
end;
if( start4 >= FRETs2b )
    FRETs2bcull	= start4;
else
    fprintf( 1, 'FRET signal to background can''t make limit less strict\n' );
    start4 = FRETs2bcull;
end;
if( start7 >= CFPs2b )
    CFPs2bcull	= start7;
else
    fprintf( 1, 'CFP signal to background can''t make limit less strict\n' );
    start7 = CFPs2bcull;
end;
if( start2 <= YFPmono )
    YFPmonocull	= start2;
else
    fprintf( 1, 'YFP monotonicity can''t make limit less strict\n' );
    start2 = YFPmonocull;
end;
if( start5 <= FRETmono )
    FRETmonocull = start5;
else
    fprintf( 1, 'FRET monotonicity can''t make limit less strict\n' );
    start5 = FRETmonocull;
end;
if( start8 <= CFPmono )
    CFPmonocull	= start8;
else
    fprintf( 1, 'CFP monotonicity can''t make limit less strict\n' );
    start8 = CFPmonocull;
end;
if( start3 <= YFPFWHM )
    YFPFWHMcull = start3;
else
    fprintf( 1, 'YFP FWHM can''t make limit less strict\n' );
    start3 = YFPFWHMcull;
end;
if( start6 <= FRETFWHM )
    FRETFWHMcull = start6;
else
    fprintf( 1, 'FRET FWHM can''t make limit less strict\n' );
    start6 = FRETFWHMcull;
end;
if( start9 <= CFPFWHM )
    CFPFWHMcull = start9;
else
    fprintf( 1, 'CFP FWHM can''t make limit less strict\n' );
    start9 = CFPFWHMcull;
end;
initialdone = 0;               % don't restore what you've just changed
culldone    = 0;
inspectdone = 0;
finaldone   = 0;
end

function limit2_callback( gcf, eventdata, handles, radio_value )
global limit2 progbarcol

if strcmp(progbarcol,'white') == 1
    progbarcol = 'yellow';
end
switch radio_value
   case 1
     limit2 = 1;
     set( handles.u0, 'value', 1 );
     set( handles.u1, 'value', 0 );
    case 2
     limit2 = 0;
     set( handles.u0, 'value', 0 );
     set( handles.u1, 'value', 1 );
end
end

Contact us