Skip to content

BF: Remove assumption about StackID index #439

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

Merged
merged 8 commits into from
Apr 9, 2016

Conversation

embaker
Copy link
Contributor

@embaker embaker commented Mar 30, 2016

In determining the shape of a multi-frame DICOM, the first value in the DimensionIndexValues was taken to be the StackID. The DICOM standard does not appear to guarantee this to always be true. Replaced the assumption by using the DimensionIndexSequence to determine the position of the StackID in the DimensionIndexValues.

@matthew-brett
Copy link
Member

Thanks a lot for this. Is there anything in the DICOM standard docs that you could copy / paste into the docstring here to explain the algorithm?

@matthew-brett
Copy link
Member

Generally this looks good and well-written, but I don't know the part of the standard that this is implementing - can you give me some pointers to help review?

Brendan - do you have time to take a look?

@embaker
Copy link
Contributor Author

embaker commented Apr 4, 2016

I am currently inserting into the docstring a description of the algorithm and references to the DICOM standard. The relevant parts of Supplement 49 of the DICOM standard are:

  • C.7.6.17 Multi-frame Dimension Module
  • C.7.6.16.2.2 Frame Content Macro

@matthew-brett
Copy link
Member

Thanks - that will be very helpful.

@matthew-brett
Copy link
Member

I think this is the definitive source for the supplement : ftp://medical.nema.org/medical/dicom/final/sup49_ft.pdf - is that right?

But - looking at the standard, it seems the supplement has already been included, e.g. C.7.6.16 Multi-frame Functional Groups Module in http://dicom.nema.org/medical/dicom/current/output/pdf/part03.pdf . So I guess the standard is the correct reference?

# the pointer pair (StackID Dicom-tag, FrameContentSequence Dicom-tag)
# that indicates that the corresponding axis in the DimensionIndexValues
# attribute refers to the StackID
stack_id_dim_pointer = ((0x20, 0x9056), (0x20, 0x9111))
Copy link
Member

Choose a reason for hiding this comment

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

Maybe get these programmatically to make it more readable? As in something like:

from nibabel.pydicom_compat import pydicom as pd
stack_id_dim_pointer = pd.datadict.tag_for_name('StackID'), pd.datatict.tag_for_name('FrameContentSequence')

Copy link
Member

Choose a reason for hiding this comment

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

Do we need to check the second "FrameContentSequence" tag? What if the first Tag is StackID and the second is something else? Is this an error in the DICOM?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will update the references to point to the current standard. I have been working off of the 2015c version of the standard that did not include the supplement.

I agree that using tag_for_name is preferable. I will rewrite like how you suggested. This brings up another thought that occurred to me: do you think that it would be beneficial to have a method/attribute that returned/stored the DICOM attribute name that each axis of the data corresponds to? A user could use the "DimensionIndexSequence" to determine these on their own, but doing it in such a manner could be error prone for them since we are removing the "StackID" axis.

I believe you are correct that the "FrameContentSequence" tag is not needed. It does appear that it would be an error in the DICOM (C.7.6.17.1 Dimension Indices) if the "FunctionalGroupPointer" was something other than the "FrameContentSequence" tag for "StackID". However, it does not appear that the DICOM standard guarantees that each axis will have a "FunctionalGroupPointer" attribute when one is not needed for that axis (i.e. the dimension attribute is not nested). If this was the case for an axis, then how I have it coded up now will not work. So i am going rewrite the code to just rely on the "DimensionIndexPointer".

Copy link
Member

Choose a reason for hiding this comment

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

Thanks for the feedback. It would be excellent to have a way of returning an attribute name per axis. I'm hoping to get some time in the next few months to add named axes to nibabel image objects, and it would be very helpful to be able to get names from dicom image axes.

Copy link
Member

Choose a reason for hiding this comment

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

For the reference, given that the supplement has just been included, maybe add a reference to the supplement and the most recent version of the standard.

@matthew-brett
Copy link
Member

Thanks for this - the code is well written and tested, good to read.

@matthew-brett matthew-brett merged commit 7397e60 into nipy:master Apr 9, 2016
matthew-brett added a commit that referenced this pull request Apr 11, 2016
MRG: test fixes and doc updates for multiframe code

Fixes to some new test failures at : https://travis-ci.org/matthew-brett/nibabel/builds/121846880

More links to sections and diagrams on multi-frame / enhanced MR image
IOP.

Follow-up to PR #439.
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.

2 participants