Skip to content

Commit

Permalink
Merge pull request #240 from OpenImaging/redesign_nn_results
Browse files Browse the repository at this point in the history
Invert negative results
  • Loading branch information
annehaley authored Dec 1, 2021
2 parents 6514c60 + 5615407 commit 9063bff
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 24 deletions.
46 changes: 23 additions & 23 deletions client/src/components/EvaluationResults.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,25 @@ export default {
},
computed: {
orderedResults() {
console.log(this.results);
return Object.entries(this.results).sort((first, second) => first[1] < second[1]);
},
},
methods: {
convertOverallQualityToColor(text = true) {
return this.convertValueToColor(1 - this.results.overall_quality, text);
},
convertValueToColor(value, text = true) {
const colors = [
'green darken-4',
'green darken-2',
'green lighten-1',
'light-green lighten-1',
'lime lighten-1',
'amber darken-1',
'orange lighten-1',
'orange darken-2',
'orange darken-4',
'red darken-2',
'red darken-4',
'black'];
'red darken-2',
'orange darken-4',
'orange darken-2',
'orange lighten-1',
'amber darken-1',
'lime lighten-1',
'light-green lighten-1',
'green lighten-1',
'green darken-2',
'green darken-4',
];
const thisColor = colors[Math.floor(Math.abs(value) * (colors.length - 1)) % colors.length];
if (text) {
return `font-weight-bold ${thisColor.replace(' ', '--text text--')}`;
Expand All @@ -43,7 +41,7 @@ export default {

<template>
<v-col
:class="convertValueToColor(1 - results.overall_quality)"
:class="convertValueToColor(results.overall_quality)"
cols="6"
style="text-align: right"
>
Expand Down Expand Up @@ -74,26 +72,26 @@ export default {
no-gutters
>
<v-col
cols="4"
cols="5"
align="right"
class="pr-3 font-weight-bold"
style="text-transform: capitalize"
>
Overall Quality
</v-col>
<v-col
cols="7"
cols="6"
class="pr-3"
>
<v-sheet
:color="convertOverallQualityToColor(text=false)"
:color="convertValueToColor(results.overall_quality, text=false)"
:width="(results.overall_quality *100)+'%'"
height="5"
class="mt-2"
/>
</v-col>
<v-col
:class="convertOverallQualityToColor()"
:class="convertValueToColor(results.overall_quality)"
cols="1"
>
{{ Math.round(results.overall_quality * 100) }}%
Expand All @@ -117,26 +115,28 @@ export default {
no-gutters
>
<v-col
cols="4"
cols="5"
align="right"
class="pr-3"
style="text-transform: capitalize"
>
{{ name.replace(/_/g, " ") }}
</v-col>
<v-col
cols="7"
cols="6"
class="pr-3"
>
<v-sheet
:color="convertValueToColor(value, text=false)"
:color="name=='normal_variants' ? 'black' :convertValueToColor(value, text=false)"
:width="(value * 100)+'%'"
height="5"
class="mt-2"
/>
</v-col>
<v-col
:class="convertValueToColor(value)"
:class="name=='normal_variants'
? 'font-weight-bold black--text'
:convertValueToColor(value)"
cols="1"
>
{{ Math.round(value * 100) }}%
Expand Down
11 changes: 10 additions & 1 deletion miqa/learning/nn_inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
'flow_artifact',
'truncation_artifact',
]
artifact_names = {
artifact: (artifact if artifact != 'susceptibility_metal' else 'metal_susceptibility')
for artifact in artifacts
}


class TiledClassifier(monai.networks.nets.Classifier):
Expand Down Expand Up @@ -156,7 +160,12 @@ def evaluate_model(model, data_loader, device, writer, epoch, run_name):
def label_results(result):
labeled_results = {'overall_quality': clamp(result[0] / 10.0, 0.0, 1.0)}
for artifact_name, value in zip(artifacts, result[regression_count:]):
labeled_results[artifact_name] = clamp(value, 0.0, 1.0)
result_name = artifact_names[artifact_name]
result_value = clamp(value, 0.0, 1.0)
if artifact_name not in ['normal_variants', 'full_brain_coverage']:
result_name = 'no_' + result_name
result_value = 1 - result_value
labeled_results[result_name] = result_value
return labeled_results


Expand Down

0 comments on commit 9063bff

Please sign in to comment.