Skip to content

Commit

Permalink
use dicom library to parse dicom files + small enh
Browse files Browse the repository at this point in the history
  • Loading branch information
lmperry committed Apr 22, 2019
1 parent 4537d46 commit 75dc1f4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ RUN apt-get update && apt-get -y install \

# Install scitran.data dependencies
RUN pip install \
pydicom \
dicom \
python-dateutil==2.6.0 \
pytz==2017.2 \
tzlocal==1.4 \
Expand Down
10 changes: 7 additions & 3 deletions dicom-mr-classifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import zipfile
import datetime
import argparse
import pydicom as dicom
import dicom
from pprint import pprint
from fnmatch import fnmatch
import classification_from_label
Expand Down Expand Up @@ -156,9 +156,12 @@ def assign_type(s):
return format_string(s)
if type(s) == list or type(s) == dicom.multival.MultiValue:
try:
return [ float(x) for x in s if x.is_integer() == False ]
return [ float(x) for x in s ]
except ValueError:
return [ format_string(x) for x in s if len(x) > 0 ]
try:
return [ int(x) for x in s ]
except ValueError:
return [ format_string(x) for x in s if len(x) > 0 ]
elif type(s) == float or type(s) == int:
return s
else:
Expand All @@ -172,6 +175,7 @@ def assign_type(s):
return format_string(s)



def format_string(in_string):
"""
Remove non-ascii characters to make sure the values will display properly
Expand Down

0 comments on commit 75dc1f4

Please sign in to comment.