[Python] error reported when reading DICOM file pydicom.errors.invaliddicomerror
When using Python to read and display DICOM files, the code is as follows:
import pydicom
import matplotlib.pyplot as plt
a = pydicom.read_file(r'C:\Users\shdn\Desktop\004.dcm')
print(a)
plt.imshow(img)
plt.show()
However, I sometimes encounter the following errors (I made the following error when reading the data given by the hospital):
The reason for this error is that the data given by the hospital may not be processed, and the file meta information header is missing, so it cannot be read directly. Solution: force reading.
The code is as follows:
import pydicom
import matplotlib.pyplot as plt
a = pydicom.read_file(r'C:\Users\shdn\Desktop\004.dcm' , force=True)
a.file_meta.TransferSyntaxUID = pydicom.uid.ImplicitVRLittleEndian
print(a)
plt.imshow(img)
plt.show()
Successfully resolved:
Read More:
- Error reported in Python reading file oserror: [errno 22] invalid argument: ‘u202ac: \ \ users \ \ yyqhk \ \ desktop \ \ 1. CSV’
- Solutions to errors reported by running pytest.ini configuration file
- Solution to errors reported by TES command in vscode – errors reported by typescript command
- Common errors reported by Eureka in spring cloud
- No code, a solution to the error in the path of reading CSV file by Python: filenotfounderror: [errno 2] no such file or directory: ‘XX. CSV‘
- When reading the CSV file with Python 3, the Unicode decodeerror: ‘UTF-8’ codec can’t decode byte 0xd0 in position 0: invalid con appears
- Android studio reported an error in the release package: Lint found fatal errors while assembling a release target
- An error is reported when uploading a file using commonsmultipartfile
- Error reading file cow.osg: read error (Could not find plugin to read objects from file “cow.osg“.)
- Error reading JSON file: json.decoder.JSONDecodeError : Extra data: line 6 column 2 (char 1329)
- FileZilla Server prompts 550 Could not open file for reading when downloading files (illustration)
- Error in reading XML file IOException parsing XML document from URL
- “Undeclared identifier” still reported in declaration header file
- Syntax error near unexpected token ‘$’Do is reported when running bash file
- File.createNewFile report errors java.io.IOException , resolved
- docker.errors.DockerException: Error while fetching server API version: (‘Connection aborted.‘, File
- The SuperMap webgl browser reported an error. The unzip.wasm file 404
- Methods to avoid fail to allocate bitmap errors in pyplot
- Vs2017 reported an error. Pthread. H header file cannot be opened and cannot be found
- Uniapp uses CMD to import uview. An error is reported, and the file search fails: ‘uview UI’‘