Skip to content

Quick Start

Wookjin Choi edited this page May 28, 2026 · 1 revision

Quick Start — NSCLC-Radiomics (LUNG1) from scratch

This pulls DICOM straight from TCIA, converts to NRRD, extracts PyRadiomics features, joins the published clinical table, and reports the Cox PH ranking. The same chain runs for any TCIA collection by swapping the first argument.

# 0. One-time: install + workspace
pip install -e .[rtstruct]
export USER_DATA=/data/$USER          # >= 30 GB free for LUNG1 (~422 patients)
mkdir -p $USER_DATA/{Lung1,Lung1-out}

# 1. DICOM pull from TCIA (CT + RTSTRUCT)
qr tcia download --collection NSCLC-Radiomics --modality CT      -o $USER_DATA/Lung1 -j 16
qr tcia download --collection NSCLC-Radiomics --modality RTSTRUCT -o $USER_DATA/Lung1 -j 16

# 2. DICOM -> NRRD per patient: CT volume + GTV-1 binary mask
for pat in $USER_DATA/Lung1/*/; do
  pid=$(basename "$pat")
  qr convert dicom-series -i "$pat"*/CT -o "$USER_DATA/Lung1-out/${pid}_CT.nrrd"
  qr convert rtstruct -d "$pat"*/CT -r "$pat"*/RTSeries/*.dcm \
     --roi GTV-1 -o "$USER_DATA/Lung1-out/${pid}_GTV-label.nrrd"
done

# 3. Manifest from the converted tree
qr convert manifest-from-dir -d "$USER_DATA/Lung1-out" \
   --image-glob '*_CT.nrrd' --mask-glob '*_GTV-label.nrrd' \
   -o "$USER_DATA/Lung1-out/manifest.csv"

# 4. PyRadiomics extraction under the nsclc-survival pattern (~1130 features)
qr extract -m "$USER_DATA/Lung1-out/manifest.csv" -p nsclc-survival \
   -o "$USER_DATA/Lung1-out/features.csv"

# 5. Join with the published clinical table
curl -sLo "$USER_DATA/Lung1-out/clinical.csv" \
  "https://www.cancerimagingarchive.net/wp-content/uploads/NSCLC-Radiomics-Lung1.clinical-version3-Oct-2019.csv"
qr results merge -f "$USER_DATA/Lung1-out/features.csv" -c "$USER_DATA/Lung1-out/clinical.csv" \
   --clinical-id-col PatientID --time-col Survival.time --event-col deadstatus.event \
   -o "$USER_DATA/Lung1-out/analysis_ready.csv"

# 6. Univariate Cox PH on every radiomic feature -> ranked CSV
qr analyze survival -i "$USER_DATA/Lung1-out/analysis_ready.csv" \
   --outcome OS_months --event OS_event -o "$USER_DATA/Lung1-out/cox_results.csv"

Expected: on ~420 patients, original_ngtdm_Busyness ranks at the top (HR ≈ 1.23, p < 1e-4) — replicating the Aerts 2014 headline. A 422-patient run takes ≈ 1 h on a 16-core workstation.

Already have NRRD + a manifest?

If your data is already NRRD with a manifest CSV (canonical lowercase columns: patient_id, modality, image_path, mask_path), skip steps 0–3 and start at step 4. Browse bundled patterns with qr pattern list / qr pattern search <kw>.

One-shot workflow assembly

qr workflow plan -t dicom_to_ml -d /data/cohort -c clinical.csv \
   --roi GTV --pattern nsclc-survival -o plan.json
qr workflow run plan.json                  # default executor: nextflow

See CLI Reference for every command and Pipelines for ready-to-run cohort bundles.

Clone this wiki locally