diff --git a/src/util/fn.ts b/src/util/fn.ts index 92b9f42c71ffc8c12dfd9cf0ea2a3ece9deeccbf..7d41fed4dec3504d19ef16fbad233042ab798e4e 100644 --- a/src/util/fn.ts +++ b/src/util/fn.ts @@ -139,7 +139,7 @@ export class QuickHash { hash = ((hash << 5) - hash) + charCode hash = hash & hash } - return hash.toString(16).slice(1, this.length+1) + return hash.toString(16).slice(1) } } @@ -226,14 +226,21 @@ export class MultiDimMap{ static KeyHash = new QuickHash() - static GetKey(...arg: any[]){ - let mapKey = `` + static GetProxyKeyMatch(...arg:any[]):string { + let proxyKeyMatch = BACKCOMAP_KEY_DICT for (let i = 0; i < arg.length; i++) { if (proxyKeyMatch) proxyKeyMatch = proxyKeyMatch[arg[i]] + } + if (proxyKeyMatch) return proxyKeyMatch as any + return null + } + + static GetKey(...arg: any[]){ + let mapKey = `` + for (let i = 0; i < arg.length; i++) { mapKey += arg[i] } - if (proxyKeyMatch) return proxyKeyMatch return MultiDimMap.KeyHash.getHash(mapKey) } diff --git a/src/util/pureConstant.service.ts b/src/util/pureConstant.service.ts index 9b1e9aa2228f22a84c528b5925f94c57cb46fbe5..0d0b2d9aef929afe356bcec3421dd45551c2700c 100644 --- a/src/util/pureConstant.service.ts +++ b/src/util/pureConstant.service.ts @@ -13,6 +13,12 @@ import { flattenReducer } from 'common/util' import { TAtlas, TId, TParc, TRegion, TRegionDetail, TSpaceFull, TSpaceSummary } from "./siibraApiConstants/types"; import { MultiDimMap, recursiveMutate } from "./fn"; +function getNgId(atlasId: string, tmplId: string, parcId: string, regionKey: string){ + const proxyId = MultiDimMap.GetProxyKeyMatch(atlasId, tmplId, parcId, regionKey) + if (proxyId) return proxyId + return '_' + MultiDimMap.GetKey(atlasId, tmplId, parcId, regionKey) +} + function parseId(id: TId){ if (typeof id === 'string') return id return `${id.kg.kgSchema}/${id.kg.kgId}` @@ -434,7 +440,7 @@ Raise/track issues at github repo: <a target = "_blank" href = "${this.repoUrl}" ) { const dedicatedMap = region.volumeSrc[tmpl.id]['collect'].filter(v => v.volume_type === 'neuroglancer/precomputed') if (dedicatedMap.length === 1) { - const ngId = '_' + MultiDimMap.GetKey(atlas['@id'], tmpl.id, parc.id, dedicatedMap[0]['@id']) + const ngId = getNgId(atlas['@id'], tmpl.id, parc.id, dedicatedMap[0]['@id']) region['ngId'] = ngId region['labelIndex'] = dedicatedMap[0].detail['neuroglancer/precomputed'].labelIndex ngLayerObj[tmpl.id][ngId] = { @@ -469,7 +475,16 @@ Raise/track issues at github repo: <a target = "_blank" href = "${this.repoUrl}" return } - const hemispheredNgId = '_' + MultiDimMap.GetKey(atlas['@id'], tmpl.id, parc.id, hemisphereKey) + if ( + tmpl.id === 'minds/core/referencespace/v1.0.0/a1655b99-82f1-420f-a3c2-fe80fd4c8588' + && parc.id === 'minds/core/parcellationatlas/v1.0.0/94c1125b-b87e-45e4-901c-00daee7f2579-290' + && hemisphereKey === 'whole brain' + ) { + region.children = [] + return + } + + const hemispheredNgId = getNgId(atlas['@id'], tmpl.id, parc.id, hemisphereKey) region['ngId'] = hemispheredNgId } } @@ -487,7 +502,7 @@ Raise/track issues at github repo: <a target = "_blank" href = "${this.repoUrl}" for (const key in (parc.volumeSrc[tmpl.id] || {})) { for (const vol of parc.volumeSrc[tmpl.id][key]) { if (vol.volume_type === 'neuroglancer/precomputed') { - const ngIdKey = '_' + MultiDimMap.GetKey(atlas['@id'], tmpl.id, parseId(parc.id), key) + const ngIdKey = getNgId(atlas['@id'], tmpl.id, parseId(parc.id), key) ngLayerObj[tmpl.id][ngIdKey] = { source: `precomputed://${vol.url}`, type: "segmentation", diff --git a/src/viewerModule/nehuba/constants.ts b/src/viewerModule/nehuba/constants.ts index 9428b63efb8eed35e8d634de1ddd82667e77107b..bbd36606525015fcd2f8e6315a061ea2a7f56a36 100644 --- a/src/viewerModule/nehuba/constants.ts +++ b/src/viewerModule/nehuba/constants.ts @@ -29,9 +29,9 @@ export function getMultiNgIdsRegionsLabelIndexMap(parcellation: any = {}, inheri const processRegion = (region: any) => { const { ngId: rNgId } = region - const existingMap = map.get(rNgId) const labelIndex = Number(region.labelIndex) - if (labelIndex) { + if (labelIndex && rNgId) { + const existingMap = map.get(rNgId) if (!existingMap) { const newMap = new Map() newMap.set(labelIndex, region)