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

Fixes #973 issue with pinnacle export CLI #995

Merged
merged 5 commits into from
Aug 17, 2020
Merged

Conversation

pchlap
Copy link
Collaborator

@pchlap pchlap commented Aug 14, 2020

This fixes the issue reported in #973 where the trial couldn't be set using the command line interface.

@SimonBiggs I don't have a test which covers this code, since it's part of the CLI. Would you expect to have a test for the CLI functions?

@pchlap pchlap linked an issue Aug 14, 2020 that may be closed by this pull request
@SimonBiggs
Copy link
Member

Would you expect to have a test for the CLI functions?

Yup, certainly, if that's okay.

Here is an example:

def compare_dicom_cli(command, original, expected):
pydicom.write_file(ORIGINAL_DICOM_FILENAME, original)
try:
subprocess.check_call(command)
cli_adjusted_ds = pydicom.read_file(ADJUSTED_DICOM_FILENAME, force=True)
assert str(cli_adjusted_ds) == str(expected)
finally:
remove_file(ORIGINAL_DICOM_FILENAME)
remove_file(ADJUSTED_DICOM_FILENAME)

Although there I removed the file after, it is much better to use a temp directory like the following:

with tempfile.TemporaryDirectory() as output_directory:
pseudonymised_file_path = anonymise_file(
dicom_filepath=test_file_path,
output_filepath=output_directory,
delete_original_file=False,
anonymise_filename=True,
replace_values=True,
# keywords_to_leave_unchanged=None,
delete_private_tags=True,
delete_unknown_tags=True,
replacement_strategy=replacement_strategy,
identifying_keywords=identifying_keywords_for_pseudo,
)
# debug print + Assert to force the print
# print("Pseudonymised file at: ", pseudonymised_file_path)
# assert False
assert exists(pseudonymised_file_path)
ds_input = pydicom.dcmread(test_file_path, force=True)
ds_pseudo = pydicom.dcmread(pseudonymised_file_path, force=True)
# simplistic stand-in to make sure *something* is happening
assert ds_input["PatientID"].value != ds_pseudo["PatientID"].value
# make sure that we are not accidentally using the hardcode replacement approach
assert ds_pseudo["PatientID"].value not in ["", "Anonymous"]

@SimonBiggs
Copy link
Member

You can feel free to ignore the following test failure:

image

Unfortunately it is intermittent... I need to get to the bottom of that :(.

@pchlap
Copy link
Collaborator Author

pchlap commented Aug 14, 2020

Would you expect to have a test for the CLI functions?

Yup, certainly, if that's okay.

Cool, thanks for the examples. I'll sort that out, hopefully I can get that done tomorrow morning :)

@pchlap pchlap requested a review from SimonBiggs August 17, 2020 05:18
@pchlap
Copy link
Collaborator Author

pchlap commented Aug 17, 2020

Hi @SimonBiggs ,

I've added some tests for the CLI, let me know what you think. If you're happy we can merge this and let it roll out in the next release. Thanks a lot!

Copy link
Member

@SimonBiggs SimonBiggs left a comment

Choose a reason for hiding this comment

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

Yup, LGTM. From what I gather, here you're mostly just doing some basic sanity checks on the CLI.

@SimonBiggs SimonBiggs merged commit 70d3c97 into master Aug 17, 2020
@SimonBiggs SimonBiggs deleted the pinnacle-cli-fix branch August 17, 2020 06:19
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.

@pchlap Pinnacle experimental tools line command
2 participants