dbdicom 0.2.0__py3-none-any.whl → 0.2.3__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of dbdicom might be problematic. Click here for more details.

Files changed (52) hide show
  1. dbdicom/__init__.py +5 -3
  2. dbdicom/create.py +77 -70
  3. dbdicom/dro.py +174 -0
  4. dbdicom/ds/dataset.py +30 -3
  5. dbdicom/ds/types/mr_image.py +18 -7
  6. dbdicom/extensions/__init__.py +10 -0
  7. dbdicom/{wrappers → extensions}/dipy.py +191 -205
  8. dbdicom/extensions/elastix.py +503 -0
  9. dbdicom/extensions/matplotlib.py +107 -0
  10. dbdicom/extensions/numpy.py +271 -0
  11. dbdicom/{wrappers → extensions}/scipy.py +131 -32
  12. dbdicom/{wrappers → extensions}/skimage.py +1 -1
  13. dbdicom/extensions/sklearn.py +243 -0
  14. dbdicom/extensions/vreg.py +1390 -0
  15. dbdicom/external/dcm4che/bin/emf2sf +57 -57
  16. dbdicom/manager.py +91 -36
  17. dbdicom/pipelines.py +66 -0
  18. dbdicom/record.py +447 -80
  19. dbdicom/types/instance.py +46 -20
  20. dbdicom/types/series.py +2182 -399
  21. dbdicom/utils/image.py +152 -21
  22. dbdicom/utils/variables.py +8 -2
  23. dbdicom/utils/vreg.py +327 -135
  24. dbdicom-0.2.3.dist-info/METADATA +88 -0
  25. dbdicom-0.2.3.dist-info/RECORD +67 -0
  26. {dbdicom-0.2.0.dist-info → dbdicom-0.2.3.dist-info}/WHEEL +1 -1
  27. dbdicom/external/__pycache__/__init__.cpython-310.pyc +0 -0
  28. dbdicom/external/__pycache__/__init__.cpython-37.pyc +0 -0
  29. dbdicom/external/dcm4che/__pycache__/__init__.cpython-310.pyc +0 -0
  30. dbdicom/external/dcm4che/__pycache__/__init__.cpython-37.pyc +0 -0
  31. dbdicom/external/dcm4che/bin/__pycache__/__init__.cpython-310.pyc +0 -0
  32. dbdicom/external/dcm4che/bin/__pycache__/__init__.cpython-37.pyc +0 -0
  33. dbdicom/external/dcm4che/lib/linux-x86/libclib_jiio.so +0 -0
  34. dbdicom/external/dcm4che/lib/linux-x86-64/libclib_jiio.so +0 -0
  35. dbdicom/external/dcm4che/lib/linux-x86-64/libopencv_java.so +0 -0
  36. dbdicom/external/dcm4che/lib/solaris-sparc/libclib_jiio.so +0 -0
  37. dbdicom/external/dcm4che/lib/solaris-sparc/libclib_jiio_vis.so +0 -0
  38. dbdicom/external/dcm4che/lib/solaris-sparc/libclib_jiio_vis2.so +0 -0
  39. dbdicom/external/dcm4che/lib/solaris-sparcv9/libclib_jiio.so +0 -0
  40. dbdicom/external/dcm4che/lib/solaris-sparcv9/libclib_jiio_vis.so +0 -0
  41. dbdicom/external/dcm4che/lib/solaris-sparcv9/libclib_jiio_vis2.so +0 -0
  42. dbdicom/external/dcm4che/lib/solaris-x86/libclib_jiio.so +0 -0
  43. dbdicom/external/dcm4che/lib/solaris-x86-64/libclib_jiio.so +0 -0
  44. dbdicom/wrappers/__init__.py +0 -7
  45. dbdicom/wrappers/elastix.py +0 -855
  46. dbdicom/wrappers/numpy.py +0 -119
  47. dbdicom/wrappers/sklearn.py +0 -151
  48. dbdicom/wrappers/vreg.py +0 -273
  49. dbdicom-0.2.0.dist-info/METADATA +0 -276
  50. dbdicom-0.2.0.dist-info/RECORD +0 -81
  51. {dbdicom-0.2.0.dist-info → dbdicom-0.2.3.dist-info}/LICENSE +0 -0
  52. {dbdicom-0.2.0.dist-info → dbdicom-0.2.3.dist-info}/top_level.txt +0 -0
dbdicom/types/instance.py CHANGED
@@ -46,10 +46,13 @@ class Instance(Record):
46
46
  ds = self.get_dataset()
47
47
  return ds.get_pixel_array()
48
48
 
49
- def set_array(self, array):
49
+ def set_array(self, array): # obsolete
50
+ self.set_pixel_array(array)
51
+
52
+ def set_pixel_values(self, array):
50
53
  self.set_pixel_array(array)
51
54
 
52
- def set_pixel_array(self, array):
55
+ def set_pixel_array(self, array): # make private
53
56
  ds = self.get_dataset()
54
57
  if ds is None:
55
58
  ds = new_dataset('MRImage')
@@ -59,7 +62,7 @@ class Instance(Record):
59
62
  # This bit added ad-hoc because set_dataset() places the datset in memory
60
63
  # So if the instance is not in memory, it needs to be written and removed again
61
64
  if not in_memory:
62
- self.clear()
65
+ self.clear()
63
66
 
64
67
  def set_dataset(self, dataset):
65
68
  self._key = self.manager.set_instance_dataset(self.uid, dataset, self.key())
@@ -71,20 +74,23 @@ class Instance(Record):
71
74
  return map_mask_to(self, target)
72
75
 
73
76
 
74
- def export_as_png(self, path):
75
- """Export image in png format."""
76
- pixelArray = np.transpose(self.array())
77
- centre, width = self.window
78
- minValue = centre - width/2
79
- maxValue = centre + width/2
80
- #cmap = plt.get_cmap(colourTable)
81
- cmap = self.colormap
82
- if cmap is None:
83
- cmap='gray'
84
- #plt.imshow(pixelArray, cmap=cmap)
85
- plt.imshow(pixelArray, cmap=cmap, vmin=minValue, vmax=maxValue)
86
- #plt.imshow(pixelArray, cmap=colourTable)
87
- #plt.clim(int(minValue), int(maxValue))
77
+ def export_as_png(self, path, center=None, width=None, colormap=None):
78
+ # Export image in png format.
79
+ if center is None or width is None:
80
+ c, w = self.window
81
+ if center is None:
82
+ center = c
83
+ if width is None:
84
+ width = w
85
+ if colormap is None:
86
+ colormap = self.colormap
87
+ if colormap is None:
88
+ colormap = 'gray'
89
+
90
+ vmin = center - width/2
91
+ vmax = center + width/2
92
+ array = np.transpose(self.array())
93
+ plt.imshow(array, cmap=colormap, vmin=vmin, vmax=vmax)
88
94
  cBar = plt.colorbar()
89
95
  cBar.minorticks_on()
90
96
  filename = self.label()
@@ -94,7 +100,7 @@ class Instance(Record):
94
100
 
95
101
 
96
102
  def export_as_csv(self, path):
97
- """Export 2D pixel Array in csv format"""
103
+ # Export 2D pixel Array in csv format
98
104
  table = np.transpose(self.array())
99
105
  cols = ['Column' + str(x) for x in range(table.shape[0])]
100
106
  rows = ['Row' + str(y) for y in range(table.shape[1])]
@@ -105,7 +111,7 @@ class Instance(Record):
105
111
 
106
112
 
107
113
  def export_as_nifti(self, path, affine=None):
108
- """Export series as a single Nifty file"""
114
+ # Export series as a single Nifty file
109
115
  ds = self.get_dataset()
110
116
  if affine is None:
111
117
  affine = ds.get_values('affine_matrix')
@@ -118,6 +124,15 @@ class Instance(Record):
118
124
  nib.save(niftiObj, filepath)
119
125
 
120
126
 
127
+ def export_as_npy(self, path):
128
+ # Export instance as a single NPY file
129
+ array = self.array()
130
+ filepath = self.label()
131
+ filepath = os.path.join(path, filepath + '.npy')
132
+ with open(filepath, 'wb') as f:
133
+ np.save(f, array)
134
+
135
+
121
136
  def BGRA_array(self):
122
137
  return image.BGRA(
123
138
  self.get_pixel_array(),
@@ -125,6 +140,17 @@ class Instance(Record):
125
140
  width = self.WindowWidth,
126
141
  center = self.WindowCenter,
127
142
  )
143
+
144
+ def set_affine(self, affine):
145
+ p = image.dismantle_affine_matrix(affine)
146
+ self.read()
147
+ self.SpacingBetweenSlices = p['SpacingBetweenSlices']
148
+ self.SliceThickness = p['SpacingBetweenSlices']
149
+ self.PixelSpacing = p['PixelSpacing']
150
+ self.ImageOrientationPatient = p['ImageOrientationPatient']
151
+ self.ImagePositionPatient = p['ImagePositionPatient']
152
+ self.SliceLocation = np.dot(p['ImagePositionPatient'], p['slice_cosine'])
153
+ self.clear()
128
154
 
129
155
 
130
156
  def map_to(source, target):
@@ -167,7 +193,7 @@ def map_to(source, target):
167
193
 
168
194
  return result
169
195
 
170
-
196
+ # Obsolete
171
197
  def map_mask_to(record, target):
172
198
  """Map non-zero image pixels onto a target image.
173
199
  Overwrite pixel values in the target"""