-
Notifications
You must be signed in to change notification settings - Fork 21
/
DicomAnnotUtils.py
506 lines (467 loc) · 23.3 KB
/
DicomAnnotUtils.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
import json
import pydicom
from pydicom.dataset import Dataset, FileMetaDataset
from pydicom import Sequence
from pydicom.uid import ExplicitVRLittleEndian, generate_uid
import numpy as np
from copy import deepcopy
import random
from datetime import datetime
import argparse
featureTemplate = {
"type": "Feature",
"properties": {
"style": {
"color":"#00fc2e",
"lineJoin":"round",
"lineCap":"round",
"isFill":True
}
},
"geometry" : {
"type":"Polygon",
"coordinates" : []
},
"bound":{
"type":"Polygon",
"coordinates" : []
}
}
annotTemplate = {
"creator": "dicomImport",
"provenance": {
"image": {
"slide": "ADD_CAMIC_SLIDE_ID",
"dicom-ReferencedSOPClassUID": "",
"dicom-ReferencedSOPInstanceUID": "",
"dicom-study": "",
"dicom-series": "",
"dicom-instance": "",
},
"analysis": {
"source": "human", # may not be true!
"execution_id": "dicom-?",
"name": "imported dicom annotation"
}
},
"properties": {
"annotations":{
"name":"imported dicom annotation",
"notes":""
}
},
"geometries": {
"type" : "FeatureCollection",
"features" : []
}
}
def _generate_random_string(n):
letters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
return ''.join(random.choice(letters) for _ in range(n))
def get_dicom_info(image_path):
# Read the DICOM file
ds = pydicom.dcmread(image_path)
# Extract DICOM attributes
patient_id = ds.get('PatientID', 'Unknown')
study_instance_uid = ds.get('StudyInstanceUID', 'Unknown')
series_instance_uid = ds.get('SeriesInstanceUID', 'Unknown')
image_width = int(ds.get('TotalPixelMatrixColumns', 0))
image_height = int(ds.get('TotalPixelMatrixRows', 0))
return {
'PatientID': patient_id,
'StudyInstanceUID': study_instance_uid,
'SeriesInstanceUID': series_instance_uid,
'ImageWidth': image_width,
'ImageHeight': image_height
}
def create_annotation_dicom(annot_arrays, slide_file, geojson):
# the slide/ref dataset
reference_ds = pydicom.dcmread(slide_file)
# the annot dataset
ds = Dataset()
# Copy file meta information
attrs_to_copy = [
'StudyID', 'PatientID', 'PatientName', 'PatientBirthDate', 'StudyInstanceUID', 'StudyDate', 'StudyTime', 'Modality', 'SeriesNumber',
'PatientSex', 'ReferringPhysicianName', 'AccessionNumber', 'Manufacturer', 'ManufacturerModelName', 'DeviceSerialNumber', 'SoftwareVersions', 'InstanceNumber'
]
for attr in attrs_to_copy:
setattr(ds, attr, getattr(reference_ds, attr))
# annotation fields
# ds.MediaStorageSOPClassUID = '1.2.840.10008.5.1.4.1.1.91.1'
ds.SOPClassUID = '1.2.840.10008.5.1.4.1.1.91.1'
ds.SeriesInstanceUID = generate_uid()
ds.SOPInstanceUID = generate_uid()
ds.ContentLabel = str(geojson['properties']['annotations']['name']).upper()
ds.ContentDescription = geojson['properties']['annotations']['notes']
ds.AnnotationCoordinateType = "2D"
ds.PixelOriginInterpretation = 'VOLUME'
ds.Laterality = 'L'
ds.Modality = "ANN"
ds.StudyID = "S1"
ds.SeriesNumber = "0"
current_date = datetime.now().strftime('%Y%m%d')
current_time = datetime.now().strftime('%H%M%S')
# Set ContentDate and ContentTime attributes
ds.ContentDate = current_date
ds.ContentTime = current_time
referenced_series_sequence = Dataset()
referenced_instance_sequence = Dataset()
referenced_instance_sequence.ReferencedSOPInstanceUID = reference_ds.SOPInstanceUID
referenced_instance_sequence.ReferencedSOPClassUID = reference_ds.SOPClassUID
referenced_series_sequence.ReferencedInstanceSequence = [referenced_instance_sequence]
referenced_series_sequence.SeriesInstanceUID = reference_ds.SeriesInstanceUID
ds.ReferencedSeriesSequence = [referenced_series_sequence]
referenced_image_sequence = Dataset()
referenced_image_sequence.ReferencedSOPClassUID = reference_ds.SOPClassUID
referenced_image_sequence.ReferencedSOPInstanceUID = reference_ds.SOPInstanceUID
ds.ReferencedImageSequence = [referenced_image_sequence]
# add the annotation data
ds.AnnotationGroupSequence = []
i = 0
idx = 1
point_indices = []
# make the array first?
for points_array in annot_arrays:
point_indices.append(idx)
idx+=len(points_array)
# now do the rest?
for points_array in annot_arrays:
# Create a new AnnotationGroupSequence item
annotation_group_item = Dataset()
annotation_group_item.PointCoordinatesData = points_array.tobytes() # Convert numpy array to bytes
annotation_group_item.LongPrimitivePointIndexList = np.array([1], dtype=np.int32).tobytes()
#annotation_group_item.LongPrimitivePointIndexList = bytes(points_array)
annotation_group_item.GraphicType = "POLYGON"
annotation_property_seq = Sequence()
item_dataset = Dataset()
item_dataset.CodeValue = "91723000"
item_dataset.CodingSchemeDesignator = "DCM"
item_dataset.CodeMeaning = "Anatomical Stucture"
annotation_property_seq.append(item_dataset)
annotation_group_item.AnnotationPropertyTypeCodeSequence = annotation_property_seq
annotation_group_item.AnnotationGroupNumber = i
i+=1
annotation_group_item.NumberOfAnnotations = 1
annotation_group_item.AnnotationAppliesToAllOpticalPaths = "YES"
annotation_group_item.AnnotationGroupUID = generate_uid()
annotation_group_item.AnnotationGroupLabel = "Annotation Group Label"
annotation_group_item.AnnotationGroupGenerationType = "MANUAL"
annotation_group_item.AnnotationPropertyCategoryCodeSequence = annotation_property_seq
annotation_group_item.AnnotationPropertyCategoryCodeSequence = annotation_property_seq
ds.AnnotationGroupSequence.append(annotation_group_item)
# Create a DICOM File Meta Information header
file_meta = FileMetaDataset()
file_meta.MediaStorageSOPClassUID = ds.SOPClassUID
file_meta.MediaStorageSOPInstanceUID = generate_uid()
file_meta.TransferSyntaxUID = ExplicitVRLittleEndian
file_meta.ImplementationVersionName = '[email protected]'
# Set the File Meta Information header
ds.file_meta = file_meta
return ds
# camic to dicom
def camicToDicom(annot_file, slide_file):
dicom_data = get_dicom_info(slide_file)
width = int(dicom_data['ImageWidth'])
height = int(dicom_data['ImageHeight'])
with open(annot_file, 'r') as f:
annot_geo = json.load(f)
annot_arrays = []
for x in annot_geo:
coordinates = x['geometries']['features'][0]['geometry']['coordinates'][0]
flattened_coords = [[pair[0] * width, pair[1] * height] for pair in coordinates]
converted_coords = np.array(flattened_coords, dtype=np.float32)
annot_arrays.append(converted_coords)
annot_ds = create_annotation_dicom(annot_arrays, slide_file, x)
return annot_ds
def _makeBound(coords_mat):
try:
min_x = float(np.min(coords_mat[:, 0]))
max_x = float(np.max(coords_mat[:, 0]))
min_y = float(np.min(coords_mat[:, 1]))
max_y = float(np.max(coords_mat[:, 1]))
bound_coords = [[min_x, min_y], [min_x, max_y], [max_x, max_y], [max_x, min_y],[min_x, min_y]]
return bound_coords
except BaseException as e:
print("coords mat")
print(coords_mat)
raise e
def _polygon_area(vertices):
n = len(vertices)
area = 0
for i in range(n):
j = (i + 1) % n
area += vertices[i][0] * vertices[j][1]
area -= vertices[j][0] * vertices[i][1]
return abs(area) / 2
def _polygon_perimeter(vertices):
perimeter = 0
n = len(vertices)
for i in range(n):
j = (i + 1) % n
perimeter += np.linalg.norm(np.array(vertices[i]) - np.array(vertices[j]))
return perimeter
def getPointCoordinatesDataArray(x):
if 'PointCoordinatesData' in x:
n = x.PointCoordinatesData
return np.frombuffer(n, dtype=np.float32)
elif 'DoublePointCoordinatesData' in x:
n = x.DoublePointCoordinatesData
return np.frombuffer(n, dtype=np.float64)
else:
raise ValueError("No coordinates found in array item")
def convert_ellipse(x1_major,y1_major,x2_major,y2_major,x1_minor,y1_minor,x2_minor,y2_minor):
center_x = (x1_major + x2_major) / 2
center_y = (y1_major + y2_major) / 2
major_axis_length = np.sqrt((x2_major - x1_major)**2 + (y2_major - y1_major)**2) / 2
minor_axis_length = np.sqrt((x2_minor - x1_minor)**2 + (y2_minor - y1_minor)**2) / 2
rotation = np.arctan2(y2_major - y1_major, x2_major - x1_major)
return center_x, center_y, major_axis_length, minor_axis_length, rotation
def dicomToCamic(annot_path, image_dimensions, output_file, source_url=None, slide_id=None, file_mode=False):
# image_dimensions is either dimensions or a ds
annot_ds = pydicom.dcmread(annot_path)
slide_width = image_dimensions['TotalPixelMatrixColumns']
slide_height = image_dimensions['TotalPixelMatrixRows']
# get physical resolution
imaged_volume_width = image_dimensions['ImagedVolumeWidth']
imaged_volume_height = image_dimensions['ImagedVolumeHeight']
pixel_size_x = imaged_volume_width / slide_width
pixel_size_y = imaged_volume_height / slide_height
# millimeters to microns
mpp_x = pixel_size_x * 1000
#mpp_y = pixel_size_y * 1000
# TODO this is just for POLYGON. generalize later.
res = []
isSegment = False
for x in annot_ds.AnnotationGroupSequence:
exported_annot = deepcopy(annotTemplate)
exported_annot['properties']['annotations']['name'] = annot_ds.ContentLabel
exported_annot['provenance']['analysis']['name'] = annot_ds.ContentLabel
exported_annot['properties']['annotations']['notes'] = annot_ds.ContentDescription
exported_annot['provenance']['analysis']['execution_id'] = "_DICOM_" + _generate_random_string(10)
if x.AnnotationGroupGenerationType == "AUTOMATIC":
exported_annot['provenance']['analysis']['source'] = 'computer'
exported_annot['provenance']['analysis']['computation'] = 'segmentation'
isSegment = True
if slide_id:
exported_annot['provenance']['image']['slide'] = slide_id
exported_annot['provenance']['image']['dicom-ReferencedSOPClassUID'] = annot_ds.ReferencedImageSequence[0].ReferencedSOPClassUID
exported_annot['provenance']['image']['dicom-ReferencedSOPInstanceUID'] = annot_ds.ReferencedImageSequence[0].ReferencedSOPInstanceUID
exported_annot['provenance']['image']["dicom-source-url"] = source_url
exported_annot['provenance']['image']["dicom-study"] = annot_ds.StudyInstanceUID
exported_annot['provenance']['image']["dicom-series"] = annot_ds.SeriesInstanceUID
exported_annot['provenance']['image']["dicom-instance"] = annot_ds.SOPInstanceUID
# handle other cases first
if x.GraphicType == "ELLIPSE":
m = getPointCoordinatesDataArray(x)
# sets of 4 points, 8 numbers
for i in range(8, len(m), 8):
ellipse_points = m[i-8: i]
x1_major = ellipse_points[0]/slide_width
y1_major = ellipse_points[1]/slide_height
x2_major = ellipse_points[2]/slide_width
y2_major = ellipse_points[3]/slide_height
x1_minor = ellipse_points[4]/slide_width
y1_minor = ellipse_points[5]/slide_height
x2_minor = ellipse_points[6]/slide_width
y2_minor = ellipse_points[7]/slide_height
center_x, center_y, major_axis_length, minor_axis_length, rotation = convert_ellipse(x1_major,y1_major,x2_major,y2_major,x1_minor,y1_minor,x2_minor,y2_minor)
newFeature = deepcopy(featureTemplate)
newFeature['geometry']['type'] = "Ellipse"
newFeature['geometry']['coordinates'] = [center_x, center_y]
newFeature['geometry']["radius"] = [major_axis_length,minor_axis_length],
newFeature['geometry']["rotation"] = rotation
newFeature['bound']['type'] = "Point"
newFeature['bound']['coordinates'] = [center_x, center_y]
if isSegment:
exported_annot["footprint"] = 4* major_axis_length*minor_axis_length*slide_height*slide_width
exported_annot["bbox"]= [center_x - major_axis_length, center_y - minor_axis_length, center_x + major_axis_length, center_y + minor_axis_length]
exported_annot["x"] = center_x
exported_annot["y"] = center_y
exported_annot['geometries']['features'] = [newFeature]
res.append(deepcopy(exported_annot))
elif x.GraphicType == "POINT":
# sets of 1 point, 2 numbers
m = getPointCoordinatesDataArray(x)
# sets of 4 points, 8 numbers
for i in range(2, len(m), 2):
point = m[i-2: i]
center_x = point[0]/slide_width
center_y = point[1]/slide_height
newFeature = deepcopy(featureTemplate)
newFeature['geometry']['type'] = "Point"
newFeature['geometry']['coordinates'] = [center_x, center_y]
newFeature['bound']['type'] = "Point"
newFeature['bound']['coordinates'] = [center_x, center_y]
if isSegment:
exported_annot["footprint"] = slide_height*slide_width # always show points for now, big thing
exported_annot["bbox"]= [center_x, center_y, slide_width, slide_height]
exported_annot["x"] = center_x
exported_annot["y"] = center_y
exported_annot['geometries']['features'] = [newFeature]
res.append(deepcopy(exported_annot))
elif x.GraphicType == "RECTANGLE":
m = getPointCoordinatesDataArray(x)
# sets of 4 points, 8 numbers
for i in range(8, len(m), 8):
rect_points = m[i-8: i]
x1 = rect_points[0]/slide_width
y1 = rect_points[1]/slide_height
x2 = rect_points[2]/slide_width
y2 = rect_points[3]/slide_height
x3 = rect_points[4]/slide_width
y3 = rect_points[5]/slide_height
x4 = rect_points[6]/slide_width
y4 = rect_points[7]/slide_height
newFeature = deepcopy(featureTemplate)
newFeature['geometry']['type'] = "Polygon"
newFeature['geometry']['coordinates'] = [[x1,y1], [x2,y2], [x3,y3], [x4,y4], [x1,y1]]
newFeature['bound']['type'] = "Polygon"
newFeature['bound']['coordinates'] = [[x1,y1], [x2,y2], [x3,y3], [x4,y4], [x1,y1]]
if isSegment:
exported_annot["footprint"] = abs(x1-x3)*abs(y2-y4)*slide_height*slide_width
exported_annot["bbox"]= [(x1+x3)/2, (y2+y4)/2, abs(x1-x3), abs(y2-y4)]
exported_annot["x"] = (x1+x3)/2
exported_annot["y"] = (y2+y4)/2
exported_annot['geometries']['features'] = [newFeature]
res.append(deepcopy(exported_annot))
elif x.GraphicType == "POLYGON" or x.GraphicType == "POLYLINE":
m = getPointCoordinatesDataArray(x)
norm_width = slide_width
norm_height = slide_height
offset_x = 0
offset_y = 0
# normalize coordinates for camicroscope
coordinates_array = (m.reshape(-1, 2))
coordinates_array = (coordinates_array - [offset_x, offset_y]) / [norm_width, norm_height]
# split into different geometry objects Index List
indexList = np.frombuffer(x.LongPrimitivePointIndexList, dtype=np.int32)
#print("IndexList", indexList)
#print("len Index List", len(indexList))
#print("coordinates_array shape", coordinates_array.shape)
if len(indexList) > 1:
# split
prevIndex = 0
for idx in indexList[1:]:
end_idx = int((idx-1)/2)
#print("prev", prevIndex, "idx", idx)
# make a thing
points = coordinates_array[prevIndex:end_idx, :]
points = np.concatenate((points, [points[0]]))
#print('len(points)', len(points))
if len(points) > 0:
newFeature = deepcopy(featureTemplate)
newFeature['geometry']['coordinates'].append(points.tolist())
bounding_box = _makeBound(points)
# [[min_x, min_y], [min_x, max_y], [max_x, max_y], [max_x, min_y],[min_x, min_y]]
newFeature['bound']['coordinates'].append(bounding_box)
if isSegment:
x1 = bounding_box[0][0]
x3 = bounding_box[2][0]
y2 = bounding_box[1][1]
y4 = bounding_box[3][1]
exported_annot["footprint"] = abs(x1-x3)*abs(y2-y4)*slide_width*slide_height
exported_annot["bbox"]= [(x1+x3)/2, (y2+y4)/2, abs(x1-x3), abs(y2-y4)]
exported_annot["x"] = (x1+x3)/2
exported_annot["y"] = (y2+y4)/2
exported_annot['geometries']['features'] = [newFeature]
res.append(deepcopy(exported_annot))
prevIndex = end_idx
# and the bound
# then add the last one
points = coordinates_array[prevIndex:, :]
points = np.concatenate((points, [points[0]]))
if len(points) > 0:
newFeature = deepcopy(featureTemplate)
newFeature['geometry']['coordinates'].append(points.tolist())
bounding_box = _makeBound(points)
# [[min_x, min_y], [min_x, max_y], [max_x, max_y], [max_x, min_y],[min_x, min_y]]
newFeature['bound']['coordinates'].append(bounding_box)
if isSegment:
x1 = bounding_box[0][0]
x3 = bounding_box[2][0]
y2 = bounding_box[1][1]
y4 = bounding_box[3][1]
exported_annot["footprint"] = abs(x1-x3)*abs(y2-y4)*slide_height*slide_width
exported_annot["bbox"]= [(x1+x3)/2, (y2+y4)/2, abs(x1-x3), abs(y2-y4)]
exported_annot["x"] = (x1+x3)/2
exported_annot["y"] = (y2+y4)/2
exported_annot['geometries']['features'] = [newFeature]
res.append(deepcopy(exported_annot))
else:
# whole thing at once. Only do area and circumference here.
points = coordinates_array
points = np.concatenate((points, [points[0]]))
newFeature = deepcopy(featureTemplate)
newFeature['geometry']['coordinates'].append(points.tolist())
bounding_box = _makeBound(points)
# [[min_x, min_y], [min_x, max_y], [max_x, max_y], [max_x, min_y],[min_x, min_y]]
newFeature['bound']['coordinates'].append(bounding_box)
if isSegment:
x1 = bounding_box[0][0]
x3 = bounding_box[2][0]
y2 = bounding_box[1][1]
y4 = bounding_box[3][1]
exported_annot["footprint"] = abs(x1-x3)*abs(y2-y4)*slide_height*slide_width
exported_annot["bbox"]= [(x1+x3)/2, (y2+y4)/2, abs(x1-x3), abs(y2-y4)]
exported_annot["x"] = (x1+x3)/2
exported_annot["y"] = (y2+y4)/2
exported_annot['geometries']['features'] = [newFeature]
area = _polygon_perimeter(points.tolist()) * mpp_x * slide_width
perimeter = _polygon_area(points.tolist()) * (mpp_x * slide_width)**2
exported_annot['properties']['annotations']['circumference'] = str(area)+ " μm"
exported_annot['properties']['annotations']['area'] = str(perimeter) + " μm²"
res.append(deepcopy(exported_annot))
if file_mode:
n = 0
for x in res:
n += 1
output_fn = output_file + "_" + str(n) + ".json"
with open(output_fn, 'w') as f:
json.dump(x, f)
print("saved to", output_fn)
else:
return res
# demonstration example
def demo():
annot_file = './annots_camic.json'
slide_file = '/Users/rbirmin/Documents/distro/images/5d8b1b52d0/e25e1997-b86a-42de-aa8c-83ca18444bf2.dcm'
annot_ds = camicToDicom(annot_file, slide_file)
annot_ds.save_as("test_out.dcm", write_like_original=False)
print("now working backwards for test")
annot_output = "./test_out.dcm"
image_dimensions = {}
ds = pydicom.dcmread(slide_file)
image_dimensions['TotalPixelMatrixColumns'] = ds.TotalPixelMatrixColumns
image_dimensions['TotalPixelMatrixRows'] = ds.TotalPixelMatrixRows
image_dimensions['ImagedVolumeWidth'] = ds.ImagedVolumeWidth
image_dimensions['ImagedVolumeHeight'] = ds.ImagedVolumeHeight
dicomToCamic(annot_output, image_dimensions, "test_out2", slide_id='65fc65851200600012eb9222', file_mode=True)
exit(0)
if __name__ == "__main__":
# Create argument parser
parser = argparse.ArgumentParser(description='Convert annotations between CAMIC and DICOM')
# Add arguments
parser.add_argument('operation', choices=['import', 'export'], help='Operation to perform (camic_to_dicom or dicom_to_camic)')
parser.add_argument('annot_file', help='Path to the annotation file (json or dcm)')
parser.add_argument('slide_file', help='Path to the slide file (dcm)')
parser.add_argument('output_file', help='Path to the output file (dcm or json)')
parser.add_argument('--slide_id', help='Slide ID (optional)')
# Parse arguments
args = parser.parse_args()
slide_id = "ADD_CAMIC_SLIDE_ID_HERE" # note: not literally here, but if you don't give a slide id, you should add it eventually to the output
if args.slide_id:
slide_id = args.slide_id
# Perform the selected operation
if args.operation == 'export':
annot_ds = camicToDicom(args.annot_file, args.slide_file)
annot_ds.save_as(args.output_file, write_like_original=False)
elif args.operation == 'import':
ds = pydicom.dcmread(args.slide_file)
dimensions = {}
dimensions['TotalPixelMatrixColumns'] = ds.TotalPixelMatrixColumns
dimensions['TotalPixelMatrixRows'] = ds.TotalPixelMatrixRows
dimensions['ImagedVolumeWidth'] = ds.ImagedVolumeWidth
dimensions['ImagedVolumeHeight'] = ds.ImagedVolumeHeight
dicomToCamic(args.annot_file, dimensions, args.output_file, slide_id=slide_id, file_mode=True)
else:
print("Invalid operation. Choose 'export' (camic_to_dicom) or 'import' (dicom_to_camic)")