Thank you for the clarification, Mark; this is very helpful to know.

Thanks again, and best regards,
David

On Mon, Apr 22, 2013 at 5:17 AM, Mark Jenkinson <[log in to unmask]> wrote:
Dear David,

The origin is not stored separately, it is part of the qform or sform.  It is the result of solving for what voxel location maps to the (0,0,0)mm location, and so can be found from the fourth column of the inverse of the qform or sform matrix (depending on which is relevant and set in your image).  Note that in your images both qform and sform are set to "Unknown" which means that they do not contain useful information and hence you cannot get the origin from these.  This indicates that the images have neither scanner orientation information encoded in them or any information about MNI coordinates.  In such a situation FSL or SPM end up going with their respective defaults (which are different).

All the best,
Mark


On 19 Apr 2013, at 20:54, David Romano <[log in to unmask]> wrote:

So just to confirm I understand:  It sounds like the fact that there are no lines in the fslhd output that have the word "origin" means this information is missing from the original .nii.gz file, which then prompted SPM to force an origin at the center voxel -- is this correct?

Thanks,
David

On Fri, Apr 19, 2013 at 3:22 AM, Jesper Andersson <[log in to unmask]> wrote:
MJ,

Once again I have to say that I'm no SPM expert, but looking more carefully at the values in the fourth column from SPM, it looks like these are the centre of the volume and so probably not specific to any MNI coordinates.  I _suspect_

that is correct. SPM uses the centre of the FOV unless told otherwise.

that this just reflects the choice of the origin for the SPM coordinate system (i.e. at the centre of the volume/FOV) whereas in FSL the origin is in the corner (coincident with the voxel coordinate origin).

Jesper


All the best,
Mark


On 19 Apr 2013, at 03:28, David Romano <[log in to unmask]> wrote:

Thanks, Mark; and to follow up on the transformation question, the file I'm working with is from the publicly dataset for the Haxby 2001 object-recognition study, and the results were from doing the following:

1) applying fslchfiletype to change the file from .nii.gz to analyze format (becasue I wasn't sure if SPM knows .nii.gz files), and then
2) reading the resulting analyze file with SPM.

In other words, the transformation was read by SPM from fsl output, which is why I was surprised the result was different.   If you like, I can point you (and the SPM folks?) to the precise file -- this seems strange to me, but I'm a just a novice at both fsl and SPM.

Thanks again,
David

On Thu, Apr 18, 2013 at 3:33 PM, Mark Jenkinson <[log in to unmask]> wrote:
Hi,

You can use fslmeants with --showall to get a text output of all voxel values, including the coordinates.
The coordinates will be in voxel coordinates.  If you want mm coordinates then you'll need to use img2stdcoord and std2imgcoord to convert between them.  There is documentation on the wiki for these.

As for the SPM info - I believe that you are looking at the SPM registration information, which is not part of the native image (although I confess that I am not an SPM expert!).  The only coordinate information that is available to FSL is that stored in the NIFTI files, and not in any mat file, as these mat files are not understood by FSL.

All the best,
        Mark



On 18 Apr 2013, at 18:31, David Romano <[log in to unmask]> wrote:

> Hi everyone,
>
> I have an fMRI nifti file which I'd like to eventually be able to:
>
> 1) convert into a time by voxel matrix, and
> 2) create a dictionary that records the MNI coordinates of each voxel (column).
>
> I've tried fsl2ascii, which produces a separate matrix for each timepoint, but these (data) matrices are stripped of any coordinate information; in my case the spatial dimensions are 40x64x64, and the corresponding ascii matrices are 4096x40, so I can only tell that the x-coordinates correspond to columns, but that's it.   I've also tried to use fslhd to identify the coordinate transformation matrix that corresponds to the original fMRI data, but it seems that information about the MNI origin is missing, or at least at odds with what I get from SPM; I've included the fslhd and SPM output below.
>
> In short, I have the following questions:
>
> A) Is there a way within FSL to convert the image at a timepoint into a (brain) vector (which I can then concatenate with others)?
> B) How does one extract the array-coordinates-to-MNI-coordinates matrix from an fMRI nifti file in FSL?
>
> I'd be grateful for any help or direction on these questions.
>
> Thanks,
> David  Romano
>
> ---- SPM output ----
> >> testvolume(1).mat
>
> ans =
>
>    -3.5000         0         0   71.7500
>          0    3.7500         0 -121.8750
>          0         0    3.7500 -121.8750
>          0         0         0    1.0000
> ---- fslhd output ----
> dromano$ fslhd bold.nii.gz
> filename       bold.nii.gz
>
> sizeof_hdr     348
> data_type      INT16
> dim0           4
> dim1           40
> dim2           64
> dim3           64
> dim4           1452
> dim5           1
> dim6           1
> dim7           1
> vox_units      mm
> time_units     s
> datatype       4
> nbyper         2
> bitpix         16
> pixdim0        0.0000000000
> pixdim1        3.5000000000
> pixdim2        3.7500000000
> pixdim3        3.7500000000
> pixdim4        2.5000000000
> pixdim5        0.0000000000
> pixdim6        0.0000000000
> pixdim7        0.0000000000
> vox_offset     352
> cal_max        2753.0000
> cal_min        0.0000
> scl_slope      1.000000
> scl_inter      0.000000
> phase_dim      0
> freq_dim       0
> slice_dim      0
> slice_name     Unknown
> slice_code     0
> slice_start    0
> slice_end      0
> slice_duration 0.000000
> time_offset    0.000000
> intent         Unknown
> intent_code    0
> intent_name
> intent_p1      0.000000
> intent_p2      0.000000
> intent_p3      0.000000
> qform_name     Unknown
> qform_code     0
> qto_xyz:1      3.500000  0.000000  0.000000  0.000000
> qto_xyz:2      0.000000  3.750000  0.000000  0.000000
> qto_xyz:3      0.000000  0.000000  3.750000  0.000000
> qto_xyz:4      0.000000  0.000000  0.000000  1.000000
> qform_xorient  Left-to-Right
> qform_yorient  Posterior-to-Anterior
> qform_zorient  Inferior-to-Superior
> sform_name     Unknown
> sform_code     0
> sto_xyz:1      0.000000  0.000000  0.000000  0.000000
> sto_xyz:2      0.000000  0.000000  0.000000  0.000000
> sto_xyz:3      0.000000  0.000000  0.000000  0.000000
> sto_xyz:4      0.000000  0.000000  0.000000  0.000000
> sform_xorient  Unknown
> sform_yorient  Unknown
> sform_zorient  Unknown
> file_type      NIFTI-1+
> file_code      1
> descrip        FSL4.0
> aux_file
>
>
>