Comments (4)
This worked. Thanks so much and the library is great.
from dicom-rs.
Thank you for reporting. You are right that the Fragments API bears a few limitations right now, but apparently it can also be misleading. Creating Fragments
should only be necessary if you have a very large frame that needs to be split into fragments. In your case, if you have a list of frames and intend to fit exactly one frame in each fragment, I would recommend skipping that API altogether.
let mut all_fragments: Vec<_> = frames.iter().enumerate().map(|(ix, frame)| {
println!("Adding frame {} with len {}", ix, frame.len());
frame.to_vec()
}).collect();
file.put(DataElement::new(
tags::PIXEL_DATA,
VR::OB,
PixelSequence::<InMemDicomObject, InMemFragment>(all_fragments.into()),
));
You might encounter two other issues:
-
The accumulation of all frame lengths in
total_frame_len
could also panic. This is generally not necessary unless you wish to provide Encapsulated Pixel Data Value Total Length (7FE0,0003). If you skip it or make it au64
, it should no longer overflow. -
One other problem is that pushing all frames into a DICOM object will require all frames to be in memory. The future of the project may hold nicer ways to write DICOM data sequentially.
from dicom-rs.
Ok awesome and good to know. In the example above do you happen to know if I will need to write the pixel data with a different approach as well? On my end it is showing that the From<> trait isn't implemented for converting a Vec<Vec> into a PixelSequence.
let mut all_fragments: Vec<_> = frames.iter().enumerate().map(|(ix, frame)| {
println!("Adding frame {} with len {}", ix, frame.len());
frame.to_vec()
}).collect();
file.put(DataElement::new(
tags::PIXEL_DATA,
VR::OB,
PixelSequence::<InMemDicomObject, InMemFragment>(all_fragments.into()),
));
the trait bound `PixelFragmentSequence<Vec<u8>>: From<Vec<Vec<u8>>>` is not satisfied
from dicom-rs.
Hmm right. You can try PixelFragmentSequence::new_fragments
instead. It makes it clear that it keeps the basic offset table empty, which is probably why I withdrew the idea of implementing From<_>
for this case.
file.put(DataElement::new(
tags::PIXEL_DATA,
VR::OB,
PixelFragmentSequence::new_fragments(all_fragments.into()),
));
from dicom-rs.
Related Issues (20)
- Adding private data elements (with creator) HOT 4
- dicom-transfer-syntax-registry does not build on Windows by default HOT 1
- Extended offset table support
- Support for multiple character repertoires (extended character sets) HOT 1
- Could not compile openjp2 HOT 10
- Issue when trying to open a DICOM file. HOT 2
- DICOM naive datetime retrieval HOT 6
- Latest version fails to build for android HOT 5
- Unusual Image Generation from RLE DICOM Files HOT 4
- Wrong VR assumed when reading pixel padding in Implicit VR dataset
- to_dynamic_image method not found in `DecodedPixelData<'_>` HOT 10
- Support resolving BulkDataURIs
- Non-deterministic behavior in dicom-storescu function check_presentation_contexts HOT 10
- Starting the discussion on async support HOT 3
- Storescp promiscuous mode HOT 1
- ERROR dicom_findscu: status code from response is missing HOT 3
- Very slow association with invalid adresses - Need to use custom timeout during connecting HOT 1
- Disable feature 'jpeg2k' in dicom-transfer-syntax-registry HOT 2
- Version of openjp2 causing issue in new projects HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dicom-rs.