Commit 31c9a56991cbf81e615d5b43e79a1e0b99394e6b
1 parent
06a58254
plotLandmarking working with multiple csvs, added labels to examples
Showing
1 changed file
with
18 additions
and
12 deletions
openbr/core/plot.cpp
| @@ -542,26 +542,32 @@ bool PlotLandmarking(const QStringList &files, const File &destination, bool sho | @@ -542,26 +542,32 @@ bool PlotLandmarking(const QStringList &files, const File &destination, bool sho | ||
| 542 | "}\n"))); | 542 | "}\n"))); |
| 543 | 543 | ||
| 544 | p.file.write(qPrintable(QString("\nsample <- readData(Sample) \n" | 544 | p.file.write(qPrintable(QString("\nsample <- readData(Sample) \n" |
| 545 | + "rows <- sample[[1]]$value\n" | ||
| 546 | + "algs <- unique(Box$%1)\n" | ||
| 547 | + "algs <- algs[!duplicated(algs)]\n" | ||
| 545 | "print(plotImage(sample[[1]],\"Sample Landmarks\",sprintf(\"Total Landmarks: %s\",sample[[1]]$value))) \n" | 548 | "print(plotImage(sample[[1]],\"Sample Landmarks\",sprintf(\"Total Landmarks: %s\",sample[[1]]$value))) \n" |
| 546 | - "truthSample <- readData(EXT)\n" | ||
| 547 | - "predictedSample <- readData(EXP)\n" | ||
| 548 | - "for (i in 1:length(predictedSample)) {\n" | ||
| 549 | - "\tmultiplot(plotImage(predictedSample[[i]],\"Predicted Landmarks\",sprintf(\"Average Landmark Error: %.3f\",predictedSample[[i]]$value)),plotImage(truthSample[[i]],\"Ground Truth Landmarks\",\"\"),cols=2)\n" | ||
| 550 | - "}\n"))); | 549 | + "for (j in 1:length(algs)) {\n" |
| 550 | + "truthSample <- readData(EXT[EXT$. == algs[[j]],])\n" | ||
| 551 | + "predictedSample <- readData(EXP[EXP$. == algs[[j]],])\n" | ||
| 552 | + "\tfor (i in 1:length(predictedSample)) {\n" | ||
| 553 | + "\t\tmultiplot(plotImage(predictedSample[[i]],sprintf(\"%s\\nPredicted Landmarks\",algs[[j]]),sprintf(\"Average Landmark Error: %.3f\",predictedSample[[i]]$value)),plotImage(truthSample[[i]],\"Ground Truth\\nLandmarks\",\"\"),cols=2)\n" | ||
| 554 | + "\t}\n" | ||
| 555 | + "}\n").arg(p.major.size > 1 ? p.major.header : (p.minor.header.isEmpty() ? p.major.header : p.minor.header)))); | ||
| 551 | 556 | ||
| 552 | p.file.write(qPrintable(QString("\n" | 557 | p.file.write(qPrintable(QString("\n" |
| 553 | "# Code to format error table\n" | 558 | "# Code to format error table\n" |
| 554 | - "StatBox <- summarySE(Box, measurevar=\"Y\", groupvars=c(\"X\"))\n\t" | ||
| 555 | - "OverallStatBox <- summarySE(Box, measurevar=\"Y\")\n" | ||
| 556 | - "mat <- matrix(paste(as.character(round(StatBox$Y, 3)), round(StatBox$ci, 3), sep=\" \\u00b1 \"),nrow=nrow(StatBox),ncol=1,byrow=TRUE)\n" | 559 | + "StatBox <- summarySE(Box, measurevar=\"Y\", groupvars=c(\"%1\",\"X\"))\n" |
| 560 | + "OverallStatBox <- summarySE(Box, measurevar=\"Y\", groupvars=c(\"%1\"))\n" | ||
| 561 | + "mat <- matrix(paste(as.character(round(StatBox$Y, 3)), round(StatBox$ci, 3), sep=\" \\u00b1 \"),nrow=rows,ncol=length(algs),byrow=FALSE)\n" | ||
| 557 | "mat <- rbind(mat, paste(as.character(round(OverallStatBox$Y, 3)), round(OverallStatBox$ci, 3), sep=\" \\u00b1 \"))\n" | 562 | "mat <- rbind(mat, paste(as.character(round(OverallStatBox$Y, 3)), round(OverallStatBox$ci, 3), sep=\" \\u00b1 \"))\n" |
| 558 | - "colnames(mat) <- c(\"Error Rate\")\n" | ||
| 559 | - "rownames(mat) <- c(seq(0,nrow(StatBox)-1),\"Aggregate\")\n" | ||
| 560 | - "ETable <- as.table(mat)\n"))); | 563 | + "mat <- rbind(mat, as.character(round(NormLength$Y, 3)))\n" |
| 564 | + "colnames(mat) <- algs\n" | ||
| 565 | + "rownames(mat) <- c(seq(0,rows-1),\"Aggregate\",\"Average IPD\")\n" | ||
| 566 | + "ETable <- as.table(mat)\n").arg(p.major.size > 1 ? p.major.header : (p.minor.header.isEmpty() ? p.major.header : p.minor.header)))); | ||
| 561 | 567 | ||
| 562 | p.file.write(qPrintable(QString("\n" | 568 | p.file.write(qPrintable(QString("\n" |
| 563 | "print(textplot(ETable))\n" | 569 | "print(textplot(ETable))\n" |
| 564 | - "print(title(sprintf(\"Landmark Error Rates\\nAverage Normalization Distance: %.3f (pixels)\",NormLength$Y)))\n"))); | 570 | + "print(title(\"Landmarking Error Rates\"))\n"))); |
| 565 | 571 | ||
| 566 | p.file.write(qPrintable(QString("ggplot(Box, aes(Y,%1%2))").arg(p.major.size > 1 ? QString(", colour=%1").arg(p.major.header) : QString(), | 572 | p.file.write(qPrintable(QString("ggplot(Box, aes(Y,%1%2))").arg(p.major.size > 1 ? QString(", colour=%1").arg(p.major.header) : QString(), |
| 567 | p.minor.size > 1 ? QString(", linetype=%1").arg(p.minor.header) : QString()) + | 573 | p.minor.size > 1 ? QString(", linetype=%1").arg(p.minor.header) : QString()) + |