Error: mrconvert cannot import diffusion gradient table

#1

Hi MRtrix Experts,

I ran the following command:
mrconvert CAT005_DWI.nii.gz CAT005.mif -fslgrad CAT005.bvec CAT005.bval

but I ran into an error as follows
mrconvert: [ERROR] error importing diffusion gradient table for image “CAT005_DWI.nii.gz”

mrinfo for CAT005_DWI.nii.gz as follows:

Image:               "CAT005_DWI.nii.gz"
  Dimensions:        128 x 128 x 59 x 65
  Voxel size:        2.109 x 2.109 x 2.11 x 1
  Data strides:      [ -1 2 3 4 ]
  Format:            NIfTI-1.1 (GZip compressed)
  Data type:         signed 16 bit integer (little endian)
  Intensity scaling: offset = 0, multiplier = 1
  Transform:                    1           0           0      -133.9
                               -0           1           0      -133.9
                               -0           0           1      -61.19
  comments:          FSL3.3

Is there anything in the command that is wrongly written?

Thanks!

Best Wishes,
Elijah

#2

Hi Elijah,

It’s hard to tell exactly what’s going wrong without seeing the contents to the files CAT005.bvec and CAT005.bval, but that’s most likely where the problem lies. Given your image has 65 volumes, the bvec file needs to have 3 rows where each row contains 65 values, and the bval file needs to contain 1 row of 65 values. If you can’t identify the issue, or the files appear to conform to these expectations, post them here and we can take a closer look.

Cheers
Rob

#3

Hi Rob,

Thanks for helping! I have checked the files and they look alright to me. The DTI file was originally converted from DICOM using dcm2nii earlier.

bvec is as follows:
0.99944 -0.0315831 0.0111001
-0.0321804 -0.997766 0.0585535
0.552785 -0.559962 0.616165
-0.00922591 0.0588778 0.998223
0.832437 0.357295 -0.422107
-0.0162288 -0.747047 -0.664346
0.563432 -0.627907 -0.535785
0.824908 0.405339 0.392443
-0.0292743 -0.663794 0.747141
0.465809 0.618373 -0.632235
0.650993 -0.233719 -0.721516
-0.586269 0.669121 0.457007
-0.284451 -0.892376 -0.350707
0.423362 0.129181 0.896895
0.911624 0.409658 -0.0157371
0.634172 0.747639 -0.198521
0.105465 0.477756 0.872395
-0.1612 -0.358484 -0.920016
0.53399 -0.807121 0.2539
-0.204452 0.726644 0.656498
-0.831968 -0.252698 -0.493675
-0.721512 -0.63711 -0.271628
0.588541 0.206726 -0.782132
0.142076 0.411619 -0.900525
-0.792339 0.531112 -0.300114
-0.0390986 0.744903 -0.666404
0.904828 -0.0738196 -0.419051
-0.464433 0.74339 -0.481911
-0.566381 0.823436 0.00630366
0.242578 0.903627 -0.351591
0.673342 -0.158698 0.722841
-0.552263 -0.129761 -0.82392
-0.946338 -0.321014 -0.0298834
-0.176422 0.96167 -0.207618
0.249468 -0.044795 -0.967782
-0.727769 0.237252 -0.643828
-0.752401 -0.601384 0.268945
0.219959 0.816068 0.534932
-0.20325 0.943052 0.263068
-0.975849 0.0637608 0.208614
-0.377133 0.445636 -0.81116
-0.52533 -0.526138 0.668319
-0.552235 -0.0536591 0.831543
0.866147 -0.459336 -0.195311
0.590753 0.766386 0.250773
-0.18613 0.0989878 -0.977283
-0.487227 -0.872108 0.0369183
-0.301766 -0.846544 0.437837
-0.48107 -0.574553 -0.661786
0.275247 -0.479687 -0.832698
-0.369565 0.353997 0.859275
-0.862744 0.485205 0.142726
0.536265 0.492962 0.685141
0.219881 0.972071 0.0849462
-0.833164 -0.224037 0.506404
-0.210187 -0.309653 0.92694
0.903304 -0.0139853 0.42892
0.177382 -0.883246 0.434412
-0.763115 0.278352 0.583608
0.204322 -0.927038 -0.314091
0.853324 -0.453541 0.25503
0.568233 -0.811194 -0.138242
-0.963439 0.106861 -0.245617
0.2702 -0.347917 0.897573
0 0 0

bval:
1000.00
1000.00
1000.00
1000.00
1000.00
1000.00
1000.00
1000.00
1000.00
1000.00
1000.00
1000.00
1000.00
1000.00
1000.00
1000.00
1000.00
1000.00
1000.00
1000.00
1000.00
1000.00
1000.00
1000.00
1000.00
1000.00
1000.00
1000.00
1000.00
1000.00
1000.00
1000.00
1000.00
1000.00
1000.00
1000.00
1000.00
1000.00
1000.00
1000.00
1000.00
1000.00
1000.00
1000.00
1000.00
1000.00
1000.00
1000.00
1000.00
1000.00
1000.00
1000.00
1000.00
1000.00
1000.00
1000.00
1000.00
1000.00
1000.00
1000.00
1000.00
1000.00
1000.00
1000.00
0.00

As a follow-up, my goal is use MRTRIX to generate the tracts, and ultimately derive connectivity matrices. Thanks for taking the time to help.

Cheers,
Elijah

#4

If that’s precisely how the data appear in the file, then it looks like both files have been erroneously transposed. E.g. the bvecs file should be 3 rows of 65 values, not 65 rows of 3 values as you have. I don’t know the inner workings of dcm2nii, nor do I know if FSL itself would actually open these files; but the FSL documentation is fairly clear on what it expects, and so this is what MRtrix3 is designed to import if users choose / need to use that format.

If you’re having trouble isolating the issue, or don’t want to go through the rigmarole of manually transposing a whole lot of text files, you can try instead using MRtrix3 to convert from DICOM. The gradient table can then be saved in bvecs/bvals form, MRtrix3 format (which is the same as what DICOM provides), or embedded within the image header if an MRtrix image format (e.g. .mif) is used (and that way you don’t have to provide command-line options to import the gradient table in every command).

#5

Hi Rob,

Just want to say thanks! It worked. How long does dwi2preproc typically take for 1 subject? It has been running for about 20 minutes…

Apparently, the bvals and bvecs were automatically transposed by Freesurfer as I’ve used the dt_recon (in Freesurfer) to process my DTI data. I will ask another question about Freesurfer for the connectivity matrices in a different thread :slight_smile:

Thanks again, Rob!

Best Wishes,
Elijah

#6

The bulk of the processing time for dwipreproc is taken up by FSL’s topup and eddy. topup isn’t multi-threaded, and is usually maybe 15 minutes for a typical resolution (assuming you only have a single pair of b=0 images) - it (just like other solutions for estimating the inhomogeneity field) has to go through a long multi-resolution pyramid to keep the solution stable, so it’s a necessary evil. eddy is multi-threaded, but has a lot of work to do; maybe 2 hours for our 67-volume acquisition? Again, will vary depending on your system / data. You can also give the CUDA version of eddy a try: dwipreproc has a -cuda option to make use of it if it’s available.

#7

Did one last week as a demo for a collaborator on their data using a custom 67 volume scheme I provided them with. Started it before lunch on my desktop computer, and after we returned it had already finished (in under an hour). That was using 8 cores; so using, e.g., 4 cores you may indeed end up around 1.5 ~ 2 hours.

So overall, I’d say: always give it at least an hour or two. The default eddy definitely takes quite some time.

#8

hello i m new here and i hv nearly the same problem but i couldn t fix it
i hv downloaded a dataset from "the cancer imaging archive(TCIA) it had the dicom format so i needed to convert it to nifti
while using the data i got error telling tht the bvec file should have 3 rows !!
and image dimension [256,256,36,2] !!
bvec :
0 0
0 0
0 0
(3rows) !
and bval
1000 0
!!!

#9

It looks like this is a 2 volume image? If so, then it’s likely to be either a trace-weighed acquisition, or an already processed output from the scanner (i.e. not the raw data). From the bvals, I’m guessing the former, but that’s just a guess. Regardless, these are not data that can be processed by our standard pipelines in MRtrix3 (or indeed any other diffusion imaging approaches that expect directional data). What you can do with this depends on what the data are exactly, and what you have in mind for the analysis…

1 Like
#10

thnx for ur reply
yeah the dimesnison of my image was [256,256,36,2] which seemed unlogical
in fact i dowloaled a data and i got many files i used to have dti file but in that dataset i got the following files i didn tknow which one to use !
i got
2-3-pl T2 FGRE S-34403
4-DWI ASSET-26022
5-SAG T1-64094
6-Ax Flair irFSE H-80553
7-Ax Flair irFSE H-84835
8-AX 3D SPGR-43615
9-AX T1-06604
10-Prop T2 TRF-43669
11-COR GRE T2-05651
12-COR T1C-76492
13-AX T1C-70939
14-AX 3D SPGRC-87409
15-SAG T1C-18188
400-Exponential Apparent Diffusion Coefficient-42784
401-Apparent Diffusion Coefficient mm2s-56391

so can u guess which one i should use !!

#11

OK, that makes more sense. I reckon you’re after 4-DWI ASSET-26022 as the main DWI series, and 5-SAG T1-64094 for the T1 structural.

1 Like
#12

i hv converted only 4-DWI what what should i do ? do i hv to put all the files u mentioned in one file then convert them or … ?
i need i nifti file

#13

hey !
there s no way to do so ?? :’(

#14

Sorry, we had the ISMRM conference last week, and it was as intense as it always is.

To answer your question, it sounds like you need to familiarise yourself with the documentation, particularly image handling in MRtrix3, DW encoding handling, and DICOM handling. I also recommend you take a look through the beginner’s tutorial, and even better, go through @martahedl’s comprehensive BATMAN tutorial.

#15

it s ok !
in fact i m not using mrtrix but dipy , i found tht this is the same problem as mine that why i asked :confused:
thnk u anyways !