Mrconvert - How to preserve intensity

Dear community,

When extracting volumes from a nifti dwi with mrconvert, the resulting nifti has a different intensity (origin on the left, output on the right).

I need your help:

  1. How can I preserve the intensity? The origin and output are signed 16 bit integer (little endian), and the intensity scaling in both nifti is the same: offset=0, scaling=1.

  2. I would also like to know how to indicate the volumes to remove instead of specifying volumes to extract, as I only need to remove a few.

  3. Finally, is there any possibility of not shortening the decimal expression of the bvec values?

For more details, I am using the following pipe:

mrconvert dwi.nii.gz -fslgrad dwi.bvec dwi.bval - | mriconvert -coord 3 1:20 - - | mrconvert -export_grad_fsl fsl_bvecs.bvec fsl_bvals.bval - dwi_good.nii.gz -force

Thank you in advance

Hi Leandro

Maybe I can provide some pointers

  1. I can’t rule out some sort of display issue from your screenshots, but are you able to check that the actual data values are indeed different? Also check that you’re looking at the same data volumes: from your command -coord 3 1:20, here image indexing starts at 0, so 1 corresponds to the second volume of the input image. With diffusion images it’s expected that some of the volumes (the b=0 ones) will have much higher intensities than the volumes with diffusion weighting (e.g. b=1000). mrconvert should certainly not be messing with the intensity values!

  2. Not as far as I know… But if it helps, you can string together multiple ranges to make things a bit easier. E.g. if you want to remove the 2nd (index 1) and 6th (index 5) volumes that would be -coord 3 0,2:4,6:end

  3. Do you mean that the output bvecs are lower precision than the input? That does seem unexpected. Maybe this thread will help? Otherwise I pass this question on to the powers that be…

Side note, you shouldn’t have to pipe together multiple mrconvert commands. It can handle multiple operations at once! like this:

mrconvert dwi.nii.gz -fslgrad dwi.bvec dwi.bval -coord 3 1:20 -export_grad_fsl fsl_bvecs.bvec fsl_bvals.bval dwi_good.nii.gz -force


1 Like

Hi Fiona, thanks for your valuable help.

  1. Sorry for the confusion. I made a mistake when comparing the intensity values by overlaying the wrong index volume in the same window (thanks for the note on indexing). After checking carefully, the intensity values are exactly the same for the original and the output, regardless of the different levels of brightness they show, which at first totally biased me along with the incorrect volume. Solved!

  2. Thanks for the suggestion.

  3. My mistake: I rechecked the files again, and it is the other way around. The bvec output has more digits in the decimal expression (top pane original bvec, bottom pane output bvec). It’s interesting where it can get those numbers from. From what I’ve read in some posts, the mrconvert shouldn’t alter the info passed for the gradient table.