function [method, params] = remove_bleaching()
    % global status;
    status = 0;
    self.dialog = dialog('name', 'Remove Photo-bleaching', ...
                         'color', [0.95 0.95 0.95], ...
                         'units', 'pixels', ...
                         'CloseRequestFcn', @(varargin) resume(0));
    set(self.dialog, ...
        'DefaultUIPanelBackGroundColor', [0.95 0.95 0.95], ...
        'DefaultUIControlUnits', 'normalized');

    % width and height in pixels
    w = 250;
    h = 200;

    % vertical and horizontal padding 
    vp = 0.05;
    hp = 0.05;

    % button height and width
    bh = (1 - 8 * vp) / 7;
    bw = (1 - 3 * hp) / 2;

    rect = get(self.dialog, 'position');
    set(self.dialog, 'position', [rect(1) rect(2) w h]);

    % ui elements: 6 rows, 2 columns
    self.methodPopupLabel ...
        = uicontrol(self.dialog, ...
            'style', 'text', ...
            'backgroundcolor', [0.95 0.95 0.95], ...
            'string', 'Threshold', ...
            'horizontalalignment', 'left', ...
            'position', [hp 6*bh+7*vp bw bh]);
    self.methodPopup ...
        = uicontrol(self.dialog, ...
            'style', 'popup', ...
            'string', 'Manual|Auto', ...
            'callback', @(varargin) methodPopupCallback(), ...
            'position', [bw+2*hp 6*bh+7*vp bw bh]);
    self.donCheck ...
        = uicontrol(self.dialog, ...
            'style', 'checkbox', ...
            'string', 'Donor', ...
            'horizontalalignment', 'left', ...
            'callback', @(varargin) checkCallback('don'), ...
            'position', [hp 5*bh+6*vp bw bh]);
    self.donEdit ...
        = uicontrol(self.dialog, ...
            'style', 'edit', ...
            'string', '0', ...
            'position', [bw+2*hp 5*bh+6*vp bw bh]);
    self.accCheck ...
        = uicontrol(self.dialog, ...
            'style', 'checkbox', ...
            'string', 'Acceptor', ...
            'horizontalalignment', 'left', ...
            'callback', @(varargin) checkCallback('acc'), ...
            'position', [hp 4*bh+5*vp bw bh]);
    self.accEdit ...
        = uicontrol(self.dialog, ...
            'style', 'edit', ...
            'string', '0', ...
            'position', [bw+2*hp 4*bh+5*vp bw bh]);
    self.sumCheck ...
        = uicontrol(self.dialog, ...
            'style', 'checkbox', ...
            'string', 'Don + Acc', ...
            'horizontalalignment', 'left', ...
            'callback', @(varargin) checkCallback('sum'), ...
            'position', [hp 3*bh+4*vp bw bh]);
    self.sumEdit ...
        = uicontrol(self.dialog, ...
            'style', 'edit', ...
            'string', '0', ...
            'position', [bw+2*hp 3*bh+4*vp bw bh]);
    self.fretCheck ...
        = uicontrol(self.dialog, ...
            'style', 'checkbox', ...
            'string', 'FRET', ...
            'horizontalalignment', 'left', ...
            'callback', @(varargin) checkCallback('fret'), ...
            'position', [hp 2*bh+3*vp bw bh]);
    self.fretEdit ...
        = uicontrol(self.dialog, ...
            'style', 'edit', ...
            'string', '0', ...
            'position', [bw+2*hp 2*bh+3*vp bw bh]);
    self.padCheck ...
        = uicontrol(self.dialog, ...
            'style', 'checkbox', ...
            'string', 'Padding', ...
            'horizontalalignment', 'left', ...
            'callback', @(varargin) checkCallback('pad'), ...
            'position', [hp bh+2*vp bw bh]);
    self.padEdit ...
        = uicontrol(self.dialog, ...
            'style', 'edit', ...
            'string', '0', ...
            'position', [bw+2*hp bh+2*vp bw bh]);
    self.okButton ...
        = uicontrol(self.dialog, ...
            'style', 'pushbutton', ...
            'string', 'Ok', ...
            'position', [hp vp bw bh], ...
            'callback', @(varargin) resume(1));
            % 'callback', ...
            %     @(source, event) return_values(1), ...
    self.cancelButton ...
        = uicontrol(self.dialog, ...
            'style', 'pushbutton', ...
            'string', 'Cancel', ...
            'position', [bw+2*hp vp bw bh], ...
            'callback', @(varargin) resume(0));
            % 'string', 'Cancel', ...
            %     @(source, event) return_values(0), ...

    function methodPopupCallback(value)
        if nargin < 1
            value = get(self.methodPopup, 'value');
        end
        vars = {'don', 'acc', 'fret', 'sum', 'pad'};
        switch value 
            case 1
                for v = 1:length(vars)
                    checkfld = sprintf('%sCheck', vars{v});
                    set(self.(checkfld), 'enable', 'on');
                    checkCallback(vars{v});
                end
            otherwise
                for v = 1:length(vars)
                    checkfld = sprintf('%sCheck', vars{v});
                    editfld = sprintf('%sEdit', vars{v});
                    set(self.(checkfld), 'enable', 'off');
                    set(self.(editfld), 'enable', 'off');
                end
        end
    end

    function checkCallback(name, value)
        checkfld = sprintf('%sCheck', name);
        editfld = sprintf('%sEdit', name);
        if nargin < 2
            value = get(self.(checkfld), 'value');
        else 
            get(self.(checkfld), 'value', value);
        end
        if value 
            set(self.(editfld), 'enable', 'on');
        else
            set(self.(editfld), 'enable', 'off');
        end
    end
    
    function resume(int)
        status = int;
        uiresume();
    end

    methodPopupCallback(1);
    uiwait(self.dialog);
    if status 
        method = get(self.methodPopup, 'value');
        vars = {'don', 'acc', 'fret', 'sum', 'pad'};
        for v = 1:length(vars)
            checkfld = sprintf('%sCheck', vars{v});
            editfld = sprintf('%sEdit', vars{v});
            if get(self.(checkfld), 'value')
                params.(vars{v}) = str2num(get(self.(editfld), 'string'));
            else
                params.(vars{v}) = NaN;
            end
        end
    else
        method = -1;
        params.fret = NaN;
        params.donor = NaN;
        params.acceptor = NaN;
        params.sum = NaN;
        params.pad = NaN;
    end
    delete(self.dialog);
end