Skip to content
Permalink
Browse files

Merge branch 'develop' of https://github.com/hcmlab/nova into develop

  • Loading branch information...
tobiasbaur committed Jun 11, 2019
2 parents dbeeab3 + 47e05d8 commit 501494b8ef0063ee950032fe14f9ed24e958c732
Showing with 70 additions and 0 deletions.
  1. +70 −0 Database/DatabaseAnnoMergeWindow.xaml.cs
@@ -990,6 +990,44 @@ private double SpearmanCorrelationMathNet(AnnoList xs, AnnoList ys)
return r;
}

private double ConcordanceCorrelationCoefficient(AnnoList xs, AnnoList ys)
{
double meanxs, meanys;
double variancexs, varianceys;
double covariance = 0;
double p;

int n = xs.Count() > ys.Count() ? ys.Count() : xs.Count();

double[] listx = new double[n];
double[] listy = new double[n];

for(int i = 0; i < n; i++)
{
if(!Double.IsNaN(xs[i].Score) && !Double.IsNaN(ys[i].Score))
{
listx[i] = xs[i].Score;
listy[i] = ys[i].Score;
}
}

meanxs = listx.Mean();
meanys = listy.Mean();

variancexs = listx.Variance();
varianceys = listy.Variance();

for (int i = 0; i < n; i++)
{
covariance = covariance + ((listx[i] - meanxs) * (listy[i] - meanys));
}
covariance = covariance / (n - 1);

p = (2 * covariance) / (variancexs + varianceys + Math.Pow((meanxs - meanys), 2));

return p;
}

private double Variance(double[] nums)
{
if (nums.Length > 1)
@@ -1259,6 +1297,17 @@ private async Task CalculateContinuousWrapper(List<AnnoList> annolists)
Stats.ToolTip = Stats.ToolTip + " | Spearman Correlation: " + interpretation;
}

double concordancecorrelation = double.MaxValue;
concordancecorrelation = ConcordanceCorrelationCoefficient(annolists[0], annolists[1]);

if (concordancecorrelation != double.MaxValue){

interpretation = CCCinterpretation(concordancecorrelation);

Stats.Content = Stats.Content + " | Concordance Correlation: " + concordancecorrelation.ToString("F3");
Stats.ToolTip = Stats.ToolTip + " | Concordance Correlation: " + interpretation;
}

double pearsoncorrelation = double.MaxValue;

pearsoncorrelation = PearsonCorrelationMathNet(annolists[0], annolists[1]);
@@ -1350,6 +1399,27 @@ private string Pearsoninterpretation(double r, int N)
return interpretation; // + " " + significance;
}

private string CCCinterpretation(double ccc)
{
string interpretation = "";

if(ccc < 0.9)
{
interpretation = "Poor";
} else if (ccc >= 0.9 && ccc < 0.95)
{
interpretation = "Moderate";
} else if(ccc >= 0.95 && ccc <= 0.99)
{
interpretation = "Substantial";
} else
{
interpretation = "Almost perfext";
}

return interpretation;
}

private string Spearmaninterpretation(double spearmancorrelation)
{
string interpretation = "";

0 comments on commit 501494b

Please sign in to comment.
You can’t perform that action at this time.