-
Notifications
You must be signed in to change notification settings - Fork 258
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
ENH: Add "element" containers and make dicom wrappers compatible #416
base: master
Are you sure you want to change the base?
Conversation
This is a bite-sized chunk from #290. The goal is to provide a nice standard way to access meta data structures, especially once they become nested. So instead of having to do something like: meta['key1'].value['key2'].value[0].value we can do: meta['key1']['key2'][0] If you need to access the full "element" you can use the |
I think we should make meta data access on the DICOM wrappers the same as meta data access on other Nibabel image classes. Are we okay with making the image classes dict-like for meta data access? If not, we should figure out what we want and implement it for the DICOM wrappers as well. For the other image classes things are a bit more complicated as there is also the existing "header" attribute which contains some meta data. I guess we could make it so that |
nibabel/elemcont.py
Outdated
@@ -0,0 +1,188 @@ | |||
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*- | |||
# vi: set ft=python sts=4 ts=4 sw=4 et: | |||
'''Containers for storing "elements" which have both a core data value as well |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Single first line (docstring standard - also makes auto-generated docs look nicer).
☔ The latest upstream changes (presumably #439) made this pull request unmergeable. Please resolve the merge conflicts. |
Hello @moloney, Thank you for updating! Cheers! There are no style issues detected in this Pull Request. 🍻 To test for issues locally, Comment last updated at 2020-03-23 22:17:20 UTC |
Add two main types: 'ElemDict' and 'ElemList'. Each can only store objects with an attribute 'value'. Standard lookups with '__getitem__' and 'get' return just this 'value' attribute. To access the underlying object, a 'get_elem' method is provided. Also updated the DICOM wrappers to provide a 'get_elem' method that returns the full DICOM element rather than just the value. Added a __iter__ method that returns the available DICOM keys.
Codecov Report
@@ Coverage Diff @@
## master #416 +/- ##
==========================================
- Coverage 91.70% 91.62% -0.09%
==========================================
Files 96 97 +1
Lines 12311 12435 +124
Branches 2173 2208 +35
==========================================
+ Hits 11290 11393 +103
- Misses 684 698 +14
- Partials 337 344 +7
Continue to review full report at Codecov.
|
@moloney Thanks for rebasing this against master. @matthew-brett Do you have the time to resume reviewing this (and/or #417, #419)? |
Add two main types:
ElemDict
andElemList
. Each can only storeobjects with an attribute
value
. Standard lookups with__getitem__
andget
return just thisvalue
attribute. Toaccess the underlying object, a
get_elem
method is provided.Also updated the DICOM wrappers to provide a
get_elem
method thatreturns the full DICOM element rather than just the value. Added a
__iter__
method that returns the available DICOM keys.