moloney / dcmstack

DICOM to Nifti conversion with meta data preservation
Other
73 stars 53 forks source link

Bug to convert philips DTI dcm files #51

Open anbai106 opened 7 years ago

anbai106 commented 7 years ago

Hello: Thanks for your work, but I maybe have a very stupid question: your convertor works for all the machines or not? I tested with Siemens, GE, Philips, but I have problem to convert Philips:

I got errors like this, because im not familiar with dicom, so I can not figure out the bug from the python source code:

Traceback (most recent call last): File "/Users/junhao.wen/Hao/Code/Python/Economy/test_dcmstack.py", line 13, in <module> stack_data = my_stack.get_data() File "build/bdist.macosx-10.6-x86_64/egg/dcmstack/dcmstack.py", line 763, in get_data File "build/bdist.macosx-10.6-x86_64/egg/dcmstack/dcmstack.py", line 726, in get_shape dcmstack.dcmstack.InvalidStackError: The DICOM stack is not valid: Unable to guess key for sorting the fourth dimension

PS: I also tried the command line, it gave the same errors. Really look forward to the reply:)

Good day

Hao

moloney commented 7 years ago

Hi,

The goal is to work on any DICOM files regardless of the manufacturer. However, I mostly work with data from Siemens instruments so that has been what most of the testing was done with.

We still don't handle multi-frame DICOM files, so if that is what you are working with there is no quick and easy solution.

If you aren't working with multi-frame DICOM files, then that error is pretty self explanatory. Since the DICOM standard doesn't provide enough info to automatically determine what the extra-spatial dimensions should be, dcmstack is forced to try to guess. Basically we have a list of DICOM element we will try to use to order the 4th dimension (see https://github.com/moloney/dcmstack/blob/master/src/dcmstack/dcmstack.py#L412). We try each of those keys in turn until we find one that works. In the case of your data, none of those listed elements works.

You can manually specify the element to use for the extra spatial dimensions. In python you would pass in the keyword to use for the time_order and/or vector_order arguments to the DcmStack constructor. On the command line you would use the --time-var and/or --vector-var options.

If you can figure out which DICOM element to use for this ordering you can let me know and it can potentially be added to the default list of elements we try.

moloney commented 3 hours ago

Support for enhanced DICOM is merged. However I still haven't taken a crack at creating a normalized b_vector or b_matrix, so support for DTI may not be ideal. The data might still convert due to other tags providing a valid sorting order, but I will leave this issue open until I know more.