Update imaging-data-commons skill from v1.4.0 to upstream v1.8.1

Rebased onto current main and re-synced from
ImagingDataCommons/imaging-data-commons-skill, which now holds SKILL.md under 500
lines upstream. references/core_capabilities.md is therefore removed rather than
refreshed: its content was redistributed into the topical guides that already own
each subject (sql_patterns, index_tables_guide, cli_guide, licensing_and_citation)
instead of a catch-all file, and upstream CI holds the budget so the split does not
have to be redone after each sync.

New since v1.4.0: the hosted IDC MCP server and REST API as first-class access paths
(references/mcp_guide.md, references/rest_api_guide.md), so a metadata question no
longer requires a ~77 MB idc-index install; licensing_and_citation.md; idc-index
0.12.5 / IDC data v24; scripts/check_version.py as the startup version check.

tests/imaging-data-commons/test_check_version.py covers the bundled script: offline,
standard library only, no idc-index needed. It is a copy of the upstream file, which
is written to be vendored — only two path constants and the frontmatter-version
assertion differ.

Verified: pytest tests/_meta tests/imaging-data-commons -> 29 passed, 1030 subtests;
skills-ref validate skills/imaging-data-commons -> valid; SKILL.md 495 lines.
This commit is contained in:
Andrey Fedorov committed 2026-08-10 17:06:22 -04:00
1 parent 7eb9c23c32
commit aaf763c3a6
17 files changed
+2099 -821

No files matched your search

@@ -1,6 +1,6 @@
# SQL Query Patterns for IDC
**Tested with:** idc-index 0.11.14 (IDC data version v23)
**Tested with:** idc-index 0.12.5 (IDC data version v24)
Quick reference for common SQL query patterns when working with IDC data. For detailed examples with context, see the "Core Capabilities" section in the main SKILL.md.
@@ -14,20 +14,73 @@ Load this guide when you need quick-reference SQL patterns for:
- Linking imaging data to clinical data
- Filtering by 3D volume geometry validity (volume_geometry_index)
- Finding RT Structure Set series and ROI metadata (rtstruct_index)
- Filtering by CT/MR/PET acquisition parameters (ct_index, mr_index, pt_index)
For table schemas, DataFrame access, and join column references, see `references/index_tables_guide.md`.
## Prerequisites
```bash
uv pip install 'idc-index==0.11.14'
```
Needs `idc-index` installed — run `python scripts/check_version.py`, which reports the installed
version and prints the install command for the interpreter you are running.
```python
from idc_index import IDCClient
client = IDCClient()
```
## Overall Data Scale
Counts and total size across all of IDC — useful for orienting a user, and for sanity-checking
that the index loaded the release you expect:
```python
stats = client.sql_query("""
SELECT
COUNT(DISTINCT collection_id) as collections,
COUNT(DISTINCT analysis_result_id) as analysis_results,
COUNT(DISTINCT PatientID) as patients,
COUNT(DISTINCT StudyInstanceUID) as studies,
COUNT(DISTINCT SeriesInstanceUID) as series,
SUM(instanceCount) as instances,
SUM(series_size_MB)/1000000 as size_TB
FROM index
""")
print(stats)
```
### Per-collection breakdown
```python
# Get summary statistics from primary index
collections_summary = client.sql_query("""
SELECT collection_id,
COUNT(DISTINCT PatientID) as patients,
COUNT(DISTINCT SeriesInstanceUID) as series,
SUM(series_size_MB) as size_mb
FROM index
GROUP BY collection_id
ORDER BY patients DESC
""")
```
For richer per-collection metadata — cancer types, tumor locations, species, supporting data —
query `collections_index` instead; for derived datasets, `analysis_results_index`. Both need
`client.fetch_index(...)` first:
```python
client.fetch_index("collections_index")
collections_info = client.sql_query("""
SELECT collection_id, cancer_types, tumor_locations, species, subjects, supporting_data
FROM collections_index
""")
client.fetch_index("analysis_results_index")
analysis_info = client.sql_query("""
SELECT analysis_result_id, analysis_result_title, subjects, collections, modalities
FROM analysis_results_index
""")
```
## Discover Available Filter Values
```python
@@ -74,7 +127,7 @@ client.sql_query("""
# List analysis result collections (curated derived datasets)
client.fetch_index("analysis_results_index")
client.sql_query("""
SELECT analysis_result_id, analysis_result_title, Collections, Modalities
SELECT analysis_result_id, analysis_result_title, collections, modalities
FROM analysis_results_index
""")
@@ -187,6 +240,51 @@ client.sql_query("""
See `references/clinical_data_guide.md` for complete patterns including value mapping and patient cohort selection.
## Version Tracking — "What's New in IDC vX?"
Use `series_init_idc_version` and `series_revised_idc_version` in the main `index` table. Do NOT
use `prior_versions_index` for this — it contains only removed series.
```python
VERSION = 24 # Replace with target version
# Series added for the first time in vVERSION
client.sql_query(f"""
SELECT collection_id,
COUNT(DISTINCT SeriesInstanceUID) as new_series,
ROUND(SUM(series_size_MB)/1000, 2) as size_GB
FROM index
WHERE series_init_idc_version = {VERSION}
GROUP BY collection_id
ORDER BY new_series DESC
""")
# Series revised (updated content) in vVERSION but originally added earlier
client.sql_query(f"""
SELECT collection_id,
COUNT(DISTINCT SeriesInstanceUID) as revised_series
FROM index
WHERE series_revised_idc_version = {VERSION}
AND series_init_idc_version < {VERSION}
GROUP BY collection_id
ORDER BY revised_series DESC
""")
# When was each collection first added to IDC?
client.fetch_index("version_metadata_index")
client.sql_query("""
WITH first_versions AS (
SELECT collection_id, MIN(series_init_idc_version) as first_version
FROM index
GROUP BY collection_id
)
SELECT f.collection_id, f.first_version, v.version_timestamp as first_release_date
FROM first_versions f
JOIN version_metadata_index v ON f.first_version = v.idc_version
ORDER BY f.first_version DESC
""")
```
## Troubleshooting
**Issue:** Query returns error "table not found"
@@ -277,6 +375,84 @@ client.sql_query("""
""")
```
## Modality Acquisition Parameters
`ct_index`, `mr_index`, and `pt_index` (added in idc-index 0.12.3) expose acquisition and reconstruction parameters for CT, MR, and PET series. All join on `SeriesInstanceUID`. Dose-modulated CT acquisitions have `_min`/`_max` columns for tube current, exposure, and exposure time.
```python
client.fetch_index("ct_index")
client.fetch_index("mr_index")
client.fetch_index("pt_index")
# CT: thin-slice series (≤2mm) with standard reconstruction
client.sql_query("""
SELECT i.collection_id, i.SeriesInstanceUID, i.BodyPartExamined,
c.SliceThickness, c.ConvolutionKernel, c.KVP
FROM index i
JOIN ct_index c ON i.SeriesInstanceUID = c.SeriesInstanceUID
WHERE c.SliceThickness <= 2.0
AND c.ConvolutionKernel IS NOT NULL
LIMIT 10
""")
# CT: dose-modulated acquisitions (tube current varies across slices)
client.sql_query("""
SELECT i.collection_id, c.SeriesInstanceUID,
c.XRayTubeCurrent_min, c.XRayTubeCurrent_max, c.SliceThickness
FROM ct_index c
JOIN index i ON c.SeriesInstanceUID = i.SeriesInstanceUID
WHERE c.XRayTubeCurrent_min != c.XRayTubeCurrent_max
LIMIT 10
""")
# MR: DWI series (have non-null DiffusionBValue) at 3T
client.sql_query("""
SELECT i.collection_id, i.SeriesInstanceUID, i.SeriesDescription,
m.MagneticFieldStrength, m.DiffusionBValue
FROM index i
JOIN mr_index m ON i.SeriesInstanceUID = m.SeriesInstanceUID
WHERE m.DiffusionBValue IS NOT NULL
AND m.MagneticFieldStrength >= 2.9
LIMIT 10
""")
# MR: multi-echo series (EchoTime stored as array with multiple values)
client.sql_query("""
SELECT i.collection_id, i.SeriesInstanceUID,
m.EchoTime, m.EchoTrainLength, m.ScanningSequence
FROM index i
JOIN mr_index m ON i.SeriesInstanceUID = m.SeriesInstanceUID
WHERE m.EchoTrainLength > 1
LIMIT 10
""")
# PET: FDG studies with specific reconstruction method
client.sql_query("""
SELECT i.collection_id, i.SeriesInstanceUID,
p.RadionuclideCodeMeaning, p.ReconstructionMethod,
p.Units, p.DecayCorrection
FROM index i
JOIN pt_index p ON i.SeriesInstanceUID = p.SeriesInstanceUID
WHERE p.RadionuclideCodeMeaning LIKE '%fluorodeoxyglucose%'
LIMIT 10
""")
# PET: dynamic acquisitions (ActualFrameDuration is array with multiple values)
client.sql_query("""
SELECT i.collection_id, i.SeriesInstanceUID,
p.NumberOfTimeSlices, p.ActualFrameDuration
FROM index i
JOIN pt_index p ON i.SeriesInstanceUID = p.SeriesInstanceUID
WHERE p.NumberOfTimeSlices > 1
LIMIT 10
""")
```
Key columns by table (use `client.indices_overview["ct_index"]["schema"]` for the full list):
- **ct_index**: `SliceThickness`, `KVP`, `ConvolutionKernel`, `SpiralPitchFactor`, `XRayTubeCurrent_min/max`, `Exposure_min/max`, `PixelSpacing_row_mm/col_mm`, `Rows`, `Columns`
- **mr_index**: `MagneticFieldStrength`, `ScanningSequence`, `SequenceVariant`, `MRAcquisitionType`, `EchoTime` (array), `RepetitionTime`, `FlipAngle`, `DiffusionBValue` (array), `NumberOfTemporalPositions`, `ReceiveCoilName`
- **pt_index**: `RadionuclideCodeMeaning`, `Radiopharmaceutical`, `RadionuclideTotalDose`, `ReconstructionMethod`, `DecayCorrection`, `AttenuationCorrectionMethod`, `ActualFrameDuration` (array), `NumberOfTimeSlices`
## Resources
- `references/index_tables_guide.md` for table schemas, DataFrame access, and join column references