Dwi2response failed

Hello Community

I’m new to using MRtrix and I ran into a problem when using the dwi2response command.

dwi2response tournier dwi.mif resp.txt
dwi2response: 
dwi2response: Note that this script makes use of commands / algorithms that have relevant articles for citation. Please consult the help page (-help option) for more information.
dwi2response: 
dwi2response: Generated temporary directory: /tmp/dwi2response-tmp-SYKG4W/
Command: mrconvert /home/dario/Desktop/20160708_232214_StructuralConnectivity_1_42_E4/dwi.mif - -stride 0,0,0,1 | dwiextract - /tmp/dwi2response-tmp-SYKG4W/dwi.mif
dwi2response: 
dwi2response: [ERROR] Command failed: mrconvert /home/dario/Desktop/20160708_232214_StructuralConnectivity_1_42_E4/dwi.mif - -stride 0,0,0,1 | dwiextract - /tmp/dwi2response-tmp-SYKG4W/dwi.mif
dwi2response: Output of failed command:
dwiextract: [ERROR] No dwi volumes present
dwi2response: Changing back to original directory (/home/dario/Desktop/20160708_232214_StructuralConnectivity_1_42_E4)
dwi2response: Script failed while executing the command: mrconvert /home/dario/Desktop/20160708_232214_StructuralConnectivity_1_42_E4/dwi.mif - -stride 0,0,0,1 | dwiextract - /tmp/dwi2response-tmp-SYKG4W/dwi.mif
dwi2response: For debugging, inspect contents of temporary directory: /tmp/dwi2response-tmp-SYKG4W/

Any suggestions?

It might be that your dwi.mif input image doesn’t contain the DW gradient table, or contains a corrupt table. What do these commands report?

mrinfo dwi.mif 
mrinfo dwi.mif -dwgrad

If the image did not contain any gradient table at all, this should have resulted in a more specific error message. The fact that it reports “No dwi volumes present” means that MRtrix3 is labeling all volumes within your file as b=0 volumes. This could be either due to that file actually containing b=0 volumes only, or (more likely) that the gradient table has been provided with the incorrect b-value units. The software expects b-values to be defined in s.mm^-2 (e.g. values of 1000 and 3000 are common), while a default threshold of 10 is used to define b=0 volumes, consistent with the DICOM standard. If your b-values are stored as ms.um^-2 (e.g. values of 1 or 3), then all DWI volumes will be erroneously labeled as b=0 volumes, which will lead to this error.

The b-values should be stored correctly, although they have a pretty wide range. Maybe it has something to do with the used brain (rat brain in vivo)?

mrinfo dwi.mif reports:


Image: “dwi.mif”


Dimensions: 173 x 126 x 211 x 197
Voxel size: 0.0753968 x 0.0751445 x 0.075237 x ?
Data strides: [ -1 -2 3 4 ]
Format: MRtrix
Data type: unsigned 16 bit integer (little endian)
Intensity scaling: offset = 0, multiplier = 1
Transform: 0.9999 -0.01343 0.0005818 -6.456
0.01343 0.9999 0.009798 -1.452
-0.0007134 -0.00979 1 -8.638
comments: StructuralConnectivity (StructuralConnectivity) [MR]
study: scanning the brain of mouse 4 , which has been scanned with …
DOB: 09/07/2016
DOS: 11/07/2016 00:43:13
dw_scheme: [ 197 entries ]
mrtrix_version: 0.3.15-264-g7372ab22

mrinfo dwi.mif -dwgrad reports all zeros.

That’s pretty much answers the question: the DW gradient table stored in the image headers is useless. How were these images obtained?

I used mrconvert to convert de DICOM file into a .mif file. It seems, as if during that conversion, the DICOM header information got lost, since the DICOM header shows an intact gradient table…

OK, that’s not good… What scanner was used to acquire the data? Was this a product sequence? If so, is there any chance you could send me the data so I can try and fix the DICOM import?

The scanner was a Bruker BioSpec, if that helps. Right now I’m trying to convert de DICOM to a .nii file instead of a .mif, maybe that works.

Ah, OK. In my experience, Bruker DICOM files are problematic on many levels. I’m surprised to hear you say you can find the information in the DICOM headers at all…

That doesn’t sound good…

I tried to calculate the response function now from the .nii file and it gave me a different, albeit similar error:

dwi2response: [ERROR] Command failed: mrconvert /home/dario/Desktop/20160708_232214_StructuralConnectivity_1_42_E4/7/dwi.nii - -stride 0,0,0,1 | dwiextract - /tmp/dwi2response-tmp-QMDCAA/dwi.mif
dwi2response: Output of failed command:
dwiextract: [ERROR] invalid diffusion gradient table dimensions
dwiextract: [ERROR] unable to get valid diffusion gradient table for image "/tmp/mrtrix-tmp-4ZimTD.mif"
dwi2response: Changing back to original directory (/home/dario/Desktop/20160708_232214_StructuralConnectivity_1_42_E4/7)
dwi2response: Script failed while executing the command: mrconvert /home/dario/Desktop/20160708_232214_StructuralConnectivity_1_42_E4/7/dwi.nii - -stride 0,0,0,1 | dwiextract - /tmp/dwi2response-tmp-QMDCAA/dwi.mif
dwi2response: For debugging, inspect contents of temporary directory: /tmp/dwi2response-tmp-QMDCAA/

OK, the first error is actually slightly misleading:
dwiextract: [ERROR] invalid diffusion gradient table dimensions
The second one is more telling:
dwiextract: [ERROR] unable to get valid diffusion gradient table for image "/tmp/mrtrix-tmp-4ZimTD.mif"

NIfTI images can’t include the diffusion gradient table in the header. So when you call dwi2response and provide a NIfTI image as input, the script has no way of knowing which volumes correspond to which directions & b-values - hence dwiextract (which is responsible for extracting the b-value shell of interest from the image series) fails. You need to either provide the gradient table from external file(s) using the -grad or -fslgrad options, or use an image format that can embed the gradient table in the image header.

Hello, I ran into a problem when using the dwi2mask command.“dwi2mask: [ERROR] Gradient encoding matrix does not represent a HARDI sequence
” The scanner is also bruker BioSpec. Can you teach me how to process the data from bruker BioSpec?

Hi @QinJiasheng,

That particular error suggests that the diffusion gradient scheme has been imported, but the b-values are not arranged in “shells” (i.e. volumes with the same diffusion sensitisation strength but different directions). This is typically the case for “DSI” acquisitions. So you’ll need to determine whether this is in fact the case for your acquired data, or whether something has gone wrong during the importing process that is leading to the error.

The best first step would be to post the output of mrinfo -dwgrad, and describe what you know about the acquisition.

Cheers
Rob

One of the issue with Bruker data is that their DICOM output is (in my experience) not consistent, at least in terms of the diffusion gradient table information. There is a script that now ships with MRtrix3 to convert their raw 2dseq format (convert_bruker, in the scripts/ folder) , but it isn’t perfect either, and can also get the directions wrong (although in this case it’s typically just a matter of inverting or swapping components of the direction vectors). It also doesn’t extract the image orientation, which might be problematic for oblique acquisitions. The other issue is that as far as I can tell from my (limited) research into the Bruker raw format, their conventions change routinely between software versions, making it very tricky to robustly interpret their header information. So the convert_bruker script is provided on a best-effort basis, in the hope that it may help users such as yourself - and if you find ways to improve it, feel free to let us know!

Thank you very much rsmith!!! I did the command and this is the result:
promote:~ admin$ mrinfo -dwgrad /Users/admin/Documents/MATLAB/DICOM
mrinfo: [done] scanning DICOM folder “/Users/admin/Documents/MATLAB/DICOM”
Select series (‘q’ to abort):
0 - 15 MR images unnamed (FLASH (pvm)) [65537]
1 - 12 MR images unnamed (RARE (pvm)) [131073]
2 - 9 MR images unnamed (RARE (pvm)) [196609]
3 - 128 MR images unnamed (FieldMap (pvm)) [262145]
4 - 700 MR images unnamed (DtiEpi (pvm)) [393217]
? 4
mrinfo: [100%] reading DICOM series “”
mrinfo: [ERROR] floating-point sequence specifier is empty
promote:~ admin$
If I used this command in the right way?:joy: Dose it means there are no b-value table in the header ? I can get the b-value table which is in the form of “.txt”

Thank you very much !!! I understand what you mean probably,but how can I use the script:joy:. I saw the script just now, should I just copy the script and then past it in the Terminal?

Yea right, I tried to covert the file in other format before, and it prompted me the data is not consistent

No, it should already be in your PATH if you installed MRtrix3 correctly. It produces a .mih file, which is a text header that MRtrix3 commands can understand, and will load the corresponding raw data given the information in that header. You can then mrconvert that to .mif or .nii if you wish (although the .nii format will lose the DW gradient table information unless you also export the bvecs/bvals using the -export_grad_fsl option).

What did you use to try converting before, just out of interest?

The only sensible point in the code that would throw this particular error message is here - which indeed would indicate that the DW gradient information is missing - or more precisely, the DICOM header contained appropriate tags to store that information, but either the tags were empty, or the information was badly formatted.

The simplest way to figure this out is to try:

mrinfo /Users/admin/Documents/MATLAB/DICOM -property dw_scheme

which will print out exactly what our DICOM importer managed to extract, without trying to interpret it in any way. Otherwise, you can use dcminfo -all DICOM_FILE, where DICOM_FILE is a single file within your DICOM folder that corresponds to one of the 700 frames from your DtiEpi series, and post the output of that so we can see what was actually written in the raw DICOM headers.

I tried this and the result is this:promote:~ admin$ mrinfo /Users/admin/Documents/MATLAB/DICOM -property dw_scheme
mrinfo: [done] scanning DICOM folder “/Users/admin/Documents/MATLAB/DICOM”
Select series (‘q’ to abort):
0 - 15 MR images unnamed (FLASH (pvm)) [65537]
1 - 12 MR images unnamed (RARE (pvm)) [131073]
2 - 9 MR images unnamed (RARE (pvm)) [196609]
3 - 128 MR images unnamed (FieldMap (pvm)) [262145]
4 - 700 MR images unnamed (DtiEpi (pvm)) [393217]
? 4
mrinfo: [100%] reading DICOM series “”
mrinfo: [WARNING] no “dw_scheme” entries found in “lyf1204depression1 (lyf1204depression1) [MR]” .And the result of the other 4 folder are the same

while the result of this is:
promote:~ admin$ dcminfo -all /Users/admin/Documents/MATLAB/DICOM/1/MRIm001
TYPE GRP ELEM VR SIZE OFFSET NAME CONTENTS


[DCM] 0002 0000 UL 4 132 FileMetaInformationGroupLength [ 192 ]
[DCM] 0002 0001 OB 2 144 FileMetaInformationVersion unknown data type
[DCM] 0002 0002 UI 26 158 MediaStorageSOPClassUID [ 1.2.840.10008.5.1.4.1.1.4 ]
[DCM] 0002 0003 UI 48 192 MediaStorageSOPInstanceUID [ 2.16.756.5.5.100.3611295486.1479.1480816577.1.0 ]
[DCM] 0002 0010 UI 20 248 TransferSyntaxUID [ 1.2.840.10008.1.2.1 ]
[DCM] 0002 0012 UI 28 276 ImplementationClassUID [ 1.2.276.0.7230010.3.0.3.5.4 ]
[DCM] 0002 0013 SH 16 312 ImplementationVersionName [ OFFIS_DCMTK_354 ]
[DCM] 0008 0008 CS 22 336 ImageType [ ORIGINAL PRIMARY OTHER ]
[DCM] 0008 0012 DA 8 366 InstanceCreationDate [ 20161204 ]
[DCM] 0008 0013 TM 6 382 InstanceCreationTime [ 122301 ]
[DCM] 0008 0016 UI 26 396 SOPClassUID [ 1.2.840.10008.5.1.4.1.1.4 ]
[DCM] 0008 0018 UI 48 430 SOPInstanceUID [ 2.16.756.5.5.100.3611295486.1479.1480816577.1.0 ]
[DCM] 0008 0020 DA 8 486 StudyDate [ 20161204 ]
[DCM] 0008 0022 DA 8 502 AcquisitionDate [ 20161204 ]
[DCM] 0008 0030 TM 6 518 StudyTime [ 085144 ]
[DCM] 0008 0032 TM 6 532 AcquisitionTime [ 092458 ]
[DCM] 0008 0050 SH 0 546 AccessionNumber [ ]
[DCM] 0008 0060 CS 2 554 Modality [ MR ]
[DCM] 0008 0070 LO 24 564 Manufacturer [ Bruker BioSpin MRI GmbH ]
[DCM] 0008 0080 LO 30 596 InstitutionName [ Southeast University, Nanjing ]
[DCM] 0008 0090 PN 0 634 ReferringPhysicianName [ ]
[DCM] 0008 1010 SH 14 642 StationName [ PharmaScan 7T ]
[DCM] 0010 0010 PN 18 664 PatientName [ lyf1204depression1 ]
[DCM] 0010 0020 LO 18 690 PatientID [ lyf1204depression1 ]
[DCM] 0010 0030 DA 0 716 PatientBirthDate [ ]
[DCM] 0010 0040 CS 2 724 PatientSex [ M ]
[DCM] 0010 1030 DS 2 734 PatientWeight [ 5 ]
[DCM] 0018 0020 CS 2 744 ScanningSequence [ RM ]
[DCM] 0018 0021 CS 4 754 SequenceVariant [ NONE ]
[DCM] 0018 0022 CS 0 766 ScanOptions [ ]
[DCM] 0018 0023 CS 2 774 MRAcquisitionType [ 2D ]
[DCM] 0018 0024 SH 12 784 SequenceName [ DtiEpi (pvm) ]
[DCM] 0018 0050 DS 4 804 SliceThickness [ 0.8 ]
[DCM] 0018 0080 DS 8 816 RepetitionTime [ 6500.001 ]
[DCM] 0018 0081 DS 6 832 EchoTime [ 28.66 ]
[DCM] 0018 0083 DS 2 846 NumberOfAverages [ 2 ]
[DCM] 0018 0084 DS 12 856 ImagingFrequency [ 300.3371139 ]
[DCM] 0018 0085 SH 2 876 ImagedNucleus [ 1H ]
[DCM] 0018 0088 DS 4 886 SpacingBetweenSlices [ 0.8 ]
[DCM] 0018 0089 IS 2 898 NumberOfPhaseEncodingSteps [ 84 ]
[DCM] 0018 0091 IS 2 908 EchoTrainLength [ 21 ]
[DCM] 0018 0094 DS 4 918 PercentPhaseFieldOfView [ 100 ]
[DCM] 0018 0095 DS 8 930 PixelBandwidth [ 1953.125 ]
[DCM] 0018 1020 LO 14 946 SoftwareVersions [ ParaVision 5.1 ]
[DCM] 0018 1030 LO 30 968 ProtocolName [ EPI-diffusion-tensor-RAT_6sta ]
[DCM] 0018 1310 US 8 1006 AcquisitionMatrix [ 84 0 0 256 ]
[DCM] 0018 1312 CS 4 1022 InPlanePhaseEncodingDirection [ COL ]
[DCM] 0018 1314 DS 2 1034 FlipAngle [ 90 ]
[DCM] 0018 5100 CS 4 1044 PatientPosition [ HFS ]
[DCM] 0020 000D UI 50 1056 StudyInstanceUID [ 2.16.756.5.5.100.3611295486.30024.1480812704.4611 ]
[DCM] 0020 000E UI 46 1114 SeriesInstanceUID [ 2.16.756.5.5.100.3611295486.1479.1480816577.1 ]
[DCM] 0020 0010 SH 16 1168 StudyID [ lyf1204depressio ]
[DCM] 0020 0011 IS 6 1192 SeriesNumber [ 393217 ]
[DCM] 0020 0012 IS 2 1206 AcquisitionNumber [ 1 ]
[DCM] 0020 0013 IS 2 1216 InstanceNumber [ 1 ]
[DCM] 0020 0032 DS 16 1226 ImagePositionPatient [ -15.9 -17.2 -6.9 ]
[DCM] 0020 0037 DS 68 1250 ImageOrientationPatient [ 1 6.123031769e-17 9.295486608e-33 -6.123031769e-17 1 1.550163777e-16 ]
[DCM] 0020 0052 UI 54 1326 FrameOfReferenceUID [ 2.16.756.5.5.100.3611295486.1479.1480816577.1.6.15.18 ]
[DCM] 0020 1002 IS 4 1388 ImagesInAcquisition [ 700 ]
[DCM] 0020 1040 LO 0 1400 PositionReferenceIndicator [ ]
[DCM] 0020 1041 DS 4 1408 SliceLocation [ -6.9 ]
[DCM] 0028 0002 US 2 1420 SamplesPerPixel [ 1 ]
[DCM] 0028 0004 CS 12 1430 PhotometricInterpretation [ MONOCHROME2 ]
[DCM] 0028 0010 US 2 1450 Rows [ 128 ]
[DCM] 0028 0011 US 2 1460 Columns [ 128 ]
[DCM] 0028 0030 DS 10 1470 PixelSpacing [ 0.25 0.25 ]
[DCM] 0028 0100 US 2 1488 BitsAllocated [ 16 ]
[DCM] 0028 0101 US 2 1498 BitsStored [ 16 ]
[DCM] 0028 0102 US 2 1508 HighBit [ 15 ]
[DCM] 0028 0103 US 2 1518 PixelRepresentation [ 1 ]
[DCM] 0028 0106 US 2 1528 SmallestImagePixelValue [ 115 ]
[DCM] 0028 0107 US 2 1538 LargestImagePixelValue [ 32766 ]
[DCM] 0028 1050 DS 6 1548 WindowCenter [ 16441 ]
[DCM] 0028 1051 DS 6 1562 WindowWidth [ 32652 ]
[DCM] 0028 1055 LO 6 1576 WindowCenterWidthExplanation [ MinMax ]
[DCM] 7FE0 0010 OW 32768 1590 PixelData unknown data type
What does this mean :joy:

Thank you very very much!!!