2.2.0#
Changes#
- Data elements with a VR of AT must now be set with values acceptable to - Tag(), and are always stored as a- BaseTag. Previously, any Python type could be set.
- BaseTag.__eq__()returns- Falserather than raising an exception when the operand cannot be converted to- BaseTag(#1327)
- DA.__str__(),- DT.__str__()and- TM.__str__()return valid DICOM strings instead of the formatted date and time representations (#1262)
- If comparing - FileDatasetinstances, the file metadata is now ignored. This makes it possible to compare a- FileDatasetobject with a- Datasetobject.
- rle_encode_frame()is deprecated and will be removed in v3.0, use- compress()or- RLELosslessEncoderinstead.
- read_file()is deprecated and will be removed in v3.0, use- dcmread()instead.
- write_file()is deprecated and will be removed in v3.0, use- dcmwrite()instead.
- Data dictionaries updated to version 2021b of the DICOM Standard 
Enhancements#
- Added a command-line interface for pydicom. Current subcommands are: - show: display all or part of a DICOM file
- codifyto produce Python code for writing files or sequence items from scratch.
 - Please see the Command-line Interface guide for examples and details of all the options for each command. 
- A field containing an invalid number of bytes will result in a warning instead of an exception when - convert_wrong_length_to_UNis set to- True.
- Private tags known via the private dictionary will now get the configured VR if read from a dataset instead of UN (#1051). 
- While reading explicit VR, a switch to implicit VR will be silently attempted if the VR bytes are not valid VR characters, and config option - assume_implicit_vr_switchis- True(default)
- New functionality to help with correct formatting of decimal strings (DS) - Added - is_valid_ds()to check whether a string is valid as a DICOM decimal string and- format_number_as_ds()to format a given- floator- Decimalas a DS while retaining the highest possible level of precision
- If - enforce_valid_valuesis set to- True, all DS objects created will be checked for the validity of their string representations.
- Added optional - auto_formatparameter to the init methods of- DSfloatand- DSdecimaland the- DS()factory function to allow explicitly requesting automatic formatting of the string representations of these objects when they are constructed.
 
- Added methods to construct - PersonNameobjects from individual components of names (- family_name,- given_name, etc.). See- from_named_components()and- from_named_components_veterinary().
- Added support for downloading the large test files with the requests package in addition to - urllib.request(#1340)
- Ensured - convert_color_space()uses 32-bit floats for calculation, added per_frame flag to allow frame-by-frame processing and improved the speed by ~20-60% (#1348)
- Optimisations for RLE encoding using pydicom (~40% faster). 
- Added support for faster decoding (~4-5x) and encoding (~20x) of RLE Lossless Pixel Data via the pylibjpeg-rle plugin (#1361, #1372). 
- Added - Dataset.compress()function for compressing uncompressed pixel data using a given encoding format as specified by a UID. Only RLE Lossless is currently supported (#1372)
- Added - encodersmodule and the following encoders:- RLELosslessEncoderwith ‘pydicom’, ‘pylibjpeg’ and ‘gdcm’ plugins
 
- Added read parameter to - get_testdata_file()to allow reading and returning the corresponding dataset (#1372)
- Handle decoded RLE segments with padding (#1438) 
- Add option to JSON functions to suppress exception and continue (#1332) 
Fixes#
- Fixed pickling a - Datasetinstance with sequences after the sequence had been read (#1278)
- Fixed JSON export of numeric values 
- Fixed handling of sequences of unknown length that switch to implicit encoding, and sequences with VR UN (#1312) 
- Do not load external data sources until needed - fixes problems with standard workflow if setuptools are not installed (#1341) 
- Fixed empty PN elements read from file being - strrather than- PersonName(#1338)
- Fixed handling of JPEG (10918-1) images compressed using RGB colourspace rather than YBR with the Pillow pixel data handler (#878) 
- Allow to deepcopy a ~pydicom.dataset.FileDataset object (#1147) 
- Fixed elements with a VR of OL, OD and OV not being set correctly when an encoded backslash was part of the element value (#1412) 
- Fixed expansion of linear segments with floating point steps in segmented LUTs (#1415) 
- Fixed handling of code extensions with person name component delimiter (#1449) 
- Fixed bug decoding RBG jpg with APP14 marker due to change in Pillow (#1444) 
- Fixed decoding for FloatPixelData and DoubleFloatPixelData via pydicom.pixel_data_handlers.numpy_handler (#1457) 
