Dear Torsten,
As FSL pre-dates NIFTI, we don't use the sform or qform coordinates in our internal representations.
However, we do use the sign of the qform or sform matrix to determine the left-right order.
There are multiple representations of warpfields within FSL, but the easiest to understand is the absolute convention (vs relative) of the field representation (vs coefficient). You can always convert to a field representation in absolute convention using the "convertwarp" tool.
For images with a radiological-ordering (negative determinant of the qform or sform) then the values stored in the abs-field form of the warpfield are just the coordinates of the destination point in the input image, with the warpfield itself being in the reference image space. The coordinates used here are the internal mm coordinates used in FSL, and these are just scaled versions of the voxel coordinates (we use the same conventions as the NIFTI voxel coordinates for radiologically-ordered images). That is, you take the voxel coordinate and multiply each coordinate by the respective voxel size, in mm, to get the mm coordinate. So if the value at a particular voxel in the warpfield was (108,30,74) and the voxel size of the input image was (2,2,2), then this would mean that this voxel (in the reference image) mapped to the voxel coordinate (54,15,37) in the input image.
For image with a neurological-ordering (positive determinant of qform/sform) the situation is as above except that the x voxel coordinate is reversed (i.e. 0 becomes N-1, 1 becomes N-2, etc.) prior to converting to mm coordinates. This way the coordinate system within FSL always has the same handedness (left-right orientation), which is achieved by effectively swapping the x-axis by comparison with the NIFTI voxel coordinates, which can be of either handedness, as given by the qform/sform.
I hope this helps.
All the best,
Mark
On 12 Mar 2014, at 17:26, Torsten Rohlfing <[log in to unmask]> wrote:
> Hi -
>
> I am trying to interface FSL's applywarp tool with another registration toolkit, and for that it would be extremely helpful to understand how applywarp defines the coordinate systems of the input and reference images.
>
> That is, for each pixel in the reference image, how is the spatial coordinate determined that is fed into the warp function, and for each mapped spatial coordinate in the input image space, how is its location in the input image's pixel grid determined?
>
> Specifically, are the NIFTI qform/sform transformations respected for either image, or are the spatial coordinates based on (and aligned with) the image grid itself? Also, is there any image grid reorientation (e.g., to RAS space) or are the coordinates based on the physical storage order of pixels in the images?
>
> Thanks!
>
> Torsten
|