Skip to content

Function: toInt32Labels() ​

ts
function toInt32Labels(source): Int32Array;

Defined in: src/atlas/labels.ts:31

Convert a label volume (or its voxel data) to an Int32Array of labels.

Values are converted one by one, never by reinterpreting the underlying buffer, so every typed-array type (int8/uint8/int16/uint16/int32/uint32/ float32/float64, any byteOffset) and plain arrays are handled. Volumes read with readVol already have scl_slope/scl_inter applied, so the values seen here are the scaled ones.

Floating-point values within 1e-4 of an integer are rounded to it.

Parameters ​

source ​

NeuroVol | ArrayLike<number>

A NeuroVol or its voxel data.

Returns ​

Int32Array

A new Int32Array (or source itself when it is already an Int32Array).

Throws ​

If a value is not finite (NaN, ±Infinity), not an integer, or outside the int32 range. The message gives the voxel index and value.

Released under the MIT License.