CellSort 1.0 > CellsortFindspikes.m

CellsortFindspikes

PURPOSE ^

[spmat, spt, spc, zsig] = CellsortFindspikes(ica_sig, thresh, dt, deconvtau, normalization)

SYNOPSIS ^

function [spmat, spt, spc] = CellsortFindspikes(ica_sig, thresh, dt, deconvtau, normalization)

DESCRIPTION ^

 [spmat, spt, spc, zsig] = CellsortFindspikes(ica_sig, thresh, dt, deconvtau, normalization)

 CELLSORT
  Deconvolve signal and find spikes using a threshold

 Inputs:
   ica_sig - nIC x T matrix of ICA temporal signals
   thresh - threshold for spike detection
   dt - time step
   deconvtau - time constant for temporal deconvolution (Butterworth
   filter); if deconvtau=0 or [], no deconvolution is performed
   normalization - type of normalization to apply to ica_sig; 0 - no
   normalization; 1 - divide by standard deviation and subtract mean

 Outputs:
   spmat - nIC x T sparse binary matrix, containing 1 at the time frame of each
   spike
   spt - list of all spike times
   spc - list of the indices of cells for each spike

 Eran Mukamel, Axel Nimmerjahn and Mark Schnitzer, 2009
 Email: eran@post.harvard.edu, mschnitz@stanford.edu

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [spmat, spt, spc] = CellsortFindspikes(ica_sig, thresh, dt, deconvtau, normalization)
0002 % [spmat, spt, spc, zsig] = CellsortFindspikes(ica_sig, thresh, dt, deconvtau, normalization)
0003 %
0004 % CELLSORT
0005 %  Deconvolve signal and find spikes using a threshold
0006 %
0007 % Inputs:
0008 %   ica_sig - nIC x T matrix of ICA temporal signals
0009 %   thresh - threshold for spike detection
0010 %   dt - time step
0011 %   deconvtau - time constant for temporal deconvolution (Butterworth
0012 %   filter); if deconvtau=0 or [], no deconvolution is performed
0013 %   normalization - type of normalization to apply to ica_sig; 0 - no
0014 %   normalization; 1 - divide by standard deviation and subtract mean
0015 %
0016 % Outputs:
0017 %   spmat - nIC x T sparse binary matrix, containing 1 at the time frame of each
0018 %   spike
0019 %   spt - list of all spike times
0020 %   spc - list of the indices of cells for each spike
0021 %
0022 % Eran Mukamel, Axel Nimmerjahn and Mark Schnitzer, 2009
0023 % Email: eran@post.harvard.edu, mschnitz@stanford.edu
0024 
0025 if size(ica_sig,2)==1
0026     ica_sig = ica_sig';
0027 end
0028 
0029 if (nargin>=3)&&(deconvtau>0)
0030     dsig = diff(ica_sig,1,2);
0031     sig = ica_sig/deconvtau + [dsig(:,1),dsig]/dt;
0032 else
0033     sig = ica_sig;
0034 end
0035 
0036 if (nargin<2)
0037     thresh=3;
0038     fprintf('Using threshold = 3 s.d. \n')
0039 end
0040 switch normalization
0041     case 0 % Absolute units
0042         zsig = sig';
0043     case 1 % Standard-deviation
0044         zsig = zscore(sig');
0045 end
0046 pp1=[zsig(1,:);zsig(1:end-1,:)];
0047 pp2=[zsig(2:end,:);zsig(end,:)];
0048 spmat = sparse((zsig>=thresh)&(zsig-pp1>=0)&(zsig-pp2>=0));
0049 
0050 if nargout>1
0051     [spt,spc] = find(spmat);
0052     spt = spt*dt;
0053 end

Generated on Wed 29-Jul-2009 12:46:53 by m2html © 2003