Skip to main content
Glama

load-dicom-series

Load a specified DICOM series into memory using the DICOM-MCP server for efficient medical image processing, accessible via the Series UID.

Instructions

Load a DICOM series into memory for processing

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
series_uidYesSeries UID of the DICOM series to load

Implementation Reference

  • The handler for the 'load-dicom-series' tool. It validates the series_uid, loads the DICOM series using the helper function load_dicom_image, caches the image array and metadata, and returns a text summary of the loaded data.
    elif name == "load-dicom-series": series_uid = arguments.get("series_uid") if not series_uid or series_uid not in dicom_data: raise ValueError(f"Invalid or unknown series UID: {series_uid}") series = dicom_data[series_uid] # Load the DICOM series image_array, metadata = load_dicom_image(series.path) # Cache the loaded data dicom_cache[series_uid] = { "image": image_array, "metadata": metadata } # Return summary information shape = image_array.shape intensity_range = (float(image_array.min()), float(image_array.max())) return [ types.TextContent( type="text", text=f"Loaded DICOM series {series_uid}\n" + f"Shape: {shape}\n" + f"Intensity range: {intensity_range}\n" + f"Metadata: {json.dumps(metadata, indent=2, default=str)}" ) ]
  • Registration of the 'load-dicom-series' tool in the handle_list_tools function, including its description and input schema.
    types.Tool( name="load-dicom-series", description="Load a DICOM series into memory for processing", inputSchema={ "type": "object", "properties": { "series_uid": {"type": "string", "description": "Series UID of the DICOM series to load"}, }, "required": ["series_uid"], }, ),
  • Input schema for the 'load-dicom-series' tool, defining the required 'series_uid' parameter.
    inputSchema={ "type": "object", "properties": { "series_uid": {"type": "string", "description": "Series UID of the DICOM series to load"}, }, "required": ["series_uid"], },
  • Core helper function that loads the DICOM series from the given path using ITK, converts to numpy array, extracts spatial metadata, and returns the image data with metadata.
    def load_dicom_image(series_path: str) -> Tuple[np.ndarray, Dict[str, Any]]: """Load a DICOM series into a 3D numpy array and metadata dictionary""" try: # Use ITK to read the DICOM series itk_image = itk.imread(series_path, itk.F) # Convert to numpy array np_array = itk.GetArrayFromImage(itk_image) # Extract metadata size = itk_image.GetLargestPossibleRegion().GetSize() spacing = itk_image.GetSpacing() origin = itk_image.GetOrigin() direction = itk_image.GetDirection().GetVnlMatrix().as_matrix().flatten().tolist() metadata = { "size": (int(size[0]), int(size[1]), int(size[2])), "spacing": (float(spacing[0]), float(spacing[1]), float(spacing[2])), "origin": (float(origin[0]), float(origin[1]), float(origin[2])), "direction": direction } return np_array, metadata except Exception as e: raise RuntimeError(f"Failed to load DICOM image: {e}")

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/shaunporwal/DICOM-MCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server