moloney / dcmstack

DICOM to Nifti conversion with meta data preservation
Other
72 stars 51 forks source link

Conversion of muti-channel multi-echo MRI data #27

Closed brennerd11 closed 9 years ago

brennerd11 commented 9 years ago

Hi,

I am trying to convert a dual-echo multi-coil MRI dataset (in total 5D 58x58x40x2x32) from DICOMs to NIFTI using dcmstack.

My problem is that I seem not to be able to figure out the right command to set the correct vector-var and time-var arguments from the command line.

Details: I would like the data to get sorted by the DICOM tags for CoilString (I think this vendor specific): (0x051, 0x0100f) and EchoTime: (0x0018, 0x0081). CoilStrings are strings running from '"A01" to "A32" in this case. EchoTime is a numeric value. For conversion I tried (as indicated by the help string)

 dcmstack --embed-meta --time-var 0x0018_0x0081 --vector-var 0x0051_0x0100f datadir

as well as variants with putting the tags in extra ' ' Unfortunately this always results in the error

UserWarning: Error adding file {...} to stack: The image collides with one already in the stack

I check the DICOMs manually using pydicom and they seem intact and the tags are set correctly. Am I simply using it wrong/misunderstanding the meaning of the arguments? I also tried to give it the meta data keys "EchoTime" and "CsaSeries.CoilString" as arguments instead of the DICOM tags but that did not seem to make a difference.

I am happy to provide example data on request.

Many thanks for dcmstack! It is a great tool.

moloney commented 9 years ago

Could you try with the "--extract-private" option? Since "CoilString" is a private tag (without a translator) it does not get extracted by default.

I really should be doing something smarter since you are specifying that as a tag we are sorting on (extract it even though it is private).

brennerd11 commented 9 years ago

Hi! Thanks for looking into this. Unfortunately it did not work. But I also noticed for other datasets the coil string was actually extracted even without the '--extract-private' option. I assume the problem originates from my (improper) usage of the --time-order argument. I observed following for a different (this time 4D) dataset with size spatial dimensions 58 x 58 x 40 and 2 echo times (1.00ms and 1.98ms) to narrow it down. When I run dcmstack without specifying a specific time order

dcmstack datadir

the conversion works properly and it outputs a 4D NIFIT. When I explicitly specify the time order

dcmstack --time-var 0x0018_0x0081 datadir

It again complains about the image collision. I double checked using pydicom that all files have the echo time (dicom tag 0x0018_0x0081) tag set correctly - e.g. in this case I have a total of 80 files with 40 having a TE of 1.00ms and 40 having a TE of 1.98ms. dcmstack version is 0.7.0.dev and pydicom version is 0.9.9 Thanks!

EDIT: I can confirm the same behavior with the 0.6.2 release

moloney commented 9 years ago

Ah yes, it is not parsing the --time-var or --vector-var tags in the numeric format (i.e. 0x18_0x81). It does work with 'EchoTime'. I will look into addressing the numeric tag issue.

brennerd11 commented 9 years ago

Worked perfectly (also for the original 5D issue) with

dcmstack --extract-private --embed-meta --time-var 'EchoTime' --vector-var 'CoilString' datadir

Thanks for the help!