From 12b0e964beff0959f61edc0ba4425be8a257b83c Mon Sep 17 00:00:00 2001 From: lcparra Date: Wed, 16 Oct 2019 13:38:17 -0400 Subject: [PATCH 1/2] Update nanRXY.m this version is more memory efficient, which is important for long data records or high sampling rates. --- nanRXY.m | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/nanRXY.m b/nanRXY.m index 00a52ea..68cf63f 100644 --- a/nanRXY.m +++ b/nanRXY.m @@ -1,15 +1,7 @@ function [Rxy,Rxx,Ryy,Ryx] = nanRXY(X,Y) -D=size(X,1); -RXY=nancov([X.' Y.'],'pairwise'); -Rxx=RXY(1:D,1:D); -Ryy=RXY(D+1:end,D+1:end); -Rxy=RXY(1:D,D+1:end); -if nargout==4, Ryx=RXY(D+1:end,1:D); end - -% D=size(X,1); -% RXY=nancov([X.' Y.'],'pairwise'); -% Rxx1=RXY(1:D,1:D); -% Rxx2=RXY(2*D+1:3*D,2*D+1:3*D); -% -% Ryy=RXY(D+1:2*D,D+1:); -% Rxy=RXY(1:D,D+1:end); \ No newline at end of file +% [Rxy,Rxx,Ryy,Ryx] = nanRXY(X,Y) computes covariance matrixes taking NaN into account. +% Assumes X and Y are organized as samples by channels. +Rxx=nancov(X,'pairwise'); +Ryy=nancov(Y,'pairwise'); +for i=1:size(X,2), for j=1:size(Y,2), c=nancov(X(:,i),Y(:,i)); Rxy(i,j)=c(1,2); end; end; +if nargout==4, Ryx=Rxy'; end From 58d32e4c1f78ddf01fd0ffbb42d7743ac7507829 Mon Sep 17 00:00:00 2001 From: lcparra Date: Wed, 16 Oct 2019 13:57:05 -0400 Subject: [PATCH 2/2] Update nanRXY.m Had to make it match to the channels by samples structure of the rest of the code. Should ultimately be changed as it is less efficient the way it currently is. --- nanRXY.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nanRXY.m b/nanRXY.m index 68cf63f..74971ce 100644 --- a/nanRXY.m +++ b/nanRXY.m @@ -1,6 +1,6 @@ function [Rxy,Rxx,Ryy,Ryx] = nanRXY(X,Y) % [Rxy,Rxx,Ryy,Ryx] = nanRXY(X,Y) computes covariance matrixes taking NaN into account. -% Assumes X and Y are organized as samples by channels. +X = X.'; Y = Y.'; % this just because the rest of the doce assumes it this way. Rxx=nancov(X,'pairwise'); Ryy=nancov(Y,'pairwise'); for i=1:size(X,2), for j=1:size(Y,2), c=nancov(X(:,i),Y(:,i)); Rxy(i,j)=c(1,2); end; end;