0001 function showclust(spikes, useassigns, show)
0002
0003
0004
0005 if (nargin < 2)
0006 useassigns = spikes.hierarchy.assigns;
0007 end
0008 if (nargin < 3)
0009 show = unique(useassigns);
0010 end
0011 show = reshape(show, 1, []);
0012
0013 smallWindow = 0.01;
0014
0015 tmin = (size(spikes.waveforms,2) - spikes.threshT + 1)./spikes.Fs;
0016 if (isfield(spikes,'options') && isfield(spikes.options, 'refractory_period'))
0017 tref = spikes.options.refractory_period;
0018 else
0019 tref = max(0.002, tmin*1.5);
0020 end
0021 tminl = tmin - 1/spikes.Fs;
0022
0023 clf;
0024 ylims = [min(spikes.waveforms(:)) max(spikes.waveforms(:))];
0025 tlims = [0 max(spikes.spiketimes)];
0026 cmap = colormap;
0027 for clust = 1:length(show)
0028 members = find(useassigns == show(clust));
0029 memberwaves = spikes.waveforms(members,:);
0030 membertimes = sort(spikes.spiketimes(members));
0031 subplot(length(show),3, 3 * (clust-1) + 1);
0032 [n,x,y] = histxt(memberwaves);
0033 imagesc(x,y,n); axis xy;
0034 if (clust < length(show))
0035 set(gca,'XTickLabel',{});
0036 end
0037 set(gca, 'YLim', ylims, 'YTickLabel', {}, 'Color', cmap(1,:));
0038
0039 if (show(clust) ~= 0), clustname = ['Cluster# ' num2str(show(clust))];
0040 else clustname = 'Outliers';
0041 end
0042 hy = ylabel({clustname, ['N = ' num2str(size(members,1))]});
0043
0044 subplot(length(show),3,3 * (clust-1) + 2);
0045 [a, scores] = isiQuality(membertimes, membertimes, tmin, smallWindow, tref, spikes.Fs);
0046 isis = sort(diff(membertimes)); isis = isis(isis <= smallWindow);
0047 isis = round(isis*spikes.Fs)/spikes.Fs;
0048 smalltimes = linspace(0,smallWindow,smallWindow*spikes.Fs+1);
0049 if (~isempty(isis)), n = histc(isis,smalltimes); else n = zeros(length(smalltimes)); end;
0050 plot(smalltimes,n); ylim = get(gca, 'YLim');
0051 patch([0 tref tref 0]', [0 0 ylim(2) ylim(2)]', -[0.1 0.1 0.1 0.1], [0.8 0.8 0.8], 'EdgeColor', 'none');
0052 patch([0 tminl tminl 0]', [0 0 ylim(2) ylim(2)]', -[0.1 0.1 0.1 0.1], [0.6 0.6 0.6], 'EdgeColor', 'none');
0053 set(gca,'Xlim',[0 0.01]);
0054 if (clust < length(show)), set(gca,'XTickLabel',{});
0055 else xlabel('ISI (sec)');
0056 end
0057
0058 subplot(length(show),3,3 * (clust-1) + 3);
0059 [n,x] = hist(membertimes,1:10:max(tlims)); bar(x,n,1.0); shading flat;
0060 set(gca,'Xlim',tlims);
0061 if (clust < length(show)), set(gca,'XTickLabel',{});
0062 else xlabel('t (sec)');
0063 end
0064 if (clust == 1), title('Spike Times'); end;
0065
0066
0067 set(hy, 'Units', 'char');
0068 hy_pos = get(hy, 'Position'); hy_pos = hy_pos + [-6*rem(clust,2),0,0]; set(hy, 'Position', hy_pos);
0069 end