Skip to main content

Med Module

import * as sethealth from '@sethealth/core';[...]

API reference#

med.destroyAll( opts?: DestroyAllMedOptions )

Destroys all the loaded `MedHandler`s. Freeing the memory.

med.ensureSources( meds: undefined, opts: EnsureSourcesMedOptions, onProgress?: ProgressCallback )

MedHandlers in sethealth might or might not have a source. A source is usually a URL from which the medical data can be downloaded and it's required in order to be shared.

This method, when passed an array of `MedHandler`, ensures all the medical data in the array have a source. If a medical data does not have a source, it will upload it and store the source, if the medical data already have a source, it will just skip over.

med.get( id: string )

Returns the `MedHandler` of a volume based on its `id`


Returns an array of `MedHandler` of all the previous loaded medical data.

med.loadFromFiles( files: ArrayLike, onProgress?: ProgressCallback )

Loads new MedHandlers from an array of files. Under the hood, it will look at the file extensions as heuristics to determine how the files should be parsed:

- `".nii"`, `".nii.gz"`: loaded as "nifty" - `""`, `".dcm"`: loaded as "dicom" - `".nrrd"`, `".nrrd.gx"`: loaded as "nrrd" Once the "type" is infered, it will use `loadFromSource()` under the hood, and return the same results.

med.loadFromFilesystem( openFolders: boolean, onStart?: undefined | , onProgress?: ProgressCallback )

Will open a native UI so the users can import files or folder from their local filesystem. Once the files are loaded, it will use `loadFromFiles()` under the hood, and return the same results.

med.loadFromSource( source: MedSource | string, onProgress?: ProgressCallback )

Loads a new `MedHandler` from a source. A "source" can be an URL, a File, an ArrayBuffer, or an array of those. and indicates what type of input it is, such as: "dicom", "nifty", "nrrd", "png", "raw".

Some types like "png" and "raw" needs extra metadata in order to be loaded as a `MedHandler`, since this file formats does not provide this metadata out of the box. Please look at `MedSource` interface for further information. Once the medical data is loaded, it's cached by sethealth until it's manually removed using the "destroy()" method, or `med.destroyAll()`, which destroys all the previously loaded medical data. Note that medical data can consume a lot of memory make sure to `destroy()` all the medical data that are not about to be used. Given a source, this method returns an array of the loaded medical data. Most of the time, it will be an array with a single MedHandler, but `dicom` source type might return several. One `MedHandler` will only handle one medical data