nrrdread.m supports reading of 4D volumes, so it should work as is. Let me know if you find any issues with it.
The displacement field volume contains exactly that. Each element in the 3D array is a 3-element vector.
What may be confusing is that Slicer stores elements in RAS coordinates, while the geometry of image saved to file is specified in LPS. Displacement vector elements are defined in RAS coordinates in Slicer and when we save a vector volume from Slicer, we do not alter the stored vector components (we don’t know if the vector components correspond to color, spatial coordinates, etc.). Image geometry is stored in LPS by most medical imaging software, that’s why we follow this convention, too. We should probably change Slicer to somehow know that vector components should be converted to LPS for displacement field images, but for now you can do this yourself by inverting the sign of the first two components of the displacement vector that you have read using nrrdread.
Fortunately, this is very simple: Image is specified in LPS physical space. You can convert between LPS and IJK array indexes by using
img.ijkToLpsTransform provided by
If you process data outside Slicer, I would recommend using LPS coordinate system.
In Slicer, displacement vector values at current mouse pointer position are shown in Transforms module’s Information section (“Displacement vector RAS: (…, …, …)”).
If you exported a transform to a displacement field image and that image is shown in a slice viewer, you can also see the displacement values in the Data Probe window (in the bottom left corner).