Repository navigation
Tutorial proposal: validated CT/DICOM SEG tensors with patient-disjoint splits #115
Description
Hi IDC team,
Following our LinkedIn discussion about the IDC catalog on Hugging Face, I would like to contribute a compact, CPU-friendly notebook that takes a small public CT/DICOM SEG cohort through correspondence checks, tensor conversion, and a reproducible patient-disjoint train/test split.
The Getting Started Part 2 notebook already covers searching, downloading, and CT/SEG visualization. This contribution would build on it, focusing on validation and preparing traceable inputs for a PyTorch segmentation workflow.
Proposed dataset and scope
My initial candidate is C4KC-KiTS, which includes CT and manually annotated kidney/tumor segmentations. The TCIA collection page documents the acquisition phases, DICOM SEG conversion history, and CC BY 3.0 license.
I propose a default cohort of four patients, with the estimated download size shown before downloading and processing one case at a time. The first version would support single-frame CT series and BINARY SEG objects on the same spatial grid; unsupported or ambiguous cases would produce an explicit validation error.
Notebook workflow
- Discover and record the cohort. Use the Hugging Face catalog and/or
idc-indexfor discovery andidc-indexfor downloads, without requiring a BigQuery account. Record the catalog revision/IDC release, package versions, patient/study/series UIDs, selected SEG instances, licenses, and source citations. - Resolve CT↔SEG correspondence. Follow the SEG's referenced series and source SOP Instance UIDs to select the correct CT reconstruction/phase. Matching PatientID or StudyInstanceUID alone is insufficient.
- Validate spatial alignment. Check frame of reference, orientation, positions, spacing, dimensions, and source-instance coverage. Sort CT slices geometrically and reconstruct SEG frames in the corresponding source-instance order using
highdicom. Distinguish omitted empty segmentation frames from missing CT data; reject incompatible grids rather than silently resampling. - Create tensors and inspect overlays. Apply CT modality rescaling to HU. Export a
float32image tensor[1, D, H, W], binary mask channels[K, D, H, W], and spatial metadata. Preserve segment numbers, labels, and coded meanings in a channel mapping, including consistent semantic mapping across cases. Keep overlapping segments separate. Show representative CT/mask overlays and summary checks. - Split by patient. Use a fixed seed and stable patient ordering; keep every study, series, and slice belonging to a patient in one partition. Export a split manifest and assert that patient sets are disjoint. This small split is an instructional example within the public data, not the official KiTS challenge evaluation split.
- Demonstrate consumption. Provide a minimal PyTorch Dataset example, without training a model or requiring a GPU.
Deliverable and validation
A proposed location is notebooks/advanced_topics/ct_seg_to_tensors.ipynb, with a README entry and the repository's required Colab link, update date, Support, and Acknowledgments sections.
Before submitting a PR, I would run the notebook end to end on the selected real cohort, check UID/geometry correspondence and patient separation, and record the actual download size and runtime. Any intensity normalization would be explicit and separate from the HU data.
Would C4KC-KiTS and this scope be a useful starting point, or would you prefer another CT/SEG collection or notebook location? I can prepare the PR around your recommendation.
Best regards,
Denis
Activity
fedorov commentedon Oct 13, 2026
@denis-samatov thank you for the initiative and your contribution!
I took a quick glance over the notebook, and will need more time to better understand, but I do have several comments right away. I think quite a bit of what you prepared can be simplified using the capabilities already available in
idc-indexandhighdicom.The segmented series is already captured in
seg_indextable available viaidc-index. You do not need to do the mapping manually!We have most if not all of those checks pre-computed and available via the
volume_geometry_indextable!I believe this can already be done using the functionality implemented in
highdicom, as discussed in https://huggingface.co/datasets/ImagingDataCommons/idc-index-data#loading-images-as-tensors.Did you consider the above approaches? Do you have reasons not to use those?
I understand this kind of details may not be easy to find. I recommend you give a try to the skill and hosted MCP server we maintain to support IDC users, see https://learn.canceridc.dev/ai-assistants/agents.
denis-samatov commentedon Oct 15, 2026
fedorov commentedon Oct 15, 2026
Thank you for the quick response! I approved the workflow, which passed, and will comment in the PR after I make the time to review!