Skip to content

Commit

Permalink
added statistics for connectivity dependence on delta Ori and delta xy.
Browse files Browse the repository at this point in the history
  • Loading branch information
dimitri-yatsenko committed Jun 23, 2014
1 parent 46512a9 commit 45c4796
Show file tree
Hide file tree
Showing 4 changed files with 132 additions and 263 deletions.
2 changes: 1 addition & 1 deletion +cove/estimate.m
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@

case 'lv-glasso'
assert(length(hypers)==2)
cove.set('max_latent',inf) % prevent latent variables
cove.set('max_latent',inf) % allow any number of latent variables
scale = mean(diag(C));
extras = cove.lvglasso(C/scale,hypers(1),hypers(2),cove.set);
extras.S = extras.S/scale; % scale back
Expand Down
2 changes: 1 addition & 1 deletion +cove/set.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
if isempty(STATE) || (nargin>=1 && strcmpi(name,'restore'))
STATE = struct(...
'refit', false, ...
'max_latent', 0 ...
'max_latent', inf ...
);
end

Expand Down
23 changes: 18 additions & 5 deletions +covest/QuadLoss.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@
covest.QuadLoss (computed) # my newest table
-> covest.CovMatrix
-----
quad_loss : double # quadratic loss value
quad_loss=null : double # quadratic loss value
%}

classdef QuadLoss < dj.Relvar & dj.AutoPopulate

properties(Constant)
loss = @(S,Sigma) trace(Sigma/S-eye(size(S,1)))/size(S,1)^2;
end

properties
popRel = covest.CovMatrix & 'nfolds>1'
end
Expand All @@ -16,12 +20,12 @@
function makeTuples(self, key)
opt = fetch(covest.Method & key,'*');
[k,nFolds] = fetch1(covest.Fold & key, 'k','nfolds');
loss = @(S,Sigma) trace(Sigma/S-eye(size(S,1)))/size(S,1)^2;

% X := nBins * nDirs * nTrials * nCells
[X,selection] = fetch1(covest.Traces*covest.ActiveCells & key, ...
'trace_segments', 'selection');
X = double(X(:,:,:,selection));
[nBins, nDirs, nTrials, nCells] = size(X);

% exclude spontaneous activity if necessary
evokedBins = fetch1(covest.Traces & key, 'evoked_bins');
Expand All @@ -35,10 +39,19 @@ function makeTuples(self, key)
end

% split into training and testing
C = fetch1(covest.CovMatrix & key, 'cov_matrix');
[M,V,R,delta] = fetch1(covest.CovMatrix & key, ...
'means','variances','corr_matrix','delta');
[~, XTest] = cove.splitTrials(X,k,nFolds);
CTest = cove.estimate(XTest,[],evokedBins, 'sample', {});
key.quad_loss = loss(C,CTest);
assert(~isempty(XTest))
X = bsxfun(@minus, X, M);
V0 = reshape(nanmean(reshape(V,[],nCells)),[1 1 1 nCells]);
V = bsxfun(@plus,(1-delta)*V,delta*V0);
X = bsxfun(@rdivide, X, sqrt(V));
RTest = cov(reshape(X,[],nCells));



key.quad_loss = self.loss(R,RTest);
self.insert(key)
end
end
Expand Down
Loading

0 comments on commit 45c4796

Please sign in to comment.