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

Create Frame Constructs #19

Merged
merged 2 commits into from
Jul 13, 2018
Merged

Create Frame Constructs #19

merged 2 commits into from
Jul 13, 2018

Conversation

suyashkumar
Copy link
Contributor

@suyashkumar suyashkumar commented Jul 12, 2018

This change creates the concept of a Frame which wraps NativeFrame and EncapsulatedFrame into one Frame entity. This Frame entity will be streamable via a channel as a DICOM is being parsed. This change adds more abstraction (and therefore a little more boilerplate) when working with Frames.

@suyashkumar suyashkumar changed the title [WIP] Update Frame Constructs [WIP] Create/Update Frame Constructs Jul 12, 2018
element.go Outdated
// Frame represents a single encapsulated or native image frame
type Frame struct {
IsEncapsulated bool
EncapsulatedFrame EncapsulatedFrame
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can flatten the Frame data structure if we just dump EncapsulatedFrames []byte and NativeFrames [][]int inside the Frame and bring along other attributes like Rows, Cols, and BitsPerSample along for each Frame...even though those attributes are really only needed for work with NativeFrames

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It turns out those attributes are required for both encapsulated and native images so including them in the top level of Frame would not be too bad. They just make less sense for encapsulated images to have included with the Frame itself, but that's okay...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for now, will likely leave as is, if a refactor is needed it can happen later. Including those elements with every Frame doesn't really add value for EncapsulatedFrames since that information already exists in the encapsulated frame data. We also assume that clients have the previously parsed elements if they happen to need those elements, so no need to duplicate storage of that data for all types of frames.

@@ -40,12 +40,12 @@ type parser struct {
decoder *dicomio.Decoder
parsedElements *DataSet
op ParseOptions
frameChannel chan [][]int
frameChannel chan *Frame
Copy link
Contributor Author

@suyashkumar suyashkumar Jul 12, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we'll use this to stream pointers of parsed frames over to a consumer

element.go Outdated
s := fmt.Sprintf("image{offsets: %v, frames: [", data.Offsets)
for i := 0; i < len(data.Frames); i++ {
if data.Frames[i].IsEncapsulated {
csum := sha256.Sum256(data.Frames[i].EncapsulatedFrame.Data)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

semantically, it may be better for a Frame to contain EncapsulatedData instead of an EncapsulatedFrame... so we'd have expressions like

data.Frames[i].EncapsulatedData.Data

or

data.Frames[i].Encapsulated.Data

// Frame wraps a single encapsulated or native image frame
type Frame struct {
IsEncapsulated bool
EncapsulatedData EncapsulatedFrame
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Field called EncapsulatedData to better represent the hierarchy of Frames containing EncapsulatedData instead of Frames containing other EncapsulatedFrames...ideally we can come up with a better name for the struct too. Perhaps EncapsulatedFrameData?

@suyashkumar suyashkumar changed the title [WIP] Create/Update Frame Constructs Create Frame Constructs Jul 13, 2018
@suyashkumar suyashkumar merged commit 3c07546 into master Jul 13, 2018
@suyashkumar
Copy link
Contributor Author

Not blocking on the naming for now, we can revisit as things develop

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant