Skip to content

Commit 7d8b8c3

Browse files
fedorovclaude
andcommitted
Add indices_overview code example and troubleshooting for missing columns
Addresses the failure mode where agents query `index` for modality-specific parameters (SliceThickness, KVP, etc.) instead of using ct_index/mr_index/pt_index. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 06d9690 commit 7d8b8c3

2 files changed

Lines changed: 40 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/).
1919

2020
### Changed
2121

22+
- Added concrete `indices_overview` code example showing how to search for a column across all tables and read column schemas without fetching the table; directly addresses the failure mode where agents query `index` for modality-specific parameters (SliceThickness, KVP, etc.) instead of using `ct_index`/`mr_index`/`pt_index`
23+
- Added troubleshooting entry "Column not found in `index` table" with a working `indices_overview` search snippet and join example, covering common acquisition/reconstruction parameters that live in the modality-specific index tables
2224
- Updated idc-index reference to 0.12.3
2325
- Clarified `download_from_selection` API: added explicit warning that it takes filter keyword arguments (not a DataFrame), comparison table vs `download_dicom_series` (which has a different first-argument order), and restructured the download example as a step-by-step query → extract UIDs → pass list flow
2426
- Documented `download_dicom_series` as an alternative download method with its own signature (`seriesInstanceUID` as first arg, then `downloadDir`)

SKILL.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,25 @@ The `idc-index` package provides multiple metadata index tables, accessible via
126126

127127
**Important:** Use `client.indices_overview` to get current table descriptions and column schemas. This is the authoritative source for available columns and their types — always query it when writing SQL or exploring data structure.
128128

129+
```python
130+
from idc_index import IDCClient
131+
132+
client = IDCClient()
133+
134+
# Find which table(s) contain a specific column (no fetch required)
135+
target = "SliceThickness"
136+
for table_name, info in client.indices_overview.items():
137+
if any(c["name"] == target for c in info["schema"]["columns"]):
138+
print(f"'{target}' is in: {table_name}")
139+
# → 'SliceThickness' is in: ct_index
140+
141+
# List all columns in a table from the schema (no fetch required)
142+
ct_cols = [c["name"] for c in client.indices_overview["ct_index"]["schema"]["columns"]]
143+
print("ct_index columns:", ct_cols)
144+
# → ['SeriesInstanceUID', 'PixelSpacing_row_mm', 'PixelSpacing_col_mm', 'Rows',
145+
# 'Columns', 'SliceThickness', 'KVP', 'ConvolutionKernel', ...]
146+
```
147+
129148
### Available Tables
130149

131150
Always call `client.fetch_index("table_name")` before querying any index table — it is safe and idempotent for all tables, including those loaded automatically at startup.
@@ -703,6 +722,25 @@ See `references/bigquery_guide.md` for schemas, column descriptions, and query e
703722
- Use `LIMIT 5` to test query first
704723
- Check field names against metadata schema documentation
705724

725+
**Issue: Column not found in `index` table (e.g., `SliceThickness`, `PixelSpacing`, `KVP`, `EchoTime`, `InjectedDose`)**
726+
- **Cause:** The `index` table contains series-level metadata only; modality-specific acquisition and reconstruction parameters live in dedicated tables (`ct_index`, `mr_index`, `pt_index`)
727+
- **Solution:** Search `client.indices_overview` to find the right table, then fetch and join on `SeriesInstanceUID`:
728+
```python
729+
target = "SliceThickness"
730+
for table_name, info in client.indices_overview.items():
731+
if any(c["name"] == target for c in info["schema"]["columns"]):
732+
print(f"Found in: {table_name}")
733+
# → Found in: ct_index
734+
735+
client.fetch_index("ct_index")
736+
result = client.sql_query("""
737+
SELECT i.SeriesInstanceUID, i.Modality, c.SliceThickness, c.KVP, c.PixelSpacing_row_mm
738+
FROM index i
739+
JOIN ct_index c USING (SeriesInstanceUID)
740+
WHERE i.collection_id = 'your_collection'
741+
""")
742+
```
743+
706744
**Issue: Downloaded DICOM files won't open**
707745
- **Cause:** Corrupted download or incompatible viewer
708746
- **Solution:**

0 commit comments

Comments
 (0)