IDC BREAST-DIAGNOSIS: Breast Cancer MRI, mammography, CT, PET (88 patients): sample notebook
A worked notebook for IDC BREAST-DIAGNOSIS: Breast Cancer MRI, mammography, CT, PET (88 patients), with 4 code cells and the output each one printed. On Scigantic it opens in a hosted JupyterLab with the dataset already mounted, so nothing is downloaded first.
- Provider
- NCI Imaging Data Commons; BREAST-DIAGNOSIS contributors; tables and sample by Scigantic
- License
- Per series (series.parquet license_short_name): CC BY 3.0 523. Cite the source DOI(s) and the IDC.
- Size
- 7 parquet tables
- Stored at
- Amazon S3, s3://scigantic-idc-open/breast_diagnosis (us-east-1)
- Access
- Free and public. No account with the data provider is needed.
- DOI
- 10.7937/k9/tcia.2015.sdnrqxxr
The notebook
BREAST-DIAGNOSIS on the Imaging Data Commons: 88 patients, 523 series, 59.44 GB
Breast Cancer imaging of the breast from the NCI Imaging Data Commons (IDC). Series by modality: MR 345, SR 94, MG 58, CT 18, PT 8.
The images of this collection were withdrawn at the source. The collection's 429 image series (MR 345, MG 58, CT 18, PT 8; DOI 10.7937/k9/tcia.2015.sdnrqxxr) are no longer in the IDC buckets (checked on AWS and Google Cloud, 2026-11-17), and the TCIA collection page, updated 2026-10-23, offers only the clinical spreadsheet and notes that some series will return after corrections. The 94 structured-report (SR) series of the analysis result 10.7937/tcia.2019.wgllssg1 are still readable. series.parquet is kept as a record of what the collection held at IDC v24; a pull of an image series returns nothing.
This mount is the collection's index: series.parquet (one row per DICOM series), studies.parquet, patients.parquet and the IDC clinical table. There is no sample/ folder. README.md and BUILD_REPORT.json at the mount root say how this was built (idc-index, IDC v25).
The code below reads all of it with the scigantic-nci package (pip install "scigantic-nci[dicom]", already installed in this image): from scigantic_nci import idc, then calls such as idc.series("breast_diagnosis"), idc.clinical and idc.pull_series. Run anywhere else, the same calls read s3://scigantic-idc-open/breast_diagnosis/ anonymously.
import os, json
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import pydicom
from scigantic_nci import idc, NciError
plt.rcParams['figure.dpi'] = 72 # keeps the saved figures small enough for the notebook preview
try:
from matplotlib_inline.backend_inline import set_matplotlib_formats
set_matplotlib_formats('jpeg') # slide renders are photographic; JPEG is a fifth the size of PNG here
except ImportError:
pass
C = 'breast_diagnosis'
# scigantic_nci reads the mounted archive when its BUILD_REPORT.json names this collection, else s3://scigantic-idc-open/<collection>/ anonymously.
M = os.environ.get('SCIGANTIC_MOUNT_PATH', '/mnt/archive')
on_mount = os.path.exists(f'{M}/BUILD_REPORT.json') and json.load(open(f'{M}/BUILD_REPORT.json')).get('collection_id') == C
print('reading', C, 'from', M if on_mount else f's3://scigantic-idc-open/{C}/')
report = idc.report(C)
series = idc.series(C) # one row per DICOM series, with its public S3 location
patients = idc.patients(C)
studies = idc.studies(C)
print(report['collection_name'], '| IDC', report['idc_data_version'], '| built', report['built_at'][:10])
print(f"{len(patients):,} patients, {len(studies):,} studies, {len(series):,} series, {series.series_size_MB.sum()/1024:,.1f} GB in the IDC buckets\n")
by_mod = series.groupby('Modality').agg(series=('SeriesInstanceUID', 'count'), patients=('PatientID', 'nunique'), GB=('series_size_MB', lambda s: round(s.sum() / 1024, 2))).sort_values('series', ascending=False)
print(by_mod.to_string())
fig, ax = plt.subplots(figsize=(7, 3))
by_mod['patients'].plot.bar(ax=ax, color='#4a6fa5'); ax.set_ylabel('patients'); ax.set_title(f"{report['collection_name']}: patients per modality"); plt.tight_layout()
Output:
reading breast_diagnosis from /mnt/archive
BREAST-DIAGNOSIS | IDC v25 | built 2026-11-17
88 patients, 148 studies, 523 series, 59.4 GB in the IDC buckets
series patients GB
Modality
MR 345 84 56.89
SR 94 50 0.00
MG 58 17 1.14
CT 18 3 1.37
PT 8 3 0.04
1. Studies and patients
A study is one imaging visit (all series acquired together); a patient may have several. studies.parquet collapses the series table to one row per study with the modalities present, patients.parquet to one row per patient.
print('Studies per patient:'); print(patients.n_studies.describe()[['min', '50%', 'max']].to_string())
print('\nModality combinations per study (top 8):'); print(studies.modalities.value_counts().head(8).to_string())
sex = patients.PatientSex.replace('', np.nan).dropna()
if len(sex): print('\nPatientSex:', sex.value_counts().to_dict())
ages = pd.to_numeric(series.PatientAge.dropna().astype(str).str.extract(r'(\d+)')[0], errors='coerce')
if ages.notna().sum() > 10: print(f'PatientAge at imaging: median {ages.median():.0f} y (IQR {ages.quantile(.25):.0f}-{ages.quantile(.75):.0f}) on {ages.notna().sum():,} series')
if 'BodyPartExamined' in series: print('\nBodyPartExamined:', series.BodyPartExamined.dropna().value_counts().head(6).to_dict())
print('\nLicenses (per series):', series.license_short_name.value_counts().to_dict())
Output:
Studies per patient: min 1.0 50% 1.0 max 9.0 Modality combinations per study (top 8): modalities MR, SR 64 MR 48 MG, SR 18 CT, PT, SR 6 CT 5 MG 5 CT, PT 2 ...
2. No sample images
This archive used to hold one CT, one MR and one PT series. They were removed on 2026-11-17, after the images were withdrawn at the source.
3. Clinical tables
IDC ships 1 clinical table(s) for this collection (breast_diagnosis_clinical; idc.clinical_tables lists them), keyed by dicom_patient_id = PatientID. clinical/dictionary.parquet (idc.clinical_dictionary) carries the human-readable label and the coded values for every column; coded columns store the code.
clin = idc.clinical(C, 'breast_diagnosis_clinical')
dictionary = idc.clinical_dictionary(C)
print(clin.shape, 'rows x cols in', 'breast_diagnosis_clinical')
print(dictionary[dictionary.short_table_name == 'breast_diagnosis_clinical'][['column', 'column_label']].head(15).to_string(index=False))
joined = patients.merge(clin, left_on='PatientID', right_on='dicom_patient_id', how='left')
print(f'\n{joined.dicom_patient_id.notna().sum()} of {len(patients)} imaged patients have a clinical row')
Output:
(51, 18) rows x cols in breast_diagnosis_clinical
column column_label
dicom_patient_id idc_provenance_dicom_patient_id
source_batch idc_provenance_source_batch
breast_dx_case Breast Dx Case
background None
pathology_dx Dx
which_breast Which breast
er ER
pr PR
her2 HER2
e_cadherin E-Cadherin
ki67 Ki67
oncotype_score Oncotype score
oncotype_risk Oncotype risk
...
4. What can still be pulled from IDC
Only the 94 structured reports (SR), one breast imaging report per series. idc.pull_series(row, dest) reads a series anonymously from s3:// / /. For an MR, MG, CT or PT row of series.parquet it raises NciError: no objects under ..., because those objects are gone.
sr = idc.series(C, modality='SR').sort_values('series_size_MB') # the series that are still in the IDC bucket
row = sr.iloc[0]
files = idc.pull_series(row, '/tmp/idc_pull') # anonymous read of s3://<aws_bucket>/<crdc_series_uuid>/
d = pydicom.dcmread(files[0])
print(len(sr), 'SR series still in the IDC bucket; pulled', len(files), 'file(s) for patient', row.PatientID)
print(d.Modality, '|', d.get('SeriesDescription'), '|', d.ConceptNameCodeSequence[0].CodeMeaning)
Output:
94 SR series still in the IDC bucket; pulled 1 file(s) for patient BreastDx-01-0036 SR | Standard Breast Imaging Report | Breast Imaging Report
Try this in the AI assistant
The chat panel is prefilled with the first of these.
- *Summarize series.parquet: how many series, studies and patients per modality did this collection hold?*
- *Which clinical variables in breast_diagnosis_clinical are most complete, and how do they relate to the imaging studies per patient?*
Licenses are per series (license_short_name in series.parquet). Cite the collection DOI(s) in README.md and the IDC papers (Fedorov et al. 2021, 2023) when you publish.
Run it
Open this notebook to run it, see the dataset page for the full description, or browse the full catalog.