Introduce a robust coordinate transformation system to manage the relationship
between original CT space and rotated/standardized segmentation spaces.
This includes a new directory hierarchy to separate unrotated crops from
rotated outputs and utility functions for geometric mapping.
Key changes:
- Implement `imaging/transforms.py` to handle bounding box metadata,
affine standardization, and coordinate mapping between spaces.
- Restructure dataset output: unrotated segmentation files (binary, SDF,
ROI, etc.) are now stored in a `<vol>/crop/` subdirectory to distinguish
them from `<vol>/rotated/` aligned versions.
- Add `level_file_path` utility to abstract file discovery across legacy
(top-level) and new (crop-based) directory structures.
- Enhance `seg_bone` to capture and export bounding box metadata
(`bbox2`, `nn_bbox`, `bbox_orig`) into `transform.json`.
- Implement `xfr_cbt_native.py` for mapping screw positions back to
original CT space.
- Update preprocessing and visualization scripts to support the new
directory layout and transformation metadata.
- Improve TinyDB metadata migration logic to prevent accidental corruption
of existing database structures.
Refactor the preprocessing and segmentation pipeline to handle AP orientation
variations and improve anatomical boundary detection.
Key changes include:
- Implement automated AP orientation detection in `process_single_image`
to handle prone scans by flipping CT and labels when necessary.
- Enhance `segment_spinous_process` using a gap-based approach to identify
the spinal canal, providing more stable thresholds for spinous process
and vertebral body segmentation.
- Improve optimization search space by using the vertebral body (VBODY)
projection for x/z bounding box calculation instead of the whole bone.
- Refactor `render_bone_figure` to unify 2D/3D visualization and support
detailed anatomical coloring (VBODY, spinous process).
- Update `cl_score_torch_xfr` with more robust penalty handling for
out-of-bone and null-voxel regions.
- Add `retry_robust` utility to handle transient NFS file system errors.
- Update `xfr_preprocess.py` to include anatomical segmentation coloring
in rotated level visualizations.