Skip to content

Commit

Permalink
scripts to generate figures, fig. 5 (top), supp. fig. (algofig)
Browse files Browse the repository at this point in the history
  • Loading branch information
evadyer committed Jul 26, 2016
1 parent 75a2cad commit e901439
Show file tree
Hide file tree
Showing 11 changed files with 89 additions and 6 deletions.
Binary file added code/celldetect/data/traindata-celldetect-V1.mat
Binary file not shown.
File renamed without changes.
8 changes: 8 additions & 0 deletions code/spatialstats/norms.m
@@ -0,0 +1,8 @@
function [Xn,nmz] = norms(X)

% normalize the columns of X
nmz = sqrt(sum(X.^2));
Xn = X./repmat(nmz,size(X,1),1);


end
61 changes: 61 additions & 0 deletions code/spatialstats/script_fig5.m
@@ -0,0 +1,61 @@
% script_fig5
% creates top panel of Figure 5

load('finalresults-cell2vesseldist.mat')
load('centroids_rfr1.mat')

dist_vessel = nndist; clear nndist
out = knnsearch(Centroids(:,1:3),Centroids(:,1:3),'K',2);
nncell = out(:,2)';
dist_cell = sqrt(sum(((Centroids(:,1:3)-Centroids(nncell,1:3))').^2))';

% compute cell density (nn approach)
k=5; % dvec = cell density estimates over volume
[pout,pts,volvox,dvec,numvox] = knndensityest(Centroids(:,1:3),k);

%%
figure;
subplot(131);
hist(dvec,linspace(0,6e5))
axis tight
title('Distribution of cell density over volume')
xlabel('cell density (x 10^5 cells/cubic mm)')
ylabel('counts')

subplot(132);
hist(dist_cell*0.65,linspace(0,140,100))
axis tight
title('Distances from cell centers to closest cell center')
xlabel('cubic microns')
ylabel('neurons')


subplot(133);
hist(dist_vessel*0.65,linspace(0,140,100))
axis tight
title('Distances from cell centers to closest vessel voxel')
xlabel('cubic microns')
ylabel('neurons')

sample_stats.celldensity_mean = mean(dvec);
sample_stats.celldensity_var = var(dvec);

sample_stats.ccdist_mean = mean(dist_cell);
sample_stats.ccdist_var = var(dist_cell);

sample_stats.cvdist_mean = mean(dist_vessel);
sample_stats.cvdist_var = var(dist_vessel);

sample_stats.totstats = [mean(dvec),var(dvec),mean(dist_cell), var(dist_cell), mean(dist_vessel),var(dist_vessel)];


%%
% visualize density
figure;
for i=1:size(pout,3);
imagesc(log(pout(:,:,i)),[min(log(pout(:))),max(log(pout(:)))]),
pause,
end



10 changes: 6 additions & 4 deletions code/spatialstats/script_stats_fig4.m
@@ -1,4 +1,6 @@
%

load('centroids_rfr1.mat') % in /xbrain/results
load('traindata-celldetect-V1.mat') % /xbrain/data/groundtruth/V1

id1 = find((Centroids(:,4)<0.9).*(Centroids(:,4)>=0.7));
id2 = find((Centroids(:,4)<0.7).*(Centroids(:,4)>=0.5));
Expand Down Expand Up @@ -31,9 +33,9 @@
x0 = [x0; [xx1(:), yy1(:), zz1(:)]];

clear C1
C1(:,1) = Centroids_ed0(1,:)+xmin;
C1(:,2) = Centroids_ed0(2,:)+ymin;
C1(:,3) = Centroids_ed0(3,:)+zmin;
C1(:,1) = Centroids_gt(1,:)+xmin;
C1(:,2) = Centroids_gt(2,:)+ymin;
C1(:,3) = Centroids_gt(3,:)+zmin;

%%

Expand Down
16 changes: 14 additions & 2 deletions code/spatialstats/script_statsnviz.m
Expand Up @@ -3,7 +3,7 @@
minsz = 500; % minimum number of voxels for conn comps (set rest to zero)

%% Load nii file (with segmentation)
Gt = load_nii('proj4_x1351-1650_y1851-2150_z395-495_r0_cube1_eva5.nii');
Gt = load_nii('proj4_x1351-1650_y1851-2150_z395-495_r0_cube1_anno_eva8.nii');

% neuron and vessel segmentation
Nmap = (Gt.img==1);
Expand All @@ -16,11 +16,23 @@
% (3) distance from centroid of cell to closest vessel
% (4)

Results = computedensitystats(Nmap,Vmap,minsz,erodesz,maxdist);
maxdist=10;
Results = computedensitystats(Nmap,Vmap,maxdist);

corr = visualizecorrelations(Results);


%%








%% this part isnt working.

% cluster cells based upon their size
labels = kmeans(numvox_nb,numclust);
[val,id] = sort(labels);
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added results/distcell2vessel.mat
Binary file not shown.
Binary file added results/finalresults-cell2vesseldist.mat
Binary file not shown.

0 comments on commit e901439

Please sign in to comment.