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. ...

November 26, 2026

GPU Acceleration with the C++ Standard Libray

DAXPY updates each element of a vector independently. We’ll turn a CPU loop into a standard C++ algorithm, run it on an NVIDIA GPU, and compare the effective bandwidth. CPU loop y[i] += a * x[i] Sequential algorithm transform(seq) GPU offload transform(par_unseq) nvc++ -stdpar=gpu This walkthrough is based on a self-paced course from NVIDIA’s Deep Learning Institute. DAXPY as a Bandwidth Benchmark DAXPY stands for Double-precision AX Plus Y, and it computes the following equation. ...

March 9, 2026

Model Context Protocol

Model Context Protocol (MCP) is an open source standard for LLMs to be interacting with applications. MCP is originally introduced by Anthropic in this post. With MCP, LLMs now can have assess to custom tools or data source to provide a more intelligent response. In addition, MCP also allows developers to build agents capable of more tasks, such as searching the internet or exploring dataset. MCP essentially standardizes LLM applications to work with many toolings. A nice quote by an Anthropic developer, “the models are only as good as the context provided to them”. ...

June 4, 2025 · Jun Kwan