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

chore: clean up siibra-api region types

parent 5cd5e0de
No related branches found
No related tags found
No related merge requests found
Showing with 62 additions and 68 deletions
...@@ -5,3 +5,4 @@ ...@@ -5,3 +5,4 @@
- Added version check for siibra-api - Added version check for siibra-api
- Updated deploy template - Updated deploy template
- Remove unused components - Remove unused components
- Clean up siibra-api types
...@@ -8,6 +8,8 @@ import { viewerStateSetConnectivityRegion, viewerStateNavigateToRegion, viewerSt ...@@ -8,6 +8,8 @@ import { viewerStateSetConnectivityRegion, viewerStateNavigateToRegion, viewerSt
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"; import { getPosFromRegion } from "src/util/siibraApiConstants/fn";
import { TRegionDetail } from "src/util/siibraApiConstants/types";
import { IHasId } from "src/util/interfaces";
@Directive() @Directive()
export class RegionBase { export class RegionBase {
...@@ -15,7 +17,14 @@ export class RegionBase { ...@@ -15,7 +17,14 @@ export class RegionBase {
public rgbString: string public rgbString: string
public rgbDarkmode: boolean public rgbDarkmode: boolean
private _region: any private _region: TRegionDetail & {
context: {
atlas: IHasId
template: IHasId
parcellation: IHasId
}
ngId?: string
}
private _position: [number, number, number] private _position: [number, number, number]
set position(val){ set position(val){
...@@ -34,16 +43,12 @@ export class RegionBase { ...@@ -34,16 +43,12 @@ export class RegionBase {
set region(val) { set region(val) {
this._region = val this._region = val
this.region$.next(this._region) this.region$.next(this._region)
this.hasContext$.next(!!this._region.context) this.hasContext$.next(!!this._region?.context)
this.position = null 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) const pos = getPosFromRegion(val)
if (pos) { if (pos) {
this.position = pos this.position = pos
...@@ -65,7 +70,7 @@ export class RegionBase { ...@@ -65,7 +70,7 @@ export class RegionBase {
get originDatainfos(){ get originDatainfos(){
if (!this._region) return [] if (!this._region) return []
return this._region._dataset_specs || this._region.originDatainfos return (this._region._dataset_specs || []).filter(spec => spec['@type'] === 'minds/core/dataset/v1.0.0')
} }
public hasContext$: BehaviorSubject<boolean> = new BehaviorSubject(false) public hasContext$: BehaviorSubject<boolean> = new BehaviorSubject(false)
......
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
<mat-card-title> <mat-card-title>
<div class="position-relative region-name iv-custom-comp text"> <div class="position-relative region-name iv-custom-comp text">
{{ region.name }} {{ region.name }}
<small *ngIf="region.status"> ({{region.status}})</small>
</div> </div>
</mat-card-title> </mat-card-title>
...@@ -22,20 +21,7 @@ ...@@ -22,20 +21,7 @@
</span> </span>
<!-- origin datas format --> <!-- origin datas format -->
<div *ngFor="let originDataset of (region.originDatasets || []); let index = index"
class="ml-2">
<i>&#183;</i>
<span *ngIf="originDataset?.format?.name as regionOrDsFormatName; else fallbackODsnameTmpl">
{{ regionOrDsFormatName }}
</span>
<ng-template #fallbackODsnameTmpl>
<span>
{{ regionOriginDatasetLabels$ | async | renderViewOriginDatasetlabel : index }}
</span>
</ng-template>
</div>
<mat-divider vertical="true" class="ml-2 h-2rem"></mat-divider> <mat-divider vertical="true" class="ml-2 h-2rem"></mat-divider>
<!-- position --> <!-- position -->
......
<div class="d-flex flex-row"> <div class="d-flex flex-row">
<small class="text-truncate flex-shrink-1 flex-grow-1"> <small class="text-truncate flex-shrink-1 flex-grow-1">
{{ region.name }}<span *ngIf="region.status" class="text-muted">{{' (' + region.status + ')'}}</span> {{ region.name }}
</small> </small>
<div class="flex-grow-0 flex-shrink-0 d-flex flex-row"> <div class="flex-grow-0 flex-shrink-0 d-flex flex-row">
......
...@@ -5,14 +5,14 @@ import { ARIA_LABELS, CONST } from 'common/constants' ...@@ -5,14 +5,14 @@ import { ARIA_LABELS, CONST } from 'common/constants'
import { TBSSummary } from "../../kgDataset"; import { TBSSummary } from "../../kgDataset";
import { BsFeatureService } from "../../service"; import { BsFeatureService } from "../../service";
import { MAT_DIALOG_DATA } from "@angular/material/dialog"; import { MAT_DIALOG_DATA } from "@angular/material/dialog";
import { TDatainfos } from "src/util/siibraApiConstants/types"; import { TDatainfosDetail } from "src/util/siibraApiConstants/types";
import { TRegion } from "../../type"; import { TRegion } from "../../type";
/** /**
* this component is specifically used to render side panel ebrains dataset view * this component is specifically used to render side panel ebrains dataset view
*/ */
export type TInjectableData = TDatainfos & { export type TInjectableData = TDatainfosDetail & {
dataType?: string dataType?: string
view?: ViewRef | TemplateRef<any> view?: ViewRef | TemplateRef<any>
region?: TRegion region?: TRegion
......
...@@ -2,7 +2,7 @@ import { Directive, HostListener, Inject, Input, Optional } from "@angular/core" ...@@ -2,7 +2,7 @@ import { Directive, HostListener, Inject, Input, Optional } from "@angular/core"
import { MatDialog, MatDialogConfig } from "@angular/material/dialog"; import { MatDialog, MatDialogConfig } from "@angular/material/dialog";
import { MatSnackBar } from "@angular/material/snack-bar"; import { MatSnackBar } from "@angular/material/snack-bar";
import { OVERWRITE_SHOW_DATASET_DIALOG_TOKEN, TOverwriteShowDatasetDialog } from "src/util/interfaces"; import { OVERWRITE_SHOW_DATASET_DIALOG_TOKEN, TOverwriteShowDatasetDialog } from "src/util/interfaces";
import { TRegion as TSiibraRegion } from "src/util/siibraApiConstants/types"; import { TRegionDetail as TSiibraRegion } from "src/util/siibraApiConstants/types";
import { TRegion as TContextRegion } from 'src/atlasComponents/regionalFeatures/bsFeatures/type' import { TRegion as TContextRegion } from 'src/atlasComponents/regionalFeatures/bsFeatures/type'
export const IAV_DATASET_SHOW_DATASET_DIALOG_CMP = 'IAV_DATASET_SHOW_DATASET_DIALOG_CMP' export const IAV_DATASET_SHOW_DATASET_DIALOG_CMP = 'IAV_DATASET_SHOW_DATASET_DIALOG_CMP'
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
*/ */
import { IHasId } from "./interfaces"; import { IHasId } from "./interfaces";
import { TRegion } from "./siibraApiConstants/types"; import { TRegionSummary } from "./siibraApiConstants/types";
type TAppend = { type TAppend = {
parent: IHasId | { name: string } parent: IHasId | { name: string }
...@@ -22,7 +22,7 @@ type TPatchRegion = { ...@@ -22,7 +22,7 @@ type TPatchRegion = {
'@id': string '@id': string
targetSpace: IHasId[] | '*' targetSpace: IHasId[] | '*'
targetParcellation: IHasId[] | '*' targetParcellation: IHasId[] | '*'
payload: Partial<TRegion> payload: Partial<TRegionSummary>
} & (TAppend | TPatch) } & (TAppend | TPatch)
const encoder = new TextEncoder() const encoder = new TextEncoder()
......
...@@ -9,7 +9,7 @@ import { LoggingService } from "src/logging"; ...@@ -9,7 +9,7 @@ import { LoggingService } from "src/logging";
import { viewerStateFetchedAtlasesSelector, viewerStateSelectedTemplateSelector } from "src/services/state/viewerState/selectors"; import { viewerStateFetchedAtlasesSelector, viewerStateSelectedTemplateSelector } from "src/services/state/viewerState/selectors";
import { BS_ENDPOINT, BACKENDURL } from "src/util/constants"; import { BS_ENDPOINT, BACKENDURL } from "src/util/constants";
import { flattenReducer } from 'common/util' import { flattenReducer } from 'common/util'
import { IVolumeTypeDetail, TAtlas, TId, TParc, TRegion, TRegionDetail, TSpaceFull, TSpaceSummary, TVolumeSrc } from "./siibraApiConstants/types"; import { IVolumeTypeDetail, TAtlas, TId, TParc, TRegionDetail, TRegionSummary, TSpaceFull, TSpaceSummary, TVolumeSrc } from "./siibraApiConstants/types";
import { MultiDimMap, recursiveMutate, mutateDeepMerge } from "./fn"; import { MultiDimMap, recursiveMutate, mutateDeepMerge } from "./fn";
import { patchRegions } from './patchPureConstants' import { patchRegions } from './patchPureConstants'
import { environment } from "src/environments/environment"; import { environment } from "src/environments/environment";
...@@ -216,7 +216,7 @@ Raise/track issues at github repo: <a target = "_blank" href = "${this.repoUrl}" ...@@ -216,7 +216,7 @@ Raise/track issues at github repo: <a target = "_blank" href = "${this.repoUrl}"
) )
private getRegions(atlasId: string, parcId: string, spaceId: string){ private getRegions(atlasId: string, parcId: string, spaceId: string){
return this.http.get<TRegion[]>( return this.http.get<TRegionSummary[]>(
`${this.bsEndpoint}/atlases/${encodeURIComponent(atlasId)}/parcellations/${encodeURIComponent(parcId)}/regions`, `${this.bsEndpoint}/atlases/${encodeURIComponent(atlasId)}/parcellations/${encodeURIComponent(parcId)}/regions`,
{ {
params: { params: {
...@@ -252,7 +252,7 @@ Raise/track issues at github repo: <a target = "_blank" href = "${this.repoUrl}" ...@@ -252,7 +252,7 @@ Raise/track issues at github repo: <a target = "_blank" href = "${this.repoUrl}"
if (p.parent['name'] === region.name) { if (p.parent['name'] === region.name) {
if (!region.children) region.children = [] if (!region.children) region.children = []
region.children.push( region.children.push(
p.payload as TRegion p.payload as TRegionSummary
) )
} }
} }
...@@ -547,7 +547,11 @@ Raise/track issues at github repo: <a target = "_blank" href = "${this.repoUrl}" ...@@ -547,7 +547,11 @@ Raise/track issues at github repo: <a target = "_blank" href = "${this.repoUrl}"
* in the case of interpolated, it sucks that the ngLayerObj will be set multiple times * in the case of interpolated, it sucks that the ngLayerObj will be set multiple times
*/ */
const dedicatedMap = region._dataset_specs.filter(spec => spec.space_id === tmpl.id && spec['volume_type'] === 'neuroglancer/precomputed') const dedicatedMap = region._dataset_specs.filter(
spec => spec["@type"] === 'fzj/tmp/volume_type/v0.0.1'
&& spec.space_id === tmpl.id
&& spec['volume_type'] === 'neuroglancer/precomputed'
) as TVolumeSrc<'neuroglancer/precomputed'>[]
if (dedicatedMap.length === 1) { if (dedicatedMap.length === 1) {
const ngId = getNgId(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['ngId'] = ngId
......
...@@ -96,7 +96,14 @@ export type TParcSummary = { ...@@ -96,7 +96,14 @@ export type TParcSummary = {
name: string name: string
} }
export type TDatainfos = { export type TDatainfoSummary = {
'@type': 'minds/core/dataset/v1.0.0'
kgSchema: string
kgId: string
}
export type TDatainfosDetail = {
'@type': 'minds/core/dataset/v1.0.0'
name: string name: string
description: string description: string
urls: { urls: {
...@@ -148,22 +155,37 @@ export type TParc = { ...@@ -148,22 +155,37 @@ export type TParc = {
_dataset_specs: TDatasetSpec[] _dataset_specs: TDatasetSpec[]
} }
export type TRegionSummary = {
name: string
labelIndex: number
rgb: [number, number, number]
id: number
availableIn: {
id: string
name: string
}[]
_dataset_specs: (TVolumeSrc<keyof IVolumeTypeDetail> | TDatainfoSummary)[]
children: TRegionSummary[]
}
export type TRegionDetail = { export type TRegionDetail = {
name: string name: string
children: TRegionDetail[]
rgb: number[]
id: string
labelIndex: number labelIndex: number
volumeSrc: { rgb: [number, number, number]
[key: string]: { id: {
[key: string]: TVolumeSrc<keyof IVolumeTypeDetail>[] kg: TKgIdentifier
}
} }
availableIn: { availableIn: {
id: string id: string
name: string name: string
}[] }[]
_dataset_specs: (TVolumeSrc<keyof IVolumeTypeDetail> | TDatainfosDetail)[]
children: TRegionDetail[]
hasRegionalMap: boolean hasRegionalMap: boolean
links: {
[key: string]: string
}
props: { props: {
components: { components: {
centroid: [number, number, number] centroid: [number, number, number]
...@@ -171,31 +193,6 @@ export type TRegionDetail = { ...@@ -171,31 +193,6 @@ export type TRegionDetail = {
}[] }[]
space: any space: any
} }
links: {
[key: string]: string
}
originDatainfos: TDatainfos[]
} }
export type TRegion = {
name: string
children: TRegion[]
labelIndex?: number
rgb?: number[]
id?: {
kg: TKgIdentifier
}
_dataset_specs: TVolumeSrc<keyof IVolumeTypeDetail>[]
/**
* missing
*/
originDatasets?: ({
filename: string
} & TKgIdentifier) []
position?: number[]
}
...@@ -7,7 +7,7 @@ import { distinctUntilChanged, map } from "rxjs/operators"; ...@@ -7,7 +7,7 @@ import { distinctUntilChanged, map } from "rxjs/operators";
import { viewerStateHelperSelectParcellationWithId, viewerStateRemoveAdditionalLayer, viewerStateSetSelectedRegions } from "src/services/state/viewerState.store.helper"; import { viewerStateHelperSelectParcellationWithId, viewerStateRemoveAdditionalLayer, viewerStateSetSelectedRegions } from "src/services/state/viewerState.store.helper";
import { ngViewerActionClearView, ngViewerSelectorClearViewEntries } from "src/services/state/ngViewerState.store.helper"; import { ngViewerActionClearView, ngViewerSelectorClearViewEntries } from "src/services/state/ngViewerState.store.helper";
import { OVERWRITE_SHOW_DATASET_DIALOG_TOKEN } from "src/util/interfaces"; import { OVERWRITE_SHOW_DATASET_DIALOG_TOKEN } from "src/util/interfaces";
import { TDatainfos, TParc, TSimpleInfo } from "src/util/siibraApiConstants/types"; import { TDatainfosDetail } from "src/util/siibraApiConstants/types";
@Component({ @Component({
selector: 'viewer-state-breadcrumb', selector: 'viewer-state-breadcrumb',
...@@ -120,10 +120,11 @@ export class ViewerStateBreadCrumb { ...@@ -120,10 +120,11 @@ export class ViewerStateBreadCrumb {
}) })
export class OriginalDatainfoPipe implements PipeTransform{ export class OriginalDatainfoPipe implements PipeTransform{
public transform(arr: TDatainfos[]): TDatainfos[]{ public transform(arr: TDatainfosDetail[]): TDatainfosDetail[]{
if (arr.length > 0) { if (arr.length > 0) {
return arr.map(d => { return arr.map(d => {
return { return {
'@type': 'minds/core/dataset/v1.0.0',
name: d.name, name: d.name,
description: d.name, description: d.name,
urls: [], urls: [],
......
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