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

[WIP] 141 add dicom loader #200

Closed
Closed
Changes from 1 commit
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
f5ccf2a
Adding rotation transform. (#126)
madil90 Mar 5, 2020
f39e8c1
108-resize (#125)
wyli Mar 5, 2020
28ad305
113-gaussian-noise (#139)
wyli Mar 5, 2020
7f29477
133 dataset and example with dict transforms (#134)
wyli Mar 5, 2020
445a568
107-zoom (#138)
madil90 Mar 5, 2020
db05942
Fix gpu zoom errors. (#149)
madil90 Mar 6, 2020
2bda586
58-implement-transform-adaptor-2: Re-adding work via new branch as th…
atbenmurray Mar 6, 2020
b850167
update doc api deps (#158)
wyli Mar 8, 2020
03bebf5
152-random-zoom (#153)
madil90 Mar 9, 2020
1e230ed
Adding RandomFlip. (#154)
madil90 Mar 9, 2020
7304182
112 combining spatial transforms (#131)
wyli Mar 9, 2020
39b2cb2
144 loadnifti transform common dataset (#145)
Nic-Ma Mar 9, 2020
35da65c
spacing and orientation; revise transforms cropping and zooming (#162)
wyli Mar 10, 2020
5c49f8f
156 event handlers support arbitrary format (#159)
Nic-Ma Mar 10, 2020
d166f6a
152-random-rotate (#155)
madil90 Mar 10, 2020
5b1f258
add dictionary-based wrapper random spatial transforms (#166)
wyli Mar 11, 2020
3a8f99c
160 develop TensorBoard event handler (#161)
Nic-Ma Mar 12, 2020
e40917f
Adding dict-based and random spatial transforms. (#163)
madil90 Mar 12, 2020
204e42d
two stages ci (#172)
wyli Mar 12, 2020
895e0f2
165 update check all examples (#171)
Nic-Ma Mar 13, 2020
c40f739
179 add DeleteKeys transform (#180)
Nic-Ma Mar 16, 2020
216298c
176 revise docs (#177)
wyli Mar 16, 2020
c2b12d3
[DLMED] fix typos in documentations (#185)
Nic-Ma Mar 18, 2020
3568c2b
181 use MONAI in pytorch medical segmentation program (#182)
Nic-Ma Mar 19, 2020
b86b63a
added setuptools support
mhubii Mar 19, 2020
3781679
updated README
mhubii Mar 19, 2020
2b9ab58
removed relative paths
mhubii Mar 19, 2020
4762c6f
changed form
mhubii Mar 19, 2020
40a06b0
fixes pull request config (#194)
wyli Mar 19, 2020
e7bb1c1
Merge branch 'master' into master
wyli Mar 19, 2020
1e55e23
exchanged raw install by pip install with folder flag
mhubii Mar 19, 2020
e4b3c36
Merge branch 'master' of https://github.com/mhubii/MONAI
mhubii Mar 19, 2020
9f10654
188 setuptools (#193)
mhubii Mar 19, 2020
e7b6564
188 setup docker image (#192)
wyli Mar 20, 2020
d191b09
191 develop determinism integration test (#195)
Nic-Ma Mar 20, 2020
85efd81
Merge branch 'master' into 135-add-DICOM-loader
mhubii Mar 22, 2020
8de36ae
Merge remote-tracking branch 'upstream/master'
mhubii Mar 22, 2020
a9521bf
solved merge conflicts
mhubii Mar 22, 2020
732befd
Merge branch 'master' into 135-add-DICOM-loader
mhubii Mar 22, 2020
469a136
added SimpleITK and pydicom to dependencies
mhubii Mar 22, 2020
f7c0205
fixed typo
mhubii Mar 23, 2020
d1a21d6
added LoadDICOM and dictionary loader
mhubii Mar 23, 2020
21ae759
added utility functions for dicom handling
mhubii Mar 23, 2020
5c0a207
added tests on pydicom's sample data
mhubii Mar 23, 2020
805c214
added spaces to inline comment
mhubii Mar 23, 2020
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
33 changes: 33 additions & 0 deletions monai/utils/medical_image_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import os
import argparse
import numpy as np
import pydicom
import SimpleITK as Sitk

ALLOWED_SRC_FORMATS = ['.nii', '.nii.gz', '.mhd', '.mha', '.dcm']
Expand All @@ -34,6 +35,38 @@ def contain_dicom(path):
return False


Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for your update here.
Actually, I think you can treat this converter tool as a temporary reference code and move all the data converter logic into other transforms(or new transforms) after "LoadDICOM".
When all logic is ready in transforms, we can delete this tool and users can use transforms to load DICOM directly.
Thanks.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hi @mhubii ,

Do you want to merge this PR first to my previous DICOM PR first and work on that PR directly?
Thanks.

# Convert values from DICOM files to standard Python types
def convert_value(value): # https://github.com/pydicom/pydicom/issues/319
t = type(value)
if t in (list, int, float):
pass
elif t == str:
value = value.encode()
elif t == pydicom.valuerep.MultiValue:
value = np.array(value)
elif t == pydicom.valuerep.PersonName3:
value = str(value)
elif t == pydicom.valuerep.DSfloat:
value = float(value)
elif t == pydicom.valuerep.IS:
value = int(value)
else:
value = repr(value)
return value

# Convert a DICOM file into a dictionary
def dictify_dicom(dataset):
dictionary = dict()
for element in dataset:
if element.tag == (0x7fe0, 0x0010): # skip pixel array tags
continue
if element.VR == 'SQ': # recursive call for sequences
dictionary[element.tag] = [dictify_dicom(item) for item in element]
else:
dictionary[element.tag] = convert_value(element.value)
return dictionary


def get_dicom_dir_list(source_dir):
dicom_dir_list = []

Expand Down