I think you are right, it is not possible to get from the native space to the MNI space with only the transforms saved in derivatives by QSIPREP.
What you need is to save the temporary files of qsiprep ( with the -w option in your qsiprep command).
The _from-orig_to-T1w_mode-image_xfm.txt file is the registration between an individual T1w to the template T1w in case where multiple T1w are present. If only one T1w is present, this transform is the identity. (more info here)
I identify three stages to get to the MNI:
The native image is transformed into a _lps image using mapflow but I don’t see the command used in QSIPREP. My guess is that there must be some deobliquing and changing of the image orientation to LPS with AFNI. The directory in the temporary folder where this _lps image is stored is: qsiprep_wf/single_subject_pilote2_wf/anat_preproc_wf/anat_template_wf/t1_conform/mapflow/_t1_conform0/sub-pilote2_T1w_lps.nii.gz
To find the native T1w to the acpc space transform, you have to look into in temporary folder: qsiprep_wf/single_subject_pilote2_wf/anat_preproc_wf/skullstrip_wf/rigid_acpc_align
The command to calculate the transform looks like that:
This defines your space-T1w from which you can get to the MNI using for instance the sub-pilote2_from-T1w_to-MNI152NLin2009cAsym_mode-image_xfm.h5 transform.
Hi Julien, thank you so much for going through these steps with me .
I did save the temporary files -w and this is why I could use the transform0GenericAffine.mat rigid transformation to go to the ACPC.
However, when digging into those intermediate files, I missed the _lps reorientation part. This is the missing transformation file in my case. It seems it is not stored.
Yes, I confirm, I don’t know either for the moment how to reproduce the transformation from the original T1w image to the _lps image which is stored here:
which gives me the sub-pilote2_T1w_deoblique.nii.gz image in LPS orientation (my original image was in RAS) but stil a different position than the sub-pilote2_T1w_lps.nii.gz produced by qsiprep.
Your best option is probably to use antsRegistration to register your unprocessed T1w to the the desc-preproc_T1w in the qsiprep outputs with a Rigid transformation. The transform file can then be applied to your segmentation. This is what happens when getting the freesurfer processed T1w into alignment with the desc-preproc_T1w in the hsvs workflow, for example.
There are some header tricks that happen to images when they enter qsiprep that allow them to be read/interpreted uniformly across all the software packages. The deobliquing is one of these, which I’m not sure how to translate into an ITK transform file.