Browse Source

Changing extractCenters to layout with first column for region index; multiple entries can be made for a single region

Andrej Studen@Labkey-KNM 1 year ago
parent
commit
74028781c2
1 changed files with 8 additions and 6 deletions
  1. 8 6
      matlab/extractCenters.m

+ 8 - 6
matlab/extractCenters.m

@@ -8,9 +8,10 @@ function fcenters=extractCenters(data,v0,sigma2,na)
     [~,~,~,nd]=size(data);
     fcenters=zeros(nr,nd);
     na2=int8(0.5*(na+1));
-    for fi=1:nr
-        fs=0;
-        fv=v0(fi,:);%zero beased coordinates
+    fs=zeros(nr,1);
+    for vi=1:nr
+        fv=v0(vi,2:4);%zero beased coordinates
+        fi=v0(vi,1)
         idx0=int8(fv);
         idx=idx0;
         for i=1:na
@@ -23,11 +24,12 @@ function fcenters=extractCenters(data,v0,sigma2,na)
                     fd=df*df';
                     fw=exp(-0.5*fd/sigma2);
                     fcenters(fi,:)=fcenters(fi,:)+fw*reshape(data(idx(1)+1,idx(2)+1,idx(3)+1,:),1,[]);
-                    fs=fs+fw;
+                    fs(fi)=fs(fi)+fw;
                 end
             end
         end
-        fcenters(fi,:)=fcenters(fi,:)/fs;
+     end
+     qS=fs*ones(size(fcenters(1,:)));
+     fcenters=fcenters./qS;
 
-    end
 end