InMemDicomObject with defined Length retains Length value after changes to inner value of object
jmlaka opened this issue · comments
Suppose we have a sequence with defined Length
from reading a dicom file.
Parsing the sequence into items yields InMemDicomObject
s with defined Length
value.
After changes are made to such InMemDicomObject (.remove_element .put ...) it retains it's original Length value.
How I found out:
Constructing file output from such changed InMemDicomObjects results in faulty output.
A workaround is constructing a InMemDicomObject::from_element_iter(vec![original_object])
which sets the Length::UNDEFINED
Can the API be changed so that any changes to internal value of InMemDicomObject will reset the Length to undefined ?
Thank you
Thank you for reporting, @jmlaka. That is right, the byte length is not updated automatically. Recalculating it on every change would be too expensive, but resetting it to undefined sounds good to me!
How I found out:
Constructing file output from such changed InMemDicomObjects results in faulty output.
This sounds more serious though. I had the impression that I had fixed these cases in #172, but as it turns out, it only redetermines the length of primitive data elements, and not of nested data sets. In cases where the length cannot be trusted, it is better to leave the length as implicitly defined upon writing.
Could you work on a pull request? Much appreciated!
Resolved via #364.