image-core
Create, read, write, inspect, clone, index, compare, and validate ANTsPy ANTsImage objects while preserving physical-space metadata.
- License 许可
- Apache-2.0
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- image-core
- license
- Apache 2.0
- metadata
- { "disco-role": "operating" }
- description
- Create, read, write, inspect, clone, index, compare, and validate ANTsPy ANTsImage objects while preserving physical-space metadata.
- disable-model-invocation
- true
02 资源文件 4
- 参考文档references/api-reference.md12.7 KB
- 参考文档references/troubleshooting.md9.6 KB
- 参考文档references/workflows.md7.7 KB
- 脚本scripts/antspy_image_smoke.py4.3 KB
03 SKILL.md 正文
ANTsPy Image Core
Use this sub-skill when a task is about the ants.ANTsImage lifecycle: constructing images from NumPy arrays, reading or writing image files, inspecting pixel type and physical metadata, cloning or casting images, indexing image data, comparing image values, checking physical-space consistency, or using packaged ANTsPy fixture data.
Start Here
- Import the public package as
import ants; the package distribution isantspyx. - For verified signatures, parameter notes, metadata semantics, and dtype rules, read API reference.
- For practical recipes, use workflows for creation, IO, NumPy round trips, metadata repair, indexing, and vector/RGB images.
- For common failures, use troubleshooting before changing image data or metadata.
- For a tiny deterministic runtime check, run scripts/antspy_image_smoke.py in an environment with
antspyxinstalled.
Core Rules
ANTsImagestores voxel values plus physical-space metadata:origin,spacing,direction,dimension,pixeltype,dtype,shape,components, and RGB/vector flags.img.numpy()returns a copy; editing it does not mutate the image.img.view()returns shared memory; editing it mutates the image.ants.from_numpy(array)uses default physical metadata unlessorigin,spacing, anddirectionare passed. Preferimg.new_image_like(array)orants.from_numpy_like(array, img)for metadata-preserving array transforms.- Image-image arithmetic and image-mask indexing require matching physical space. Check with
ants.image_physical_space_consistency(a, b); usedatatype=Truewhen pixel type and component count must also match. ants.allclose(a, b)compares voxel arrays only and does not prove matching physical metadata.- Supported scalar pixel types are
unsigned char,unsigned int,float, anddouble; NumPy names map touint8,uint32,float32, andfloat64with constructor caveats in API reference.
Route Elsewhere
- Filtering, masks, thresholding,
iMath, morphology, cropping/padding, denoising, and resampling details: image-ops-math. - Registration workflows, transform application chains, transform IO, displacement fields, motion correction, Jacobians, and templates: registration-transforms.
- Segmentation, labels, overlap metrics, label geometry, label matrices, and point images: segmentation-labels.
- Plotting, RGB display, animation, image-to-matrix interop, nibabel, SimpleITK, and external visualization formats: visualization-interop.
- Deep learning patch extraction, augmentation, one-hot utilities, and learning-specific array/image preparation: learning-deeplearn.
Boundary Notes
ants.ANTsTransform,ants.create_ants_transform,ants.read_transform, andants.write_transformare mentioned here only to distinguish image metadata from transform objects. Use registration-transforms for transform construction, application, composition, inversion, or registration output handling.- Channel utilities such as
merge_channels,split_channels,rgb_to_vector, andvector_to_rgbare core enough for diagnosing vector/RGBANTsImageshape and component semantics; display-oriented RGB workflows route to visualization/interop.
References
- API reference: verified signatures, properties, constructors, IO, metadata setters/getters, pixel types, indexing, comparisons, fixture data, and transform-routing boundaries.
- Workflows: self-contained recipes for image creation, read/write, NumPy conversion, metadata validation, indexing, component images, and fixture use.
- Troubleshooting: import/backend failures, dtype and list input errors, physical-space mismatches, RGB/vector component confusion, IO/header failures, and indexing pitfalls.
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).