Skip to content

Commit

Permalink
pydcmio/dcmanonymizer/anonymize: use progressbar.
Browse files Browse the repository at this point in the history
  • Loading branch information
AGrigis committed May 4, 2018
1 parent be2a4ee commit 6f2bf13
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ install:
- pip install pep8
- pip install nibabel
- pip install dicom
- pip install progressbar2
- pip install .

script:
Expand Down
21 changes: 9 additions & 12 deletions pydcmio/dcmanonymizer/anonymize.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import json
import re
import dicom
from pip.utils.ui import DownloadProgressBar
import progressbar

# Dcmio import
from .callbacks import callback_private
Expand Down Expand Up @@ -99,19 +99,16 @@ def anonymize_dicomdir(inputdir, outdir, write_logs=True):
PRIVATE_DEIDENTIFY.setdefault(key, []).append(pattern)

# Process all DICOM files
progress_indicator = DownloadProgressBar(max=len(input_dicoms))
dcmfiles = []
logfiles = []
for cnt, input_dicom in enumerate(input_dicoms):
statinfo = os.stat(input_dicom)
DownloadProgressBar.suffix = "{0:.3f}MB".format(
statinfo.st_size / 10e5)
progress_indicator.next(1)
output_dicom, output_log = anonymize_dicomfile(
input_dicom, outdir, outname=str(cnt), write_log=write_logs)
dcmfiles.append(output_dicom)
logfiles.append(output_log)
progress_indicator.finish()
with progressbar.ProgressBar(max_value=len(input_dicoms),
redirect_stdout=True) as bar:
for cnt, input_dicom in enumerate(input_dicoms):
output_dicom, output_log = anonymize_dicomfile(
input_dicom, outdir, outname=str(cnt), write_log=write_logs)
dcmfiles.append(output_dicom)
logfiles.append(output_log)
bar.update(cnt)

return dcmfiles, logfiles

Expand Down
3 changes: 2 additions & 1 deletion pydcmio/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@
REQUIRES = [
"numpy>=1.6.1",
"pydicom>=0.9",
"nibabel>=2.0.2"
"nibabel>=2.0.2",
"progressbar2>=3.34.3"
]
EXTRA_REQUIRES = {}
SCRIPTS = [
Expand Down

0 comments on commit 6f2bf13

Please sign in to comment.