Map a NIFTI1 coordinates to world Space i.e RAS+ Space

I have a NIFTI1 file with header info as below

qform_code : scanner
sform_code : scanner

As per this link, which method[check the Orientation information part] I can use to map the image voxel coordinates[i,j,k], to world coordinates i.e RAS+ space, since both qform_code and sform_code are 1, so which method will be used Method 2 or Method 3?

As per the Nifti Affines, Method 3 must be used.

If we can use the Method 3, can I loop over the image and convert each i,j,k coordinate using nilearn.image.coord_transform to find world coordinates?

By the standard, sform takes precedence when sform_code > 0.

However, it should be noted that ANTs will absolutely ignore sforms. So this is somewhat context dependent.

As I understand it, the original idea of qform and sform was be to allow you to have an “original” mapping (qform) as well as a registered mapping (sform) without resampling your file. In practice, keeping two coordinate systems means your data is treated differently by different software. If your qform and sform are different, I’d recommend copying your sform to your qform and getting on with your day.

This might be useful http://blog.chrisgorgolewski.org/2014/12/how-to-convert-between-voxel-and-mm.html

Thank you @effigies and @ChrisGorgolewski , can you also look at my other question .

@ChrisGorgolewski, what are mm coordinates in your tutorial?

Scanner space (I think!).