Home > chronux_1_1 > spikesort > graphics > showclust.m

showclust

PURPOSE ^

SHOWCLUST temporary utility to show clusters

SYNOPSIS ^

function showclust(spikes, useassigns, show);

DESCRIPTION ^

    SHOWCLUST  temporary utility to show clusters
       SHOWCLUST(SPIKES, [USEASSIGNS], [SHOW]);

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

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

Generated on Sun 13-Aug-2006 11:49:44 by m2html © 2003