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.

brightpatch
function brightpatch
%Version 4/3/09 Runs to bright patch filter. Also can be run as a
%standalone
global  fontpics h_startupQ bpfilter h_startupQfig
global standalone darkgreen
global bringincr AOIshape filtersize

standalone = 0;%set to 1 if to be used alone, set to 0 if part of FretSCal
%bpfilter = 1  ;%set to 1 if to be used alone, set to 0 if part of FretSCal
%or Colocal
if standalone == 1
    fontpics = 12;
    darkgreen = [ 0 .7 .7 ];
    filtersize = 9;  %filtersize is the WHOLE AREA OF INTEREST INCLUDING INNER EDGE OF BACKGROUND. Set by hand for standalone.
else
    filtersize = AOIshape + 2*(bringincr);
end

h_startupQfig = figure('Color', darkgreen,'units','normalized','name','Filter out bright patches','ToolBar','none','NumberTitle','off','menubar','none','position',[ .35 .35 .3 .3 ]);
uicontrol( 'units', 'normalized', 'style', 'text', 'string', 'Filter out bright patches', 'position', [ .2 .85 .6 .12 ], 'background','black','fore','white', 'fontsize', fontpics );
h_startupQ.u0 = uicontrol( 'units', 'normalized', 'style', 'radiobutton', 'string', 'Turn bright patch filter ON', ...
    'position', [ .2 .65 .6 .12 ], 'fontsize', fontpics );
h_startupQ.u1 = uicontrol( 'units', 'normalized', 'style', 'radiobutton', 'string', 'Turn bright patch filter OFF', ...
    'position', [ .2 .45 .6 .12 ], 'fontsize', fontpics );
set(  h_startupQ.u0, 'callback', {@getbf_callback, h_startupQ, 1 } );
set(  h_startupQ.u1, 'callback', {@getbf_callback, h_startupQ, 2 } );
if( bpfilter == 1 )
    set( h_startupQ.u0, 'value', 1 );
    set( h_startupQ.u1, 'value', 0 );
else
    set( h_startupQ.u0, 'value', 0 );
    set( h_startupQ.u1, 'value', 1 );
end;
uicontrol( h_startupQfig, 'style','pushbutton', 'units', 'normalized', 'string','Done',...
    'position',[ 1/3 .15 1/3 .1 ], 'callback',@startcallback, 'fontsize', fontpics);%fupdate;
end

function getbf_callback( gcf, eventdata, handles, radio_value )
global bpfilter

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

function startcallback( gcf, eventdata, handles )

global bpfilter h_startupQfig standalone h_brightpatchfig patchpixel h_patchpixel
global fontpics darkgreen h_inputtif test
global Pathname FileName

close(h_startupQfig);
pause(.2);
test =0;
if bpfilter == 0 && standalone == 0
    fupdate;
elseif bpfilter == 1
    [FileName,Pathname,FilterIndex] = uigetfile( '*.*','Select test tif' );%path to input directory end with dirsep
    if FilterIndex ~= 0
        h_inputtif = imtool(fullfile(Pathname,FileName),'Displayrange',[],'InitialMagnification','fit');
        h_brightpatchfig = figure( 'Color', darkgreen,'units','normalized','name','Set up filter for bright patches','ToolBar','none','NumberTitle','off','menubar','none','position',[ .6 .7 .2 .2 ],'nextplot','new' );
        uicontrol( 'units', 'normalized', 'style', 'text', 'string', 'Input pixel intensity at edge of patch and test before accepting', 'position', [ .05 .75 .9 .22 ],  'background','black','fore','white','fontsize', fontpics );
        h_patchpixel = uicontrol( h_brightpatchfig, 'units', 'normalized',...
            'style', 'edit', 'string', patchpixel, 'position', [ .35 .5 .3 .15],...
            'back', 'white', 'fore', 'black', 'fontsize', fontpics );
        uicontrol( 'style','pushbutton', 'units', 'normalized',  'string','Test',...
            'position',[ .1 .1 .3 .12], 'callback',@patchpixel_callback, 'fontsize', fontpics );
        uicontrol( 'style','pushbutton', 'units', 'normalized',  'string','Accept',...
            'position',[ .6 .1 .3 .12], 'callback',@accept_callback, 'fontsize', fontpics );
    end
end
end

function patchpixel_callback( gcf, eventdata, handles )
global h_brightpatchfig patchpixel h_patchpixel inputtif filtersize test testimage
global Pathname FileName
test = test + 1;
if test > 1
    try
        close (testimage);
    catch
        fprintf(1,'Tried to close test image, but failed.Normally closes automatically.\n');
    end
end
patchpixel = sscanf((get( h_patchpixel, 'string' )),'%d');
if(isempty(patchpixel) == 1)
    patchfilter = 0;
    patchpixel = 0;
else
    patchfilter = 1;
end;
if patchfilter == 1
    inputtif = imread(fullfile(Pathname,FileName));
    TI = inputtif;
    PF = ordfilt2(TI, 1, ones(filtersize));
    ptest = zeros(size(inputtif),'uint16');
    tf = PF >= patchpixel;
    TI(tf) = ptest(tf);%only replace with 0 if tf is true
    testimage = figure( 'numbertitle', 'off', 'Name', 'Test image');
    imshow(TI,'displayrange',[],'border','tight','InitialMagnification','fit');
    iptwindowalign(h_brightpatchfig,'left', testimage,'right');
    iptwindowalign(h_brightpatchfig,'top', testimage,'top');
end
end
function accept_callback( gcf, eventdata, handles )
global standalone testimage h_inputtif h_brightpatchfig test
if test >= 1
    try
        close (testimage);
    catch
        fprintf(1,'Tried to close test image, but failed. Normally closes automatically.\n');
    end
end
try
    close(h_inputtif);
catch
end
try
    close(h_brightpatchfig);
catch
end
if standalone == 0
    fupdate;
end
end

Contact us