Allow for constant log(dFC) across bins. i.e. all bins will contain (approximately) and equal number of datum points.
In other words binsize for the refence is adapted such that the number of points per bin is equal.
This commit is contained in:
parent
2274e88690
commit
3998755f40
20
CCREClass.m
20
CCREClass.m
@ -11,8 +11,11 @@ classdef CCREClass<CREClass
|
|||||||
end
|
end
|
||||||
properties
|
properties
|
||||||
DataRef %This parameter will contain the reference set.
|
DataRef %This parameter will contain the reference set.
|
||||||
nBinRef
|
nBinRef %number of "bins" to use for the reference distribution
|
||||||
CCRE %parameter containing the conditional Cumulative Residual Entropy
|
CCRE %parameter containing the conditional Cumulative Residual Entropy
|
||||||
|
EquidistantBinFlag=true; % set to true to get equidistant bins, set to false to get equi-content bins,
|
||||||
|
% if set to false: each bin will contain (aproximately) an equal
|
||||||
|
% number of pixel values.
|
||||||
end
|
end
|
||||||
|
|
||||||
methods %constructor
|
methods %constructor
|
||||||
@ -58,14 +61,21 @@ classdef CCREClass<CREClass
|
|||||||
if isempty(obj.DataRef);return;end %if no refdata given, return;
|
if isempty(obj.DataRef);return;end %if no refdata given, return;
|
||||||
%calculate histogram for RefData
|
%calculate histogram for RefData
|
||||||
EVarEpsDataGivenRef=0; %clear previous calculations
|
EVarEpsDataGivenRef=0; %clear previous calculations
|
||||||
[pDataRef,E]=histcounts(obj.DataRef(:),obj.nBinRef,'Normalization','probability');
|
if obj.EquidistantBinFlag
|
||||||
[JointHist,E1,E2]=histcounts2(obj.Data(:),obj.DataRef(:),[obj.nBin,obj.nBinRef],'Normalization','probability');
|
[pDataRef,E]=histcounts(obj.DataRef(:),obj.nBinRef,'Normalization','probability');
|
||||||
|
[JointHist,E1,E2]=histcounts2(obj.Data(:),obj.DataRef(:),[obj.nBin,obj.nBinRef],'Normalization','probability'); %obtain bin edges for Target
|
||||||
|
else
|
||||||
|
prc=linspace(0,100,obj.nBinRef+1); % define the edges of the bins as a precentile
|
||||||
|
Edges=prctile(obj.DataRef(:),prc);
|
||||||
|
[pDataRef,E]=histcounts(obj.DataRef(:),Edges,'Normalization','probability');
|
||||||
|
[JointHist,E1,E2]=histcounts2(obj.Data(:),obj.DataRef(:),[obj.nBin,obj.nBinRef],'Normalization','probability'); %obtain bin edges for Target
|
||||||
|
end
|
||||||
for k=1:numel(pDataRef) %loop over the bins in pDataRef NB: must be equal to the bins in JointHist for the Ref
|
for k=1:numel(pDataRef) %loop over the bins in pDataRef NB: must be equal to the bins in JointHist for the Ref
|
||||||
if pDataRef(k)==0;continue;end% if no data at this line go to the next
|
if pDataRef(k)==0;continue;end% if no data at this line go to the next
|
||||||
ind=E(k)<=obj.DataRef(:)&obj.DataRef(:)<E(k+1);
|
ind=E(k)<=obj.DataRef(:)&obj.DataRef(:)<E(k+1); %get an index to all points in Ref data inside the current bin
|
||||||
CRE_DataGivenDataRef=CREClass;
|
CRE_DataGivenDataRef=CREClass;
|
||||||
CRE_DataGivenDataRef.Data=obj.Data(ind);
|
CRE_DataGivenDataRef.Data=obj.Data(ind);
|
||||||
CRE_DataGivenDataRef.nBin=E1;
|
CRE_DataGivenDataRef.nBin=E1; %force the same bin definition for all itterations. This value is ignored if UseHistProxy is set to false
|
||||||
CRE_DataGivenDataRef.Calc;
|
CRE_DataGivenDataRef.Calc;
|
||||||
EVarEpsDataGivenRef=EVarEpsDataGivenRef+pDataRef(k)*CRE_DataGivenDataRef.CRE; % I really have to check this line on merit.
|
EVarEpsDataGivenRef=EVarEpsDataGivenRef+pDataRef(k)*CRE_DataGivenDataRef.CRE; % I really have to check this line on merit.
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user