image-data-utilities
Prepare, validate, convert, and display chest X-ray image inputs while preserving DICOM originals and reporting utility metadata.
- License 许可
- Apache-2.0
- 最近更新
- 2026-10-08
- Stars
- ★ 11
- Forks
- 3
01 前言 Front Matter
- name
- image-data-utilities
- license
- Apache 2.0
- metadata
- { "disco-role": "operating" }
- description
- Prepare, validate, convert, and display chest X-ray image inputs while preserving DICOM originals and reporting utility metadata.
- disable-model-invocation
- true
02 资源文件 4
- 参考文档references/api-reference.md5.0 KB
- 参考文档references/data-formats.md4.5 KB
- 参考文档references/troubleshooting.md5.0 KB
- 参考文档references/workflows.md5.0 KB
03 SKILL.md 正文
Image-data utilities
Use this skill when a chest X-ray input must be checked, made viewable, or handed between the upload/UI layer and an image-capable tool. It covers the two utility tools:
DicomProcessorToolconverts a DICOM pixel array to a temporary PNG and returns conversion metadata.ImageVisualizerToolvalidates a JPG/PNG path and returns the path plus display metadata. Its normal_runpath reports a display result; it does not call the matplotlib rendering method in the current implementation.
This skill does not perform model inference. Route interpretation, classification, segmentation, grounding, or report generation to chest-xray-analysis. Route LangGraph construction to agent-orchestration, upload widgets, chat history, and Gradio state to web-interface, and benchmark data preparation to benchmark-evaluation.
Operating contract
- Keep the input path and its role explicit:
original_pathis the preserved source used for archival or a tool that explicitly supports that format;display_pathis a viewable PNG/JPG path for the UI or an image-only tool. - Validate a path before invoking a utility. Use the bundled
scripts/validate_image_input.pyfor existence, supported suffix, lightweight file-signature, and optional output-directory checks. - For DICOM, preserve the original file first. Convert a working/display copy
with
DicomProcessorTool; never replace the original with the generated PNG. - Treat DICOM-derived fields such as
PatientIDandStudyDateas sensitive. Pass only the metadata needed by the next step, avoid logging it, and do not claim that conversion anonymizes the source. - Inspect the returned tuple for an
errorkey before usingimage_path. Utility failures are data-preparation failures, not evidence about the patient's image.
See api-reference.md for exact inputs and outputs, data-formats.md for format and privacy rules, workflows.md for path handoffs, and troubleshooting.md for recovery actions.
Choose the path
Existing PNG/JPG/JPEG
- Validate the file and optional destination directory.
- Pass the existing image path to
ImageVisualizerTool._runwhen a display record is required. - Pass that same path to a downstream model tool only when its contract accepts the format. Keep this utility step separate from model-specific preprocessing.
ImageVisualizerInput documents JPG and PNG. JPEG is commonly represented by
.jpg or .jpeg; do not silently accept an arbitrary suffix merely because a
reader might open it.
DICOM
- Validate the original file as DICOM-like input without dumping tags.
- Call
DicomProcessorTool._run(dicom_path, window_center, window_width). - If both window parameters are absent, the tool first uses the first value of
DICOM
WindowCenter/WindowWidthwhen present. If either is still absent, it uses a min/max scale. If both are present, it clips and scales to uint8. - If
RescaleSlopeandRescaleInterceptare both present, apply them before windowing or min/max scaling (as the tool does). - Use returned
image_pathas the display path and retain the original DICOM path as the source path. The metadata also recordsoriginal_pathandoutput_pathon success. - Use the PNG for a model tool that only reads JPG/PNG/PIL/skimage inputs. A DICOM conversion is not a promise that every model tool can read DICOM.
A caller may supply a positive window width and a clinically appropriate center when the source values are known. Do not invent window settings to compensate for a malformed file; fix or reroute the input instead.
Display parameters
ImageVisualizerTool._run accepts image_path, optional title, optional
description, figsize=(width, height), and cmap="rgb". For a grayscale CXR,
use a grayscale colormap such as "gray" when actual rendering is requested.
The implementation treats "rgb" specially and passes other colormap names to
matplotlib. If a non-rgb colormap is selected for a multi-channel array, its
renderer keeps only the first channel.
The success result is a two-item tuple: output={"image_path": image_path} and
metadata containing whether title/description were supplied, the requested
figsize and cmap, and analysis_status="completed". A missing file returns
an error tuple; do not treat that as a successful visualization.
UI path distinction
The interface stores uploaded data in managed temporary storage. It keeps an
original_file_path for the uploaded file and a separate display_file_path.
For a .dcm upload it converts only for display; for a regular image the two
paths can be the same. UI rendering should use display_file_path, while a
message/tool handoff must choose the path according to the receiving tool's
format contract. In particular, do not encode raw DICOM bytes as if they were a
JPEG data URL. If an image API needs base64, encode the PNG display derivative
and use its actual image MIME type, while retaining the original for archival
or explicitly DICOM-aware processing.
The utility result from image_visualizer contains the path to show in the UI;
it is not a model answer. See web-interface for
state and event handling.
Safety and cleanup
- Do not print full DICOM metadata or embed sensitive tags in titles, descriptions, chat messages, or benchmark records.
- Use a caller-owned temporary/output directory with appropriate permissions.
The DICOM tool creates a unique
processed_dicom_<token>.png; it does not anonymize or automatically delete that file. - Clean generated derivatives only through an explicit, narrowly scoped cleanup policy owned by the caller. Never delete the original input as part of this skill.
- Stop on a missing path, unsupported suffix, invalid pixel data, or unwritable destination and report the actionable error. Do not fall back to a random file or silently reinterpret a DICOM as an ordinary image.
04 同仓库更多 Skills
obsidian-clipper-template-creator
Guide for creating templates for the Obsidian Web Clipper. Use when you want to create a new clipping template, understand available variables, or format clipped content.
obsidian-clipper-template-creator
Guide for creating templates for the Obsidian Web Clipper. Use when you want to create a new clipping template, understand available variables, or format clipped content.
python-api
Programmatic Object-Detection-Metrics API guidance for BoundingBox, BoundingBoxes, Evaluator, enums, coordinate conversion, AP/mAP semantics, and source-style import diagnostics.
file-evaluation
Folder-based PASCAL VOC AP/mAP evaluation from ground-truth and detection text files.
object-detection-metrics
Guides legacy Object-Detection-Metrics PASCAL VOC AP/mAP evaluation from detection text folders and direct Python API classes.
nx-workspace-patterns
Configure and optimize Nx monorepo workspaces. Use when setting up Nx, configuring project boundaries, optimizing build caching, or implementing affected commands.