77 Any ,
88 BinaryIO ,
99 cast ,
10- Dict ,
11- List ,
12- Optional ,
13- Sequence ,
14- Tuple ,
15- Union ,
1610)
11+ from collections .abc import Sequence
1712from typing_extensions import Self
1813
1914import numpy as np
@@ -46,24 +41,24 @@ class MicroscopyBulkSimpleAnnotations(SOPClass):
4641 def __init__ (
4742 self ,
4843 source_images : Sequence [Dataset ],
49- annotation_coordinate_type : Union [ str , AnnotationCoordinateTypeValues ] ,
44+ annotation_coordinate_type : str | AnnotationCoordinateTypeValues ,
5045 annotation_groups : Sequence [AnnotationGroup ],
5146 series_instance_uid : str ,
5247 series_number : int ,
5348 sop_instance_uid : str ,
5449 instance_number : int ,
5550 manufacturer : str ,
5651 manufacturer_model_name : str ,
57- software_versions : Union [ str , Tuple [str ] ],
52+ software_versions : str | tuple [str ],
5853 device_serial_number : str ,
59- content_description : Optional [ str ] = None ,
60- content_creator_name : Optional [ Union [ str , PersonName ]] = None ,
61- transfer_syntax_uid : Union [ str , UID ] = ExplicitVRLittleEndian ,
62- pixel_origin_interpretation : Union [
63- str ,
54+ content_description : str | None = None ,
55+ content_creator_name : str | PersonName | None = None ,
56+ transfer_syntax_uid : str | UID = ExplicitVRLittleEndian ,
57+ pixel_origin_interpretation : (
58+ str |
6459 PixelOriginInterpretationValues
65- ] = PixelOriginInterpretationValues .VOLUME ,
66- content_label : Optional [ str ] = None ,
60+ ) = PixelOriginInterpretationValues .VOLUME ,
61+ content_label : str | None = None ,
6762 ** kwargs : Any
6863 ) -> None :
6964 """
@@ -207,14 +202,14 @@ def __init__(
207202 ref .ReferencedSOPInstanceUID = src_img .SOPInstanceUID
208203 self .ReferencedImageSequence = [ref ]
209204
210- referenced_series : Dict [str , List [Dataset ]] = defaultdict (list )
205+ referenced_series : dict [str , list [Dataset ]] = defaultdict (list )
211206 for img in source_images :
212207 ref = Dataset ()
213208 ref .ReferencedSOPClassUID = img .SOPClassUID
214209 ref .ReferencedSOPInstanceUID = img .SOPInstanceUID
215210 referenced_series [img .SeriesInstanceUID ].append (ref )
216211
217- self .ReferencedSeriesSequence : List [Dataset ] = []
212+ self .ReferencedSeriesSequence : list [Dataset ] = []
218213 for series_instance_uid , referenced_images in referenced_series .items ():
219214 ref = Dataset ()
220215 ref .SeriesInstanceUID = series_instance_uid
@@ -238,8 +233,8 @@ def __init__(
238233
239234 def get_annotation_group (
240235 self ,
241- number : Optional [ int ] = None ,
242- uid : Optional [ Union [ str , UID ]] = None ,
236+ number : int | None = None ,
237+ uid : str | UID | None = None ,
243238 ) -> AnnotationGroup :
244239 """Get an individual annotation group.
245240
@@ -303,17 +298,17 @@ def get_annotation_group(
303298
304299 def get_annotation_groups (
305300 self ,
306- annotated_property_category : Optional [ Union [ Code , CodedConcept ]] = None ,
307- annotated_property_type : Optional [ Union [ Code , CodedConcept ]] = None ,
308- label : Optional [ str ] = None ,
309- graphic_type : Optional [ Union [ str , GraphicTypeValues ]] = None ,
310- algorithm_type : Optional [
311- Union [ str , AnnotationGroupGenerationTypeValues ]
312- ] = None ,
313- algorithm_name : Optional [ str ] = None ,
314- algorithm_family : Optional [ Union [ Code , CodedConcept ]] = None ,
315- algorithm_version : Optional [ str ] = None ,
316- ) -> List [AnnotationGroup ]:
301+ annotated_property_category : Code | CodedConcept | None = None ,
302+ annotated_property_type : Code | CodedConcept | None = None ,
303+ label : str | None = None ,
304+ graphic_type : str | GraphicTypeValues | None = None ,
305+ algorithm_type : None | (
306+ str | AnnotationGroupGenerationTypeValues
307+ ) = None ,
308+ algorithm_name : str | None = None ,
309+ algorithm_family : Code | CodedConcept | None = None ,
310+ algorithm_version : str | None = None ,
311+ ) -> list [AnnotationGroup ]:
317312 """Get annotation groups matching search criteria.
318313
319314 Parameters
@@ -462,7 +457,7 @@ def from_dataset(
462457
463458
464459def annread (
465- fp : Union [ str , bytes , PathLike , BinaryIO ] ,
460+ fp : str | bytes | PathLike | BinaryIO ,
466461) -> MicroscopyBulkSimpleAnnotations :
467462 """Read a bulk annotations object stored in DICOM File Format.
468463
0 commit comments