Skip to content
2 changes: 1 addition & 1 deletion +embedding/GPFA.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function [E,ProjMatrix,VarExplained]= GPFA(D,pars,W, VarExplained)
function [E,ProjMatrix,VarExplained]= GPFA(D,pars,W)
if nargin < 3
[W, VarExplained] = deal([]);
end
Expand Down
9 changes: 7 additions & 2 deletions +embedding/PCA.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function [E,ProjMatrix,ProjMatrixInv,VarExplained] = PCA(D,pars,W, VarExplained)
function [E,ProjMatrix,ProjMatrixInv,VarExplained] = PCA(D,pars,W)

if nargin < 3
[W, VarExplained] = deal([]);
Expand All @@ -12,8 +12,13 @@
end
if pars.projectOnly
E = embedding.PCA.project(D,W);
Winv = W{1}';
data = [D{:}];
VarExplained = NeuralEmbedding.explainedVar(Winv * [E{:}], data);
VarExplained = {VarExplained(2,1)};

ProjMatrix = W;
ProjMatrixInv = {W{1}'};
ProjMatrixInv = {Winv};
else
[E,ProjMatrix,VarExplained] = embedding.PCA.reduce(D_,pars.numPC);
E = cellfun(@(e)e(1:pars.numPC,:),E,'UniformOutput',false);
Expand Down
4 changes: 3 additions & 1 deletion +metrics/+compute/arclength.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function [arclen,seglen] = arclength(px,py,varargin)
function [arclen,seglen,cumarclen] = arclength(px,py,varargin)
% arclength: compute arc length of a space curve, or any curve represented as a sequence of points
% usage: [arclen,seglen] = arclength(px,py) % a 2-d curve
% usage: [arclen,seglen] = arclength(px,py,pz) % a 3-d space curve
Expand Down Expand Up @@ -156,6 +156,7 @@
% compute the chordal linear arclengths
seglen = sqrt(sum(diff(data,[],1).^2,2));
arclen = sum(seglen);
cumarclen = cumsum(seglen);

% we can quit if the method was 'linear'.
if strcmpi(method,'linear')
Expand Down Expand Up @@ -209,6 +210,7 @@

% and sum the segments
arclen = sum(seglen);
cumarclen = cumsum(seglen);

% ==========================
% end main function
Expand Down
Loading