UCL / pet-rd-tools

Command line tools for PET-MR (pre-)processing
Apache License 2.0
13 stars 4 forks source link

nm_extract error creating listmode header #34

Closed rijobro closed 5 years ago

rijobro commented 5 years ago

For certain files, nm_extract works fine, but for some others I've had a problem (although we're not sure if it's pet-rd-tools or something else (e.g., gdcm).

In nmtools/MMR.hpp, the DICOM tag (0x029, 0x1010) is initially used. If the returned string does not contain SV10, (0x029, 0x1110) is used instead.

However, for some images, the following line (in Common.hpp):

inStream << std::fixed << element.GetValue();

returns the length of the string instead of the string itself. This then causes problems.

For these images, we can manually change the code to look straight for (0x029, 0x1110), skipping out (0x029, 0x1010) altogether.

Sorry if this message is a bit cryptic, I can probably explain it better in person. @KrisThielemans helped with the debugging.

KrisThielemans commented 5 years ago

It actually returns the string Loaded:XX with XX the number of bytes.

This post might help.

bathomas commented 5 years ago

I've switch the tag reading to using gdcm::StringFilter, which is good, but doesn't solve the problem. The issue seems to be with reading long private fields. The StringFilter will return an empty string whereas using element.GetValue() can give you the Loaded:XX issue you've observed.

So I've kind have fudged this to work by doing:

     if stringFilter returns 0
          if element.GetValue != "Loaded:" 
               return the value 
          else 
               return empty.

This appears to be okay for SMS 3.4 (roughly >=2014) data. I haven't got any old (3.2) data to hand to check if this approach works there too.

Let me know if the branch works.