Skip to content

Commit f14f4d7

Browse files
authored
Merge pull request #4 from gschramm/dcmwrite
fix dicom writing bugs with pydicom >= 3
2 parents 475f594 + 673664f commit f14f4d7

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

pymirc/fileio/labelvol_to_rtstruct.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,6 @@ def labelvol_to_rtstruct(
285285
#######################################################################
286286
#######################################################################
287287

288-
pydicom.filewriter.write_file(
288+
pydicom.filewriter.dcmwrite(
289289
os.path.join(".", filename), ds, write_like_original=False
290290
)

pymirc/fileio/write_dicom.py

+5-9
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,14 @@
77
import pydicom as dicom
88
from pydicom.dataset import Dataset, FileDataset
99

10-
from time import time
11-
1210

1311
def write_dicom_slice(
1412
pixel_array, # 2D array in LP orientation
1513
filename=None,
1614
outputdir="mydcmdir",
1715
suffix=".dcm",
1816
modality="PT",
19-
SecondaryCaptureDeviceManufctur="KUL",
17+
SecondaryCaptureDeviceManufacturer="KUL",
2018
uid_base="1.2.826.0.1.3680043.9.7147.", # UID root for Georg Schramm
2119
PatientName="Test^Patient",
2220
PatientID="08150815",
@@ -62,7 +60,7 @@ def write_dicom_slice(
6260
sl, frm : int, optional
6361
slice and frame numbers that are appended to the file name prefix if given
6462
65-
SecondaryCaptureDeviceManufctur --|
63+
SecondaryCaptureDeviceManufacturer --|
6664
uid_base |
6765
PatientName |
6866
PatientID |
@@ -76,7 +74,7 @@ def write_dicom_slice(
7674
CorrectedImage | ... dicom tags that should be present in a minimal
7775
ImageType | dicom header
7876
RescaleSlope | see function definition for default values
79-
RescaleIntercept | default None means that they are creacted automatically
77+
RescaleIntercept | default None means that they are created automatically
8078
StudyInstanceUID |
8179
SeriesInstanceUID |
8280
SOPInstanceUID |
@@ -181,7 +179,7 @@ def write_dicom_slice(
181179
ds.SOPInstanceUID = SOPInstanceUID
182180
ds.SOPClassUID = file_meta.MediaStorageSOPClassUID
183181

184-
ds.SecondaryCaptureDeviceManufctur = SecondaryCaptureDeviceManufctur
182+
ds.SecondaryCaptureDeviceManufacturer = SecondaryCaptureDeviceManufacturer
185183

186184
## These are the necessary imaging components of the FileDataset object.
187185
ds.SamplesPerPixel = 1
@@ -274,9 +272,7 @@ def write_dicom_slice(
274272

275273
if verbose:
276274
print("Writing file", os.path.join(outputdir, filename))
277-
dicom.filewriter.write_file(
278-
os.path.join(outputdir, filename), ds, write_like_original=False
279-
)
275+
dicom.dcmwrite(os.path.join(outputdir, filename), ds, write_like_original=False)
280276

281277
return os.path.join(outputdir, filename)
282278

0 commit comments

Comments
 (0)