forked from evodevosys/AroSpotFindingSuite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
calculateRandStats.m
executable file
·39 lines (33 loc) · 1.49 KB
/
calculateRandStats.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
function [randStats,cumSumPrctiles]=calculateRandStats(dataMat_o)
%% ========================================================================
% Name: calculateRandStats.m
% Version: 2.5, 25th Apr. 2013
% Author: Allison Wu
% Command: [randStats,cumSumPrctiles]=calculateRandStats(dataMat_o)
% Description:
% - take in the m-by-7-by-7 dataMat matrix, which have m number of
% spots with 7x7 pixels.
% - calculate cumulative sum percentiles (cumSumPrctiles)
% - calculate the randStats which compare the cumSumPrctiles to
% cumSumPrctiles distribution from randomly generated 7x7 pixels.
%% ========================================================================
[m,n,z]=size(dataMat_o);
randTimes=1000;
pixNum=n*z;
bDataMat=rand(pixNum,randTimes);
rdPrctiles=prctile(cumsum(sort(bDataMat)),[90,70,50,30])';
randStats=zeros(m,5);
cumSumPrctiles=zeros(m,4);
if n==7 && z==7
for i=1:m
dataMat=dataMat_o(i,:,:);
dataMat=dataMat(:);
dataMat=(dataMat-min(dataMat))/(max(dataMat)-min(dataMat));
cumSumPrctiles(i,:)=prctile(cumsum(sort(dataMat)),[90,70,50,30]); % percentiles of cumulative sum of intensity
randStats(i,1)=mean(sum(bDataMat)>sum(dataMat)); % Total Area p-value
randStats(i,2:5)=mean(rdPrctiles>repmat(cumSumPrctiles(i,:),randTimes,1));% prctile p-value
end
else
fprintf('dataMat size is not 7x7. No bootstrap stats calcuated.')
end
end