Dwiextract does not extract single shell

Hi MRtrix expert,
I am trying to extract b0 and b3000 images from a multishell acquisitions. Looking at previous messagess I did the following

dwiextract diff_preproc.nii.gz -fslgrad bvec.txt bval.txt -shell 0,3000 - | mrconvert - DWI_3000.nii.gz -datatype float32 -export_grad_fsl bvecs3 bval3 -stride 0,0,0,1

The command seems to unaffect the data, as DWI_3000.nii.gz still contains images from all shells; moreover, bvals3 shows a list of 0s in places where other bvales were printed in original bval.txt.

Should dwiextract with -shell option only provide b0 images and b3000 ones, shouldn’t? Or am I misunderstanding the command?

Many Thanks


Hi @Alessandro,

That’s odd indeed; you are right in what you expected from dwiextract: I’ve just double-checked myself, and it definitely seems to do the job for me in a very similar scenario. The only reason I can see this happening, is because those other bvalues were very close to zero: there’s a threshold below which they are assumed to be zero. Just to double check, can you show us the exact contents of the original bvec.txt and bval.txt?


Hi, @Thijs, sorry for delayed answer.

As you suspected, after checking bval txt file, I found an error in the way bval vector was printed out. Now the command works the way it should. May I ask you what does the option stride do?

Thanks for your help!



That’s probably best explained here in the docs. Hopefully that’s clear enough, let me know if anything doesn’t make sense…

Thank you @jdtournier!