-
Xiao Gui authored2cb2d701
Plugin APIs
window.interactiveViewer
metadata
selectedTemplateBSubject
BehaviourSubject that emits a TemplateDescriptor object whenever a template is selected. Emits null onInit.
selectedParcellationBSubject
BehaviourSubject that emits a ParcellationDescriptor object whenever a parcellation is selected. n.b. selecting a new template automatically select the first available parcellation. Emits null onInit.
selectedRegionsBSubject
BehaviourSubject that emits an Array of RegionDescriptor objects whenever the list of selected regions changes. Emits empty array onInit.
loadedTemplates
Array of TemplateDescriptor objects. Loaded asynchronously onInit.
layersRegionLabelIndexMap
Map of layer name to Map of labelIndex (used by neuroglancer and nehuba) to the corresponding RegionDescriptor object.
viewerHandle
nb
viewerHandle
may be undefined at any time (user be yet to select an atlas, user could have unloaded an atlas. ...etc)
setNavigationLoc(coordinates, realspace?:boolean)
Function that teleports the navigation state to coordinates : [x:number,y:number,z:number]. Optional arg determine if the set of coordinates is in realspace (default) or voxelspace.
moveToNavigationLoc(coordinates,realspace?:boolean)
same as setNavigationLoc(coordinates,realspace?), except the action is carried out over 500ms.
setNavigationOri(ori)
(NYI) Function that sets the orientation state of the viewer.
moveToNavigationOri(ori)
(NYI) same as setNavigationOri, except the action is carried out over 500ms.
showSegment(labelIndex)
Function that shows a specific segment. Will trigger selectedRegionsBSubject.
hideSegment(labelIndex)
Function that hides a specific segment. Will trigger selectRegionsBSubject
showAllSegments()
Function that shows all segments. Will trigger selectRegionsBSubject
hideAllSegments()
Function that hides all segments. Will trigger selectRegionBSubject
getLayersSegmentColourMap()
Call to get Map of layer name to Map of label index to colour map
applyLayersColourMap
Function that applies a custom colour map.
loadLayer(layerObject)
Function that loads ManagedLayersWithSpecification directly to neuroglancer. Returns the values of the object successfully added. n.b. advanced feature, will likely break other functionalities. n.b. if the layer name is already taken, the layer will not be added.
const obj = {
'advanced layer' : {
type : 'image',
source : 'nifti://http://example.com/data/nifti.nii',
},
'advanced layer 2' : {
type : 'mesh',
source : 'vtk://http://example.com/data/vtk.vtk'
}
}
const returnValue = window.interactiveViewer.viewerHandle.loadLayer(obj)
/* loads two layers, an image nifti layer and a mesh vtk layer */
console.log(returnValue)
/* prints
[{
type : 'image',
source : 'nifti...'
},
{
type : 'mesh',
source : 'vtk...'
}]
*/
removeLayer(layerObject)
Function that removes ManagedLayersWithSpecification, returns an array of the names of the layers removed.
n.b. advanced feature. may break other functionalities.
const obj = {
'name' : /^PMap/
}
const returnValue = window.interactiveViewer.viewerHandle.removeLayer(obj)
console.log(returnValue)
/* prints
['PMap 001','PMap 002']
*/
add3DLandmarks(landmarks)
adds landmarks to both the perspective view and slice view.
input
input | type | desc |
---|---|---|
landmarks | array | an array of landmarks to be rendered by the viewer |
A landmark object consist of the following keys:
key | type | desc | required |
---|---|---|---|
id | string | id of the landmark | yes |
name | string | name of the landmark | |
position | [number, number, number] | position (in mm) | yes |
color | [number, number, number] | rgb of the landmark |
const landmarks = [{
id : `fzj-xg-jugex-1`,
position : [0,0,0]
},{
id : `fzj-xg-jugex-2`,
position : [22,27,-1],
color: [255, 0, 255]
}]
window.interactiveViewer.viewerHandle.add3DLandmarks(landmarks)
/* adds landmarks in perspective view and slice view */