function Plot_spikes(pr_trains,PC1,f_N,maxtime,mintime)

% Plot the processed spike trains of each group, along with their
% 1st principal component

[groups,m]=size(pr_trains);                                                

figure
k=0;
lcomb = ceil((maxtime-mintime)*2*f_N)+1;                                      % Set the "Dirac comb"
comb = [0:lcomb-1];
time = mintime + comb/(2*f_N);                                              % Set the time array

for z=1:groups                                                              % For each group
    for zz=1:m                                                              % and each train
        k=k+1;
        if ~isempty(pr_trains{z,zz})                                        % if it isnt empty
            subplot(groups,m,k);    
            plot(time,pr_trains{z,zz});                                     % Plot processed train over time
            title(['Group ',num2str(z),', Spike Train ',num2str(zz)]);
            xlabel('Time (sec)');
            xlim([mintime time(end)])                                       % Set x-axis limits (the upper limit is slightly larger than maxtime)
        end
    end
end
            
figure
for i = 1:groups                                                            % For each group
    subplot(groups,1,i);
    plot(time,PC1{i});                                                      % Plot PC1s
    title(['PC1 of group ',num2str(i)]);
    xlabel('Time (sec)');
    xlim([mintime time(end)])
end