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 = {
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',
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',
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',
} 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) => {
return null
}
const getDefaultParcellation = (spaceId: SPACE_ID) => {
return DEFAULT_PARC[spaceId]
}
const getAtlas = (spaceId: SPACE_ID) => {
return DEFAULT_ATLAS[spaceId]
}
const getVoxelFromSpace = (spaceId: string) => {
for (const key in NM_IDS){
if (NM_IDS[key] === spaceId) return IAV_VOXEL_SIZES_NM[key]
......@@ -97,7 +123,15 @@ export const processJsonLd = (json: { [key: string]: any }): Observable<IMessagi
subject.next({
type: 'loadTemplate',
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
* 1e3 / voxelSize
*/
const scaleUmToVoxelFixed = [
1e3 / voxelSize[0],
1e3 / voxelSize[1],
1e3 / voxelSize[2],
voxelSize[0],
voxelSize[1],
voxelSize[2],
]
// NG translation works on nm scale
const scaleUmToNm = 1e3
......
import { InjectionToken } from "@angular/core";
interface ILoadTemplateByIdPayload {
['@id']: string
atlas: {
id: string
}
template: {
id: string
}
parcellation: {
id: string
}
}
interface IResourceType {
......
......@@ -40,7 +40,18 @@ export class MessagingGlue implements IWindowMessaging, OnDestroy {
* and enforce single direction flow when possible
*/
loadTempladById( payload: IMessagingActionTmpl['loadTemplate'] ){
const atlasId = this.tmplSpIdToAtlasId.get(payload['@id'])
const {
parcellation: {
id: parcellationId
},
template: {
id: templateId
},
atlas: {
id: atlasId
}
} = payload
if (!atlasId) {
return this.store.dispatch(
generalActions.generalActionError({
......@@ -51,7 +62,8 @@ export class MessagingGlue implements IWindowMessaging, OnDestroy {
this.store.dispatch(
atlasSelection.actions.selectATPById({
atlasId,
templateId: payload["@id"]
templateId,
parcellationId
})
)
}
......
......@@ -315,9 +315,59 @@ export class Effect {
*/
onSelectATPById = createEffect(() => this.action.pipe(
ofType(actions.selectATPById),
mapTo(mainActions.generalActionError({
message: `NYI, onSelectATPById`
}))
switchMap(({ atlasId, parcellationId, templateId }) =>
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(
......
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