function plot_move_ROI_z_plane_circle(X, ROI_xy, Ez_xy_logical,center_cluster_coords,rho_final, varargin)
%
%A(:,:,:,1)=abs(S22_CO1);
%A(:,:,:,2)=abs(S12_CO1);
%A(:,:,:,3)=abs(S23_CO1);
%A(:,:,:,4)=abs(S13_CO1);
%plot_move(A(:,:,:,:),'MoveStep',1,'SubPlotDim',[2,2],'MoveData',F./1e9);
%
% 'MoveStep'--> how many step to move each press
% 'PlotFcn'--> What plot function to use, imagesc, meshgrid,...
% 'SubPlotDim'--> Number of subplots in [x,y] form
% 'Titles'--> Titles of the suplots in ['Title1';'Title2';...] form. 
% 'Xlabels'--> xlabel of the suplots in ['X1';'X2';...] form. 
% 'Ylabels'--> ylabel of the suplots in ['Y1';'Y2';...] form.
% 'Cbar'--> 'on'|'off' in form {'on';'off';...} for subplots
% 'MoveData'--> Vector of data that is being moved to
%           will be displayed on plot

pvarg_inc=1;
varargplot={};
t_flag=0;
y_flag=0;
x_flag=0;
c_flag=0;
f_flag=0;
    imi=1;
    dim=[1,1];
    pltfcn='imagesc';
if nargin <1
    error('Must have Inputs')
end
if nargin>7
    for i=1:2:nargin-6
        switch varargin{i}
            case 'MoveStep'
                imi=varargin{i+1};
            case 'PlotFcn'
                pltfcn=varargin{i+1};
            case 'SubPlotDim'
                dim=varargin{i+1};
            case 'Titles'
                titles=varargin{i+1};
                t_flag=1;
            case 'Xlabels'
                xlabels=varargin{i+1};
                x_flag=1;
            case 'Ylabels'
                ylabels=varargin{i+1};
                y_flag=1;
            case 'Cbar'
                c_val=varargin{i+1};
                c_flag=1; 
            case 'MoveData'
                F=varargin{i+1};
                f_flag=1;
            otherwise
                varargplot{pvarg_inc}=varargin{i};
                varargplot{pvarg_inc+1}=varargin{i+1}; 
                pvarg_inc=pvarg_inc+2;
       end
    end
end

figure;
fig=gcf;
im=1;
cnt=1;
n=dim(1);m=dim(2);
immax=size(X,3);
[num_x, num_y, ~, num_z] = size(X);
while cnt==1
    if ~ishandle(fig)
        cnt=0;
        break;
    end
    clf; 
    for is=1:size(X,4)
        subplot(n,m,is)

        mTextBox = uicontrol('style','text');
        titleSub = ['f = ' num2str(im)];
        set(mTextBox,'String',titleSub);
        text('Position',[2 2],'string',{num2str(im)});
        
        replot(X(:,:,im,is),[],[],pltfcn,varargplot); 
        
        ROI_xy_f = cell2mat(ROI_xy(im,is));
        Ez_logical = cell2mat(Ez_xy_logical(im,is));
        

        hold on; colorbar;
         % Draw ROI and Exclusion ROI
        mask = cat(3, zeros(num_x, num_y), zeros(num_x, num_y), zeros(num_x, num_y));
        h = imagesc(mask); 
        set(h, 'AlphaData', ~ROI_xy_f*0.25);
        viscircles(center_cluster_coords(is,:),rho_final(im,is),'Color','w', 'LineWidth', 1);% hold off; 
        set(gca,'YDir','normal');
                set(gca,'Yticklabel',[]);
        set(gca,'Xticklabel',[]);
        hold off; 

        if c_flag
            if strcmpi(c_val,'on')
               colorbar;
            end
        end
        
        
        if t_flag
        title(titles(is,:));
        end
        if x_flag
            xlabel(xlabels(is,:));
        end
        if y_flag
            ylabel(ylabels(is,:));
        end
        
       

    end

  pause;
    if ~ishandle(fig)
        cnt=0;
        break;
    end
      val=double(get(fig,'CurrentCharacter'));
    if val==28
        if im>imi
        im=im-imi;
        end
    elseif val==29
        if im<immax
        im=im+imi;
        end
    else
        cnt=0;
        close(fig)
    end
    

%     mTextBox = uicontrol('style','text');
%     set(mTextBox,'String',{'Frequency:',num2str(F(im))});
%     suptitle_text = ['Frequency Index: ' num2str(im) '; SNR of PSF = ' SNR_qual '; From left to right, top to bottom: real, imag, mag, phase'];
    
%     suptitle(suptitle_text);
    %text('Position',[1 1],'string',{'Frequency:',num2str(F(im))})

    
end
