-
Notifications
You must be signed in to change notification settings - Fork 78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Default ValueReadStrategy #105
Comments
Thank you for reaching out. Note that changing the parser reading strategy is not necessary for that use case. It only means that a conversion needs to take place after the parsing, which is the standard way of working with DICOM values at the moment. To treat a DS value as a floating point number: // example
let val = DicomValue::new(dicom_value!(Strs, ["1300", "664 "]));
// converts strings automatically
let ww = val.to_float64()?;
// for multiple window levels, returns a vector
let ww = val.to_multi_float64()?; The documentation on Changing the value reading strategy requires creating the data set reader with the function |
Thank you @Enet4 for the detailed explanation. I got the idea of conversion on retrieval. Well... dates/times can be treated this way: storing strings but retrieving dates/times. However please explain why you did the same for floating-point values in contrast to integer values stored natively? Are you afraid of meeting a non-standard floating-point value, for example, with a decimal comma instead of a dot? Thank you for following up on this conversation! |
That would be a good point, and a justification to continue with this strategy, but the reasoning of this being the default is primarily to preserve the original representation: any textual value stays textual, thus preventing failures during the parsing phase and other oddities (such as decimal numbers losing precision when turned to a binary type). This does not apply uniquely to dates/times and floating point values. If the VR is IS (e.g. for Instance Number), it will still be kept as a string. This is fine, as conversion is trivially done at a later stage through |
OK @Enet4, thanks for clarifying the architecture. Now I would like to share a real code converting DICOM elements into JSON values (some of them at least):
It traces the following for a file:
Please note that |
Please use |
Thank you, it seems to work! |
I am not very experienced with Rust so the issue might be explained easily.
Please explain how to switch from
ValueReadStrategy::Preserved
toValueReadStrategy::Interpreted
option. My issue is the following: I get a DICOM element ofDS
type however the element holdsPrimitiveValue::Strs
instead ofPrimitiveValue::F64
because of usingdecode::read_value_preserved
rather thandecode::read_value
inside the library based on what I have studied in the code.My sample code is following:
I call
print_value
for eachDataElement
of a file. Almost any 16-bit image file contains theWindow Center
/Window Width
tags which are float-point values. However, my code never returnsfloat64
.The text was updated successfully, but these errors were encountered: