Skip to content
Snippets Groups Projects
Commit b178d750 authored by Xiao Gui's avatar Xiao Gui
Browse files

feat: add centroid support

parent 98365276
No related branches found
No related tags found
No related merge requests found
const { AtlasPage } = require("../util") const { AtlasPage } = require("../util")
const { ARIA_LABELS } = require('../../../common/constants') const { ARIA_LABELS } = require('../../../common/constants')
const { SHOW_CONNECTIVITY_DATA, SHOW_IN_OTHER_REF_SPACE, SHOW_ORIGIN_DATASET } = ARIA_LABELS const { SHOW_ORIGIN_DATASET } = ARIA_LABELS
const cssSelector = `[aria-label="${SHOW_ORIGIN_DATASET}"]` const cssSelector = `[aria-label="${SHOW_ORIGIN_DATASET}"]`
......
...@@ -3,11 +3,11 @@ import { select, Store, createSelector } from "@ngrx/store"; ...@@ -3,11 +3,11 @@ import { select, Store, createSelector } from "@ngrx/store";
import { uiStateOpenSidePanel, uiStateExpandSidePanel, uiActionShowSidePanelConnectivity } from 'src/services/state/uiState.store.helper' import { uiStateOpenSidePanel, uiStateExpandSidePanel, uiActionShowSidePanelConnectivity } from 'src/services/state/uiState.store.helper'
import { distinctUntilChanged, switchMap, filter, map, withLatestFrom } from "rxjs/operators"; import { distinctUntilChanged, switchMap, filter, map, withLatestFrom } from "rxjs/operators";
import { Observable, BehaviorSubject, combineLatest } from "rxjs"; import { Observable, BehaviorSubject, combineLatest } from "rxjs";
import { ARIA_LABELS } from 'common/constants'
import { flattenRegions, getIdFromKgIdObj, rgbToHsl } from 'common/util' import { flattenRegions, getIdFromKgIdObj, rgbToHsl } from 'common/util'
import { viewerStateSetConnectivityRegion, viewerStateNavigateToRegion, viewerStateToggleRegionSelect, viewerStateNewViewer, isNewerThan } from "src/services/state/viewerState.store.helper"; import { viewerStateSetConnectivityRegion, viewerStateNavigateToRegion, viewerStateToggleRegionSelect, viewerStateNewViewer, isNewerThan } from "src/services/state/viewerState.store.helper";
import { viewerStateFetchedTemplatesSelector, viewerStateGetSelectedAtlas, viewerStateSelectedTemplateFullInfoSelector, viewerStateSelectedTemplateSelector } from "src/services/state/viewerState/selectors"; import { viewerStateFetchedTemplatesSelector, viewerStateGetSelectedAtlas, viewerStateSelectedTemplateFullInfoSelector, viewerStateSelectedTemplateSelector } from "src/services/state/viewerState/selectors";
import { strToRgb, verifyPositionArg, getRegionHemisphere } from 'common/util' import { strToRgb, verifyPositionArg, getRegionHemisphere } from 'common/util'
import { getPosFromRegion } from "src/util/siibraApiConstants/fn";
export class RegionBase { export class RegionBase {
...@@ -34,11 +34,19 @@ export class RegionBase { ...@@ -34,11 +34,19 @@ export class RegionBase {
this._region = val this._region = val
this.region$.next(this._region) this.region$.next(this._region)
this.position = val?.position this.position = null
// bug the centroid returned is currently nonsense // bug the centroid returned is currently nonsense
// this.position = val?.props?.centroid_mm // this.position = val?.props?.centroid_mm
if (!this._region) return if (!this._region) return
if (val?.position) {
this.position = val?.position
}
const pos = getPosFromRegion(val)
if (pos) {
this.position = pos
}
const rgb = this._region.rgb const rgb = this._region.rgb
|| (this._region.labelIndex > 65500 && [255, 255, 255]) || (this._region.labelIndex > 65500 && [255, 255, 255])
|| strToRgb(`${this._region.ngId || this._region.name}${this._region.labelIndex}`) || strToRgb(`${this._region.ngId || this._region.name}${this._region.labelIndex}`)
...@@ -191,12 +199,6 @@ export class RegionBase { ...@@ -191,12 +199,6 @@ export class RegionBase {
navigation, navigation,
})) }))
} }
public GO_TO_REGION_CENTROID = ARIA_LABELS.GO_TO_REGION_CENTROID
public SHOW_CONNECTIVITY_DATA = ARIA_LABELS.SHOW_CONNECTIVITY_DATA
public SHOW_IN_OTHER_REF_SPACE = ARIA_LABELS.SHOW_IN_OTHER_REF_SPACE
public SHOW_ORIGIN_DATASET = ARIA_LABELS.SHOW_ORIGIN_DATASET
public AVAILABILITY_IN_OTHER_REF_SPACE = ARIA_LABELS.AVAILABILITY_IN_OTHER_REF_SPACE
} }
export const getRegionParentParcRefSpace = createSelector( export const getRegionParentParcRefSpace = createSelector(
......
...@@ -2,7 +2,7 @@ import { Component, OnDestroy } from "@angular/core"; ...@@ -2,7 +2,7 @@ import { Component, OnDestroy } from "@angular/core";
import { Store } from "@ngrx/store"; import { Store } from "@ngrx/store";
import { Observable, Subscription } from "rxjs"; import { Observable, Subscription } from "rxjs";
import { RegionBase } from '../region.base' import { RegionBase } from '../region.base'
import { CONST } from 'common/constants' import { CONST, ARIA_LABELS } from 'common/constants'
import { ComponentStore } from "src/viewerModule/componentStore"; import { ComponentStore } from "src/viewerModule/componentStore";
@Component({ @Component({
...@@ -14,6 +14,7 @@ import { ComponentStore } from "src/viewerModule/componentStore"; ...@@ -14,6 +14,7 @@ import { ComponentStore } from "src/viewerModule/componentStore";
export class RegionMenuComponent extends RegionBase implements OnDestroy { export class RegionMenuComponent extends RegionBase implements OnDestroy {
public CONST = CONST public CONST = CONST
public ARIA_LABELS = ARIA_LABELS
private subscriptions: Subscription[] = [] private subscriptions: Subscription[] = []
public activePanelTitles$: Observable<string[]> public activePanelTitles$: Observable<string[]>
......
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
<!-- position --> <!-- position -->
<button mat-icon-button *ngIf="position" <button mat-icon-button *ngIf="position"
(click)="navigateToRegion()" (click)="navigateToRegion()"
[matTooltip]="GO_TO_REGION_CENTROID + ': ' + (position | addUnitAndJoin : 'mm')"> [matTooltip]="ARIA_LABELS.GO_TO_REGION_CENTROID + ': ' + (position | nmToMm | addUnitAndJoin : 'mm')">
<mat-icon fontSet="fas" fontIcon="fa-map-marked-alt"> <mat-icon fontSet="fas" fontIcon="fa-map-marked-alt">
</mat-icon> </mat-icon>
</button> </button>
...@@ -51,6 +51,7 @@ ...@@ -51,6 +51,7 @@
<ng-container *ngFor="let info of infos"> <ng-container *ngFor="let info of infos">
<a *ngFor="let url of info.urls" <a *ngFor="let url of info.urls"
[href]="url.doi | doiParserPipe" [href]="url.doi | doiParserPipe"
[matTooltip]="ARIA_LABELS.EXPLORE_DATASET_IN_KG"
target="_blank" target="_blank"
mat-icon-button> mat-icon-button>
<i class="fas fa-external-link-alt"></i> <i class="fas fa-external-link-alt"></i>
......
...@@ -16,6 +16,7 @@ import { uiActionHideAllDatasets } from "src/services/state/uiState/actions"; ...@@ -16,6 +16,7 @@ import { uiActionHideAllDatasets } from "src/services/state/uiState/actions";
import { viewerStateFetchedAtlasesSelector } from "src/services/state/viewerState/selectors"; import { viewerStateFetchedAtlasesSelector } from "src/services/state/viewerState/selectors";
import { viewerStateChangeNavigation } from "src/services/state/viewerState/actions"; import { viewerStateChangeNavigation } from "src/services/state/viewerState/actions";
import { cvtNavigationObjToNehubaConfig } from 'src/viewerModule/nehuba/util' import { cvtNavigationObjToNehubaConfig } from 'src/viewerModule/nehuba/util'
import { getPosFromRegion } from "src/util/siibraApiConstants/fn";
const defaultPerspectiveZoom = 1e6 const defaultPerspectiveZoom = 1e6
const defaultZoom = 1e6 const defaultZoom = 1e6
...@@ -400,7 +401,7 @@ export class ViewerStateControllerUseEffect implements OnDestroy { ...@@ -400,7 +401,7 @@ export class ViewerStateControllerUseEffect implements OnDestroy {
}) })
} }
const position = region.position || (region?.props?.centroid_mm || []).map((v: number) => v*1e6) const position = region.position || getPosFromRegion(region)
if (!position) { if (!position) {
return generalActionError({ return generalActionError({
message: `${region.name} - does not have a position defined` message: `${region.name} - does not have a position defined`
......
...@@ -384,7 +384,6 @@ Raise/track issues at github repo: <a target = "_blank" href = "${this.repoUrl}" ...@@ -384,7 +384,6 @@ Raise/track issues at github repo: <a target = "_blank" href = "${this.repoUrl}"
atlases.map( atlases.map(
atlas => this.getSpacesAndParc(atlas.id).pipe( atlas => this.getSpacesAndParc(atlas.id).pipe(
map(({ templateSpaces, parcellations }) => { map(({ templateSpaces, parcellations }) => {
console.log({parcellations})
return { return {
'@id': atlas.id, '@id': atlas.id,
name: atlas.name, name: atlas.name,
......
import { TRegionDetail } from "./types";
export function getPosFromRegion(region: TRegionDetail){
if (!region?.props?.[0]) return null
return region.props[0].centroid_mm.map(v => v*1e6) as [number, number, number]
}
\ No newline at end of file
...@@ -143,11 +143,11 @@ export type TRegionDetail = { ...@@ -143,11 +143,11 @@ export type TRegionDetail = {
}[] }[]
hasRegionalMap: boolean hasRegionalMap: boolean
props: { props: {
centroid_mm: number[] centroid_mm: [number, number, number]
volume_mm: number volume_mm: number
surface_mm: number surface_mm: number
is_cortical: number is_cortical: number
} }[]
links: { links: {
[key: string]: string [key: string]: string
} }
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment