Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Phase I learning code to latest master #54

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"vue": "^2.6.10",
"vue-async-computed": "^3.5.1",
"vue-router": "3.4.3",
"vuetify": "^2.3.7",
"vuetify": "2.3.22",
"vue-google-charts": "0.3.3",
"vuex": "^3.0.1"
},
"devDependencies": {
Expand Down
85 changes: 81 additions & 4 deletions client/src/components/DataImportExport.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@ import { mapActions } from "vuex";
export default {
name: "DataImportExport",
components: {},
inject: ["girderRest"],
inject: ["girderRest", "notificationBus"],
data: () => ({
importEnabled: false,
exportEnabled: false,
importing: false,
importDialog: false
importDialog: false,
reevaluateDialog: false,
reevaluating: false,
learningMode: "randomForest"
}),
async created() {
var { data: result } = await this.girderRest.get(
Expand All @@ -18,16 +21,33 @@ export default {
this.importEnabled = result.import;
this.exportEnabled = result.export;
},
mounted() {
this.notificationBus.$on(
"message:miqa.learning_with_data",
this.learningFinished
);
},
beforeDestroy() {
this.notificationBus.$off(
"message:miqa.learning_with_data",
this.learningFinished
);
},
methods: {
...mapActions(["loadSessions"]),
async importData() {
this.importing = true;
try {
var { data: result } = await this.girderRest.post("miqa/data/import");
this.importing = false;
let msg = "";
if (result.error) {
msg = `Import failed: ${result.error}`;
} else {
msg = `Import finished with ${result.success} scans imported and ${result.failed} failed.`;
}
this.$snackbar({
text: `Import finished.
With ${result.success} scans succeeded and ${result.failed} failed.`,
text: msg,
timeout: 6000
});
this.loadSessions();
Expand All @@ -47,6 +67,20 @@ export default {
text: "Saved data to json file successfully.",
positiveButton: "Ok"
});
},
reevaluate() {
this.reevaluating = true;
this.girderRest.post(`/learning/retrain_with_data/${this.learningMode}`);
},
learningFinished(a) {
this.reevaluating = false;
this.reevaluateDialog = false;
this.loadSessions();
this.$prompt({
title: "Re-evaluate",
text: "Re-evaluate successfully",
positiveButton: "Ok"
});
}
}
};
Expand All @@ -64,6 +98,13 @@ export default {
<v-btn text color="primary" @click="exportData" :disabled="!exportEnabled"
>Export</v-btn
>
<v-btn
text
color="primary"
@click="reevaluateDialog = true"
:disabled="!exportEnabled"
>Retrain</v-btn
>
<v-dialog v-model="importDialog" width="500" :persistent="importing">
<v-card>
<v-card-title class="title">
Expand All @@ -84,6 +125,42 @@ export default {
</v-card-actions>
</v-card>
</v-dialog>
<v-dialog v-model="reevaluateDialog" width="500" :persistent="reevaluating">
<v-card>
<v-card-title class="title">
Re-evaluate
</v-card-title>
<v-card-text>
This will update the learning model with values of all current
sessions and reevaluate current unmarked sessions
<v-container fluid>
<v-radio-group v-model="learningMode" row>
<v-radio
label="Random Forest Classifier"
value="randomForest"
></v-radio>
<v-radio
label="Neural Network Classifier"
value="neuralNetwork"
></v-radio>
</v-radio-group>
</v-container>
</v-card-text>
<v-card-actions>
<v-spacer></v-spacer>
<v-btn text @click="reevaluateDialog = false" :disabled="reevaluating"
>Cancel</v-btn
>
<v-btn
text
color="primary"
@click="reevaluate"
:loading="reevaluating"
>Re-evaluate</v-btn
>
</v-card-actions>
</v-card>
</v-dialog>
</div>
</template>

Expand Down
98 changes: 98 additions & 0 deletions client/src/components/MetricsDisplay.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
<script>
import iqmMeta from "../utils/iqmMeta";

export default {
name: "MetricsDisplay",
props: {
iqm: {
type: Array,
required: true
},
goodProb: {
type: Number,
required: false
}
},
data() {
return {
selectedMetric: Object.keys(iqmMeta)[0]
};
},
computed: {
iqmMeta: () => iqmMeta,
selectItems() {
return this.iqm.map(metric => {
var key = Object.keys(metric)[0];
return {
value: key,
text: iqmMeta[key].display
};
});
},
values() {
if (!this.selectedMetric) {
return [];
}
var metric = this.iqm.find(metric => metric[this.selectedMetric]);
var value = metric[this.selectedMetric];
if (!Array.isArray(value)) {
return [
{
key: this.selectedMetric,
value
}
];
} else {
return value.map(subValueObject => {
var sub = Object.keys(subValueObject)[0];
return {
key: sub,
value: subValueObject[sub]
};
});
}
}
}
};
</script>

<template>
<v-card width="400">
<v-card-title class="subheading pb-2">
Metrics
</v-card-title>
<v-card-text class="pt-0">
<v-container fluid class="pa-0" grid-list-md>
<v-layout v-if="goodProb">
Good probability<span
class="ml-1"
:style="{ color: goodProb > 0.5 ? 'green' : 'red' }"
>{{ goodProb.toFixed(2) }}</span
>
</v-layout>
<v-layout>
<v-flex style="width: 250px;" shrink>
<v-select
v-model="selectedMetric"
:items="selectItems"
:hint="iqmMeta[selectedMetric].fullname"
persistent-hint
/>
</v-flex>
</v-layout>
<v-layout>
<v-flex>
<ul>
<li v-for="({ key, value }, i) of values" :key="i">
{{ key }}: {{ value }}
</li>
</ul>
</v-flex>
</v-layout>
<v-layout v-if="selectedMetric">
<v-flex v-html="iqmMeta[selectedMetric].description"> </v-flex>
</v-layout>
</v-container>
</v-card-text>
</v-card>
</template>
4 changes: 4 additions & 0 deletions client/src/components/NavigationTabs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ export default {
<v-icon>view_column</v-icon>
Sessions
</v-tab>
<v-tab to="/metrics">
<v-icon>bar_chart</v-icon>
Metrics
</v-tab>
<v-tab to="/settings" v-if="userLevel.value === 0">
<v-icon>settings</v-icon>
Settings
Expand Down
5 changes: 4 additions & 1 deletion client/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import App from "./App.vue";
import router from "./router";
import store from "./store";
import Girder, { RestClient, utils } from "@girder/components/src";
import NotificationBus from "@girder/components/src/utils/notifications";
import { API_URL, STATIC_PATH } from "./constants";

import vMousetrap from "./vue-utilities/v-mousetrap";
Expand All @@ -34,6 +35,8 @@ Vue.use(snackbarService(vuetify));
Vue.use(promptService(vuetify));

girder.rest = new RestClient({ apiRoot: API_URL });
const notificationBus = new NotificationBus(girder.rest);
notificationBus.connect();

import config from "itk/itkConfig";
config.itkModulesPath = STATIC_PATH + config.itkModulesPath;
Expand All @@ -49,7 +52,7 @@ girder.rest.fetchUser().then(() => {
router,
store,
render: h => h(App),
provide: { girderRest: girder.rest }
provide: { girderRest: girder.rest, notificationBus }
})
.$mount("#app")
.$snackbarAttach()
Expand Down
7 changes: 7 additions & 0 deletions client/src/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import girder from "./girder";
import Settings from "./views/Settings.vue";
import Dataset from "./views/Dataset.vue";
import Login from "./views/Login.vue";
import Metrics from "./views/Metrics.vue";

Vue.use(Router);

Expand Down Expand Up @@ -41,6 +42,12 @@ export default new Router({
component: Settings,
beforeEnter: beforeEnterAdmin
},
{
path: "/metrics",
name: "metrics",
component: Metrics,
beforeEnter: beforeEnterAdmin
},
// Order matters
{
path: "/:datasetId?",
Expand Down
4 changes: 4 additions & 0 deletions client/src/store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ const store = new Vuex.Store({
return state.datasets[datasetId];
};
},
allDatasets(state) {
console.log('allDatasets');
return Object.keys(state.datasets).map(dsId => state.datasets[dsId]);
},
currentSession(state, getters) {
if (getters.currentDataset) {
const curSessionId = getters.currentDataset.session;
Expand Down
Loading