Closed vpapaioannou closed 3 years ago
If the function is in the file deid.dicom.tags
then you need to import it from there :) The other functions (get_identifiers, replace_identifiers) are provided one level up for ease of use, but get_private
is not as commonly used and thus needs to be imported from the module where it's defined.
I what sense are they one level up? Because they exist in another file instead of tags
. Using died.dicom.tags
works.
Thanks.
So the functions get_identifiers and replace_identifiers are defined in deid.dicom.headers. When I say one level up, I mean that they are imported into the dicom/__init__.py
(see here https://github.com/pydicom/deid/blob/master/deid/dicom/__init__.py). This means that either of these imports works for those functions:
from deid.dicom import get_identifiers
from deid.dicom.header import get_identifiers
But this is not the case for get_private. The design is modeled after pydicom, which also provides a subset of functions at the top level as a courtesy. https://github.com/pydicom/pydicom/blob/master/pydicom/__init__.py#L32
Thank you again! It's clear now.
Running
from deid.dicom import get_private
I get the errorImportError: cannot import name 'get_private'
while I can seeget_private
function indeid/dicom/tags.py
file. For e.g.get_identfiers
thefrom deid.dicom import get_identifiers
works fine.I see
remove_private
lies within another file while it appears relevant toget_private
. Is there a reason for that?Thanks.