Hi,
Running img2imgcoord is very inefficient (as it needs to do an internal, local warp inversion) and img2stdcoord is not going in the right direction. What is much better is to run std2imgcoord like this:
std2imgcoord -warp highres2standard_warp.nii.gz -std standard -img highres -vox coords.txt
However, as Matthew pointed out, your input coordinates need to be in MNI mm conventions, rather than in voxels (the -vox option used above just specifies that the output coordinates, in the highres space, will be in voxels). This shouldn't be tricky though, as you just need to build an input coordinate file that includes all the MNI mm coords. So instead of starting at the voxel coordinate 0,0,0 and going to 91,109,91, you start at a mm coordinate of 90,-126,-72 and move with increments of -2 in x, +2 in y and +2 in z, finishing with -90,90,108. Once you have this file then just run it through the command above and it should work efficiently.
All the best,
Mark
> On 10 Sep 2017, at 13:50, Matthew Webster <[log in to unmask]> wrote:
>
> Hello,
> I’ve re-read your first question and noticed that you’re converting standard space _voxels_ into subject space. In this case you are best off using img2imgcoord with the -vox option as std2imgcoord takes input in mm.
>
> Kind Regards
> Matthew
> --------------------------------
> Dr Matthew Webster
> FMRIB Centre
> John Radcliffe Hospital
> University of Oxford
>
>> On 9 Sep 2017, at 15:00, Matthew Webster <[log in to unmask]> wrote:
>>
>> Hello,
>> The second call ( std2imgcoord ) is the right one to use ( both im2stdcoord and std2imgcoord ) assume the transforms provided are _to_ standard space, e.g. subject2standard_warp. Looking at your previous question, the output from fout are the millimetre displacements in x,y,z, but it might be worth retrying the full conversion of “test.cvs” with std2imgcoord as opposed to img2stdcoord as it can be a bit faster.
>>
>> Hope this helps,
>> Kind Regards
>> Matthew
>> --------------------------------
>> Dr Matthew Webster
>> FMRIB Centre
>> John Radcliffe Hospital
>> University of Oxford
>>
>>> On 8 Sep 2017, at 08:35, Dr. Thomas Möbius <[log in to unmask]> wrote:
>>>
>>> Is it
>>>
>>> %echo 46 55 46 | img2stdcoord -img $template -std $subject -warp $warp -
>>> 7.53598 11.8152 51.9142
>>>
>>> or
>>>
>>> %echo 46 55 46 | std2imgcoord -std $template -img $subject -warp $warp -
>>> 57.1917 100.317 67.9114
>>>
>>> to get the coordinates of the MNI-voxel (46,55,46) in the subject?
>>>
>>> Here,
>>>
>>> log=subject_to_MNI152_T1_2mm_brain.log
>>> warp=subject_warpcoef.nii.gz
>>> template=MNI152_T1_2mm_brain.nii.gz
>>> subject=subject.nii.gz
>>>
>>> Regards,
>>> Thomas
>>>
>>>
>>> Am 06.09.2017 um 12:43 schrieb Dr. Thomas Möbius:
>>>> I need your help.
>>>> For *all* voxels in the MNI template brain, I need their respected
>>>> coordinates in a subject's brain.
>>>> Essentially, I need the output of
>>>> echo 0 0 0 | img2stdcoord -img subject.nii.gz -std \
>>>> MNI152_T1_2mm_brain.nii.gz \
>>>> -warp subject_warpcoef.nii.gz
>>>> for all voxels (0,0,0)…(91,109,91). Unfortunately, running
>>>> $template=MNI152_T1_2mm_brain.nii.gz
>>>> img2stdcoord -img subject.nii.gz -std $template \
>>>> -warp subject_warpcoef.nii.gz test.csv > coord.csv
>>>> for a file
>>>> % head test.csv
>>>> 0 0 0
>>>> 0 0 1
>>>> 0 0 2
>>>> 0 0 3
>>>> 0 0 4
>>>> is very, very, very slow. (Overnight run kind of long, and,
>>>> unfortunately, too long for a few 100 subjects.)
>>>> Thank you very much for your help!
>>>> --------------------------------------------------------------------
>>>> What I have so far: From an E-Mail correspondence with Mark Jenkinson
>>>> and some Python code he provided, it was suggested that the --fout of
>>>> fnirt already contains these coordinates but possibly in some FSL
>>>> internal coordinate system.
>>>> Unfortunately,
>>>> $template=MNI152_T1_2mm_brain.nii.gz
>>>> fnirt --ref=$template \
>>>> --in=subject.nii.gz \
>>>> --config=T1_2_MNI152_2mm \
>>>> --fout=subject-fout.nii.gz
>>>> % echo 46 55 46 | img2stdcoord -img subject.nii.gz -std $template \
>>>> -warp subject_warpcoef.nii.gz -
>>>> -47.5376 38.9939 138.936
>>>> and
>>>> In [1]: %paste
>>>> import nibabel as ni
>>>> fout = ni.load('subject-fout.nii.gz')
>>>> data = fout.get_data()
>>>> ## -- End pasted text --
>>>> In [2]: data[0,0,0]
>>>> Out[2]: array([-0.00299128, 0.02409595, 0.00995562],
>>>> dtype=float32)
>>>> In [3]: data[46,55,46]
>>>> Out[3]: array([ -2.07558155, 17.0630188 , 4.20218515],
>>>> dtype=float32)
>>>> yield very different results.
>>>> --------------------------------------------------------------------
>>>> I would very much appreciate your help. Thanks!
>>>> Thomas
|