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-09-03
- Stars
- ★ 351
- Forks
- 27
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 资源文件 5
- 参考文档references/api-reference.md5.0 KB
- 参考文档references/data-formats.md4.5 KB
- 参考文档references/troubleshooting.md5.0 KB
- 参考文档references/workflows.md5.0 KB
- 脚本scripts/validate_image_input.py8.6 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
passnet-triton-opt
Make a single PassNet Triton kernel fast AND numerically faithful: performance model (when a replacement can win at all), block/grid/warp tuning, autotune policy, launch overhead, and per-op numeric recipes to pass the dtype baseline tolerances. Use when a pass matches and is correct but speedup below expected, or when correctness fails by small numeric margins.
passnet-solve
END-TO-END playbook for solving one PassNet sample: analyze the computation graphs, decide the optimization strategy (what to fuse, what to replace, what to leave alone), drive the iteration loop, and maximize the sample score. This is the ENTRY skill — invoke it first for any PassNet optimization task; it tells you when to use passnet-pattern-fusion, passnet-triton-opt and passnet-feedback.
passnet-skill
PassNet GPU kernel optimization via compiler passes. Design and implement Triton-based optimization passes, create pass files under ./pass_dir/, self-evaluate with pass_evaluator, and iterate to maximize GPU speedup.
passnet-pattern-fusion
Author PassNet pass files: write patterns that actually MATCH the FX graph, pick fusion regions (which ops to absorb into one Triton kernel), and structure multi-pass submissions with the mandatory shared-dispatch architecture. Use when creating or fixing pattern()/replacement_args()/replacement_func() files, when a pass "failed to match", or when deciding how to fuse multiple kernels/ops.
passnet-orchestrate
Round/batch planning and decision support for PassNet graph optimization. Use for multi-sample triage, worker allocation, eval-budget policy, and post-eval keep/revert decisions. For solving one concrete sample end to end, use passnet-solve as the entry skill; consult this skill only when you need broader planning or a specific decision gate.
passnet-feedback
Fast, deterministic feedback for PassNet work: pre-flight pattern/match verification WITHOUT burning a GPU evaluation, per-node bottleneck analysis of a sample's graphs, and eval-log parsing into per-variant status + estimated score + failure classification. Use BEFORE every GPU evaluation (check_pattern), at the START of a sample (analyze_graph), and AFTER every evaluation (parse_eval_log).