Dear Thomas,
> I have some questions about the FNIRT program of FSL which are most
> basically yes/no-questions.
>
> I would like to use FSL to fit a diffeomorphism from a given template
> brain (MNI) to a subject's brain, and find for each voxel in the
> template brains Nifti its (world) coordinates in the subject's brain,
> say as a 4D-Nifti1-file with the 4th dimension containing the
> coordinates. (Well, ultimately, I need it as a Python numpy.ndarray, so
> if it would be possible to do this directly in Python, this would be
> great.)
>
> The first thing, which I am unsure about, is the direction, i.e.,
> whether it is:
>
> template=MNI152_T1_2mm_brain.nii.gz
> subject=subject.nii.gz
> omat=subject.mat
> cout=subject-cout.nii.gz
> iout=subject-iout.nii.gz
> fout=subject-fout.nii.gz
>
> flirt -in $subject -ref $template -omat $omat
>
> fnirt --in=$subject --ref=$template --aff=$omat \
> --config=T1_2_MNI152_2mm --cout=$cout --iout=$iout --fout=$fout
this will generate an output (cout or fout) that gives you the mapping from each coordinate in ref-space to coordinates in in-space. Which if I understand you correctly is what you want.
>
> or whether it is:
>
> flirt -in $template -ref $subject -omat $omat
>
> fnirt --in=$template --ref=$subject --aff=$omat \
> --cout=$cout --iout=$iout --fout=$fout
>
> So, I am unsure about the direction. My suspicion is that it is the
> latter and I am not able to use a standard configuration file.
>
> Q1: Is this correct?
No, the former is what you want.
>
> Now given $omat and $cout, the documentation says that $cout already
> contains all the information of the diffeomorphism [1] and indeed, when
> parsing the Nifti1 file $cout (using Nibabel) its affine is identical to
> the matrix in $omat. Which is why I don't understand, why these two yield
> different results [2]:
>
> echo 0 0 0 | img2stdcoord -img $template -std $subject -warp $cout -
> 137.263 -15.2549 -91.5712
>
> echo 0 0 0 | img2stdcoord -img $template -std $subject -warp $cout \
> -premat $omat -
> 114.185 -72.6476 -70.785
>
> I am not sure whether I need to specify -premat or not, and in case I
> do, whether $omat is now applied twice.
>
> Q2: Which of the two is the correct one?
If you use the --cout warps you should _not_ specify the affine as premat. In your second example you have applied it twice.
>
> Q3: Now, do I really need to create a file that contains all the lines
> 0 0 0\n0 0 1\n 0 0 2\n... in order to get all the coordinates of
> all the voxels in $template, or does there exists a special tool in
> FSL for this?
I am afraid that we don’t have any tools that directly outputs all the coordinates. My suggestion would be that you take a look at the code for applywarp to see how it is used. I am not sure how easy it would be to integrate with Python though.
>
> Q4: Given $cout (or alternatively $omat and $fout), is it possible to do
> the whole img2stdcoord calculation directly in Python (using more or
> less standard libraries)?
I am afraid Python is still just a fat snake to me. Maybe someone else knows?
Jesper
>
> Thank you very much for your help.
>
> Regards,
> Thomas
>
> [1] https://fsl.fmrib.ox.ac.uk/fsl/fslwiki/FNIRT/UserGuide#A--cout
>
> [2] https://fsl.fmrib.ox.ac.uk/fsl/fslwiki/FLIRT/UserGuide#img2stdcoord
>
> --
> Dr. Thomas W. D. Möbius
> Institut für Medizinische Informatik und Statistik
> Christian Albrechts-Universität zu Kiel
> Brunswiker Str. 10
> 24105 Kiel
> Telefon: +49 431 500 - 30719
> Fax: +49 431 500 - 30704
> E-Mail: [log in to unmask]
|