◆ FORGE Suite
GitHubMechanical Neuroimaging Lab · Univ. of Delaware
Skip to content

Image orientation

A NIfTI file says where each voxel is in the scanner with an affine: a matrix that maps voxel indices (i, j, k) to millimetres in the scanner's patient coordinates. FORGE builds this affine from the ISMRMRD acquisition headers so that its images overlay correctly on other images from the same session, such as an anatomical scan. This page explains how.

FORGE's voxel order

FORGE stores an image with y, the phase-encode direction, varying fastest, then x (read), then z (slice or partition). A NIfTI file's first axis, i, is the fastest-varying one, so in FORGE's files:

NIfTI axis Size Direction
i Ny phase encode
j Nx read
k Nz slice

From LPS to RAS

ISMRMRD stores the read, phase and slice directions and the slab position in the scanner's LPS convention: x increases to the patient's left, y to the posterior and z to the superior. NIfTI uses RAS: x to the right, y to the anterior, z to the superior. Converting flips the sign of the first two coordinates of every direction and of the position.

The affine's three columns are then the phase, read and slice directions in RAS, each scaled by the voxel size along that axis.

The origin

The ISMRMRD position is the centre of the slab. NIfTI's offset must be the position of voxel (0, 0, 0). FORGE puts the slab centre at index N/2 on each encoded axis, so the offset is the centre minus N/2 voxels along each of the three directions. For a single slice (Nz = 1) there is no step along the slice direction.

Handedness

The phase, read and slice directions don't always form a right-handed set. When they don't, the rotation can't be stored as a quaternion directly. FORGE then sets the NIfTI qfac to −1 and flips the slice column, as the format requires, so the qform and the sform describe the same affine.

What is checked

The test suite compares FORGE's affines with known geometry (NiftiOrientationTests.cpp). The orientation of 2D, multiband and 3D EMPIRE reconstructions has also been checked against MPRAGE images from the same sessions.

History

Before version 0.14.0, the affine labelled axis i as the read direction even though the data were stored phase-fastest, so i and j were swapped in world space. The offset pointed at the slab centre instead of voxel (0, 0, 0), and scl_slope was 100. Images made with older versions should be reconstructed again; see Fix the image geometry.