function fig = getGFtboxFigure( m )
%fig = getGFtboxFigure( m )
%   If m is being run from GFtbox, return a handle to the GFtbox figure,
%   otherwise return empty.

    if isempty( m.pictures )
        fig = [];
    elseif ~ishandle( m.pictures(1) )
        fig = [];
    else
        fig = ancestor( m.pictures(1), 'figure' );
        if ~ishandle( fig )
            fig = [];
        end
    end
end
