Last active
July 22, 2019 13:31
-
-
Save philippotto/9a0ca5c96c0428226e3ad2db03f5aa80 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function applyMapping(api) { | |
const trees = api.tracing.getAllTrees(); | |
const currentTreeId = api.tracing.getActiveTreeId(); | |
const currentTree = trees[currentTreeId]; | |
const segmentationName = api.data.getVolumeTracingLayerName() | |
const cellIdSet = new Set() | |
for (const node of currentTree.nodes.values()) { | |
const cellId = await api.data.getDataValue(segmentationName, node.position); | |
cellIdSet.add(cellId); | |
} | |
const cellIds = Array.from(cellIdSet.values()); | |
const mapping = {}; | |
for (const cellId of cellIds) { | |
mapping[cellId] = cellId | |
} | |
api.data.setMapping(segmentationName, mapping, { hideUnmappedIds: true}) | |
} | |
webknossos.apiReady(3).then(api => { | |
api.utils.registerOverwrite("SET_ACTIVE_TREE", (store, next, originalAction) => { | |
next(originalAction); | |
applyMapping(api) | |
}); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment