a NVImage encapsulates some images data and provides methods to query and operate on images

Constructors

  • Parameters

    • dataBuffer: ArrayBuffer | ArrayBuffer[] = null

      an array buffer of image data to load (there are also methods that abstract this more. See loadFromUrl, and loadFromFile)

    • name: string = ''

      a name for this image. Default is an empty string

    • colormap: string = 'gray'

      a color map to use. default is gray

    • opacity: number = 1.0

      the opacity for this image. default is 1

    • pairedImgData: ArrayBuffer = null

      Allows loading formats where header and image are separate files (e.g. nifti.hdr, nifti.img)

    • cal_min: number = NaN

      minimum intensity for color brightness/contrast

    • cal_max: number = NaN

      maximum intensity for color brightness/contrast

    • trustCalMinMax: boolean = true

      whether or not to trust cal_min and cal_max from the nifti header (trusting results in faster loading)

    • percentileFrac: number = 0.02

      the percentile to use for setting the robust range of the display values (smart intensity setting for images with large ranges)

    • ignoreZeroVoxels: boolean = false

      whether or not to ignore zero voxels in setting the robust range of display values

    • useQFormNotSForm: boolean = false

      give precedence to QForm (Quaternion) or SForm (Matrix)

    • colormapNegative: string = ''

      a color map to use for symmetrical negative intensities

    • frame4D: number = 0

      volume displayed, 0 indexed, must be less than nFrame4D

      FIXME the following params are documented but not included in the actual constructor

    • imageType: ImageType = NVIMAGE_TYPE.UNKNOWN

      TODO

    • cal_minNeg: number = NaN

      TODO

    • cal_maxNeg: number = NaN

      TODO

    • colorbarVisible: boolean = true

      TODO

    • colormapLabel: LUT = null

      TODO

    Returns NVImage

Methods

  • Update options for image

    Parameters

    • options: ImageFromUrlOptions

    Returns void

  • set contrast/brightness to robust range (2%..98%)

    Parameters

    • vol: number = Number.POSITIVE_INFINITY

      volume for estimate (use -1 to use estimate on all loaded volumes; use INFINITY for current volume)

    Returns number[]

    volume brightness and returns array [pct2, pct98, mnScale, mxScale]

  • make a clone of a NVImage instance and return a new NVImage

    Returns NVImage

    NVImage instance

    myImage = NVImage.loadFromFile(SomeFileObject) // files can be from dialogs or drag and drop
    clonedImage = myImage.clone()
  • get nifti specific metadata about the image

    Returns ImageMetadata

  • read a 3D slab of voxels from a volume

    Parameters

    • voxStart: number[] = ...

      first row, column and slice (RAS order) for selection

    • voxEnd: number[] = ...

      final row, column and slice (RAS order) for selection

    • dataType: string = 'same'

      array data type. Options: 'same' (default), 'uint8', 'float32', 'scaled', 'normalized', 'windowed'

    Returns [TypedVoxelArray, number[]]

    the an array where ret[0] is the voxel values and ret[1] is dimension of selection

  • write a 3D slab of voxels from a volume

    Parameters

    • voxStart: number[] = ...

      first row, column and slice (RAS order) for selection

    • voxEnd: number[] = ...

      final row, column and slice (RAS order) for selection

    • img: TypedVoxelArray = ...

      array of voxel values to insert (RAS order)

    Returns void

  • Parameters

    • id: number

      id of 3D Object (is this the base volume or an overlay?)

    • gl: WebGL2RenderingContext

      WebGL rendering context

    Returns NiivueObject3D

    new 3D object in model space

  • Converts NVImage to NIfTI compliant byte array

    Parameters

    • drawingBytes: Uint8Array = null

    Returns Uint8Array

  • fill a NVImage instance with zeros for the image data

    Returns void

    myImage = NVImage.loadFromFile(SomeFileObject) // files can be from dialogs or drag and drop
    clonedImageWithZeros = myImage.clone().zeroImage()
  • factory function to load and return a new NVImage instance from a base64 encoded string

    Parameters

    • dims: number[] = ...
    • pixDims: number[] = ...
    • affine: number[] = ...
    • datatypeCode: number = 2
    • img: Uint8Array = ...

    Returns Uint8Array

    NVImage instance

    myImage = NVImage.loadFromBase64('SomeBase64String')
    
  • factory function to load and return a new NVImage instance from a base64 encoded string

    Parameters

    • __namedParameters: ImageFromBase64

    Returns NVImage

    NVImage instance

    myImage = NVImage.loadFromBase64('SomeBase64String')
    
  • factory function to load and return a new NVImage instance from a file in the browser

    Parameters

    • __namedParameters: ImageFromFileOptions

    Returns Promise<NVImage>

  • factory function to load and return a new NVImage instance from a given URL

    Parameters

    • __namedParameters: Partial<Omit<ImageFromUrlOptions, "url">> & {
          url?: string | ArrayBuffer | Uint8Array;
      } = {}

    Returns Promise<NVImage>

    NVImage instance

  • a factory function to make a zero filled image given a NVImage as a reference

    Parameters

    • nvImage: NVImage

      an existing NVImage as a reference

    • dataType: string = 'same'

      the output data type. Options: 'same', 'uint8'

    Returns NVImage

    new NVImage filled with zeros for the image data

    myImage = NVImage.loadFromFile(SomeFileObject) // files can be from dialogs or drag and drop
    newZeroImage = NVImage.zerosLike(myImage)