一键导入
medical-image-resampler
Resample NIfTI medical images to target spacing with configurable interpolation methods and optional anti-aliasing for downsampling.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Resample NIfTI medical images to target spacing with configurable interpolation methods and optional anti-aliasing for downsampling.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Scan medical imaging directories and generate structured JSON or CSV manifests with file-level metadata for DICOM and NIfTI assets.
Validates DICOM series consistency by checking SeriesInstanceUID, ImageOrientationPatient, slice spacing uniformity, and detecting missing slices.
Normalizes medical image intensities using various methods (z-score, min-max, percentile, window-level). Essential preprocessing step for consistent analysis across different scanners and protocols.
Generate research-oriented HTML or Markdown case reports for volumetric medical images, including summary statistics and slice montages.
Generates a complete MONAI-based training scaffold for medical image segmentation or classification tasks. Creates training scripts, inference scripts, configuration files, data loading pipelines, and model definitions.
Validates NIfTI file headers for integrity and consistency. Checks header structure, dimension consistency, orientation matrix, data type support, and file size expectations.
| name | medical-image-resampler |
| description | Resample NIfTI medical images to target spacing with configurable interpolation methods and optional anti-aliasing for downsampling. |
| version | 0.1.0 |
| author | Medical AI Team <team@example.com> |
| license | MIT |
| tags | ["preprocessing","resampling","spatial","nifti"] |
| maturity | stable |
| category | preprocessing |
| requires_extras | ["core"] |
This skill resamples NIfTI medical images to a target voxel spacing using various interpolation methods. It supports isotropic and anisotropic resampling, with optional anti-aliasing filtering for downsampling operations to prevent aliasing artifacts.
Use this skill when you need to:
pip install -r requirements.txt
Dependencies:
./scripts/main.py [OPTIONS] INPUT_PATH
| Argument | Required | Description |
|---|---|---|
input_path | Yes | Path to input NIfTI file (.nii or .nii.gz) |
| Option | Default | Description |
|---|---|---|
--output, -o | stdout | Output file path (required) |
--spacing | - | Target spacing: "1.0,1.0,1.0" or single value "1.0" |
--interpolation | linear | Interpolation method: linear, nearest, cubic |
--anti-aliasing | false | Apply anti-aliasing filter for downsampling |
--verbose, -v | false | Enable verbose logging |
--version | - | Show version and exit |
--help | - | Show help message |
File Format: NIfTI-1 or NIfTI-2 (.nii, .nii.gz)
Requirements:
{
"success": true,
"result": {
"input_path": "string - path to input file",
"output_path": "string - path to output file",
"input_spacing": [float, float, float],
"output_spacing": [float, float, float],
"input_shape": [int, int, int],
"output_shape": [int, int, int],
"interpolation": "string - method used",
"anti_aliasing": "boolean - whether applied",
"resampling_factors": [float, float, float]
},
"metadata": {
"timestamp": "ISO 8601 timestamp",
"duration_ms": 123,
"version": "0.1.0"
}
}
NIfTI file with:
| Code | Meaning |
|---|---|
| 0 | Success |
| 1 | Validation error (invalid NIfTI, invalid parameters) |
| 2 | Runtime error (file I/O, resampling failure) |
| 3 | Usage error (missing required arguments) |
./scripts/main.py brain.nii.gz -o brain_1mm.nii.gz --spacing 1.0 --verbose
Output:
{
"success": true,
"result": {
"input_path": "brain.nii.gz",
"output_path": "brain_1mm.nii.gz",
"input_spacing": [0.8, 0.8, 1.2],
"output_spacing": [1.0, 1.0, 1.0],
"input_shape": [256, 256, 150],
"output_shape": [205, 205, 125],
"interpolation": "linear",
"anti_aliasing": false,
"resampling_factors": [1.25, 1.25, 0.96]
},
"metadata": {
"timestamp": "2024-01-15T10:30:00",
"duration_ms": 1250,
"version": "0.1.0"
}
}
./scripts/main.py spine.nii.gz -o spine_resampled.nii.gz --spacing "0.5,0.5,2.0" --interpolation cubic
./scripts/main.py high_res.nii.gz -o low_res.nii.gz --spacing "2.0,2.0,2.0" --anti-aliasing
for f in data/*.nii.gz; do
./scripts/main.py "$f" -o "resampled/$(basename $f)" --spacing 1.0
done
| Method | Description | Use Case |
|---|---|---|
nearest | Nearest neighbor interpolation | Labels/segmentations, preserving discrete values |
linear | Trilinear interpolation (default) | General purpose, continuous intensity data |
cubic | Tricubic interpolation | High-quality resampling, smooth data |
When downsampling (increasing voxel size), high-frequency content can cause aliasing artifacts. The --anti-aliasing flag applies a Gaussian pre-filter before resampling.
The filter sigma is automatically computed based on the resampling factor:
The skill handles the following error cases:
| Error | Exit Code | Message |
|---|---|---|
| Input file not found | 2 | "Input file not found: {path}" |
| Invalid NIfTI format | 1 | "Invalid NIfTI file: {reason}" |
| Invalid spacing format | 3 | "Invalid spacing format: expected 'x,y,z' or single value" |
| Invalid spacing values | 1 | "Spacing values must be positive" |
| Invalid interpolation | 3 | "Invalid interpolation method" |
| Output write failure | 2 | "Failed to write output: {reason}" |
For research use only. This skill is not intended for clinical use.