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

fix: messaging swc files

parent 34883a41
No related branches found
No related tags found
No related merge requests found
...@@ -13,12 +13,30 @@ const NM_IDS = { ...@@ -13,12 +13,30 @@ const NM_IDS = {
MNI152_2009C_ASYM: 'hbp:ICBM_Asym_r2009c(um)', MNI152_2009C_ASYM: 'hbp:ICBM_Asym_r2009c(um)',
} }
export const IAV_IDS = { const IAV_IDS = {
AMBA_V3: 'minds/core/referencespace/v1.0.0/265d32a0-3d84-40a5-926f-bf89f68212b9', AMBA_V3: 'minds/core/referencespace/v1.0.0/265d32a0-3d84-40a5-926f-bf89f68212b9',
WAXHOLM_V1_01: 'minds/core/referencespace/v1.0.0/d5717c4a-0fa1-46e6-918c-b8003069ade8', WAXHOLM_V1_01: 'minds/core/referencespace/v1.0.0/d5717c4a-0fa1-46e6-918c-b8003069ade8',
BIG_BRAIN: 'minds/core/referencespace/v1.0.0/a1655b99-82f1-420f-a3c2-fe80fd4c8588', BIG_BRAIN: 'minds/core/referencespace/v1.0.0/a1655b99-82f1-420f-a3c2-fe80fd4c8588',
COLIN: 'minds/core/referencespace/v1.0.0/7f39f7be-445b-47c0-9791-e971c0b6d992', COLIN: 'minds/core/referencespace/v1.0.0/7f39f7be-445b-47c0-9791-e971c0b6d992',
MNI152_2009C_ASYM: 'minds/core/referencespace/v1.0.0/dafcffc5-4826-4bf1-8ff6-46b8a31ff8e2', MNI152_2009C_ASYM: 'minds/core/referencespace/v1.0.0/dafcffc5-4826-4bf1-8ff6-46b8a31ff8e2',
} as const
type SPACE_ID = typeof IAV_IDS[keyof typeof IAV_IDS]
const DEFAULT_PARC: Record<SPACE_ID, string> = {
[IAV_IDS.AMBA_V3]: "minds/core/parcellationatlas/v1.0.0/05655b58-3b6f-49db-b285-64b5a0276f83",
[IAV_IDS.WAXHOLM_V1_01]: "minds/core/parcellationatlas/v1.0.0/ebb923ba-b4d5-4b82-8088-fa9215c2e1fe-v4",
[IAV_IDS.BIG_BRAIN]: "minds/core/parcellationatlas/v1.0.0/94c1125b-b87e-45e4-901c-00daee7f2579-290",
[IAV_IDS.COLIN]: "minds/core/parcellationatlas/v1.0.0/94c1125b-b87e-45e4-901c-00daee7f2579-300",
[IAV_IDS.MNI152_2009C_ASYM]: "minds/core/parcellationatlas/v1.0.0/94c1125b-b87e-45e4-901c-00daee7f2579-300",
}
const DEFAULT_ATLAS: Record<SPACE_ID, string> = {
[IAV_IDS.AMBA_V3]: "juelich/iav/atlas/v1.0.0/2",
[IAV_IDS.WAXHOLM_V1_01]: "minds/core/parcellationatlas/v1.0.0/522b368e-49a3-49fa-88d3-0870a307974a",
[IAV_IDS.BIG_BRAIN]: "juelich/iav/atlas/v1.0.0/1",
[IAV_IDS.COLIN]: "juelich/iav/atlas/v1.0.0/1",
[IAV_IDS.MNI152_2009C_ASYM]: "juelich/iav/atlas/v1.0.0/1",
} }
/** /**
...@@ -60,6 +78,14 @@ const translateSpace = (spaceId: string) => { ...@@ -60,6 +78,14 @@ const translateSpace = (spaceId: string) => {
return null return null
} }
const getDefaultParcellation = (spaceId: SPACE_ID) => {
return DEFAULT_PARC[spaceId]
}
const getAtlas = (spaceId: SPACE_ID) => {
return DEFAULT_ATLAS[spaceId]
}
const getVoxelFromSpace = (spaceId: string) => { const getVoxelFromSpace = (spaceId: string) => {
for (const key in NM_IDS){ for (const key in NM_IDS){
if (NM_IDS[key] === spaceId) return IAV_VOXEL_SIZES_NM[key] if (NM_IDS[key] === spaceId) return IAV_VOXEL_SIZES_NM[key]
...@@ -97,7 +123,15 @@ export const processJsonLd = (json: { [key: string]: any }): Observable<IMessagi ...@@ -97,7 +123,15 @@ export const processJsonLd = (json: { [key: string]: any }): Observable<IMessagi
subject.next({ subject.next({
type: 'loadTemplate', type: 'loadTemplate',
payload: { payload: {
['@id']: iavSpace template: {
id: iavSpace
},
parcellation: {
id: getDefaultParcellation(iavSpace)
},
atlas: {
id: getAtlas(iavSpace)
}
} }
}) })
...@@ -130,9 +164,9 @@ export const processJsonLd = (json: { [key: string]: any }): Observable<IMessagi ...@@ -130,9 +164,9 @@ export const processJsonLd = (json: { [key: string]: any }): Observable<IMessagi
* 1e3 / voxelSize * 1e3 / voxelSize
*/ */
const scaleUmToVoxelFixed = [ const scaleUmToVoxelFixed = [
1e3 / voxelSize[0], voxelSize[0],
1e3 / voxelSize[1], voxelSize[1],
1e3 / voxelSize[2], voxelSize[2],
] ]
// NG translation works on nm scale // NG translation works on nm scale
const scaleUmToNm = 1e3 const scaleUmToNm = 1e3
......
import { InjectionToken } from "@angular/core"; import { InjectionToken } from "@angular/core";
interface ILoadTemplateByIdPayload { interface ILoadTemplateByIdPayload {
['@id']: string atlas: {
id: string
}
template: {
id: string
}
parcellation: {
id: string
}
} }
interface IResourceType { interface IResourceType {
......
...@@ -40,7 +40,18 @@ export class MessagingGlue implements IWindowMessaging, OnDestroy { ...@@ -40,7 +40,18 @@ export class MessagingGlue implements IWindowMessaging, OnDestroy {
* and enforce single direction flow when possible * and enforce single direction flow when possible
*/ */
loadTempladById( payload: IMessagingActionTmpl['loadTemplate'] ){ loadTempladById( payload: IMessagingActionTmpl['loadTemplate'] ){
const atlasId = this.tmplSpIdToAtlasId.get(payload['@id']) const {
parcellation: {
id: parcellationId
},
template: {
id: templateId
},
atlas: {
id: atlasId
}
} = payload
if (!atlasId) { if (!atlasId) {
return this.store.dispatch( return this.store.dispatch(
generalActions.generalActionError({ generalActions.generalActionError({
...@@ -51,7 +62,8 @@ export class MessagingGlue implements IWindowMessaging, OnDestroy { ...@@ -51,7 +62,8 @@ export class MessagingGlue implements IWindowMessaging, OnDestroy {
this.store.dispatch( this.store.dispatch(
atlasSelection.actions.selectATPById({ atlasSelection.actions.selectATPById({
atlasId, atlasId,
templateId: payload["@id"] templateId,
parcellationId
}) })
) )
} }
......
...@@ -315,9 +315,59 @@ export class Effect { ...@@ -315,9 +315,59 @@ export class Effect {
*/ */
onSelectATPById = createEffect(() => this.action.pipe( onSelectATPById = createEffect(() => this.action.pipe(
ofType(actions.selectATPById), ofType(actions.selectATPById),
mapTo(mainActions.generalActionError({ switchMap(({ atlasId, parcellationId, templateId }) =>
message: `NYI, onSelectATPById` this.sapiSvc.atlases$.pipe(
})) switchMap(atlases => {
const selectedAtlas = atlasId
? atlases.find(atlas => atlas.id === atlasId)
: atlases[0]
if (!selectedAtlas) {
return of(
mainActions.generalActionError({
message: `Atlas with id ${atlasId} not found!`
})
)
}
return this.sapiSvc.getAllParcellations(selectedAtlas).pipe(
switchMap(parcs => {
const selectedParcellation = parcellationId
? parcs.find(parc => parc.id === parcellationId)
: parcs[0]
if (!selectedParcellation) {
return of(
mainActions.generalActionError({
message: `Parcellation with id ${parcellationId} not found!`
})
)
}
return this.sapiSvc.getSupportedTemplates(selectedAtlas, selectedParcellation).pipe(
switchMap(templates => {
const selectedTemplate = templateId
? templates.find(tmpl => tmpl.id === templateId)
: templates[0]
if (!selectedTemplate) {
return of(
mainActions.generalActionError({
message: `Template with id ${templateId} not found`
})
)
}
return of(
actions.setAtlasSelectionState({
selectedAtlas,
selectedParcellation,
selectedTemplate
})
)
})
)
})
)
})
)
)
)) ))
onClearViewerMode = createEffect(() => this.action.pipe( onClearViewerMode = createEffect(() => this.action.pipe(
......
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