Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.