Skip to content

Instantly share code, notes, and snippets.

@heikowissler
Created November 16, 2017 13:19
Show Gist options
  • Save heikowissler/3019d66f3c6f584c51deee2a98d2f4c5 to your computer and use it in GitHub Desktop.
Save heikowissler/3019d66f3c6f584c51deee2a98d2f4c5 to your computer and use it in GitHub Desktop.
webknossos.apiReady(2).then(async (api) => {
console.log("starting spine task");
window.taskID = 0;
window.done = [];
window.done[window.taskID] = false;
api.utils.showToast("info", 'Press "7" to automatically place a comment for unsolved tracing (means: mistracing, glia, unsure) and "9" to finish and get next task', 3000);
async function wKReadyOverwrite(store, call, action) {
window.taskID += 1;
const taskIDhere = window.taskID;
window.done[taskIDhere] = false;
call(action);
setTimeout(() => {
if (taskIDhere === window.taskID) {
api.utils.showToast("info", 'Task time out', 3000);
}
window.done[taskIDhere] = true
}, 35000);
}
async function actionOverwrite(store, call, action) {
if (!window.done[window.taskID]) {
call(action);
}
}
api.utils.registerOverwrite("WK_READY", wKReadyOverwrite);
api.utils.registerOverwrite("MOVE_PLANE_FLYCAM_ORTHO", actionOverwrite);
api.utils.registerOverwrite("MOVE_FLYCAM_ORTHO", actionOverwrite);
api.utils.registerOverwrite("CREATE_NODE", actionOverwrite);
api.utils.registerKeyHandler("9", () => {
api.utils.showToast("info", 'Task finished', 3000);
api.tracing.finishAndGetNextTask();
});
api.utils.registerKeyHandler("7", () => {
api.tracing.setCommentForNode("unsolved", api.tracing.getActiveNodeId(), api.tracing.getActiveTreeId());
api.utils.showToast("warning", 'Task marked as unsolved (mistracing, glia, unsure).', 3000);
api.tracing.finishAndGetNextTask();
});
setTimeout(() => {
if (window.taskID === 0) {
api.utils.showToast("info", 'Task time out', 3000);
}
window.done[0] = true
}, 35000);
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment