diff --git a/src/atlasViewer/atlasViewer.component.ts b/src/atlasViewer/atlasViewer.component.ts index c897c231df9f6256bee9abed0629ea797da7d1f2..4bbf3551b57b593832bf7ecb3960948f0b78052b 100644 --- a/src/atlasViewer/atlasViewer.component.ts +++ b/src/atlasViewer/atlasViewer.component.ts @@ -64,6 +64,9 @@ export class AtlasViewer implements OnDestroy, OnInit, AfterViewInit { private subscriptions: Subscription[] = [] /* handlers for nglayer */ + /** + * TODO make untangle nglayernames and its dependency on ng + */ public ngLayerNames$ : Observable<any> public ngLayers : NgLayerInterface[] private disposeHandler : any diff --git a/src/atlasViewer/atlasViewer.dataService.service.ts b/src/atlasViewer/atlasViewer.dataService.service.ts index 7dad5e9b1113ce2c159952ea8de6b2c30e045f02..a152b1647c0b24bd65e07228db1798dfec87b7dc 100644 --- a/src/atlasViewer/atlasViewer.dataService.service.ts +++ b/src/atlasViewer/atlasViewer.dataService.service.ts @@ -80,10 +80,8 @@ export class AtlasViewerDataService implements OnDestroy{ templateSpace == 'Waxholm Rat V2.0' ? 'datapath:metadata/OSLO_sp_data_rev.json' : null - - if(filterTemplateSpace){ - url.searchParams.append('fq',filterTemplateSpace) - }else if (templateSpace === 'MNI 152 ICBM 2009c Nonlinear Asymmetric'){ + + if (templateSpace === 'MNI 152 ICBM 2009c Nonlinear Asymmetric'){ return Promise.all([ fetch('res/json/***REMOVED***.json').then(res=>res.json()), fetch('res/json/***REMOVED***.json').then(res=>res.json()) @@ -115,6 +113,20 @@ export class AtlasViewerDataService implements OnDestroy{ }) }) .catch(console.error) + }else if (templateSpace === 'Waxholm Rat V2.0'){ + return fetch('res/json/camillaWaxholmPointsAggregatedData.json') + .then(res => res.json()) + .then(arr => { + this.store.dispatch({ + type : FETCHED_SPATIAL_DATA, + fetchedDataEntries : arr.map(item => Object.assign({}, item, { properties : {} })) + }) + this.store.dispatch({ + type : UPDATE_SPATIAL_DATA, + totalResults : arr.length + }) + }) + .catch(console.error) }else{ return } diff --git a/src/res/ext/camillaWaxholmPointsAggregatedData.json b/src/res/ext/camillaWaxholmPointsAggregatedData.json new file mode 100644 index 0000000000000000000000000000000000000000..0e33aa15b19d357ead67bf38e0dea3e107d19c24 --- /dev/null +++ b/src/res/ext/camillaWaxholmPointsAggregatedData.json @@ -0,0 +1,478 @@ +[ + { + "name": "Channel 1", + "templateSpace": "Waxholm Rat V2.0", + "geometry": { + "type": "point", + "space": "real", + "position": [ + -1.7382810000000006, + 5.371094500000002, + 5.566406499999999 + ], + "properties": { + "description": "Description of Channel 1", + "publications": [] + } + } + }, + { + "name": "Channel 2", + "templateSpace": "Waxholm Rat V2.0", + "geometry": { + "type": "point", + "space": "real", + "position": [ + -1.8164060000000006, + 2.4804695000000017, + 6.191406499999999 + ], + "properties": { + "description": "Description of Channel 2", + "publications": [] + } + } + }, + { + "name": "Channel 3", + "templateSpace": "Waxholm Rat V2.0", + "geometry": { + "type": "point", + "space": "real", + "position": [ + 1.8164064999999994, + 5.410157000000002, + 5.566406499999999 + ], + "properties": { + "description": "Description of Channel 3", + "publications": [] + } + } + }, + { + "name": "Channel 4", + "templateSpace": "Waxholm Rat V2.0", + "geometry": { + "type": "point", + "space": "real", + "position": [ + 1.5429689999999994, + 2.5585945000000017, + 6.347656499999999 + ], + "properties": { + "description": "Description of Channel 4", + "publications": [] + } + } + }, + { + "name": "Channel 5", + "templateSpace": "Waxholm Rat V2.0", + "geometry": { + "type": "point", + "space": "real", + "position": [ + -4.746093500000001, + -0.33203049999999834, + 6.113281499999999 + ], + "properties": { + "description": "Description of Channel 5", + "publications": [] + } + } + }, + { + "name": "Channel 6", + "templateSpace": "Waxholm Rat V2.0", + "geometry": { + "type": "point", + "space": "real", + "position": [ + -1.8554685000000006, + -0.25390549999999834, + 6.855468999999999 + ], + "properties": { + "description": "Description of Channel 6", + "publications": [] + } + } + }, + { + "name": "Channel 7", + "templateSpace": "Waxholm Rat V2.0", + "geometry": { + "type": "point", + "space": "real", + "position": [ + 1.4257814999999994, + -0.17578049999999834, + 7.011718999999999 + ], + "properties": { + "description": "Description of Channel 7", + "publications": [] + } + } + }, + { + "name": "Channel 8", + "templateSpace": "Waxholm Rat V2.0", + "geometry": { + "type": "point", + "space": "real", + "position": [ + 4.433593999999999, + -0.17578049999999834, + 6.269531499999999 + ], + "properties": { + "description": "Description of Channel 8", + "publications": [] + } + } + }, + { + "name": "Channel 9", + "templateSpace": "Waxholm Rat V2.0", + "geometry": { + "type": "point", + "space": "real", + "position": [ + -4.941406000000001, + -3.1054679999999983, + 6.621093999999999 + ], + "properties": { + "description": "Description of Channel 9", + "publications": [] + } + } + }, + { + "name": "Channel 10", + "templateSpace": "Waxholm Rat V2.0", + "geometry": { + "type": "point", + "space": "real", + "position": [ + -2.0507810000000006, + -2.9882804999999983, + 7.128906499999999 + ], + "properties": { + "description": "Description of Channel 10", + "publications": [] + } + } + }, + { + "name": "Channel 11", + "templateSpace": "Waxholm Rat V2.0", + "geometry": { + "type": "point", + "space": "real", + "position": [ + 1.5039064999999994, + -2.9492179999999983, + 7.324218999999999 + ], + "properties": { + "description": "Description of Channel 11", + "publications": [] + } + } + }, + { + "name": "Channel 12", + "templateSpace": "Waxholm Rat V2.0", + "geometry": { + "type": "point", + "space": "real", + "position": [ + 4.355468999999999, + -2.9101554999999983, + 6.894531499999999 + ], + "properties": { + "description": "Description of Channel 12", + "publications": [] + } + } + }, + { + "name": "Channel 13", + "templateSpace": "Waxholm Rat V2.0", + "geometry": { + "type": "point", + "space": "real", + "position": [ + -5.058593500000001, + -6.152342999999998, + 6.464843999999999 + ], + "properties": { + "description": "Description of Channel 13", + "publications": [] + } + } + }, + { + "name": "Channel 14", + "templateSpace": "Waxholm Rat V2.0", + "geometry": { + "type": "point", + "space": "real", + "position": [ + -1.9335935000000006, + -5.996092999999998, + 7.441406499999999 + ], + "properties": { + "description": "Description of Channel 14", + "publications": [] + } + } + }, + { + "name": "Channel 15", + "templateSpace": "Waxholm Rat V2.0", + "geometry": { + "type": "point", + "space": "real", + "position": [ + 1.3867189999999994, + -5.957030499999998, + 7.480468999999999 + ], + "properties": { + "description": "Description of Channel 15", + "publications": [] + } + } + }, + { + "name": "Channel 16", + "templateSpace": "Waxholm Rat V2.0", + "geometry": { + "type": "point", + "space": "real", + "position": [ + 4.550781499999999, + -5.957030499999998, + 6.894531499999999 + ], + "properties": { + "description": "Description of Channel 16", + "publications": [] + } + } + }, + { + "name": "Ground", + "templateSpace": "Waxholm Rat V2.0", + "geometry": { + "type": "point", + "space": "real", + "position": [ + -0.05859350000000063, + -9.550780499999998, + 7.089843999999999 + ], + "properties": { + "description": "Description of Ground", + "publications": [] + } + } + }, + { + "name": "hbp-00941_ERP_j10_hippo-histo", + "templateSpace": "Waxholm Rat V2.0", + "geometry": { + "type": "point", + "space": "real", + "position": [ + 2.0976564999999994, + -2.5273429999999983, + 3.5234377499999994 + ], + "properties": { + "description": "Description of hbp-00941_ERP_j10_hippo-histo", + "publications": [] + } + } + }, + { + "name": "hbp-00941_ERP_j10_histo-M2_nr1", + "templateSpace": "Waxholm Rat V2.0", + "geometry": { + "type": "point", + "space": "real", + "position": [ + -1.0781247500000006, + 4.984375750000002, + 4.996093999999999 + ], + "properties": { + "description": "Description of hbp-00941_ERP_j10_histo-M2_nr1", + "publications": [] + } + } + }, + { + "name": "hbp-00941_ERP_j10_histo-M2_nr2", + "templateSpace": "Waxholm Rat V2.0", + "geometry": { + "type": "point", + "space": "real", + "position": [ + -1.4804685000000006, + 4.957032000000002, + 5.007812749999999 + ], + "properties": { + "description": "Description of hbp-00941_ERP_j10_histo-M2_nr2", + "publications": [] + } + } + }, + { + "name": "hbp-00941_ERP_j11_hippo-histo", + "templateSpace": "Waxholm Rat V2.0", + "geometry": { + "type": "point", + "space": "real", + "position": [ + 2.9921877499999994, + -2.9257804999999983, + 4.039062749999999 + ], + "properties": { + "description": "Description of hbp-00941_ERP_j11_hippo-histo", + "publications": [] + } + } + }, + { + "name": "hbp-00941_ERP_j11_histo-M2_nr1", + "templateSpace": "Waxholm Rat V2.0", + "geometry": { + "type": "point", + "space": "real", + "position": [ + -1.3242185000000006, + 4.507813250000002, + 5.148437749999999 + ], + "properties": { + "description": "Description of hbp-00941_ERP_j11_histo-M2_nr1", + "publications": [] + } + } + }, + { + "name": "hbp-00941_ERP_j11_histo-M2_nr2", + "templateSpace": "Waxholm Rat V2.0", + "geometry": { + "type": "point", + "space": "real", + "position": [ + -1.6445310000000006, + 4.523438250000002, + 5.187500249999999 + ], + "properties": { + "description": "Description of hbp-00941_ERP_j11_histo-M2_nr2", + "publications": [] + } + } + }, + { + "name": "S1BFsurface", + "templateSpace": "Waxholm Rat V2.0", + "geometry": { + "type": "point", + "space": "real", + "position": [ + -5.378906000000001, + -2.3906242499999983, + 6.375000249999999 + ], + "properties": { + "description": "Description of S1BFsurface", + "publications": [] + } + } + }, + { + "name": "dorsal HPC CA1 surface", + "templateSpace": "Waxholm Rat V2.0", + "geometry": { + "type": "point", + "space": "real", + "position": [ + -2.5898435000000006, + -2.5820304999999983, + 7.027343999999999 + ], + "properties": { + "description": "Description of dorsal HPC CA1 surface", + "publications": [] + } + } + }, + { + "name": "V1Msurface", + "templateSpace": "Waxholm Rat V2.0", + "geometry": { + "type": "point", + "space": "real", + "position": [ + -3.4843747500000006, + -5.167967999999998, + 7.160156499999999 + ], + "properties": { + "description": "Description of V1Msurface", + "publications": [] + } + } + }, + { + "name": "PHR surface", + "templateSpace": "Waxholm Rat V2.0", + "geometry": { + "type": "point", + "space": "real", + "position": [ + -5.480468500000001, + -4.261717999999998, + 6.480468999999999 + ], + "properties": { + "description": "Description of PHR surface", + "publications": [] + } + } + }, + { + "name": "PHRborder", + "templateSpace": "Waxholm Rat V2.0", + "geometry": { + "type": "point", + "space": "real", + "position": [ + -6.980468500000001, + -5.613280499999998, + 1.6289064999999994 + ], + "properties": { + "description": "Description of PHRborder", + "publications": [] + } + } + } +] \ No newline at end of file diff --git a/src/ui/layerbrowser/layerbrowser.component.ts b/src/ui/layerbrowser/layerbrowser.component.ts index b144220b66e0ce2e5727436fd85244732540e8dd..5de054dc184ff7b15058974344c54513e4105183 100644 --- a/src/ui/layerbrowser/layerbrowser.component.ts +++ b/src/ui/layerbrowser/layerbrowser.component.ts @@ -13,6 +13,9 @@ import { filter, distinctUntilChanged, map, delay } from "rxjs/operators"; export class LayerBrowser implements OnDestroy{ + /** + * TODO make untangle nglayernames and its dependency on ng + */ ngLayers : NgLayerInterface[] = [] lockedLayers : string[] = [] diff --git a/src/ui/nehubaContainer/nehubaViewer/nehubaViewer.component.ts b/src/ui/nehubaContainer/nehubaViewer/nehubaViewer.component.ts index d9218a9458fcd19e1e506aa643aa2519a1edc326..c2506a5511be0c22d0a84d44df972e67d1f9e56d 100644 --- a/src/ui/nehubaContainer/nehubaViewer/nehubaViewer.component.ts +++ b/src/ui/nehubaContainer/nehubaViewer/nehubaViewer.component.ts @@ -28,8 +28,13 @@ export class NehubaViewerUnit implements OnDestroy{ initNiftiLayers : any[] = [] config : any - nehubaViewer : any + private _dim: [number, number, number] + get dim(){ + return this._dim + ? this._dim + : [1.5e9, 1.5e9, 1.5e9] + } _s1$ : any _s2$ : any @@ -75,6 +80,19 @@ export class NehubaViewerUnit implements OnDestroy{ this.constantService.loadExportNehubaPromise .then(() => { + const layers = this.config.dataset.initialNgState.layers + const key = Object.keys(layers)[0] + const regex = /http.*$/.exec(layers[key].source) + if(regex[0]){ + fetch(`${regex[0]}/info`) + .then(res => res.json()) + .then(json => { + const {resolution, size} = json.scales[0] + this._dim = resolution.map((v, idx) => v * size[idx]) + }) + .catch(e => this.errorEmitter.emit(e)) + } + this.patchNG() this.loadNehuba() }) @@ -456,6 +474,7 @@ export class NehubaViewerUnit implements OnDestroy{ return this.workerService.worker.postMessage({ type : 'GET_USERLANDMARKS_VTK', + scale: Math.min(...this.dim.map(v => v * 2e-9)), landmarks : landmarks.map(lm => lm.position.map(coord => coord * 1e6)) }) } @@ -477,6 +496,7 @@ export class NehubaViewerUnit implements OnDestroy{ this.workerService.worker.postMessage({ type : 'GET_LANDMARKS_VTK', template : this.templateId, + scale: Math.min(...this.dim.map(v => v * 1.4e-8)), landmarks : geometries.map(geometry => geometry === null ? null diff --git a/src/util/worker.js b/src/util/worker.js index 8fd3f883eb71f7dff0a443fc675b50e4d1b2d02c..0ab35834b383d53c420d55cd85ecbb24b2c8483d 100644 --- a/src/util/worker.js +++ b/src/util/worker.js @@ -108,7 +108,7 @@ const getMeshPoly = (polyIndices, currentIdx) => polyIndices.map(triplet => const encoder = new TextEncoder() -const parseLmToVtk = (landmarks) => { +const parseLmToVtk = (landmarks, scale) => { const reduce = landmarks.reduce((acc,curr,idx) => { //curr : null | [number,number,number] | [ [number,number,number], [number,number,number], [number,number,number] ][] @@ -117,7 +117,7 @@ const parseLmToVtk = (landmarks) => { if(!isNaN(curr[0])) return { currentVertexIndex : acc.currentVertexIndex + 12, - vertexString : acc.vertexString.concat(getIcoVertex(curr, 2.8)), + vertexString : acc.vertexString.concat(getIcoVertex(curr, scale)), polyCount : acc.polyCount + 20, polyString : acc.polyString.concat(getIcoPoly(acc.currentVertexIndex)), labelString : acc.labelString.concat(Array(12).fill(idx.toString()).join('\n')) @@ -171,8 +171,11 @@ const getLandmarksVtk = (action) => { // landmarks are array of triples in nm (array of array of numbers) const landmarks = action.landmarks const template = action.template + const scale = action.scale + ? action.scale + : 2.8 - const vtk = parseLmToVtk(landmarks) + const vtk = parseLmToVtk(landmarks, scale) if(!vtk) return @@ -193,7 +196,10 @@ let userLandmarkVtkUrl const getuserLandmarksVtk = (action) => { const landmarks = action.landmarks - const vtk = parseLmToVtk(landmarks) + const scale = action.scale + ? action.scale + : 2.8 + const vtk = parseLmToVtk(landmarks, scale) if(!vtk) return