From d415527c18c9dbbf4207b53e397816d41ca6c4db Mon Sep 17 00:00:00 2001 From: fsdavid <daviti1@mail.com> Date: Fri, 11 Dec 2020 13:08:05 +0100 Subject: [PATCH] Adding versioning on connectivity --- src/res/ext/MNI152.json | 6 +- src/res/ext/colin.json | 6 +- .../connectivityBrowser.component.ts | 57 +++++++++++++++++-- .../connectivityBrowser.template.html | 2 +- .../nehubaContainer.component.ts | 1 + .../nehubaContainer.template.html | 7 ++- 6 files changed, 67 insertions(+), 12 deletions(-) diff --git a/src/res/ext/MNI152.json b/src/res/ext/MNI152.json index a32f86032..d05c35841 100644 --- a/src/res/ext/MNI152.json +++ b/src/res/ext/MNI152.json @@ -17,7 +17,9 @@ "auxillaryMeshIndices": [ 65535 ], - "hasAdditionalViewMode": [], + "hasAdditionalViewMode": [ + "connectivity" + ], "originDatasets": [ { "kgSchema": "minds/core/dataset/v1.0.0", @@ -78867,4 +78869,4 @@ "name": "ICBM 2009c Nonlinear Asymmetric", "description": "An unbiased non-linear average of multiple subjects from the MNI152 database, which provides high-spatial resolution and signal-to-noise while not being biased towards a single brain (Fonov et al., 2011). This template space is widely used as a reference space in neuroimaging. HBP provides the JuBrain probabilistic cytoarchitectonic atlas (Amunts/Zilles, 2015) as well as a probabilistic atlas of large fibre bundles (Guevara, Mangin et al., 2017) in this space." } -} \ No newline at end of file +} diff --git a/src/res/ext/colin.json b/src/res/ext/colin.json index 542e23c76..f6638ee25 100644 --- a/src/res/ext/colin.json +++ b/src/res/ext/colin.json @@ -16,7 +16,9 @@ "auxillaryMeshIndices": [ 65535 ], - "hasAdditionalViewMode": [], + "hasAdditionalViewMode": [ + "connectivity" + ], "originDatasets": [ { "kgSchema": "minds/core/dataset/v1.0.0", @@ -18386,4 +18388,4 @@ "name": "MNI Colin 27", "description": "A stereotaxic average of 27 T1-weighted MRI scans of the same individual. (Holmes et al., 1998), mapped to fit the MNI305 space. Although not capturing brain variability, it is well established in neuroscience due to its high definition. HBP provides the JuBrain probabilistic cytoarchitectonic atlas (Amunts et al.) in this space." } -} \ No newline at end of file +} diff --git a/src/ui/connectivityBrowser/connectivityBrowser.component.ts b/src/ui/connectivityBrowser/connectivityBrowser.component.ts index 0525e2c8e..03f768c8a 100644 --- a/src/ui/connectivityBrowser/connectivityBrowser.component.ts +++ b/src/ui/connectivityBrowser/connectivityBrowser.component.ts @@ -94,13 +94,21 @@ export class ConnectivityBrowserComponent implements OnInit, AfterViewInit, OnDe if (newRegionName !== this.regionName && this.defaultColorMap) { this.restoreDefaultColormap() } + + if (val.status + && !val.name.includes('left hemisphere') + && !val.name.includes('right hemisphere')) { + this.regionHemisphere = val.status + } + this.regionName = newRegionName // TODO may not be necessary this.changeDetectionRef.detectChanges() } - + @Input() parcellationId: any public regionName: string + public regionHemisphere: string = null public datasetList: any[] = [] public selectedDataset: any public selectedDatasetDescription: string = '' @@ -140,7 +148,7 @@ export class ConnectivityBrowserComponent implements OnInit, AfterViewInit, OnDe ngOnInit(): void { this.httpClient.get<[]>(this.connectivityUrl).subscribe(res => { - this.datasetList = res + this.datasetList = res.filter(dl => dl['parcellation id'] === this.parcellationId) this.selectedDataset = this.datasetList[0].name this.selectedDatasetDescription = this.datasetList[0].description @@ -259,6 +267,14 @@ export class ConnectivityBrowserComponent implements OnInit, AfterViewInit, OnDe } public ngOnDestroy(): void { + this.connectivityNumberReceived.emit(null) + this.store$.dispatch( + ngViewerActionClearView({ + payload: { + [CONNECTIVITY_NAME_PLATE]: false + } + }) + ) this.restoreDefaultColormap() this.subscriptions.forEach(s => s.unsubscribe()) } @@ -309,7 +325,22 @@ export class ConnectivityBrowserComponent implements OnInit, AfterViewInit, OnDe } getRegionWithName(region) { - return this.allRegions.find(ar => ar.name === region) + return this.allRegions.find(ar => { + if (this.regionHemisphere) { + let regionName = region + let regionStatus = null + if (regionName.includes('left hemisphere')) { + regionStatus = 'left hemisphere' + regionName = regionName.replace(' - left hemisphere', ''); + } else if (regionName.includes('right hemisphere')) { + regionStatus = 'right hemisphere' + regionName = regionName.replace(' - right hemisphere', ''); + } + return ar.name === regionName && ar.status === regionStatus + } + + return ar.name === region + }) } public restoreDefaultColormap() { @@ -324,7 +355,7 @@ export class ConnectivityBrowserComponent implements OnInit, AfterViewInit, OnDe const existingMap: Map<string, Map<number, { red: number, green: number, blue: number }>> = (getWindow().interactiveViewer.viewerHandle.getLayersSegmentColourMap()) const colorMap = new Map(existingMap) - + this.allRegions.forEach(r => { if (r.ngId) { colorMap.get(r.ngId).set(r.labelIndex, {red: 255, green: 255, blue: 255}) @@ -333,7 +364,23 @@ export class ConnectivityBrowserComponent implements OnInit, AfterViewInit, OnDe this.connectedAreas.forEach(area => { const areaAsRegion = this.allRegions - .filter(r => r.name === area.name) + .filter(r => { + + if (this.regionHemisphere) { + let regionName = area.name + let regionStatus = null + if (regionName.includes('left hemisphere')) { + regionStatus = 'left hemisphere' + regionName = regionName.replace(' - left hemisphere', ''); + } else if (regionName.includes('right hemisphere')) { + regionStatus = 'right hemisphere' + regionName = regionName.replace(' - right hemisphere', ''); + } + return r.name === regionName && r.status === regionStatus + } + + return r.name === area.name + }) .map(r => r) if (areaAsRegion && areaAsRegion.length && areaAsRegion[0].ngId) { diff --git a/src/ui/connectivityBrowser/connectivityBrowser.template.html b/src/ui/connectivityBrowser/connectivityBrowser.template.html index 05dd7a044..3f69aa9c2 100644 --- a/src/ui/connectivityBrowser/connectivityBrowser.template.html +++ b/src/ui/connectivityBrowser/connectivityBrowser.template.html @@ -2,7 +2,7 @@ <hbp-connectivity-matrix-row #connectivityComponent *ngIf="regionName" - [region]="regionName" + [region]="regionName + (regionHemisphere? ' - ' + regionHemisphere : '')" theme="dark" [loadurl]="loadUrl" show-export="true" diff --git a/src/ui/nehubaContainer/nehubaContainer.component.ts b/src/ui/nehubaContainer/nehubaContainer.component.ts index ec1161905..31baa1076 100644 --- a/src/ui/nehubaContainer/nehubaContainer.component.ts +++ b/src/ui/nehubaContainer/nehubaContainer.component.ts @@ -307,6 +307,7 @@ export class NehubaContainer implements OnInit, OnChanges, OnDestroy { public hoveredPanelIndices$: Observable<number> public connectivityNumber: string + public connectivityLoadUrl: string constructor( private pureConstantService: PureContantService, diff --git a/src/ui/nehubaContainer/nehubaContainer.template.html b/src/ui/nehubaContainer/nehubaContainer.template.html index 002a4eedf..b08904a09 100644 --- a/src/ui/nehubaContainer/nehubaContainer.template.html +++ b/src/ui/nehubaContainer/nehubaContainer.template.html @@ -569,8 +569,10 @@ <ng-container *ngFor="let region of selectedRegions$ | async"> <connectivity-browser class="pe-all flex-shrink-1" [region]="region" + [parcellationId]="selectedParcellation['@id']" (setOpenState)="expansionPanel.expanded = $event" (connectivityNumberReceived)="connectivityNumber = $event" + (connectivityLoadUrl)="connectivityLoadUrl = $event" [accordionExpanded]="expansionPanel.expanded"> </connectivity-browser> </ng-container> @@ -591,10 +593,11 @@ iav-counter #connectedCounterDir="iavCounter"> - <hbp-connectivity-matrix-row *ngIf="region && region.name" [region]="region.name" + <hbp-connectivity-matrix-row *ngIf="region && region.name" + [region]="region.name + (region.status? ' - ' + region.status : '')" (connectivityDataReceived)="connectedCounterDir.value = $event.detail.length" class="invisible d-block h-0 w-0" - loadurl="https://connectivity-query-v1-1-connectivity.apps-dev.hbp.eu/v1.1/studies/1345998a08539dc24bda8817c7d5804558d83b1c"> + [loadurl]="connectivityLoadUrl"> </hbp-connectivity-matrix-row> </div> </mat-accordion> -- GitLab