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

adding stop_before_pixels to read_file of dicom parser #164

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ and **Merged pull requests**. Critical items to know are:
Referenced versions in headers are tagged on Github, in parentheses are for pypi.

## [vxx](https://github.com/pydicom/deid/tree/master) (master)
- adding stop_before_pixels to read_file in parser (0.2.24)
- removing verbosity of debug logger (0.2.23)
- changing iteration technique through fields to properly add nested uids [#153](https://github.com/pydicom/deid/issues/153) (0.2.22)
- change to return results from detect when recipe does not contain filters [#155](https://github.com/pydicom/deid/issues/155)
Expand Down
7 changes: 6 additions & 1 deletion deid/dicom/header.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,12 @@


def get_identifiers(
dicom_files, force=True, config=None, strip_sequences=False, remove_private=False
dicom_files,
force=True,
config=None,
strip_sequences=False,
remove_private=False,
stop_before_pixels=False,
):
"""extract all identifiers from a dicom image.
This function returns a lookup by file name, where each value indexed
Expand Down
12 changes: 8 additions & 4 deletions deid/dicom/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ class DicomParser:
file. For each, we store the element and child elements
"""

def __init__(self, dicom_file, recipe=None, config=None, force=True):
def __init__(
self, dicom_file, recipe=None, config=None, force=True, stop_before_pixels=False
):

# Lookup for the dicom
self.lookup = {}
Expand All @@ -70,7 +72,7 @@ def __init__(self, dicom_file, recipe=None, config=None, force=True):
# Deid can be a recipe or filename
if not isinstance(recipe, DeidRecipe):
recipe = DeidRecipe(recipe)
self.load(dicom_file, force=force)
self.load(dicom_file, force=force, stop_before_pixels=stop_before_pixels)
self.recipe = recipe

def __str__(self):
Expand All @@ -79,7 +81,7 @@ def __str__(self):
def __repr__(self):
return self.__str__()

def load(self, dicom_file, force=True):
def load(self, dicom_file, force=True, stop_before_pixels=False):
"""Ensure that the dicom file exists, and use full path. Here
we load the file, and save the dicom, dicom_file, and dicom_name.
"""
Expand All @@ -94,7 +96,9 @@ def load(self, dicom_file, force=True):
# If we must read the file, the path must exist
if not os.path.exists(dicom_file):
bot.exit("%s does not exist." % dicom_file)
self.dicom = read_file(dicom_file, force=force)
self.dicom = read_file(
dicom_file, force=force, stop_before_pixels=stop_before_pixels
)

# Set class variables that might be helpful later
self.dicom_file = os.path.abspath(self.dicom.filename)
Expand Down
2 changes: 1 addition & 1 deletion deid/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

"""

__version__ = "0.2.23"
__version__ = "0.2.24"
AUTHOR = "Vanessa Sochat"
AUTHOR_EMAIL = "[email protected]"
NAME = "deid"
Expand Down