def demo_gap():print("=== Gap Demo ===") t = copy.deepcopy(meta) n = t.slice_count gap_numbers =list(range(1, n+1))for i inrange(3, len(gap_numbers)): gap_numbers[i] +=1 t.set_nonshared_item(CommonTags.InstanceNumber, gap_numbers)print("Gap InstanceNumber ->", get_dicom_status(t).value) nums =sorted([int(x) for x in t.get_values(CommonTags.InstanceNumber)]) diffs = [nums[i+1]-nums[i] for i inrange(len(nums)-1)]print("diffs:", diffs[:7], "...")demo_gap()
=== Gap Demo ===
Gap InstanceNumber -> gap_instance_number
diffs: [1, 1, 2, 1, 1, 1, 1] ...
Location‑Related Issues
Missing location (both ImagePositionPatient and SliceLocation absent)
Dwelling location (repeated positions)
Reversed location (mixed forward/backward)
Gap location (irregular large gaps vs average spacing)
Compatibility Strategy
DiCube keeps working under imperfect data with clear limitations:
Pixels: load/process normally, apply rescale if needed
Metadata: retain all tags for round‑trip integrity
Space: set to None and warn if spatial consistency fails
Limitations: spatial ops (transform, resample, registration) disabled without valid space
Priority: Report Only the Most Severe Issue
Checks follow severity order (Series UID, Instance Number, dtype, spacing/shape/orientation, location, others). Only the first failing category is reported to avoid overload.
Summary
CONSISTENT = regular 3D grid
Non‑location issues: missing / non_uniform / gap / duplicate
Location issues: dwelling / reversed / gap
Fail‑soft design: keep working where possible, restrict spatial ops when invalid
Severity‑ordered reporting to focus on root cause first