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.

getsearchlimits
function getsearchlimits
%Version 4/3/09 Displays the window that gets called with search limits. Many of the
%globals get passed to getcullimits.

global bigincr smlincr AOIshape fontpics darkgreen bringincr
global slider1 slider2 slider3 slider4 slider5 slider6 slider7 slider8 slider9
global sliderw valuew labelw primary limit1
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

x = .1; y = .5; w = .8; h = .5; spacing = .048;
sliderw = w/2;
valuew  = w/10;
labelw  = 4*w/10;

smin(1)= 1.0;smax(1)=10.0;start1=YFPs2b;   bigincr(1)=.1/(smax(1)-smin(1));smlincr(1)=.01/(smax(1)-smin(1));
smin(4)= 1.0;smax(4)=10.0;start4=FRETs2b;  bigincr(4)=.1/(smax(4)-smin(4));smlincr(4)=.01/(smax(4)-smin(4));
smin(7)= 1.0;smax(7)=10.0;start7=CFPs2b;   bigincr(7)=.1/(smax(7)-smin(7));smlincr(7)=.01/(smax(7)-smin(7));
smin(2)= -.5;smax(2)=.5;start2=YFPmono;  bigincr(2)=.1/(smax(2)-smin(2));smlincr(2)=.01/(smax(2)-smin(2));
smin(5)= -.5;smax(5)=.5;start5=FRETmono; bigincr(5)=.1/(smax(5)-smin(5));smlincr(5)=.01/(smax(5)-smin(5));
smin(8)= -.5;smax(8)=.5;start8=CFPmono;  bigincr(8)=.1/(smax(8)-smin(8));smlincr(8)=.01/(smax(8)-smin(8));
smin(3)= 1.0;smax(3)=AOIshape + bringincr;start3=YFPFWHM; bigincr(3)=.1/(smax(3)-smin(3));smlincr(3)=.01/(smax(3)-smin(3));
smin(6)= 1.0;smax(6)=AOIshape + bringincr;start6=FRETFWHM;bigincr(6)=.1/(smax(6)-smin(6));smlincr(6)=.01/(smax(6)-smin(6));
smin(9)= 1.0;smax(9)=AOIshape + bringincr;start9=CFPFWHM; bigincr(9)=.1/(smax(9)-smin(9));smlincr(9)=.01/(smax(9)-smin(9));

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 ) );

if YFPFWHM > AOIshape + bringincr
    start3 = AOIshape + bringincr;
    YFPFWHM = AOIshape + bringincr;
end
if FRETFWHM > AOIshape + bringincr
    start6 = AOIshape+ bringincr;
    FRETFWHM = AOIshape + bringincr;
end
if CFPFWHM > AOIshape+ bringincr
    start9 = AOIshape+ bringincr;
    CFPFWHM = AOIshape+ bringincr;
end

h_getlimits.fig = figure('Color', darkgreen, 'units','normalized','name','Search Limits','ToolBar','none','NumberTitle','off','menubar','none','position',[ .1 .4 .8 .5 ], 'name', 'Search Limits');
uicontrol( 'units', 'normalized', 'style', 'text', 'string', 'Search 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+.3-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+.3-i*spacing  labelw spacing ], 'fontsize', fontpics );
slider1 = uicontrol(h_getlimits.fig, 'style','slider','units','normalized','background','white', ...
    'position', [ x y+.3-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+.3-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+.3-i*spacing  labelw spacing ], 'fontsize', fontpics );
slider2 = uicontrol(h_getlimits.fig, 'style','slider','units','normalized','background','white', ...
    'position', [ x y+.3-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+.3-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+.3-i*spacing  labelw spacing ], 'fontsize', fontpics );
slider3 = uicontrol(h_getlimits.fig, 'style','slider','units','normalized','background','white', ...
    'position', [ x y+.3-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+.3-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+.3-i*spacing  labelw spacing ], 'fontsize', fontpics );
slider4 = uicontrol(h_getlimits.fig, 'style','slider','units','normalized','background','white', ...
    'position', [ x y+.3-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+.3-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+.3-i*spacing  labelw spacing ], 'fontsize', fontpics );
slider5 = uicontrol(h_getlimits.fig, 'style','slider','units','normalized','background','white', ...
    'position', [ x y+.3-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+.3-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+.3-i*spacing  labelw spacing ], 'fontsize', fontpics );
slider6 = uicontrol(h_getlimits.fig, 'style','slider','units','normalized','background','white', ...
    'position', [ x y+.3-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+.3-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+.3-i*spacing  labelw spacing ], 'fontsize', fontpics );
slider7 = uicontrol(h_getlimits.fig, 'style','slider','units','normalized','background','white', ...
    'position', [ x y+.3-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+.3-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+.3-i*spacing  labelw spacing ], 'fontsize', fontpics );
slider8 = uicontrol(h_getlimits.fig, 'style','slider','units','normalized','background','white', ...
    'position', [ x y+.3-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+.3-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+.3-i*spacing  labelw spacing ], 'fontsize', fontpics );
slider9 = uicontrol(h_getlimits.fig, 'style','slider','units','normalized','background','white', ...
    'position', [ x y+.3-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 limits ONLY on primary, %s, channel. Ignore other channel settings.',primarys);
h_limit1.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_limit1.u1 = uicontrol( 'units', 'normalized', 'style', 'radiobutton', 'string', 'Apply limits on ALL channels.', ...
            'position', [ 2.25/10 .15 5.5/10 1/12 ], 'background','red','fore','white','fontsize', fontpics );

set( h_limit1.u0, 'callback', {@limit1_callback, h_limit1, 1 } );
set( h_limit1.u1, 'callback', {@limit1_callback, h_limit1, 2 } );
if limit1 == 1
    set(h_limit1.u0,'value',1);
    set(h_limit1.u1,'value',0);    
elseif limit1 == 0
    set(h_limit1.u0,'value',0);
    set(h_limit1.u1,'value',1); 
end
    
uicontrol( 'style','pushbutton', 'units', 'normalized',  'string','Done',...
    'position',[ .45 .02 .1 .1], 'callback','fupdate;close(gcf)','fontsize', fontpics);
end


function getlimits_callback( gcf, eventdata, handles, index )

global initialdone culldone inspectdone finaldone
global 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 string7c string8c string9c string4c string5c string6c
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 = .5; spacing = .048;


start1 = get(slider1,'value');
start1 =(round(start1*100))/100;% too avoid any floating point surprises, I round to nearest 100th.
start4 = get(slider4,'value');
start4 =(round(start4*100))/100;
start7 = get(slider7,'value');
start7 =(round(start7*100))/100;
start2 = get(slider2,'value');
start2 =(round(start2*100))/100;
start5 = get(slider5,'value');
start5 =(round(start5*100))/100;
start8 = get(slider8,'value');
start8 =(round(start8*100))/100;
start3 = get(slider3,'value');
start3 =(round(start3*100))/100;
start6 = get(slider6,'value');
start6 =(round(start6*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+.3-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+.3-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+.3-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+.3-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+.3-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+.3-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+.3-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+.3-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+.3-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+.3-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+.3-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+.3-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+.3-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+.3-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+.3-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+.3-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+.3-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+.3-index*spacing  labelw spacing ], 'fontsize', fontpics );
end;
YFPs2b	= start1;
FRETs2b	= start4;
CFPs2b	= start7;
YFPmono	= start2;
FRETmono	= start5;
CFPmono	= start8;
YFPFWHM	= start3;
FRETFWHM	= start6;
CFPFWHM	= start9;
YFPs2bcull	= start1;
FRETs2bcull	= start4;
CFPs2bcull	= start7;
YFPmonocull	= start2;
FRETmonocull	= start5;
CFPmonocull	= start8;
YFPFWHMcull	= start3;
FRETFWHMcull	= start6;
CFPFWHMcull	= start9;
progbarcol = 'red';


initialdone = 0;               % don't restore what you've just changed
culldone    = 0;
inspectdone = 0;
finaldone   = 0;
end

function limit1_callback( gcf, eventdata, handles, radio_value )
global limit1 progbarcol

progbarcol = 'red';
switch radio_value
   case 1
     limit1 = 1;
     set( handles.u0, 'value', 1 );
     set( handles.u1, 'value', 0 );
    case 2
     limit1 = 0;
     set( handles.u0, 'value', 0 );
     set( handles.u1, 'value', 1 );
end
end

     

Contact us