https://github.com/PerezOrtegaJ/Neural_Ensemble_Analysis
Raw File
Tip revision: 9d37fd031dfbdb4eb69faa449d0a6416267a7d4f authored by Jesús Pérez on 28 July 2020, 20:36:58 UTC
Update README.md
Tip revision: 9d37fd0
Plot_Peaks_On_Raster.m
function rasterColor = Plot_Peaks_On_Raster(raster,peak_indices,sequence,name,colors)
% Plot Peaks on raster
%
%       Plot_Peaks_On_Raster(raster,peak_indices,sequence,colors)
%
% Pķrez-Ortega Jes·s - Feb 2020

n = max(sequence);
switch (nargin)
    case 3
        name = '';
        colors = Read_Colors(n);
    case 4
        colors = Read_Colors(n);
end

rasterColor = zeros(size(raster));

% Find vectors
id = find(peak_indices>0);
ensembles(1,:) = unique(sequence);
for i = ensembles
    % find vectors of each ensemble
    x = [];
    x(id(sequence==i)) = 1;
    x = logical(x);
    
    % Assign an numeric value to each ensemble
    rasterColor(:,x) = i;
end

% Assign value of -1 to the spikes (or active frames)
rasterColor(logical(raster)) = -1;

[cells,frames] = size(raster);


Set_Figure(['Peaks on Raster (' name ')'],[0 0 1220 300]);
axis([0.5 frames 0.5 cells+0.5]); hold on
imagesc(rasterColor,[-1 length(ensembles)]);
colormap([0 0 0;1 1 1;colors])

ylim([0.5 cells+0.5])
box on
set(gca,'XTicklabel','','XTick',[0 frames])
title(strrep(name,'_','-'))
back to top