=1, integer only, corresponds to the total number of bases. % We found that P = 3 is usually sufficient for a patch with area less % than 1000 mm2. % % output: An [NxM] matrix U, where the M columns of U are the spatial basis vectors % (M = P if P is an integer >= 1) % % Author: Tulaya Limpiti % last updated: 5/25/2009 function U = SpatialBasesGen(ForwardSoln,PatchID,P) % find dipoles that belong to the patch dipoleLoc = find(PatchID); % concatenate all relevant dipole forward solutions if (length(size(ForwardSoln)) == 2) % [Nx1] forward solution with known moment Hr = ForwardSoln(:,dipoleLoc); elseif (length(size(ForwardSoln)) == 3) % [Nx2] or [Nx3] forward solution with fixed but unknown moment Htmp = ForwardSoln(dipoleLoc,:,:); Hr = squeeze(Htmp(1,:,:)); if (length(dipoleLoc) >1) for i = 2:length(dipoleLoc) Hr = [Hr, squeeze(Htmp(i,:,:))]; end end clear Htmp end % construct spatial bases [Uf,U,Uorth,Sr,Vr,Pr] = rnkreduce(Hr,P); clear Sr Vr Uorth Uf