Understanding DICOM
Digital Imaging and Communications in Medicine (DICOM) is the international standard for medical imaging information and related data. It defines the formats for medical images used in clinical practice. The T2 TSE tra example from the Siemens Healthineers gallery contains 21 MR frames in a single file. The examples use pydicom and NumPy and expect IMG-0001-00001.dcm in the current directory. import numpy as np from pydicom import dcmread from pydicom.pixels import pixel_array path = "IMG-0001-00001.dcm" ds = dcmread(path, stop_before_pixels=True) # Read the image and scanner metadata. print(ds.SOPClassUID.name) # Enhanced MR Image Storage print(ds.NumberOfFrames, ds.Rows, ds.Columns) # 21 frames, 896 rows, 732 columns print(ds.Modality) # MR print(ds.get("ManufacturerModelName")) # MAGNETOM Vida print(ds.get("MagneticFieldStrength")) # 3 tesla print(ds.file_meta.TransferSyntaxUID.name) # Explicit VR Little Endian # (0028,0010) is the DICOM tag for Rows. US means unsigned 16-bit integer. rows = ds[0x0028, 0x0010] print(rows.tag, rows.VR, rows.value) # (0028,0010) US 896, meaning 896 rows # Enhanced MR stores pixel spacing and display settings per frame. frame_info = ds.PerFrameFunctionalGroupsSequence[0] measures = frame_info.PixelMeasuresSequence[0] window = frame_info.FrameVOILUTSequence[0] # Pixel spacing measures the distance between adjacent pixel centres. print(measures.PixelSpacing) # 0.2567 mm between rows and between columns # The window maps a range of intensities to shades of grey. print(window.WindowCenter, window.WindowWidth) # centre 517, width 1102 # Decode nine frames spread across the scan. indices = np.linspace(0, int(ds.NumberOfFrames) - 1, 9, dtype=int) frames = [pixel_array(path, index=int(index)) for index in indices] print(len(frames), *frames[0].shape) # 9 frames, 896 rows, 732 columns Nine frames sampled across the 21-frame scan. Each uses its stored display window. ...