3.1.0#

Changes#

  • DICOM dictionary updated to 2024d.

  • Prefer using pylibjpeg over GDCM when encoding RLE Lossless.

  • Prefer using Pillow when decoding JPEG Baseline 8-bit and JPEG Extended 12-bit

  • Improvements made to communications with the plugins when decoding and encoding pixel data and correcting for inter-frame decoding variations in multi-frame datasets (#2262).

  • The metadata returned by Decoder.as_buffer is now a dict containing the per-frame metadata to help account for inter-frame variations in frame properties when decoding.

  • Apply PEP 735 to build environment. It modifies how build dependencies are installed.

Fixes#

  • Restore buffered element positions when an operation using reset_buffer_position() raises an exception.

  • Fixed JSON serialization of buffered binary element values, including use of a bulk data URI handler without reading the buffer into memory.

  • Changed logging of missing plugin imports to use logging.DEBUG (#2128).

  • Include all examples module datasets with the package (#2128, #2131).

  • Fixed an invalid VR value in the private data dictionary (#2132).

  • Fixed checking for Bits Stored when converting Float Pixel Data and Double Float Pixel Data using the pixels backend (#2135).

  • Fixed decoding of pixel data for images with Bits Allocated of 1 when frame boundaries are not aligned with byte boundaries (#2134).

  • Fixed a number of issues with decoding pixel data on big endian systems such as s390x (#2147).

  • Fixed being unable to pickle datasets containing LUT descriptor elements such as LUT Descriptor and Red Palette Color LUT Descriptor (#2160).

  • Fixed decompress() and compress() changing the SOP Instance UID when not required (#2171).

  • Make sure the value of multi-valued tags is always returned as an instance of MultiValue.

  • Make sure that no download of examples is attempted on importing examples if the example data is not found locally (#2223).

  • Add mitigation and better error messaging for SWIG errors when using GDCM to decompress datasets with more than 2**31 - 1 bytes (#2227).

  • Use the setting writing_validation_mode also for writing values with VRs supporting only ASCII characters (#2243).

  • Correctly handle empty values represented as empty strings in json while converting them to a dataset (#2221).

  • Correctly handle empty components of multi-valued DS and IS elements when converting to and from JSON.

  • Correctly handle empty LUT data (#2238).

  • Fixed data in the “unused” bits above Bits Stored sometimes being included in the returned pixel data for JPEG 2000 and JPEG-LS (#2260).

  • Correctly handle meta data tags incorrectly written in implicit transfer syntax (#2290)

  • Made debugging of read_dataset() a bit more robust (#2292).

  • Fixed deepcopy of private blocks in Dataset (#2294)

  • Fixed private_block() returning an outdated block after the private creator was removed using pop(), popitem() or clear(), or replaced by a different private creator. New private elements could be added without a private creator element.

  • Fixed UID.is_deflated returning False for JPIP Referenced Deflate and JPIP HTJ2K Referenced Deflate, and fixed dcmread() and dcmwrite() not inflating/deflating the dataset for those two transfer syntaxes (PS3.5 Sections A.7 and A.12).

  • Fixed from_named_components() and from_named_components_veterinary() replacing non-ASCII characters in str components with ? when no encodings are given; the value is now encoded when written using the character set of the dataset.

  • Make float data elements with NaN value compare as equal - this is semantically better suited then the mathematical comparison, where NaN != NaN (#2273)

  • Fixed fileset-uid-property-annotation with Python 3.14 (#2358)

  • Fixed compress() silently producing byte swapped pixel data when the source dataset uses Explicit VR Big Endian (#2340).

  • Fixed apply_voi() and apply_modality_lut() wrapping out-of-range LUT indices instead of clamping them to the last entry (#2381).

  • Fixed compression of packed one-bit pixel data stored as OW with Explicit VR Big Endian byte ordering, including frames ending within a byte or word.

  • Fixed decoding text with ISO 2022 escape sequences for ISO_IR 58 (GB2312) character sets (#2383).

  • Fixed Dataset.pixel_array raising AttributeError when future_behavior() is enabled (#2354).

  • Fixed DSdecimal not comparing NaN values as equal, matching the behavior of DSfloat fixed in #2273 (#2427).

  • Fixed pixel_array raising a bare StopIteration when encapsulated Pixel Data contains fewer frames than Number of Frames (#2371).

  • Fixed read_sequence_item() converting KeyboardInterrupt and SystemExit to OSError (#2333).

  • Fixed codify generating invalid Python for standard data elements without keywords.

  • Fixed format_number_as_ds() returning a 17 character string when rounding adds a digit before the decimal point, such as 9.999999999999998.

  • Fixed reading files truncated within the 32-bit length of an explicit VR data element raising struct.error. These now follow the configured reading validation mode, raising EOFError or issuing a warning (#2394).

  • Fixed codify failing or producing invalid code for multi-valued AT and PN elements, empty multi-valued elements and empty AT elements, and failing for empty binary elements when excluding large values.

  • Fixed apply_color_lut() raising AttributeError for missing palette LUT data; a ValueError naming the missing element(s) is raised instead (#2433).

  • Fixed Dataset.to_json() adding an empty "Value" array for empty sequences, which should have no "Value" as per Part 18, Annex F.2.5.

Enhancements#

  • Python 3.12, 3.13 and 3.14 are now supported.

  • Added the option to pass a bool ndarray to set_pixel_data() to store with Bits Allocated of 1 using bit-packing (#2141).

  • Added a check to set_pixel_data() to ensure that the pixel data length doesn’t exceed the allowed maximum.

  • Added the Dataset.is_decompressed convenience property for determining whether a dataset uses a compressed transfer syntax or not (#2155).

  • Updated UIDs to version 2024d of the DICOM Standard

  • The following UID constants have been added:

  • Added ability to specify tag numbers in the CLI commands (allows private tags to be specified)

  • Removed exec and eval from tests, CLI, and scripts for improved security (#2193)

  • Added support for up to 16-bit input images to convert_color_space()

  • Added support for YBR_PARTIAL_420 and YBR_PARTIAL_422 to convert_color_space() (#2210)

  • Added support for compressing and decompressing Deflated Image Frame Compression (#2213)

  • Suggest an element keyword when an unknown camel case dataset attribute is used.

  • Added enhanced exception notes (Python >= 3.11) giving a pseudo-code path to the DICOM object where an error occurred. Activated using with dataset: context; already used internally in key locations (#2168)

  • Include the element tag in the BytesLengthException raised when ambiguous VR correction fails during writing due to an invalid value length (#2168)

  • Added support for adding unknown public transfer syntaxes to register_transfer_syntax()

  • When decoding JPEG pixel data use Pillow’s color transformations rather than convert_color_space() where applicable (#2228)

  • Take the color space information from an Adobe APP14 marker into account when decoding pixel data for JPEG transfer syntaxes.

  • apply_modality_lut() and apply_voi() now support LUT Descriptor bit depth per entry values in the range 1-16 bits, with a warning for non-conformant values (#2317).

  • Warn when multiples of the same element are found within a dataset or sequence item (#2420).

  • Improved memory usage for apply_windowing() (#2315)

  • When parsing fails because a value’s length doesn’t match the VR determined from a data dictionary lookup, report that VR in the error message (previously None) and suggest update_raw_element() (#2170)

  • The error for an unknown VR now names the pydicom version and the edition of the DICOM Standard it implements (#2336)