Skip to content

Function: writeVec() ​

ts
function writeVec(
   vec, 
   fileName, 
   options?): Promise<void>;

Defined in: src/io/io.ts:498

Write a NeuroVec to a 4D NIfTI-1 file.

The layout is taken from the class, not guessed from the dimensions: BigNeuroVec (what readVec returns) is time-first, dim = [T, X, Y, Z], with its geometry on volumeSpace; DenseNeuroVec and its subclasses (Float32NeuroVec, Int16NeuroVec, ...) and SparseNeuroVec are time-last, dim = [X, Y, Z, T], with the affine on their 4D space. All are written as NIfTI [X, Y, Z, T]. Any other NeuroVec implementation throws INVALID_ARGUMENT.

The header carries the full spatial affine as both qform and sform (codes 1), as writeVol does; a sheared affine is written as sform only. When the vec's space has a time spacing (spacing[3] time-last, spacing[0] time-first) it becomes pixdim[4] and the units are mm and seconds; otherwise pixdim[4] is 1 and the units are mm only. The datatype follows the data (SparseNeuroVec writes FLOAT32) unless dataType is given. Compression follows the extension, as for writeVol.

Parameters ​

vec ​

NeuroVec

fileName ​

string

options? ​

WriteVolOptions = {}

Returns ​

Promise<void>

Released under the MIT License.