-
-
Notifications
You must be signed in to change notification settings - Fork 55
CLI 'pixel' command #285
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
Open
WillForan
wants to merge
15
commits into
pydicom:master
Choose a base branch
from
WillForan:cli-pixelclean
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
CLI 'pixel' command #285
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
243a52c
fix: main.identifiers saves dicom
WillForan d023793
WIP: failing test for cli interface to come
WillForan b1cddf3
feat(main:pixels): cli option 'pixel' cleaning
WillForan 00002aa
chore(version): bump minor for cli feat (0.4.6 -> 0.5.0)
WillForan 093c322
fix: codespell linting
WillForan 2e36cf3
fix: flake8 lint, isort
WillForan 1a0a1ca
refactor: pixel_main now just main
WillForan af0afba
fix(_get_clean_name): use os.path.join
WillForan 89bf7cb
refactor(clean-pixels): command 'clean-pixels' with --type dicom
WillForan 3a737c1
test(_get_clean_name): test+demo DicomCleaner export naming
WillForan 910c5d8
refactor(dicom.pixels.clean): remove image_type
WillForan fe724de
doc(comments): outdated comment in test; .IMA is Siemens dcm ext
WillForan 09a81d5
Merge branch 'master' into cli-pixelclean
WillForan dfee025
chore(CHANGELOG.md): add 0.5.0
WillForan db39739
fix(main): DRY up subparser.add_parser for --deid and --input
WillForan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| #!/usr/bin/env python3 | ||
| """ | ||
| CLI 'main' entrypoint for pixel scrubbing | ||
| """ | ||
| import argparse # for typing only | ||
| import tempfile | ||
|
|
||
| from deid.dicom import get_files | ||
| from deid.dicom.pixels import DicomCleaner | ||
| from deid.logger import bot | ||
|
|
||
|
|
||
| def main(args: argparse.Namespace, parser: argparse.ArgumentParser = None): | ||
| """ | ||
| CLI interface for pixel cleaning. | ||
| Used as `main` by py:func:`deid.main.main` | ||
|
|
||
| Also see `getting-started/dicom-pixels` | ||
|
|
||
| Parameters | ||
| ========== | ||
| args: Likely created by py:func:`deid.main.get_parser`. | ||
| Uses output_folder, deid | ||
|
|
||
| parser: for compatibility with other *.main functions. Ignored. | ||
| """ | ||
|
|
||
| output_folder = args.outfolder | ||
| if output_folder is None: | ||
| output_folder = tempfile.mkdtemp() | ||
|
|
||
| if args.input is None: | ||
| bot.exit("No input folder specified. Specify inputs as additional arguments.") | ||
| dicom_files = list(get_files(args.input)) | ||
|
|
||
| bot.info("Looking at %i input dicoms" % len(dicom_files)) | ||
|
|
||
| # NOTE: self.results and self.file is updated each call to detect | ||
| # may want new client for each file to be safe? | ||
| client = DicomCleaner(output_folder=output_folder, deid=args.deid) | ||
| for dcm in dicom_files: | ||
| #: py:func:`deid.dicom.pixels.detect._has_burned_pixels_single` dictionary, not used so not saved | ||
| client.detect(dcm) | ||
| client.clean() | ||
| # prefix and extension empty to reuse same name as input | ||
| # folder=None means use self.output_folder | ||
| client.save_dicom(output_folder=None, prefix="", extension="") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.