annotate rDiff/src/tests/rDiff_nonparametric.m @ 2:233c30f91d66

updated python based GFF parsing module which will handle GTF/GFF/GFF3 file types
author vipints <vipin@cbio.mskcc.org>
date Tue, 08 Oct 2013 07:15:44 -0400
parents 0f80a5141704
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
1 function [pval,info] = rDiff_nonparametric(CFG,READS1,READS2,variance_function_nonparametric_1, variance_function_nonparametric_2)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
2
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
3 bootstraps=CFG.bootstraps;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
4
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
5 %Initizialize the reads
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
6 SUMS1=[]; %the readcoverage for sample 1
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
7 SUMS2=[]; %the readcoverage for sample 2
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
8 reads1=[]; %the total of reads in sample 1
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
9 reads2=[]; %the total of reads in sample 2
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
10 NON_EMPTY=[];
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
11 for i=1:length(READS1)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
12 if not(isempty(READS1{i}))
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
13 NON_EMPTY=[NON_EMPTY,i];
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
14 end
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
15 end
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
16 READS1={READS1{ NON_EMPTY}};
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
17 NON_EMPTY=[];
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
18 for i=1:length(READS2)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
19 if not(isempty(READS2{i}))
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
20 NON_EMPTY=[NON_EMPTY,i];
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
21 end
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
22 end
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
23 READS2={READS2{NON_EMPTY}};
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
24 for i=1:length(READS1)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
25 SUMS1=[SUMS1;sum(READS1{i},1)];
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
26 reads1=[reads1;READS1{i}];
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
27 end
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
28 for i=1:length(READS2)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
29 SUMS2=[SUMS2;sum(READS2{i},1)];
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
30 reads2=[reads2;READS2{i}];
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
31 end
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
32
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
33 if size(reads1,1)==0 || size(reads2,1)==0
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
34 pval=1;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
35 info=1;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
36 bootstrap_results=1;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
37 statistic=1;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
38 return
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
39 end
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
40
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
41
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
42 %Get masks for the highly covered positions
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
43 [MASKS]=get_nonparametric_masks(CFG,reads1,reads2);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
44
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
45
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
46 %Determine number of masks
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
47 NR_OF_MASKS=size(MASKS,1);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
48
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
49 % Predict variance
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
50 VARIANCE1=(1e-8)*ones(size(reads1,2),1);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
51 for i=1:length(READS1)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
52 TEMP_VARIANCE1=predict_variance(sum(READS1{i},1)',variance_function_nonparametric_1);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
53 TEMP_VARIANCE1(isnan(TEMP_VARIANCE1))=0;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
54 TEMP_VARIANCE1(isinf(TEMP_VARIANCE1))=0;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
55 VARIANCE1=VARIANCE1+TEMP_VARIANCE1;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
56 end
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
57
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
58 VARIANCE2=(1e-8)*ones(size(reads1,2),1);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
59 for i=1:length(READS2)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
60 TEMP_VARIANCE2=predict_variance(sum(READS2{i},1)',variance_function_nonparametric_2);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
61 TEMP_VARIANCE2(isnan(TEMP_VARIANCE2))=0;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
62 TEMP_VARIANCE2(isinf(TEMP_VARIANCE2))=0;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
63 VARIANCE2=VARIANCE2+TEMP_VARIANCE2;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
64 end
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
65
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
66 %Get the mean variance
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
67 VARIANCE1=VARIANCE1/length(READS1);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
68 VARIANCE2=VARIANCE2/length(READS2);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
69
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
70 %Concatenation of all reads
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
71 allreads = [reads1;reads2];
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
72
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
73
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
74 %Determine the subsampling rate
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
75 p=sum(allreads,1)/size(allreads,1);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
76 R=size(reads1,1);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
77 c=(p.*(1-p))/(size(allreads,1)-1);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
78 N1s=size(allreads,1)*c./(c+(VARIANCE1'/(R^2)));
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
79
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
80 p=sum(allreads,1)/size(allreads,1);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
81 R=size(reads2,1);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
82 c=(p.*(1-p))/(size(allreads,1)-1);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
83 N2s=size(allreads,1)*c./(c+(VARIANCE2'/(R^2)));
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
84
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
85 %Round to get integer values
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
86 N1s=ceil(full(N1s));
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
87 N2s=ceil(full(N2s));
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
88
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
89
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
90 %Total number of reads in each replicate
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
91 N1 = size(reads1,1);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
92 N2 = size(reads2,1);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
93 N = N1 + N2;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
94
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
95
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
96 bootstrap_results=ones(NR_OF_MASKS,bootstraps);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
97 COUNTER=0;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
98 R1s=[];
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
99 R2s=[];
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
100 statistic=ones(NR_OF_MASKS,bootstraps);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
101 nr_of_slices=CFG.nr_of_slices;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
102
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
103 TOTAL_SUM1=sum(reads1,1);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
104 TOTAL_SUM2=sum(reads2,1);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
105 TOTAL_SUM=TOTAL_SUM1+TOTAL_SUM2;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
106
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
107 clear reads1
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
108 clear reads2
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
109 %Use the transpose to make the selection of columms faster
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
110 all_reads_trans=allreads';
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
111 clear allreads
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
112 if length(unique(TOTAL_SUM))<nr_of_slices+5
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
113 pval=1;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
114 bootstrap_results=[];
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
115 statistic=[];
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
116 pval=1;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
117 info = 1;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
118 return
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
119 end
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
120
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
121 [SUM_SORTED,SUM_POS]=sort(TOTAL_SUM);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
122 NR_OF_ZEROS=sum(TOTAL_SUM==0);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
123
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
124 %precompute this sum once
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
125 all_reads_trans_row_sum=sum(all_reads_trans,1);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
126
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
127 %These field contain
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
128 STAT_DIST=zeros(NR_OF_MASKS,nr_of_slices);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
129 TEMP_DIST=zeros(1,nr_of_slices);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
130
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
131 %Precompute normalizing constants
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
132 SUM_TOTAL_SUM1=sum(TOTAL_SUM1);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
133 SUM_TOTAL_SUM2=sum(TOTAL_SUM2);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
134 SUM_SUM_TOTAL_SUM=SUM_TOTAL_SUM1+SUM_TOTAL_SUM2;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
135
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
136 %Precompute the some of the values or the slices
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
137 SLICES=zeros(nr_of_slices,size(TOTAL_SUM,2))==1;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
138 N1_arr=zeros(nr_of_slices,1);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
139 N2_arr=zeros(nr_of_slices,1);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
140 FACT_arr=zeros(nr_of_slices,1);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
141 V1_cell=cell(nr_of_slices,1);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
142 V2_cell=cell(nr_of_slices,1);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
143
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
144 %Detemine regions wher to match the variances
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
145 for s=nr_of_slices:(-1):1
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
146 LOWER_POS=min(NR_OF_ZEROS+ceil(((nr_of_slices-s)/nr_of_slices)*(length(TOTAL_SUM)-NR_OF_ZEROS))+1,length(TOTAL_SUM));
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
147 UPPER_POS=min(NR_OF_ZEROS+ceil(((nr_of_slices-s+1)/nr_of_slices)*(length(TOTAL_SUM)-NR_OF_ZEROS))+1,length(TOTAL_SUM));
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
148
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
149 SLICE_LOWER_BOUND=SUM_SORTED(LOWER_POS);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
150 SLICE_UPPER_BOUND=SUM_SORTED(UPPER_POS);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
151 if s==nr_of_slices
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
152 SLICE=and(TOTAL_SUM>=SLICE_LOWER_BOUND,TOTAL_SUM<=SLICE_UPPER_BOUND);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
153 else
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
154 SLICE=and(TOTAL_SUM>SLICE_LOWER_BOUND,TOTAL_SUM<=SLICE_UPPER_BOUND);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
155 end
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
156 SLICES(s,:)=SLICE;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
157
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
158 N1s_temp=ceil(median(N1s(SLICE)));
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
159 N2s_temp=ceil(median(N2s(SLICE)));
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
160 N1s_temp=min(N1s_temp,N1);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
161 N2s_temp=min(N2s_temp,N2);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
162
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
163 N1_arr(s)=N1s_temp;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
164 N2_arr(s)=N2s_temp;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
165
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
166 FACT_arr(s)=sum(TOTAL_SUM1(SLICE)+TOTAL_SUM2(SLICE))/(SUM_SUM_TOTAL_SUM);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
167
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
168 V1_cell{s}=TOTAL_SUM1(SLICE)/SUM_TOTAL_SUM1;%temporary variable to safe time
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
169 V2_cell{s}=TOTAL_SUM2(SLICE)/SUM_TOTAL_SUM2;%temporary variable to safe time
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
170 for mask_ix=1:NR_OF_MASKS
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
171 STAT_DIST(mask_ix,s)=eucl_dist_weigthed(V1_cell{s},V2_cell{s},MASKS(mask_ix,SLICES(s,:)));
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
172 end
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
173 end
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
174 SUM_SLICES=sum(SLICES,2);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
175 STAT_DIST(isnan(TEMP_DIST))=0;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
176 all_reads_trans_slices=cell(nr_of_slices,1);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
177 for s=nr_of_slices:(-1):1
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
178 all_reads_trans_slices{s}=all_reads_trans(SLICES(s,:),:);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
179 end
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
180
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
181 for i = 1:bootstraps
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
182 % permutation of the reads
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
183 read_per = randperm(N);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
184
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
185 %Peform the computation for each region where the variances are matched
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
186 for s=nr_of_slices:(-1):1
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
187 if SUM_SLICES(s)==0;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
188 continue;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
189 end
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
190 %Create random samples 1 and 2
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
191 sample1 = sum(all_reads_trans_slices{s}(:,read_per(1:N1_arr(s))),2);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
192 sample2 = sum(all_reads_trans_slices{s}(:,read_per((N1_arr(s)+1):(N1_arr(s)+N2_arr(s)))),2);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
193
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
194 W1=sample1/sum(sample1)*FACT_arr(s);%temporary variable to safe time
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
195 W2=sample2/sum(sample2)*FACT_arr(s);%temporary variable to safe time
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
196
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
197 for mask_ix=1:NR_OF_MASKS
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
198 TEMP_DIST(mask_ix,s)=eucl_dist_weigthed(W1,W2,MASKS(mask_ix,SLICES(s,:))');
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
199 end
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
200
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
201 end
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
202
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
203 %make sure the normalisation doe not intruduces nan's
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
204 TEMP_DIST(isnan(TEMP_DIST))=0;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
205
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
206 COUNTER=COUNTER+1;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
207 %Compute the average from the different matching regionon
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
208 statistic(:,COUNTER)=mean(STAT_DIST,2);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
209 bootstrap_results(:,COUNTER)=mean(TEMP_DIST,2);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
210 end
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
211
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
212 bootstrap_results=bootstrap_results(:,1:COUNTER);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
213 statistic=statistic(:,1:COUNTER);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
214
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
215 pval=double(sum(bootstrap_results>=statistic,2)) / COUNTER;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
216
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
217 info = {bootstrap_results,statistic,pval};
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
218 pval=min(pval)*10;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
219
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
220 function result = eucl_dist_weigthed(A,B,W)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
221
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
222 result = sqrt(sum( W.*((A - B) .^ 2) ));