Hi Lilla,

Thank you for your response.
I would argue that they seem to be aligned, yet they are not. If you look at the cerebellum the Jacobian is shifted in respect to the brain_IBSR_01.mgz. Further, there must be a jacobian for each voxel of the brain_IBSR_01.mgz (at least inside the brain mask), which does not happen (the box is smaller than the brain). Though, I will not discuss this point again.

Just as final note, if anyone want to retrieve the deformation field, a simple way is to virtually create a 4d image that encode the position of each voxel (3 x 3d images), deform this images using the applyMorph, and subtract the initial virtual 4d image. The Jacobian matrix can also be calculated through this fields.

Regards,
Andre Santos Ribeiro
PhD Student, Imperial College London



On Wed, Aug 6, 2014 at 3:35 PM, Lilla Zollei <lzollei@nmr.mgh.harvard.edu> wrote:

Hi Andre,

The jacobian field is computed in the coordinate space of the moving volume so if you overlay it with brain_IBSR_01.mgz, you will see that they match.

We currently do not have an executbale in 5.3 that writes out the m3z transforms in nifti format.


Lilla

On Tue, 5 Aug 2014, André Ribeiro wrote:

Hi,

The Freesurfer that I am using is: freesurfer-Linux-centos6_x86_64-stable-pub-v5.3.0.

The source, target, registered, Jacobian images and deformation field are provided in attachment.

I mean with voxel-wise that by visualizing both (overlayed) there is a shift between the Jacobian and the registered image. I used the same image as target so I would suspect that it is not a header problem (though did not used a different viewer). Additionally, by looking at the Jacobian (and assuming this is
correct) the algorithm seems to relaxed allowing really high and low jacobians.

Further, how can I obtain the deformation fields in a nifti format?



​[icon_10_generic_list.png]  combined_toIBSR_02_elreg_afteraseg-norm.m3z

​​[icon_10_generic_list.png]  brain_IBSR_02.mgz

​​[icon_10_generic_list.png]  brain_IBSR_01.mgz

​​[icon_10_generic_list.png]  reg_IBSR_01_2_IBSR_02_brain.nii.gz

​​[icon_10_generic_list.png]  jacobian.nii.gz



​Regards,
Andre Santos Ribeiro
PhD Student, Imperial College London



On Tue, Aug 5, 2014 at 4:24 PM, Lilla Zollei <lzollei@nmr.mgh.harvard.edu> wrote:

      Hi Andre,

      What do you mean by they "do not seem to match voxel-wise"? Are they of different size or are they not in a corresponding space?

      Which version of FreeSurfer are you using?

      Could you send the volumes over? I don't see anything wrong with the commands so I would like ot take a look at the files.

      Lilla

      On Tue, 5 Aug 2014, André Ribeiro wrote:

            Hi,

            Ok so most of my problems are now fixed, but there is still one problem regarding the Jacobian.

            So first of all my images were normalized as follows:
            createMorph --out fullCVSmorph.tm3d --template f2/mri/brain.mgz --subject f1/mri/brain.mgz --in gcam combined_tof2_elreg_afteraseg-norm.m3z
            applyMorph --template f2/mri/brain.mgz --transform fullCVSmorph.tm3d vol f1/mri/brain.mgz reg_f1_brain.nii.gz trilinear

            then for the Jacobian:
            mri_jacobian -tm3d combined_tof2_elreg_afteraseg-norm.m3z f1_brain.nii.gz jacobian.nii.gz

            Now if I visualize both the reg_f1_brain.nii.gz and jacobian.nii.gz they do not seem to match voxel-wise, and therefore cannot be applied for VBM. Both the jacobian and the registered t1 brain image use the same transform and therefore should be aligned. Am I making some mistake here?

            Sorry for this question in advance.

            Regards,
            Andre Santos Ribeiro
            PhD Student, Imperial College London



            On Fri, Jul 11, 2014 at 4:11 PM, Lilla Zollei <lzollei@nmr.mgh.harvard.edu> wrote:

                  Hi,

                        First, in the mri_cvs_register I kept all the files and therefore the "combined_toIBSR_02_elreg_afteraseg-norm.tm3d" file was not removed. If I try to replicate this file through the
                        "createMorph --out fullCVSmorph.tm3d --template template.mgz --subject movingvol.mgz --in gcam nlalign-afteraseg-norm.m3z morph el_reg_toTEMPLATE.tm3d" the file produced is different from the one previously created by the program (and gives far worse registration results when
            used with
                        the "applyMorph"). Is
                        something wrong here?


            No, there is nothing wrong. In the above command you are just not composing the right files. I assume that you have run the default mri_cvs_register command. In that case there are two non-linear registration steps one aided by aseg info and one by intensities. In the above you are
            skipping the morph
            created by the former so that is why you are not getting the same combined output. Instead of "morph el_reg_toTEMPLATE.tm3d" you would need to use "morph combined*aseg.tm3d"

                  Second, even if the two files gave the same results wouldn’t this fullCVSmorph.tm3d (otherwise called combined_toIBSR_02_elreg_afteraseg-norm.tm3d) have both information from  *afteraseg-norm.m3z and el_reg_toTEMPLATE.tm3d, and therefore the Jacobian applied solely to the
                  nlalign-afteraseg-norm.m3z would not
                  match.


            It is correct. The jacobians of fullCVSmorph.tm3d and nlalign-afteraseg-norm.m3z will not match. I am a bit confused about whey you think they should.

                  Lastly, am I right assuming the "combined_toIBSR_02_elreg_afteraseg-norm.tm3d" is the last registration (and most accurate) performed by mri_cvs_register?


            Yes. In the most current FS version though we use the m3z files as we are trying to phase out the tm3d format.

            Lilla

                  On Fri, Jul 11, 2014 at 3:11 PM, Lilla Zollei <lzollei@nmr.mgh.harvard.edu> wrote:

                        Hi, You should use the final m3z file. The -tm3d flag just indicates that the file was created by mri_cvs_register.
                        Lilla

                        On Fri, 11 Jul 2014, André Ribeiro wrote:

                              I got an error using the mri_jacobina.
                              The function returns:

                              The input morph originated from a tm3d (mri_cvs_register file).
                              GCAMread(/home/afs13/Documents/data/test_freesurfer_reg/combined_toIBSR_02_elreg_aseg.tm3d): invalid version # 0.000

                              mri_jacobian: could not read input morph /home/afs13/Documents/data/test_freesurfer_reg/combined_toIBSR_02_elreg_aseg.tm3d


                              The command is provided below:
                              mri_jacobian -tm3d /home/afs13/Documents/data/test_freesurfer_reg/combined_toIBSR_02_elreg_aseg.tm3d /home/afs13/Documents/data/test_freesurfer_reg/brain.mgz /home/afs13/Documents/data/test_freesurfer_reg/test_jac.nii.gz

                              Regards,
                              Andre Santos Ribeiro
                              PhD Student, Imperial College London



                              On Fri, Jul 11, 2014 at 11:09 AM, André Ribeiro <afs13@imperial.ac.uk> wrote:
                                    Thank you! Didn't realized that function existed.

                                    Regards,
                                    Andre Santos Ribeiro

                              On Thu, Jul 10, 2014 at 4:59 PM, Lilla Zollei <lzollei@nmr.mgh.harvard.edu> wrote:

                                    Hi Andre

                                    You can run:

                                    mri_jacobian -tm3d <3d morph> <template volume> <output volume>

                                    --Lilla

                                    On Thu, 10 Jul 2014, André Ribeiro wrote:

                                          Dear Freesurfer Community,

                                          How can I obtain the Jacobian of the deformation field estimated through mri_cvs_register for further use like VBM analysis?


                                          Regards,
                                          Andre Santos Ribeiro



                              _______________________________________________
                              Freesurfer mailing list
                              Freesurfer@nmr.mgh.harvard.edu
                              https://mail.nmr.mgh.harvard.edu/mailman/listinfo/freesurfer


                              The information in this e-mail is intended only for the person to whom it is
                              addressed. If you believe this e-mail was sent to you in error and the e-mail
                              contains patient information, please contact the Partners Compliance HelpLine at
                              http://www.partners.org/complianceline . If the e-mail was sent to you in error
                              but does not contain patient information, please contact the sender and properly
                              dispose of the e-mail.





                  _______________________________________________
                  Freesurfer mailing list
                  Freesurfer@nmr.mgh.harvard.edu
                  https://mail.nmr.mgh.harvard.edu/mailman/listinfo/freesurfer


                  The information in this e-mail is intended only for the person to whom it is
                  addressed. If you believe this e-mail was sent to you in error and the e-mail
                  contains patient information, please contact the Partners Compliance HelpLine at
                  http://www.partners.org/complianceline . If the e-mail was sent to you in error
                  but does not contain patient information, please contact the sender and properly
                  dispose of the e-mail.




            _______________________________________________
            Freesurfer mailing list
            Freesurfer@nmr.mgh.harvard.edu
            https://mail.nmr.mgh.harvard.edu/mailman/listinfo/freesurfer


            The information in this e-mail is intended only for the person to whom it is
            addressed. If you believe this e-mail was sent to you in error and the e-mail
            contains patient information, please contact the Partners Compliance HelpLine at
            http://www.partners.org/complianceline . If the e-mail was sent to you in error
            but does not contain patient information, please contact the sender and properly
            dispose of the e-mail.




_______________________________________________
Freesurfer mailing list
Freesurfer@nmr.mgh.harvard.edu
https://mail.nmr.mgh.harvard.edu/mailman/listinfo/freesurfer


The information in this e-mail is intended only for the person to whom it is
addressed. If you believe this e-mail was sent to you in error and the e-mail
contains patient information, please contact the Partners Compliance HelpLine at
http://www.partners.org/complianceline . If the e-mail was sent to you in error
but does not contain patient information, please contact the sender and properly
dispose of the e-mail.