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] Add stub for Dataset and type Dataset element attributes #1940

Closed
wants to merge 10 commits into from
7 changes: 7 additions & 0 deletions doc/reference/uid.rst
Original file line number Diff line number Diff line change
Expand Up @@ -135,15 +135,18 @@ Storage SOP Class UIDs
EncapsulatedPDFStorage
EncapsulatedSTLStorage
EnhancedCTImageStorage
EnhancedContinuousRTImageStorage
EnhancedMRColorImageStorage
EnhancedMRImageStorage
EnhancedPETImageStorage
EnhancedRTImageStorage
EnhancedSRStorage
EnhancedUSVolumeStorage
EnhancedXAImageStorage
EnhancedXRFImageStorage
EnhancedXRayRadiationDoseSRStorage
ExtensibleSRStorage
General32bitECGWaveformStorage
GeneralAudioWaveformStorage
GeneralECGWaveformStorage
GenericImplantTemplateStorage
Expand All @@ -157,6 +160,7 @@ Storage SOP Class UIDs
IntraocularLensCalculationsStorage
IntravascularOpticalCoherenceTomographyImageStorageForPresentation
IntravascularOpticalCoherenceTomographyImageStorageForProcessing
InventoryStorage
KeratometryMeasurementsStorage
KeyObjectSelectionDocumentStorage
LegacyConvertedEnhancedCTImageStorage
Expand Down Expand Up @@ -187,6 +191,7 @@ Storage SOP Class UIDs
ParametricMapStorage
PatientRadiationDoseSRStorage
PerformedImagingAgentAdministrationSRStorage
PhotoacousticImageStorage
PlannedImagingAgentAdministrationSRStorage
PositronEmissionTomographyImageStorage
ProcedureLogStorage
Expand All @@ -200,6 +205,7 @@ Storage SOP Class UIDs
RTImageStorage
RTIonBeamsTreatmentRecordStorage
RTIonPlanStorage
RTPatientPositionAcquisitionInstructionStorage
RTPhysicianIntentStorage
RTPlanStorage
RTRadiationRecordSetStorage
Expand Down Expand Up @@ -241,6 +247,7 @@ Storage SOP Class UIDs
VLPhotographicImageStorage
VLSlideCoordinatesMicroscopicImageStorage
VLWholeSlideMicroscopyImageStorage
VariableModalityLUTSoftcopyPresentationStateStorage
VideoEndoscopicImageStorage
VideoMicroscopicImageStorage
VideoPhotographicImageStorage
Expand Down
23 changes: 23 additions & 0 deletions src/pydicom/_dicom_dict.py
Original file line number Diff line number Diff line change
Expand Up @@ -958,6 +958,8 @@
0x00181201: ('TM', '1-n', "Time of Last Calibration", '', 'TimeOfLastCalibration'), # noqa
0x00181202: ('DT', '1', "DateTime of Last Calibration", '', 'DateTimeOfLastCalibration'), # noqa
0x00181203: ('DT', '1', "Calibration DateTime", '', 'CalibrationDateTime'), # noqa
0x00181204: ('DA', '1', "Date of Manufacture", '', 'DateOfManufacture'), # noqa
0x00181205: ('DA', '1', "Date of Installation", '', 'DateOfInstallation'), # noqa
0x00181210: ('SH', '1-n', "Convolution Kernel", '', 'ConvolutionKernel'), # noqa
0x00181240: ('IS', '1-n', "Upper/Lower Pixel Values", 'Retired', 'UpperLowerPixelValues'), # noqa
0x00181242: ('IS', '1', "Actual Frame Duration", '', 'ActualFrameDuration'), # noqa
Expand Down Expand Up @@ -1576,6 +1578,27 @@
0x0018980E: ('SQ', '1', "Transducer Beam Steering Code Sequence", '', 'TransducerBeamSteeringCodeSequence'), # noqa
0x0018980F: ('SQ', '1', "Transducer Application Code Sequence", '', 'TransducerApplicationCodeSequence'), # noqa
0x00189810: ('US or SS', '1', "Zero Velocity Pixel Value", '', 'ZeroVelocityPixelValue'), # noqa
0x00189821: ('SQ', '1', "Photoacoustic Excitation Characteristics Sequence", '', 'PhotoacousticExcitationCharacteristicsSequence'), # noqa
0x00189822: ('FD', '1', "Excitation Spectral Width", '', 'ExcitationSpectralWidth'), # noqa
0x00189823: ('FD', '1', "Excitation Energy", '', 'ExcitationEnergy'), # noqa
0x00189824: ('FD', '1', "Excitation Pulse Duration", '', 'ExcitationPulseDuration'), # noqa
0x00189825: ('SQ', '1', "Excitation Wavelength Sequence", '', 'ExcitationWavelengthSequence'), # noqa
0x00189826: ('FD', '1', "Excitation Wavelength", '', 'ExcitationWavelength'), # noqa
0x00189828: ('CS', '1', "Illumination Translation Flag", '', 'IlluminationTranslationFlag'), # noqa
0x00189829: ('CS', '1', "Acoustic Coupling Medium Flag", '', 'AcousticCouplingMediumFlag'), # noqa
0x0018982A: ('SQ', '1', "Acoustic Coupling Medium Code Sequence", '', 'AcousticCouplingMediumCodeSequence'), # noqa
0x0018982B: ('FD', '1', "Acoustic Coupling Medium Temperature", '', 'AcousticCouplingMediumTemperature'), # noqa
0x0018982C: ('SQ', '1', "Transducer Response Sequence", '', 'TransducerResponseSequence'), # noqa
0x0018982D: ('FD', '1', "Center Frequency", '', 'CenterFrequency'), # noqa
0x0018982E: ('FD', '1', "Fractional Bandwidth", '', 'FractionalBandwidth'), # noqa
0x0018982F: ('FD', '1', "Lower Cutoff Frequency", '', 'LowerCutoffFrequency'), # noqa
0x00189830: ('FD', '1', "Upper Cutoff Frequency", '', 'UpperCutoffFrequency'), # noqa
0x00189831: ('SQ', '1', "Transducer Technology Sequence", '', 'TransducerTechnologySequence'), # noqa
0x00189832: ('SQ', '1', "Sound Speed Correction Mechanism Code Sequence", '', 'SoundSpeedCorrectionMechanismCodeSequence'), # noqa
0x00189833: ('FD', '1', "Object Sound Speed", '', 'ObjectSoundSpeed'), # noqa
0x00189834: ('FD', '1', "Acoustic Coupling Medium Sound Speed", '', 'AcousticCouplingMediumSoundSpeed'), # noqa
0x00189835: ('SQ', '1', "Photoacoustic Image Frame Type Sequence", '', 'PhotoacousticImageFrameTypeSequence'), # noqa
0x00189836: ('SQ', '1', "Image Data Type Code Sequence", '', 'ImageDataTypeCodeSequence'), # noqa
0x00189900: ('LO', '1', "Reference Location Label", '', 'ReferenceLocationLabel'), # noqa
0x00189901: ('UT', '1', "Reference Location Description", '', 'ReferenceLocationDescription'), # noqa
0x00189902: ('SQ', '1', "Reference Basis Code Sequence", '', 'ReferenceBasisCodeSequence'), # noqa
Expand Down
2 changes: 1 addition & 1 deletion src/pydicom/_private_dict.py
Original file line number Diff line number Diff line change
Expand Up @@ -2664,7 +2664,7 @@
'0011xx40': ('SL', '1', 'Pasting Overlap', ''), # noqa
'0011xx41': ('IS', '24', 'Sub-image Collimator Vertices', ''), # noqa
'0011xx42': ('LO', '1', 'View IP', ''), # noqa
'0011xx43': ('IS', '24', 'Key-stone Co-ordinates', ''), # noqa
'0011xx43': ('IS', '24', 'Key-stone Coordinates', ''), # noqa
'0011xx44': ('CS', '1', 'Receptor Type', ''), # noqa
'0011xx46': ('LO', '1-n', 'Unknown', ''), # noqa
'0011xx47': ('DS', '1', 'Unknown', ''), # noqa
Expand Down
4 changes: 3 additions & 1 deletion src/pydicom/_uid_dict.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@
'1.2.840.10008.5.1.4.1.1.6': ('Ultrasound Image Storage', 'SOP Class', '', 'Retired', 'UltrasoundImageStorageRetired'), # noqa
'1.2.840.10008.5.1.4.1.1.6.1': ('Ultrasound Image Storage', 'SOP Class', '', '', 'UltrasoundImageStorage'), # noqa
'1.2.840.10008.5.1.4.1.1.6.2': ('Enhanced US Volume Storage', 'SOP Class', '', '', 'EnhancedUSVolumeStorage'), # noqa
'1.2.840.10008.5.1.4.1.1.6.3': ('Photoacoustic Image Storage', 'SOP Class', '', '', 'PhotoacousticImageStorage'), # noqa
'1.2.840.10008.5.1.4.1.1.7': ('Secondary Capture Image Storage', 'SOP Class', '', '', 'SecondaryCaptureImageStorage'), # noqa
'1.2.840.10008.5.1.4.1.1.7.1': ('Multi-frame Single Bit Secondary Capture Image Storage', 'SOP Class', '', '', 'MultiFrameSingleBitSecondaryCaptureImageStorage'), # noqa
'1.2.840.10008.5.1.4.1.1.7.2': ('Multi-frame Grayscale Byte Secondary Capture Image Storage', 'SOP Class', '', '', 'MultiFrameGrayscaleByteSecondaryCaptureImageStorage'), # noqa
Expand All @@ -165,6 +166,7 @@
'1.2.840.10008.5.1.4.1.1.9.1.1': ('12-lead ECG Waveform Storage', 'SOP Class', '', '', 'TwelveLeadECGWaveformStorage'), # noqa
'1.2.840.10008.5.1.4.1.1.9.1.2': ('General ECG Waveform Storage', 'SOP Class', '', '', 'GeneralECGWaveformStorage'), # noqa
'1.2.840.10008.5.1.4.1.1.9.1.3': ('Ambulatory ECG Waveform Storage', 'SOP Class', '', '', 'AmbulatoryECGWaveformStorage'), # noqa
'1.2.840.10008.5.1.4.1.1.9.1.4': ('General 32-bit ECG Waveform Storage', 'SOP Class', '', '', 'General32bitECGWaveformStorage'), # noqa
'1.2.840.10008.5.1.4.1.1.9.2.1': ('Hemodynamic Waveform Storage', 'SOP Class', '', '', 'HemodynamicWaveformStorage'), # noqa
'1.2.840.10008.5.1.4.1.1.9.3.1': ('Cardiac Electrophysiology Waveform Storage', 'SOP Class', '', '', 'CardiacElectrophysiologyWaveformStorage'), # noqa
'1.2.840.10008.5.1.4.1.1.9.4.1': ('Basic Voice Audio Waveform Storage', 'SOP Class', '', '', 'BasicVoiceAudioWaveformStorage'), # noqa
Expand All @@ -190,7 +192,7 @@
'1.2.840.10008.5.1.4.1.1.11.9': ('Volume Rendering Volumetric Presentation State Storage', 'SOP Class', '', '', 'VolumeRenderingVolumetricPresentationStateStorage'), # noqa
'1.2.840.10008.5.1.4.1.1.11.10': ('Segmented Volume Rendering Volumetric Presentation State Storage', 'SOP Class', '', '', 'SegmentedVolumeRenderingVolumetricPresentationStateStorage'), # noqa
'1.2.840.10008.5.1.4.1.1.11.11': ('Multiple Volume Rendering Volumetric Presentation State Storage', 'SOP Class', '', '', 'MultipleVolumeRenderingVolumetricPresentationStateStorage'), # noqa
'1.2.840.10008.5.1.4.1.1.11.12': ('Variable Modality LUT Softcopy Presentation State Storage', 'SOP Class', '', '', 'VariableModalityLUTPresentationStateStorage'), # noqa
'1.2.840.10008.5.1.4.1.1.11.12': ('Variable Modality LUT Softcopy Presentation State Storage', 'SOP Class', '', '', 'VariableModalityLUTSoftcopyPresentationStateStorage'), # noqa
'1.2.840.10008.5.1.4.1.1.12.1': ('X-Ray Angiographic Image Storage', 'SOP Class', '', '', 'XRayAngiographicImageStorage'), # noqa
'1.2.840.10008.5.1.4.1.1.12.1.1': ('Enhanced XA Image Storage', 'SOP Class', '', '', 'EnhancedXAImageStorage'), # noqa
'1.2.840.10008.5.1.4.1.1.12.2': ('X-Ray Radiofluoroscopic Image Storage', 'SOP Class', '', '', 'XRayRadiofluoroscopicImageStorage'), # noqa
Expand Down
2 changes: 1 addition & 1 deletion src/pydicom/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@

# DICOM Standard version used for:
# _dicom_dict.py, _uid_dict.py and uid.py
__dicom_version__: str = "2023b"
__dicom_version__: str = "2023d"
16 changes: 0 additions & 16 deletions src/pydicom/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -2923,22 +2923,6 @@ def __init__(self, *args: _DatasetType, **kwargs: Any) -> None:
super().__init__(*args, **kwargs)
FileMetaDataset.validate(self._dict)

# Set type hints for the possible contents - VR, Type (1|1C|3)
self.FileMetaInformationGroupLength: int # UL, 1
self.FileMetaInformationVersion: bytes # OB, 1
self.MediaStorageSOPClassUID: UID # UI, 1
self.MediaStorageSOPInstanceUID: UID # UI, 1
self.TransferSyntaxUID: UID # UI, 1
self.ImplementationClassUID: UID # UI, 1
self.ImplementationVersionName: str | None # SH, 3
self.SourceApplicationEntityTitle: str | None # AE, 3
self.SendingApplicationEntityTitle: str | None # AE, 3
self.ReceivingApplicationEntityTitle: str | None # AE, 3
self.SourcePresentationAddress: str | None # UR, 3
self.ReceivingPresentationAddress: str | None # UR, 3
self.PrivateInformationCreatorUID: UID | None # UI, 3
self.PrivateInformation: bytes # OB, 1C

@staticmethod
def validate(init_value: _DatasetType) -> None:
"""Raise errors if initialization value is not acceptable for file_meta
Expand Down
202 changes: 202 additions & 0 deletions src/pydicom/stubs/__init__.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,202 @@
from collections.abc import MutableSequence
import datetime
from decimal import Decimal

from pydicom.dataset import Dataset
from pydicom.tag import BaseTag
from pydicom.uid import UID
from pydicom.valuerep import PersonName, DA, DSfloat, DSdecimal, DT, IS, ISfloat, TM

BytesSequence = MutableSequence[bytes]
StrSequence = MutableSequence[str]
IntSequence = MutableSequence[int]
FloatSequence = MutableSequence[float]

BytesType = None | bytes
BytesListType = None | BytesSequence
DateType = None | str | datetime.date | DA
DateListType = None | StrSequence | MutableSequence[datetime.date] | MutableSequence[DA]
DateTimeType = None | str | datetime.datetime | DT
DateTimeListType = (
None | StrSequence | MutableSequence[datetime.datetime] | MutableSequence[DT]
)
DecimalStringType = None | str | int | float | Decimal | DSfloat | DSdecimal
DecimalStringListType = (
None
| StrSequence
| IntSequence
| FloatSequence
| MutableSequence[Decimal]
| MutableSequence[DSfloat]
| MutableSequence[DSdecimal]
)
FloatType = None | float
FloatListType = None | FloatSequence
IntType = None | int
IntListType = None | IntSequence
IntegerStringType = None | str | int | IS | ISfloat
IntegerStringListType = (
None | StrSequence | IntSequence | MutableSequence[IS] | MutableSequence[ISfloat]
)
PersonNameType = None | str | PersonName
PersonNameListType = None | StrSequence | MutableSequence[PersonName]
StringType = None | str
StringListType = None | StrSequence
TagType = None | int | str | tuple[int, int] | BaseTag
TagListType = (
None
| IntSequence
| StrSequence
| MutableSequence[tuple[int, int]]
| MutableSequence[BaseTag]
)
TimeType = None | str | datetime.time | TM
TimeListType = None | StrSequence | MutableSequence[datetime.time] | MutableSequence[TM]
UIDType = None | str | UID
UIDListType = None | StrSequence | MutableSequence[UID]

# Standard VRs
# _1: VM is 1, _1N: VM is 1-n, _N: VM is 2+-n
AE_1_Type = StringType
AE_1N_Type = StringType | StringListType
AE_N_Type = StringListType

AS_1_Type = StringType
AS_1N_Type = StringType | StringListType
AS_N_Type = StringListType

AT_1_Type = TagType
AT_1N_Type = TagType | TagListType
AT_N_Type = TagListType

CS_1_Type = StringType
CS_1N_Type = StringType | StringListType
CS_N_Type = StringListType

DA_1_Type = DateType
DA_1N_Type = DateType | DateListType
DA_N_Type = DateListType

DS_1_Type = DecimalStringType
DS_1N_Type = DecimalStringType | DecimalStringListType
DS_N_Type = DecimalStringListType

DT_1_Type = DateTimeType
DT_1N_Type = DateTimeType | DateTimeListType
DT_N_Type = DateTimeListType

FD_1_Type = FloatType
FD_1N_Type = FloatType | FloatListType
FD_N_Type = FloatListType

FL_1_Type = FloatType
FL_1N_Type = FloatType | FloatListType
FL_N_Type = FloatListType

IS_1_Type = IntegerStringType
IS_1N_Type = IntegerStringType | IntegerStringListType
IS_N_Type = IntegerStringListType

LO_1_Type = StringType
LO_1N_Type = StringType | StringListType
LO_N_Type = StringListType

LT_1_Type = StringType
LT_1N_Type = StringType | StringListType
LT_N_Type = StringListType

OB_1_Type = BytesType
OB_1N_Type = BytesType | BytesListType
OB_N_Type = BytesListType

OD_1_Type = BytesType
OD_1N_Type = BytesType | BytesListType
OD_N_Type = BytesListType

OF_1_Type = BytesType
OF_1N_Type = BytesType | BytesListType
OF_N_Type = BytesListType

OL_1_Type = BytesType
OL_1N_Type = BytesType | BytesListType
OL_N_Type = BytesListType

OW_1_Type = BytesType
OW_1N_Type = BytesType | BytesListType
OW_N_Type = BytesListType

OV_1_Type = BytesType
OV_1N_Type = BytesType | BytesListType
OV_N_Type = BytesListType

PN_1_Type = PersonNameType
PN_1N_Type = PersonNameType | PersonNameListType
PN_N_Type = PersonNameListType

SH_1_Type = StringType
SH_1N_Type = StringType | StringListType
SH_N_Type = StringListType

SL_1_Type = IntType
SL_1N_Type = IntType | IntListType
SL_N_Type = IntListType

SQType = None | MutableSequence[Dataset]

SS_1_Type = IntType
SS_1N_Type = IntType | IntListType
SS_N_Type = IntListType

ST_1_Type = StringType
ST_1N_Type = StringType | StringListType
ST_N_Type = StringListType

SV_1_Type = IntType
SV_1N_Type = IntType | IntListType
SV_N_Type = IntListType

TM_1_Type = TimeType
TM_1N_Type = TimeType | TimeListType
TM_N_Type = TimeListType

UC_1_Type = StringType
UC_1N_Type = StringType | StringListType
UC_N_Type = StringListType

UI_1_Type = UIDType
UI_1N_Type = UIDType | UIDListType
UI_N_Type = UIDListType

UL_1_Type = IntType
UL_1N_Type = IntType | IntListType
UL_N_Type = IntListType

UN_1_Type = BytesType
UN_1N_Type = BytesType | BytesListType
UN_N_Type = BytesListType

UR_1_Type = StringType
UR_1N_Type = StringType | StringListType
UR_N_Type = StringListType

US_1_Type = IntType
US_1N_Type = IntType | IntListType
US_N_Type = IntListType

UT_1_Type = StringType
UT_1N_Type = StringType | StringListType
UT_N_Type = StringListType

UV_1_Type = IntType
UV_1N_Type = IntType | IntListType
UV_N_Type = IntListType

# Ambiguous VRs
# US or SS or OW: 1, 1-n
US_SS_OW_Type = IntType | BytesType | IntListType | BytesListType
# US or OW: 1, 1-n
US_OW_Type = IntType | BytesType | IntListType | BytesListType
# US or SS: 1, 3, 4
US_SS_Type = IntType | IntListType
# OB or OW: 1
OB_OW_Type = BytesType