Package: dicomsdl
DICOMSDLA fast and light-weighted DICOM software development library.IntroductionDigital Imaging and Communications in Medicine (DICOM) is a standard for managing informations in medical imaging developed by American College of Radiology (ACR) and National Electrical Manufacturers Association (NEMA). It defines a file format and a communication protocol over network.DICOM Software Development Library (DICOM SDL) is a software developed libraries for easy and quick development of an application managing DICOM formatted files. DICOM SDL allows to make programs that read DICOM formatted files without in depth knowledge of DICOM.DICOM SDL is intended to process a huge bunch of DICOM formatted image in high speed. For example, processing 1M+ dicom files for deep learning, speed really matters. To achieve the processing speed, DICOM SDL use an extension written in C++. DICOM SDL works much faster than pure DICOM implementation(see tutorials/timeit_test.ipynb). If your job is simple such as image extraction or get study date, DICOM SDL may be what you want.DICOM SDL canread DICOM formatted files.read medical images in DICOM file, if file encodes in raw/jpeg/jpeg2000/RLE/JPEG-LS format.modify and save into DICOM formatted files.DICOM SDL is especially optimized for reading lots of DICOM formatted files quickly, and would be very useful for scanning and processing huge numbers of DICOM files.DICOM SDL cannotsend/receive DICOM over network.InstallTo install on python,$ pip install -U dicomsdlTo get code and compile,$ git clone --recursive https://github.com/tsangel/dicomsdl
$ python setup.py installIf you want to use AVX2, then set environment USE_AVX2.$ set USER_AVX=ON
$ python setup.py installDICOMSDL was successfully compiled and ran on following environmentsMicrosoft Windows 7/10/11 (x86, x64), Python 3.6-3.11Linux x86/x64 (Ubuntu), Python 2.7, 3.5-3.11MacOS 10.9+ (x86_64, arm64), Python 3.6-3.11
(No more support python 2.7-3.5 on Windows and MacOS since 0.108.5.)If you haveImportErrorin Microsoft Windows, installMicrosoft Visual C++ Redistributable.Some examplesPlease look ipynb files in tutorial folder for detailed explanations.>>>importdicomsdlasdicom>>>dset=dicom.open("somefile.dcm")>>>print(dset.Rows,dset.Columns)512512>>>dset.getPixelDataInfo(){'Rows':512,'Cols':512,'NumberOfFrames':1,'SamplesPerPixel':1,'PlanarConfiguration':None,'BitsAllocated':16,'BytesAllocated':2,'BitsStored':16,'PixelRepresentation':True,'dtype':'h','PhotometricInterpretation':'MONOCHROME2','WindowCenter':None,'WindowWidth':None,'RescaleIntercept':-1024.0,'RescaleSlope':1.0}>>>dset.pixelData()array([[-3024.,-3024.,-3024.,...,-3024.,-3024.,-3024.],[-3024.,-3024.,-3024.,...,-3024.,-3024.,-3024.],[-3024.,-3024.,-3024.,...,-3024.,-3024.,-3024.],...,[-3024.,-3024.,-3024.,...,-3024.,-3024.,-3024.],[-3024.,-3024.,-3024.,...,-3024.,-3024.,-3024.],[-3024.,-3024.,-3024.,...,-3024.,-3024.,-3024.]],dtype=float32)>>>dset.pixelData(storedvalue=True)array([[-2000,-2000,-2000,...,-2000,-2000,-2000],[-2000,-2000,-2000,...,-2000,-2000,-2000],[-2000,-2000,-2000,...,-2000,-2000,-2000],...,[-2000,-2000,-2000,...,-2000,-2000,-2000],[-2000,-2000,-2000,...,-2000,-2000,-2000],[-2000,-2000,-2000,...,-2000,-2000,-2000]],dtype=int16)>>>dset.RescaleIntercept-1024.0>>>dset['RescaleIntercept']# another way to get value-1024.0>>>dset[0x00281052]# yet another way to get value-1024.0>>>dset.getDataElement('RescaleSlope')<dicomsdl._dicomsdl.DataElementobjectat0x10ff5d0f0>>>>dset.getDataElement('RescaleIntercept').toDouble()# yet yet another-1024.0>>>dset.getDataElement('RescaleIntercept').value()# yet yet yet another-1024.0>>>print(dset['00540016.0.00180031'])# from another exampleFDG--fluorodeoxyglucose>>>print(dset.WindowCenter)# return None if dicom file doesn't have value.None>>>dset.toPilImage().show()...popupimage...>>>print(dset.dump())TAGVRLENVMOFFSETKEYWORD'00020000'UL410x8c212# FileMetaInformationGroupLength'00020001'OB210x9c'\x00\x01'# FileMetaInformationVersion'00020002'UI2610xa6'1.2.840.10008.5.1.4.1.1.2'=CTImageStorage# MediaStorageSOPClassUID...