Skip to content

Commit

Permalink
Updated docs
Browse files Browse the repository at this point in the history
  • Loading branch information
jmarkow committed Jan 25, 2016
1 parent 2763503 commit 138965d
Show file tree
Hide file tree
Showing 10 changed files with 228 additions and 66 deletions.
238 changes: 194 additions & 44 deletions docs/usage.rst

Large diffs are not rendered by default.

4 changes: 1 addition & 3 deletions helpers/spikoclust_autosort.m
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,12 @@

if gap_check
gap_stats=evalclusters(SPIKE_DATA,'kmeans','gap','klist',clust_check);
gap_stats
clust_check=[gap_stats.OptimalK-1:gap_stats.OptimalK+1];
clust_check
end

[idx CLUSTER_DATA MODEL]=spikoclust_gmmsort(SPIKE_DATA,...
'smem',smem,'garbage',garbage,'clust_check',clust_check,...
'pcs',pcs,'workers',workers,'modelselection',modelselection,'outlierpoints',outlierpoints);
'workers',workers,'modelselection',modelselection,'outlierpoints',outlierpoints);

MODEL.features=PCS;
features=size(CLUSTER_DATA,2); % what's the dimensionality of the data used for sorting?
Expand Down
1 change: 1 addition & 0 deletions helpers/spikoclust_cluster_quality.m
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
%
%


nmodels=size(MODEL.mu,1);

clusters=unique(LABELS(LABELS>0)); % how many clusters?
Expand Down
10 changes: 4 additions & 6 deletions helpers/spikoclust_denoise_signal.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
%
%

ndims_ephys=ndims(EPHYS_DATA);
[samples,ntrials,nchannels]=size(EPHYS_DATA);

if nargin<2 | isempty(CHIN), CHIN=1:nchannels; end
if nargin<3 | isempty(CHOUT), CHOUT=CHIN; end

nparams=length(varargin);
Expand Down Expand Up @@ -41,9 +45,6 @@
end

car_electrodes=setdiff(1:length(CHIN),exclude_channels); % which electrodes are good for CAR?
ndims_ephys=ndims(EPHYS_DATA);

[samples,ntrials,nchannels]=size(EPHYS_DATA);

% map each channel appropriately

Expand Down Expand Up @@ -99,6 +100,3 @@
end

end



2 changes: 0 additions & 2 deletions helpers/spikoclust_gmmsort.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
clust_check=varargin{i+1};
case 'clustreplicates'
clustreplicates=varargin{i+1};
case 'pcs'
pcs=varargin{i+1};
case 'garbage'
garbage=varargin{i+1};
case 'workers'
Expand Down
16 changes: 10 additions & 6 deletions helpers/spikoclust_guisort.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@

% all features excluding IFR and SPIKES.times

features_all={'max','min','ne','^2','neo','wid','pgrad','ngrad','PC1','PC2','PC3','PC4'};
features={'PCA','pose','nege','posgrad','neggrad','min','max','width','ISI'};
features_all={'max','min','ne','^2','neo','wid','pgrad','ngrad','PC1','PC2','PC3','PC4'};
features={'PCA','pose','nege','posgrad','neggrad','min','max','width','ISI'};

% possible features include, min, max, PCA, width, energy and wavelet coefficients

channel_labels=[];
colors={'b','r','g','c','m','y','r','g','b'};
outliercolor='k';
Expand Down Expand Up @@ -78,7 +78,7 @@
if nchannels==1

geom_features=spikoclust_shape_features(SPIKES.windows);

if any(strcmp('max',lower(features)))
spike_data=[spike_data geom_features(:,1)];
property_names{end+1}='max';
Expand Down Expand Up @@ -424,10 +424,9 @@ function change_cluster(varargin)
LABELS=zeros(size(idx));

for i=1:nclust
LABELS(idx==clusters(loc(i)))=i;
LABELS(idx==clusters(loc(i)))=i;
end


clustermodel.R(:,1:nclust)=clustermodel.R(:,loc);
clustermodel.mixing(1:nclust)=clustermodel.mixing(loc);
clustermodel.sigma=clustermodel.sigma(:,:,loc);
Expand All @@ -451,6 +450,11 @@ function change_cluster(varargin)
legend_labels{end+1}='Outliers';
end


if all(LABELS==0)
LABELS=ones(size(LABELS));
end

% compute any other stats we want, ISI, etc...
[WINDOWS TIMES TRIALS SPIKEDATA ISI STATS]=...
spikoclust_cluster_quality(SPIKES.storewindows,SPIKES.times,CLUSTER_DATA,LABELS,SPIKES.trial,MODEL);
Expand Down
11 changes: 8 additions & 3 deletions helpers/spikoclust_robpca.m
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
function [PROJ,PCS,LAMBDA,MODEL]=cov_check(DATA,REPLICATES)
function [PROJ,PCS,LAMBDA,MODEL]=spikoclust_robpca(DATA,K,REPLICATES)
%
%
%
%
%

if nargin<2

if nargin<3 | isempty(REPLICATES)
REPLICATES=10;
end

if nargin<2 | isempty(K)
K=6;
end

likelihood=zeros(1,REPLICATES);
for i=1:REPLICATES
tmp_newmodel{i}=spikoclust_gmem(DATA,[],1,'garbage',1,'merge',0,'debug',0,'display_mode',0);
Expand All @@ -19,7 +24,7 @@

[~,loc]=max(likelihood);
MODEL=tmp_newmodel{loc(1)};
[PCS,LAMBDA]=eigs(MODEL.sigma(:,:,1));
[PCS,LAMBDA]=eigs(MODEL.sigma(:,:,1),K);
LAMBDA=diag(LAMBDA);
[~,idx]=sort(LAMBDA,'descend');
PCS=PCS(:,idx);
Expand Down
6 changes: 6 additions & 0 deletions helpers/spikoclust_spike_detect.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,18 @@
% threshold for detecting spikes (can pass a vector where each element corresponds to threshold for trial)
%



SPIKES=[];

if nargin<1
error('Need the input data to continue!');
end

if isvector(DATA)
DATA=DATA(:);
end

%%%%%%%%%%%%%%%%%%%%%%%%%%%

% input argument collection
Expand Down
4 changes: 3 additions & 1 deletion helpers/spikoclust_spike_remove.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
%
%

if isvector(DATA)
DATA=DATA(:);
end

nspikes=length(SPIKES.times);
edges=round(SPIKES.frame*SPIKES.fs);
Expand Down Expand Up @@ -51,4 +54,3 @@
SPIKELESS(counter:counter+nsamples)=DATA(coords(i,1):coords(i,2),coords(i,3));
counter=counter+nsamples+1;
end

2 changes: 1 addition & 1 deletion spikoclust_sort.m
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@
spikes=spikoclust_noisewhiten(spikes,spikeless,'maxnoisetraces',maxnoisetraces);
end

% upsample and align, then downsample and whiten!!!
% upsample and align, then downsample for sorting!!!

spikes=spikoclust_upsample_align(spikes,'interpolate_fs',interpolate_fs,'align_feature',align_feature);
[nsamples,ntrials,nchannels]=size(spikes.windows);
Expand Down

0 comments on commit 138965d

Please sign in to comment.