-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inconsistent Affine Matrix Among Different Way of Converting #33
Comments
Interesting comparison! I had to discard the idea of passing through DICOM converted by Bruker because I found some inconsistencies (and in general converting twice may cause twice amount of problems). An attempt to explain how I implemented the code can be found in the wiki page. After diagonalising your outcomes, answers seem to confirm some coherence, at least in the scale if not in orientation and translation, between bru2nii and bruker2nifti:
After some tests performed with the dataset benchmarking kindly offered by Michael Naveau bruker2nifti turned out to have an issue (the still open issue #11), that comes out only for some scanner settings. Issue that did not affected my project, reason why I sill need to work out a way for solving this - without using the RECO parameter file, but only the VisuPars, as suggested in the manuals. Please be patient, will try to investigate where is the flaw. I suspect it is in the sign of the stack progression in the VisuPars. In the meantime can you please copy and paste your VisuPars parameter file below? This would be very helpful! |
Thank you @SebastianoF for doing these tests. Do you have any idea on which scanner settings cause the issue ? (for cross reference, related to : neurolabusc/Bru2Nii#17) |
Does that mean Bru2Nii produce the right affine matrix? I am so confused. Here are the visu_pars. I anonymize it.
|
@naveau The position is HEAD_PRONE. The species is PRIMATE. I also tested Matlab code from CristinaChavarrias/Bruker2nifti I am surprised that none of the conversion methods gives the same affine matrix. Any other way to convert Bruker data to NIFTI? I can't get francopestilli/mpi to work on my Linux machine. |
Did you try http://pvconv.sourceforge.net/ ? |
@cecilyen It is not too surprising. All converters are created with equal intentions, but some are more equals than others :-) . As long as Bruker will not release an official converter, we can only guess what there is in the black box from input and output. Moreover, there is a huge difference between the requirements of the scanner and what you need in the nifti header. For what I can tell from here, bru2nii works better than bruker2nifti. I think the latest version uses the RECO parameter file, that is not always available. But if you have them you should go for this one. Thanks for sharing the data will be helpful! @naveau The typical VisuCoreOrientation that I had so far, for example for a 2D PILOT FOV sequence with three orthogonal volumes, is as follows:
The one posted by @cecilyen is a 3D sequence, therefore there is only one orientation matrix. My guess is that the orientation matrix represents a perpendicular vector to a plane of the stack of images. The intended moves would be understanding which one is the plane and where is located the origin. Then understanding if the 2D and 3D shares the same convention. What do you think? Thanks for the link! Now that I remember, I did not manage to make pvconv.pl run a a first attempt. This, plus the fact that perl scares me, I did not try to run it again. |
@naveau pvconv needs d3proc, which is obsoleted in PV 6. I found lamyj/dicomifier can convert from Bruker to DICOM and then to NIFTI. |
I did some reverse engineering on ParaVision 6's orientation. Where R, P, and S are the readout, phase encoding and slice selection axis. XX, YY, and ZZ are X, Y, Z gradient axis. One can find the position matrix by setting angles of R, P, and S to zero in the PV 6. Then, find PVM_SPackArrGradOrient in the method file. I will talk about PVM_SPackArrGradOrient in the next post. |
PVM_SPackArrGradOrient is very tricky and is depending on the orientation of the subject. There are six orientations for Primate: Axial LR, Axial AP, Sagittal HF, Saggital AP, Coronal HF and Coronal LR In PV 6.0.1 manual p.660, Bruker mentioned about how to get gradient coordinate by ACQ_grad_matrix. ACQ_grad_matrix in acqp (input to the console) file is equal to PVM_SPackArrGradOrient in method file (input from the user). So, I substituted ACQ_grad_matrix by PVM_SPackArrGradOrient from now. Another parameter changed during geometry manipulation is PVM_SliceGeo. It is a new undocumented parameter only exists in PV 6. It is related to PVM_SPackArrGradOrient * Position_Matrix with R and P transposed depending on orientation. Ps. I did all tests using Bruker's FLASH 3D sequence. I hope these findings are not changed by different sequences. This is not the end of the story, I will cover how to get VisuCoreOrientation in the next post. |
VisuCoreOrientation in visu_pars only exists for acquired and reconstructed data. It is affected by reconstruction parameters in reco file. One of the most important parameters is RECO_transposition, which is orientation dependent. If RECO_transposition is 1, the first two rows of the transformation matrix, i.e. R and P, is transposed. So does the final data. In this scenario, the final equation looks like: I will list RECO_transposition, PVM_SPackArrGradOrien, and PVM_SliceGeo for six orientations in Primate Head Prone position in the following post. |
Very-interesting! Many thanks for sharing!
Passages matrix between the PVM_SPackArrGradOrient and PVM_SliceGeo is
as Not sure the connection between the abbreviation AxLR, AxAP, SagHF... The only thing I can think of is that HF stands for HeadFoot, but can not say if for primates or rodents as it is not the same. |
|
For Primate Head Prone, ParaVision is using Neurological RAS coordinate, i.e. +X, +Y and +Z is on the Right, Anterior and Superior/Head. |
@cecilyen: Thanks for your answers! You may be interested to know that I recently received a scanned sample in raw data with the same VisuPars parameter file of another study. Both are 3D scans. |
Would like to share a small experiment I did to be sure about what I was saying in the previous post. Let A and B be two studies consecutively acquired in the same place, with the same protocol, where
Now, if I switch the VisuPars parameter files between the two scans and I do the conversion again, I got exactly the same result: A is still correctly converted reading the VisuPars of B, and B is still incorrectly converted reading the VisuPars of A. Option 1: there is another file encoding the missing information to realign correctly the image. If option 1 is correct, the @naveau converter based also on RECO is more insightful. Although RECO is not always available. In both cases, there is a counterxample disproving that VisuPars have all the information to reconstruct the affine matrix. This may also explain why the DICOM created by ParaVision are raising as well controversies: according to the manual, in passing from the raw data to DICOM, only the VisuPars is considered. Will let you know more in the next episode about what exactly was different from one scan to the other during the acquisition (there was certainly something different) as soon as I will be talking with the radiologists. In the meantime this one and related issues will remain open... |
An addendum to @cecilyen, for PV5.1, there is no VisuSubjectType in I don't see a mention of the options in the manual, I will have to dig through at the console next time I can check. |
We are trying to build a working flow of our fMRI processing. The first step is converting Bruker's data to NIFTI. There are several ways of converting including using your bruker2nifti. But, I found the affine transformation is different among these methods. Below is the original parameters from Bruker, Bru2Nii, bruker2nifti and Bruker's DICOM+AFNI's to3d. Any ideas? PS. I am cross-posting this in Bru2Nii as well.
ParaVision 6.0.1
3D FLASH
##$PVM_Fov=( 3 )
58 58 58
##$PVM_SpatResol=( 3 )
0.453125 0.453125 0.453125
##$PVM_SPackArrSliceOrient=( 1 )
coronal
##$PVM_SPackArrReadOrient=( 1 )
H_F
##$PVM_SPackArrReadOffset=( 1 )
0
##$PVM_SPackArrPhase1Offset=( 1 )
0
##$PVM_SPackArrPhase2Offset=( 1 )
0
##$PVM_SPackArrSliceOffset=( 1 )
0
##$PVM_SPackArrGradOrient=( 1, 3, 3 )
0.241395201113481 0.0866782944696308 0.966548100276038
0.970351084097186 -0.00911025585436366 -0.24152800423488
-0.0121297349846693 0.996194698091746 -0.0863075490504608
##$VisuCoreOrientation=( 1, 9 )
0.970351084097186 -0.00911025585436366 0.24152800423488
0.241395201113481 0.0866782944696308 -0.966548100276038
-0.0121297349846693 0.996194698091746 0.0863075490504608
neurolabusc/Bru2Nii v1.0.20170719
qform_code 252 1 0
sform_code 254 1 1
quatern_b 256 1 0.0
quatern_c 260 1 0.0
quatern_d 264 1 0.0
qoffset_x 268 1 0.0
qoffset_y 272 1 0.0
qoffset_z 276 1 0.0
srow_x 280 4 0.43969 0.109382 0.005496 -35.769691
srow_y 296 4 0.109442 -0.437967 -0.039108 23.712318
srow_z 312 4 0.004128 -0.039276 0.451401 -26.848299
SebastianoF/bruker2nifti Sep 4, 2017 Python 2.7
qform_code 252 1 2
sform_code 254 1 1
quatern_b 256 1 -0.000757
quatern_c 260 1 -0.043614
quatern_d 264 1 -0.991602
qoffset_x 268 1 28.997601
qoffset_y 272 1 28.999701
qoffset_z 276 1 28.7724
srow_x 280 4 -0.439667 0.10943 -0.004123 28.997601
srow_y 296 4 -0.109384 -0.437991 0.039286 28.999701
srow_z 312 4 0.005483 0.039105 0.451403 28.7724
Converting Bruker DICOM to NIFTI by AFNI's to3d
qform_code 252 1 1
sform_code 254 1 1
quatern_b 256 1 0.086631
quatern_c 260 1 -0.670329
quatern_d 264 1 0.732007
qoffset_x 268 1 34.79163
qoffset_y 272 1 -28.773438
qoffset_z 276 1 18.542217
srow_x 280 4 -0.43969 -0.109382 0.005496 34.79163
srow_y 296 4 0.004128 -0.039276 -0.451401 30.91342
srow_z 312 4 0.109442 -0.437967 0.039108 18.542217
The text was updated successfully, but these errors were encountered: