populse / mri_conv

3 stars 0 forks source link

Get bvec / bval in FSL format and mrtrix format #14

Open manuegrx opened 10 months ago

manuegrx commented 10 months ago

As explain here, mri_conv allows to obtain bvec and bval in one file in MRTRIX format (if the option is check, a bvecs/bvals text file with a '-bvecs-bvals-MRtrix' suffix and a '.txt' extension is created) for DICOM (Philips and Brucker).

If we used the option "save bvecs & bvals in 2 files", one file is created for bval and an other for the bvec. Following my request the extension of the file have been change to .bvec and .bval (see https://github.com/populse/mri_conv/commit/0e1ed5937bcfe7529db0c0a2b97df33f3f00e6a1) in order to be similar to FSL format. However in this case it is not in FSL format but is is still as in MRTRIX format because in FSL format the gradient vectors should be provided with respect to the image axes, not in real or scanner coordinates (as it is the case for MRTRIX format) !

We can find the differences between the two format here but the main features are the following:

If we import BIDS format in mri_conv, the bvec/bval imported are in FSL format.

It could be nice if mri_conv allows to have both MRTRIX format and FSL format when we import DICOM (and PARE_REC but I did not tested yet).

If it is not possible to get FSL format for now, maybe we could change a little be the documentation to make things clearer !

manuegrx commented 10 months ago

I need to do more test and to check with different data but it seems that currently in mri_conv the bvec are always provided with respect to the image axes, not in real or scanner coordinates (so like the FSL format)

montigno commented 10 months ago

Hi @manuegrx,

If you have an algorithm or code that allows to generate real bvec/bval FSL, I can integrate it into mri_conv. For the Dicom I based myself on this site http://neurohut.blogspot.com/2015/11/how-to-extract-bval-bvec-from-dicom.html. We see that in step 4, we transpose the vectors to the image reference plane. I don't remember with which software I compared the bvec/bval (Dicomifier or dcm2niix), but it was quite similar. We can work together to have good code for each MRI format (Bruker, Dicom, Philips, etc.).

manuegrx commented 10 months ago

Hi @montigno !

I'll be out of the office for 2 weeks but when I come back I'm available to work together on this subject !

I will first create a small database with data for each format/ each constructor and test with dcm2niix and mrtrix to know exactly what we need to have for each format (mrtrix and fsl)

montigno commented 10 months ago

very good idea !!

manuegrx commented 9 months ago

I began to gather some data and to compare mri_conv / dcm2niix and mrtrix. Here are some first comments:

@montigno I am available to discuss about this

manuegrx commented 9 months ago

As discussed with @montigno yesterday the priority is to change the code for Philips (DICOM and PAR/REC) and brucker data in order to have both fsl format and mrtrix format. The main modifications to do are:

In a second time, it will be great to add correct tag for Siemens and GE. It is a little be more complicated as it will be necessary to change the way to get the tag depending on the manufacturer/ type of DICOM. For GE it will be necessary to add a "correction" to have the bvec in FSL format.

Here is a quick table with the different tags used for bvec/ bval (filled with dcm2niix info and with test data) :

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

Manufacturer | DICOM “type” | Tag SOP Class UID (0x0008, 0x0016) (text or number, it seems to depend on how you read the DICOM) | Tag bval | Tag bvec | Comments -- | -- | -- | -- | -- | -- Philips | Classic DICOM | 'MR Image Storage' or '1.2.840.10008.5.1.4.1.1.4' | 0x18, 0x9087 | 0x18, 0x9089 |   Philips | Enhanced DICOM | 'Enhanced MR Image Storage' or '1.2.840.10008.5.1.4.1.1.4.1' | 0x18, 0x9087 or 0x2001, 0x1003 | 0x18, 0x9089 | Tags embedded in others tags One DICOM by sequence Siemens | Classic DICOM | 'MR Image Storage', '1.2.840.10008.5.1.4.1.1.4' | 0019 x 100c | 0x19, 0x100e |   Siemens | Enhanced DICOM | 'Enhanced MR Image Storage', '1.2.840.10008.5.1.4.1.1.4.1' | 0x18, 0x9087 | 0x18, 0x9089 | Tags embedded in others tags One DICOM by sequence– To check on example data GE | Classic DICOM | 'MR Image Storage', '1.2.840.10008.5.1.4.1.1.4' | 0x43, 0x1039 Slop_int 6 (ex: (0043, 1039) [Slop_int_6... slop_int_9] IS: [1000, 8, 0, 0]) | 0x19,0x10bb and 0x19,0x10bc and 0x19,0x10bd | Bvec relative to the frequency, phase and slice so not with reference to the scanner bore (as Siemens and Philips) . Need to be correted using the tag In-plane Phase Encoding Direction (0018,1312) —> see dcm2niix function https://github.com/rordenlab/dcm2niix/blob/master/console/nii_dicom_batch.cpp#L247
montigno commented 8 months ago

Hi @manuegrx,

Great for the table ! I will complete it if I have any other information.

I did not have time to modify mri_conv for the conversions of bevcs/bvals into FSL or MrTrix format.

I will watch all this after November 15.

See you soon !

montigno commented 5 months ago

Hi @manuegrx,

You will find in the 'devpt' branch, a beta version of mri_conv. Normally, the bvec vectors now respect the fsl format (image-based orientation) and the MRTrix format (scanner-based orientation). It remains to be tested on Dicoms from different manufacturers.

To be continued !

See you soon

manuegrx commented 5 months ago

Hi @montigno !

Thank you, I tested a little bit the devpt branch!

It seems fine for DICOM Philips:

However, the devpt branch does not working with PAR/REC. No bvec/bval/mrtrix bvec bval files are created. It is as if mri_conv had not detected that this was diffusion data. It works with the same PAR/REC in the master version. Do you know why ?

montigno commented 5 months ago

Hi @manuegrx,

Effectively, it could not calculate the bvecs for fsl. It needs the rotation matrix calculated with the angles ap, fh and rl from PARREC. The axes of this matrix depend on the image type (sagittal, coronal or axial). To find the right axes, I will stick to the dicoms, so I will need the PARREC and Dicom from the same sequence, I have some of them, but if you also have them that would be good..

To be continued !

See you soon

manuegrx commented 5 months ago

Okay it explains why the .bvec and .bval files (in FSL format) are not present :)

But in my test the "-bvecs-bvals-MRtrix.txt" (in MRTRIX format) is also not created. As it is what it was already done before (and as it is correct) , I think we should keep it !

montigno commented 4 months ago

Hi @manuegrx,

You will find in the 'devpt' branch, an other beta version of mri_conv (24.1.1a) It now works for Philips. Nevertheless it remains to find the right directions of bval.

I will need Dicom and Philips of the same sequence

To be continued !

See you soon

manuegrx commented 4 months ago

Hi @montigno ,

Thank you, it works well !

manuegrx commented 4 months ago

@montigno I will ask if I can have the same sequence in DICOM and PAR/REC, I let you know