Skip to content

Commit 7c770dd

Browse files
authored
Merge pull request #189 from DigitalSlideArchive/guided-mode-bugs
Guided mode bugs
2 parents bfea426 + f551709 commit 7c770dd

File tree

2 files changed

+31
-16
lines changed

2 files changed

+31
-16
lines changed

wsi_superpixel_guided_labeling/web_client/views/vue/components/ActiveLearning/ActiveLearningFilmStrip.vue

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,19 @@ export default {
6464
},
6565
updateAll(usePrediction) {
6666
_.forEach(store.superpixelsToDisplay, (superpixel) => {
67-
// Account for missing "default" category in predictions
68-
const value = usePrediction ? superpixel.prediction + 1 : 0;
69-
superpixel.selectedCategory = value;
70-
updateMetadata(superpixel, value, false);
67+
let categoryIndex = 0;
68+
if (usePrediction) {
69+
// Try to match prediction category to label category
70+
const prediction = superpixel.predictionCategories[superpixel.prediction];
71+
const predictionCategory = prediction.label;
72+
categoryIndex = superpixel.labelCategories.findIndex((cat) => {
73+
return cat.label === predictionCategory;
74+
});
75+
}
76+
// Default to "no label" if no match found
77+
categoryIndex = categoryIndex === -1 ? 0 : categoryIndex;
78+
superpixel.selectedCategory = categoryIndex;
79+
updateMetadata(superpixel, categoryIndex, false);
7180
store.labelingChangeLog.push(superpixel);
7281
});
7382
},

wsi_superpixel_guided_labeling/web_client/views/vue/components/ActiveLearning/ActiveLearningFilmStripCard.vue

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import Vue from 'vue';
33
import _ from 'underscore';
44
55
import { store, nextCard } from '../store';
6-
import { updateMetadata } from '../utils';
6+
import { isValidNumber, updateMetadata } from '../utils';
77
88
export default Vue.extend({
99
props: ['index'],
@@ -51,7 +51,7 @@ export default Vue.extend({
5151
return `Certainty ${this.superpixelDecision.certainty.toFixed(5)}`;
5252
},
5353
validCategories() {
54-
const categories = this.superpixelDecision.labelCategories;
54+
const categories = store.categories;
5555
return _.filter(categories, (c) => !['default'].includes(c.label));
5656
},
5757
wsiRegionUrl() {
@@ -117,19 +117,25 @@ export default Vue.extend({
117117
store.labelingChangeLog.push(this.superpixelDecision);
118118
},
119119
lastCategorySelected(categoryNumber) {
120-
if (!this.isSelected || typeof categoryNumber !== 'number') {
120+
if (!this.isSelected || !isValidNumber(categoryNumber)) {
121121
return;
122122
}
123-
if (categoryNumber <= this.superpixelDecision.predictionCategories.length) {
124-
// Be extra careful to select the correct category
125-
const newCategory = store.categories[categoryNumber];
126-
const newCategoryIndex = this.categoryIndex(newCategory.label);
127-
this.superpixelDecision.selectedCategory = newCategoryIndex;
128-
this.$nextTick(() => {
129-
store.lastCategorySelected = null;
130-
nextCard();
131-
});
123+
124+
if (
125+
categoryNumber === 0 ||
126+
categoryNumber >= this.superpixelDecision.labelCategories.length
127+
) {
128+
// Be careful to select a valid category
129+
return;
132130
}
131+
132+
const newCategory = store.categories[categoryNumber];
133+
const newCategoryIndex = this.categoryIndex(newCategory.label);
134+
this.superpixelDecision.selectedCategory = newCategoryIndex;
135+
this.$nextTick(() => {
136+
store.lastCategorySelected = null;
137+
nextCard();
138+
});
133139
store.lastCategorySelected = null; // reset state
134140
}
135141
},

0 commit comments

Comments
 (0)