From 1b47d01493564faf5eb3ac83f4459963f56cf8be Mon Sep 17 00:00:00 2001 From: Xiao Gui <xgui3783@gmail.com> Date: Tue, 27 Jul 2021 17:56:40 +0200 Subject: [PATCH] feat: enable connectivity maps in threesurfer view --- .../connectivityBrowser.component.ts | 8 +++++- src/util/fn.ts | 13 +++++++++- .../threeSurferGlue/threeSurfer.component.ts | 25 +++++++++++++------ 3 files changed, 36 insertions(+), 10 deletions(-) diff --git a/src/atlasComponents/connectivity/connectivityBrowser/connectivityBrowser.component.ts b/src/atlasComponents/connectivity/connectivityBrowser/connectivityBrowser.component.ts index af4f139d6..f7573cfb5 100644 --- a/src/atlasComponents/connectivity/connectivityBrowser/connectivityBrowser.component.ts +++ b/src/atlasComponents/connectivity/connectivityBrowser/connectivityBrowser.component.ts @@ -73,6 +73,12 @@ export class ConnectivityBrowserComponent implements OnInit, AfterViewInit, OnDe type: 'SET_OVERWRITTEN_COLOR_MAP', payload: flag? CONNECTIVITY_NAME_PLATE : false, }) + + if (flag) { + this.addNewColorMap() + } else { + this.restoreDefaultColormap() + } } @Output() @@ -381,7 +387,7 @@ export class ConnectivityBrowserComponent implements OnInit, AfterViewInit, OnDe public addNewColorMap() { if (!this.defaultColorMap) { - this.defaultColorMap = new Map(getWindow().interactiveViewer.viewerHandle.getLayersSegmentColourMap()) + this.defaultColorMap = getWindow().interactiveViewer.viewerHandle.getLayersSegmentColourMap() } const existingMap: Map<string, Map<number, { red: number, green: number, blue: number }>> = (getWindow().interactiveViewer.viewerHandle.getLayersSegmentColourMap()) diff --git a/src/util/fn.ts b/src/util/fn.ts index d635978e7..db3ad47ce 100644 --- a/src/util/fn.ts +++ b/src/util/fn.ts @@ -143,6 +143,14 @@ export class QuickHash { } } +// fsaverage uses threesurfer, which, whilst do not use ngId, uses 'left' and 'right' as keys +const fsAverageKeyVal = { + "minds/core/parcellationatlas/v1.0.0/94c1125b-b87e-45e4-901c-00daee7f2579-290": { + "left hemisphere": "left", + "right hemisphere": "right" + } +} + /** * in order to maintain backwards compat with url encoding of selected regions * TODO setup a sentry to catch if these are ever used. if not, retire the hard coding @@ -234,7 +242,10 @@ const BACKCOMAP_KEY_DICT = { "juelich/iav/atlas/v1.0.0/3": { "whole brain": "cortical layers" }, - } + }, + + // fsaverage + "minds/core/referencespace/v1.0.0/tmp-fsaverage": fsAverageKeyVal, } } diff --git a/src/viewerModule/threeSurfer/threeSurferGlue/threeSurfer.component.ts b/src/viewerModule/threeSurfer/threeSurferGlue/threeSurfer.component.ts index 47e58895e..c720fb1a0 100644 --- a/src/viewerModule/threeSurfer/threeSurferGlue/threeSurfer.component.ts +++ b/src/viewerModule/threeSurfer/threeSurferGlue/threeSurfer.component.ts @@ -68,6 +68,8 @@ function cameraNavsAreSimilar(c1: TCameraOrientation, c2: TCameraOrientation){ export class ThreeSurferGlueCmp implements IViewer<'threeSurfer'>, OnChanges, AfterViewInit, OnDestroy { + private loanedColorMap = new WeakSet() + @Input() selectedTemplate: any @@ -109,16 +111,22 @@ export class ThreeSurferGlueCmp implements IViewer<'threeSurfer'>, OnChanges, Af add3DLandmarks: nyi, loadLayer: nyi, applyLayersColourMap: (map: Map<string, Map<number, { red: number, green: number, blue: number }>>) => { - const applyCm = new Map() - for (const [hem, m] of map.entries()) { - const nMap = new Map() - applyCm.set(hem, nMap) - for (const [lbl, vals] of m.entries()) { - const { red, green, blue } = vals - nMap.set(lbl, [red/255, green/255, blue/255]) + if (this.loanedColorMap.has(map)) { + this.externalHemisphLblColorMap = null + } else { + + const applyCm = new Map() + for (const [hem, m] of map.entries()) { + const nMap = new Map() + applyCm.set(hem, nMap) + for (const [lbl, vals] of m.entries()) { + const { red, green, blue } = vals + nMap.set(lbl, [red/255, green/255, blue/255]) + } } + this.externalHemisphLblColorMap = applyCm } - this.externalHemisphLblColorMap = applyCm + this.applyColorMap() }, getLayersSegmentColourMap: () => { const map = this.getColormapCopy() @@ -134,6 +142,7 @@ export class ThreeSurferGlueCmp implements IViewer<'threeSurfer'>, OnChanges, Af }) } } + this.loanedColorMap.add(outmap) return outmap }, getNgHash: nyi, -- GitLab