ImFusion Web SDK

@imfusion/sdk

ImFusion Web SDK

This package provides a wasm module and javascript bindings for a subset of the ImFusion SDK.

See websdk-demo.imfusion.com for a live demo.

Getting Started

To use this package, import LoadImFusionLib and use it to get an instance of the SDK module. You can optionally pass a canvas element to be used as the render area by the SDK.

ts
const Module = await LoadImFusionLib({ canvas: canvas });
Module.init();

You can now use the SDK functions. For example, to load a dataset:

ts
// load file data into an array buffer, and write it to a file in the wasm filesystem.
Module.FS.writeFile(filePath, fileData);

// Load the file using the data model.
const dataList = Module.dataModelHandle().loadFile(filePath);

And to display the first data in the loaded dataset:

ts
const display = Module.displayHandle();

display.viewGroupHandle().showData(dataList.get(0));

Refer to the module documentation for more information on the available functionalities.

License

Use of this package is governed by the ImFusion end user license agreement, included as LICENSE.txt in the package.

ImFusion Web SDK

Example

ts
import { init } from '@imfusion/sdk';

const canvas = document.getElementById('canvas') as HTMLCanvasElement;
const imf = await init(canvas, { autoResize: true });

const data = await imf.loadFileFromUrl('/scans/ct.nii.gz');
imf.showAll(data);

Interfaces

InterfaceDescription
ImFusionThe main ImFusion Web SDK interface.
InitOptionsOptions for initializing the ImFusion Web SDK wrapper.
CreateImageOptionsOptions for creating an Image from pixel data (see createImage()).
CustomGlObjectInterface for defining a custom GL Object
WasmModule-
ClassHandleBase interface for JS handles that refer to underlying C++ objects.
HandleArrayArray of ClassHandles with alias-aware membership checks.
AlgorithmListList of Algorithms as returned e.g. from compatibleAlgorithms
AlgorithmAn Algorithm instance as returned by e.g. compatibleAlgorithms
AnimationAn Animation as returned by MainModule#runAnimation or MainModule#runLoopedAnimation. Can be used to cancel an animation early.
AnnotationAn annotation.
AnnotationModelContainer class holding all annotations. Annotations have unique IDs and each belongs to a dataset.
BrushClass that allows enabling/disabling and setting options for the Brush.
CameraModels the extrinsic (position/orientation) and intrinsic (projection) parameters of a camera.
DataA dataset held by the Web SDK.
ImageDescriptorStruct describing the essential properties of an image.
ImageDescriptorWorldConvenience struct extending an ImageDescriptor to also include a matrix describing the image orientation in world coordinates.
ImageInfoDataComponent storing general information on the image origin.
ImageImage shared on multiple devices
SharedImageSetSet of images independent of their storage location.
SharedImageSetListBase interface for JS handles that refer to underlying C++ objects.
DataModelObservable collection of datasets with unique names.
IntegerListWrapper for a C++ vector of integers.
LabelConfigMapWrapper for a C++ map of number to [LabelConfig]LabelConfig.
ViewA single rendering view (e.g. single anatomical plane) that is hosted inside a Display.
SliceViewA 2D MPR View.
VolumeViewA Volumetric 3D View.
ViewListWrapper of a C++ array of Views.
DisplayOptions2dConfigures the display options for 2D slice rendering of images.
DisplayOptions3dConfigures the display options for 3D volume rendering of images.
DisplayAutoLayouterThis class facilitates the layouting of Views inside a Display by encapsulating logic to generate layouts for dynamic view configurations based on a customizable set of layouting algorithms.
RadiologyViewGroupClass representing a set of views typically available in radiology workstations.
RadiologyViewOverlaysHelper class to create and manage ViewOverlays commonly shown in radiology workstations.
DisplayClass representing the main render area.
StringListBase interface for JS handles that refer to underlying C++ objects.
GraphData representing a (potentially directed) graph.
GraphDisplayOptionsGraphDisplayOptions provides an object for configuring the rendering of the corresponding Graph in the different views.
AlignedBoxClass representing an axis aligned rectangular cuboid in 3D space.
GlViewStateEncapsulates the OpenGL view state defined by the viewport, a projection matrix and a model-view matrix.
GlObjectAbstract base class for a renderable OpenGL object that can be hosted in a GlView.
MenuItemListWrapper of a C++ array of MenuItems.
MenuRepresents a hierarchical menu of actions used to describe menu bars, context menus, or popup menus.
MenuItemA menu item is either an action, a separator, or a recursive submenu.
MenuActionRepresents an item inside a Menu where a callback function is called when user clicks on it.
MenuSeparatorBase interface for JS handles that refer to underlying C++ objects.
MeshSubclass of Data that represents a surface mesh.
MeshDisplayOptionsMeshDisplayOptions provides an object for configuring the rendering/appearance of the corresponding Mesh in the different views.
ExamplePropertiesUIBase interface for JS handles that refer to underlying C++ objects.
TransferFunction1D transfer function for classification during rendering.
EmbindModule-

Functions

FunctionDescription
preloadWasmFetch and compile the SDK's WebAssembly module ahead of init.
initInitialize the ImFusion Web SDK.
prefetchPrefetch and cache data from a URL. A later call to imf.loadFileFromUrl() with the same URL will use the cached bytes or take ownership of the fetch if still in flight.
clearPrefetchAbort any in-flight fetch for this URL and remove the fetched data.

Type Aliases

Type AliasDescription
ProgressCallbackCallback called on download progress.
EmbindString-
AlgorithmStatusConstantAlgorithm Status
EasingCurveEasing curve for animations
AnnotationTypeEnumeration of available annotation types.
AnnotationEventEnumeration of annotation lifecycle events.
CameraModeIntrinsic projection mode of a Camera.
DataKindKinds of data.
DataModalityImage modalities of data.
PixelTypePixel/voxel data type
ImageDescriptorComparisonBitflag enumeration to be used with ImageDescriptor::isApprox() to select which aspects of the descriptor should be compared.
ImageDescriptorWorldComparisonBitflag enumeration to be used with isApprox() to select which aspects of the descriptor should be compared.
ImageInfoPatientSexGender of the patient
ImageInfoLateralityLaterality of (paired) body part examined
ImageInfoAnatomicalOrientationTypeDICOM Anatomical Orientation Type
FileFormatSupported file formats.
RenderModeEnumeration of built-in render modes for the VolumeView.
VolumeViewResetOptionOptions for VolumeView.reset.
SliceBlendingModeEnumeration of the blending modes available for rendering multiple images.
SliceInterpolationModeInterpolation mode during rendering
LongPressDetectionConfigConfiguration variables for detection of long presses
DisplayLayoutModeEnumeration of available layouting modes for DisplayAutoLayouter#setLayoutMode.
OverlayTypeEnumeration to select default overlays to add to a view.
OrientationMeshTypeEnumeration of available meshes to show in the OrientationOverlay
GraphDimensionSpatial dimensionality of a Graph.
GraphTypeThe type of a Graph.
GlViewportStructure describing an OpenGL viewport
EventResultSimple record that is returned by the input event handling mechanism of Display to indicate how to proceed.
MeshVertexNormalWeightingWeighting schemes for averaging normals of faces around a vertex to obtain vertex normals
GraphEdgeAn edge in a Graph.
vec2-
vec2f-
vec2i-
vec3-
GraphNodeA node in a Graph.
vec3f-
vec3i-
vec4-
LabelConfigObject holding the metadata of a label value.
vec4f-
vec4i-
mat44x4 matrix in row-major storage order. I.e. mat[1] corresponds to row = 0, col = 1, and mat[4] corresponds to row = 1, col = 0
TransferFunctionKeyPointDescribes a single key point of a TransferFunction tissue.
TransferFunctionModeRepresentation used by a TransferFunction.
MainModule-

Classes

ClassDescription
ErrnoError-
FSStream-
FSNode-

Namespaces

NamespaceDescription
RuntimeExports-

On this page