$npx -y skills add K-Dense-AI/scientific-agent-skills --skill imaging-data-commonsQuery and download public cancer imaging data from NCI Imaging Data Commons using idc-index. Use for accessing large-scale radiology (CT, MR, PET) and pathology datasets for AI training or research. No authentication required. Query by metadata, visualize in browser, check licens
| 1 | # Imaging Data Commons |
| 2 | |
| 3 | ## Overview |
| 4 | |
| 5 | Use the `idc-index` Python package to query and download public cancer imaging data from the National Cancer Institute Imaging Data Commons (IDC). No authentication required for data access. |
| 6 | |
| 7 | **Current IDC Data Version: v23** (always verify with `IDCClient().get_idc_version()`) |
| 8 | |
| 9 | **Primary tool:** `idc-index` ([GitHub](https://github.com/imagingdatacommons/idc-index)) |
| 10 | |
| 11 | **CRITICAL - Check package version and upgrade if needed (run this FIRST):** |
| 12 | |
| 13 | ```python |
| 14 | import idc_index |
| 15 | |
| 16 | REQUIRED_VERSION = "0.11.14" # Must match metadata.idc-index in this file |
| 17 | installed = idc_index.__version__ |
| 18 | |
| 19 | if installed < REQUIRED_VERSION: |
| 20 | print(f"Upgrading idc-index from {installed} to {REQUIRED_VERSION}...") |
| 21 | import subprocess |
| 22 | subprocess.run(["pip3", "install", "--upgrade", "--break-system-packages", "idc-index"], check=True) |
| 23 | print("Upgrade complete. Restart Python to use new version.") |
| 24 | else: |
| 25 | print(f"idc-index {installed} meets requirement ({REQUIRED_VERSION})") |
| 26 | ``` |
| 27 | |
| 28 | **Verify IDC data version and check current data scale:** |
| 29 | |
| 30 | ```python |
| 31 | from idc_index import IDCClient |
| 32 | client = IDCClient() |
| 33 | |
| 34 | # Verify IDC data version (should be "v23") |
| 35 | print(f"IDC data version: {client.get_idc_version()}") |
| 36 | |
| 37 | # Get collection count and total series |
| 38 | stats = client.sql_query(""" |
| 39 | SELECT |
| 40 | COUNT(DISTINCT collection_id) as collections, |
| 41 | COUNT(DISTINCT analysis_result_id) as analysis_results, |
| 42 | COUNT(DISTINCT PatientID) as patients, |
| 43 | COUNT(DISTINCT StudyInstanceUID) as studies, |
| 44 | COUNT(DISTINCT SeriesInstanceUID) as series, |
| 45 | SUM(instanceCount) as instances, |
| 46 | SUM(series_size_MB)/1000000 as size_TB |
| 47 | FROM index |
| 48 | """) |
| 49 | print(stats) |
| 50 | ``` |
| 51 | |
| 52 | **Core workflow:** |
| 53 | 1. Query metadata → `client.sql_query()` |
| 54 | 2. Download DICOM files → `client.download_from_selection()` |
| 55 | 3. Visualize in browser → `client.get_viewer_URL(seriesInstanceUID=...)` |
| 56 | |
| 57 | ## When to Use This Skill |
| 58 | |
| 59 | - Finding publicly available radiology (CT, MR, PET) or pathology (slide microscopy) images |
| 60 | - Selecting image subsets by cancer type, modality, anatomical site, or other metadata |
| 61 | - Downloading DICOM data from IDC |
| 62 | - Checking data licenses before use in research or commercial applications |
| 63 | - Visualizing medical images in a browser without local DICOM viewer software |
| 64 | |
| 65 | ## Quick Navigation |
| 66 | |
| 67 | **Core Sections (inline):** |
| 68 | - IDC Data Model - Collection and analysis result hierarchy |
| 69 | - Index Tables - Available tables and joining patterns |
| 70 | - Installation - Package setup and version verification |
| 71 | - Core Capabilities - Essential API patterns (query, download, visualize, license, citations, batch) |
| 72 | - Best Practices - Usage guidelines |
| 73 | - Troubleshooting - Common issues and solutions |
| 74 | |
| 75 | **Reference Guides (load on demand):** |
| 76 | |
| 77 | | Guide | When to Load | |
| 78 | |-------|--------------| |
| 79 | | `index_tables_guide.md` | Complex JOINs, schema discovery, DataFrame access | |
| 80 | | `use_cases.md` | End-to-end workflow examples (training datasets, batch downloads) | |
| 81 | | `sql_patterns.md` | Quick SQL patterns for filter discovery, annotations, size estimation | |
| 82 | | `clinical_data_guide.md` | Clinical/tabular data, imaging+clinical joins, value mapping | |
| 83 | | `cloud_storage_guide.md` | Direct S3/GCS access, versioning, UUID mapping | |
| 84 | | `dicomweb_guide.md` | DICOMweb endpoints, PACS integration | |
| 85 | | `digital_pathology_guide.md` | Slide microscopy (SM), annotations (ANN), pathology workflows | |
| 86 | | `bigquery_guide.md` | Full DICOM metadata, private elements (requires GCP) | |
| 87 | | `cli_guide.md` | Command-line tools (`idc download`, manifest files) | |
| 88 | | `parquet_access_guide.md` | Direct Parquet queries via GCS (no idc-index install needed) | |
| 89 | |
| 90 | ## IDC Data Model |
| 91 | |
| 92 | IDC adds two grouping levels above the standard DICOM hierarchy (Patient → Study → Series → Instance): |
| 93 | |
| 94 | - **collection_id**: Groups patients by disease, modality, or research focus (e.g., `tcga_luad`, `nlst`). A patient belongs to exactly one collection. |
| 95 | - **analysis_result_id**: Identifies derived objects (segmentations, annotations, radiomics features) across one or more original collections. |
| 96 | |
| 97 | Use `collection_id` to find original imaging data, may include annotations deposited along with the images; use `analysis_result_id` to find AI-generated or expert annotations. |
| 98 | |
| 99 | **Key identifiers for queries:** |
| 100 | | Identi |