Skip to content
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

Data set level reading and writing of encapsulated pixel data #42

Merged
merged 14 commits into from
May 24, 2020

Conversation

Enet4
Copy link
Owner

@Enet4 Enet4 commented May 23, 2020

This PR extends the data set reader/writer so that it understands the logic of pixel sequences in the data set. This ultimately makes it possible to read files with an encapsulated pixel data. Resolves #23.

  • Two new types of DataTokens: PixelSequenceStart (for the beginning of an encapsulated pixel data element) and ItemValue (for the raw contents of a pixel data item).
  • Handle Pixel Data (7EF0, 0010) elements with an undefined length as encapsulated pixel data.
  • New DICOM value variant PixelSequence allows you to represent DICOM pixel sequences in memory, including .
    • The current implementation of InMemDicomObject will collect all fragments and the offset table as-is into memory, thus retaining the fact that the pixel data is encapsulated.

The known caveat is that DICOM values and data tokens need to own the memory that they are working with. This means that data may still need to be copied around in some cases (e.g. saving a DICOM object to disk), and that each data token has to be fully contained in memory. This is likely to be reiterated to address the concerns presented in #1, so that tokens may instead borrow or refer to an arbitrary reader source.

Enet4 added 7 commits May 23, 2020 00:20
- extend stateful encoder/decoded to read/write raw bytes
- new data token type ItemValue
- add method `Header.is_encapsulated_pixeldata`
- on pixeldata element with undefined length, treat data as encapsulated
replaces DataElementHeader with encapsulated pixel data check
- @ DataSetWriter, treat encapsulated element start as a new sequence
- at DataSetReader, discard last pixel data header
  on first read to prevent reentrance
- also test behavior on DataSetWriter
to PixelSequenceStart, simpler and possibly more familiar
- implement pixel sequence reading so that all
  fragments are joined together in a single vector
Enet4 added 7 commits May 23, 2020 23:29
- new type parameter P in value::Value and dependents
   - for representing Pixel information
- new variant PixelSequence in value::Value
- into_tokens algorithms adjusted accordingly to produce
  pixel sequence tokens
  - ItemValue impl for tokens of a single item with raw data
- InMemDicomObject now contains pixel sequence items
  on encapsulated pixel data
- add test for reading encapsulated
  pixel data with non-empty offset table
- adjust output width and spacing calculation
- write sequence delimitation item
- write pixel sequence items
- use DICOM conventional byte printing format
- ensure that the following items are stored as compressed fragments
  at the end of the first one
- generalize methods for taking iterators of `Result<DataToken>`
  instead of data set readers explicitly
  - easier to test
- add tests on turning tokens into in-mem objects
clippy::into_iter_on_ref
@Enet4 Enet4 merged commit 8f43089 into master May 24, 2020
@Enet4 Enet4 deleted the new/encapsulated-data branch August 4, 2020 11:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support PixelData of undefined length
1 participant