function Plotting

disp(' ');
disp('                      Plot PDC results -> 1');
disp('                      Plot DTF results -> 2');
disp('  Plot processed spike trains and PC1s -> 3');
disp('Plot spike train firing rates and PC1s -> 4');
disp('                   Plot pooled results -> 5');
plot_type = input('');


if plot_type == 1 || plot_type == 2
    if plot_type == 1
        d = 'PDC';
    else
        d = 'DTF';
    end
    [FileName,PathName] = uigetfile('*.mat',['Select the Mat-file with the ',num2str(d),'-results data to be plotted'],'PDCresults_');
    if isequal(FileName,0)
        error('You did not specify a file')
    end
    h = fullfile(PathName, FileName);                                 % open a user-specified file of preprocessed data...
    load(h);
    E = size(ep_times,1);                                                   % Count the number of epochs...
    channels = length(PDC{1}(:,:,1));                                       % and the number of data arrays
    
    if strcmp(d,'DTF')
        Signif = cell(1,E);
        for i=1:E
            Signif{i} = zeros(size(DTF{1}));
        end
    end
            
    PlotPDC(eval(d),COH,S,Signif,ep_times,freq,E,channels,1);                       % Call plotPDC to plot results
                   
                
elseif plot_type == 3
    [FileName,PathName] = uigetfile('*.mat','Select the Mat-file with the pre-processed spike trains'); % Or load file
    if isequal(FileName,0)
        error('You did not specify a file')
    end
    h = fullfile(PathName, FileName);                                                               % Load the file
    load(h);
    count_rate = archive.sampling_rate; 
    maxtime = archive.experim_time;
    
    Plot_spikes(pr_spikes,PC1,count_rate/2,maxtime);
    
    
elseif plot_type == 4
    [FileName,PathName] = uigetfile('*.mat','Select the Mat-file with the firing rates'); % Or load file
    if isequal(FileName,0)
        error('You did not specify a file')
    end
    h = fullfile(PathName, FileName);                                                               % Load the file
    load(h);

    Plot_rates(Rates,PC1,Bins);
 
    
elseif plot_type == 5
    [FileName,PathName] = uigetfile('*.mat','Select the Mat-file with the pooled results'); % Or load file
    if isequal(FileName,0)
        error('You did not specify a file')
    end
    h = fullfile(PathName, FileName);                                                               % Load the file
    load(h);
    E = size(ep_times,1);                                                   % Count the number of epochs...
    channels = length(PDC{1}(:,:,1));                                       % and the number of data arrays

    PlotPDC(PDC,COH,S,Signif,ep_times,freq,E,channels,2);      % Call plotPDC to plot the pooled measures.
    
    
else
    error('You have to choose one of the above options!')
end