|
Download itrialspace/README.md from NeuIPS-Submission-ID-3185/NeurIPS-Code: direct link, hf CLI and curl.
- Browser
- Download file 15.9 kB
-
https://huggingface.co/NeuIPS-Submission-ID-3185/NeurIPS-Code/resolve/main/itrialspace/README.md
- Command line
-
hf download hf://NeuIPS-Submission-ID-3185/NeurIPS-Code/itrialspace/README.md
-
curl -L -o README.md https://huggingface.co/NeuIPS-Submission-ID-3185/NeurIPS-Code/resolve/main/itrialspace/README.md
15.9 kB
| <!-- BLINDED COPY for double-blind peer review β author, institution, and repository-identifying information removed. Do not use for attribution. --> | |
| <!-- markdownlint-disable MD033 MD041 --> | |
| <div align="center"> | |
| # iTrialSpace | |
| **A Synthetic Imaging Clinical-Trial Engine for lung-CT AI evaluation.** | |
| *Specify the cohort you need β then manufacture anatomically grounded synthetic CTs to match, | |
| and evaluate detectors and vision-language models under controlled, one-variable-at-a-time conditions.* | |
| </div> | |
| > β οΈ **License pending.** The license is being finalized β see [`LICENSE`](LICENSE). Please do | |
| > not redistribute until it is confirmed. **Research use only β not for clinical use.** | |
| --- | |
| ## What it is | |
| iTrialSpace turns medical-imaging AI evaluation from *"find more data"* into *"specify the data | |
| you need."* It harmonizes **13,140 nodule profiles** from **7 public lung-CT datasets**, plans | |
| virtual clinical-trial cohorts across **13 trial modes**, inserts donor nodule masks into real | |
| host anatomy, synthesizes CT volumes with a ControlNet-conditioned diffusion model | |
| (**NodMAISI**), and evaluates **vision-language models (VLMs)** under systematically controlled | |
| conditions. | |
| **Why it exists.** Public lung-screening datasets are each narrow in their own way β some are | |
| enriched for heavy smokers, some lack malignancy labels, some contain only large cancers β so AI | |
| models end up tested on data that under-represents where they fail. iTrialSpace lets you declare a | |
| cohort by its *statistical properties* (prevalence, size distribution, lobe distribution, | |
| demographics) and generates synthetic CTs to match, enabling controlled experiments that fixed | |
| retrospective datasets cannot support. | |
| **What this repository is.** A clean, installable, **code-only** monorepo. Source CT *images* and | |
| trained model *weights* are not redistributed here (they carry their own licenses and are large); | |
| the derived synthetic data is released separately as a dataset (see [Data & release](#7-data--release)). | |
| --- | |
| ## Track β how to read this README | |
| A guided path from zero to a full evaluation. Each row is a section below; follow them in order, | |
| or jump to what you need. | |
| | # | Section | What you'll get | | |
| |---|---------|-----------------| | |
| | 1 | [Highlights](#1-highlights) | The capabilities at a glance | | |
| | 2 | [Architecture](#2-architecture) | The five-stage engine and how the pieces connect | | |
| | 3 | [Installation](#3-installation) | Environment, the package, and the extras matrix | | |
| | 4 | [Configuration](#4-configuration) | The one env var that makes it run anywhere | | |
| | 5 | [Quickstart](#5-quickstart) | Install β configure β smoke-test in five commands | | |
| | 6 | [The end-to-end pipeline](#6-the-end-to-end-pipeline) | index β trials β masks β synthesis β evaluation | | |
| | 7 | [Data & release](#7-data--release) | The 7 datasets, what is shared, how to assemble it | | |
| | 8 | [Trial modes](#8-trial-modes) | The 13 cohort designs you can synthesize | | |
| | 9 | [VLM evaluation (end to end)](#9-vlm-evaluation-end-to-end) | Build β run β analyze, locally or on SLURM | | |
| | 10 | [Reproducibility](#10-reproducibility) | Frozen splits, the reporting convention, checksums | | |
| | 11 | [Apps: NoduleMap & Retriever](#11-apps-nodulemap--retriever) | Explore and search the nodule space | | |
| | 12 | [Command reference](#12-command-reference) | Console scripts and module entry points | | |
| | 13 | [Project layout](#13-project-layout) | Where everything lives | | |
| | 14 | [Citation, contributing, license](#14-citation-contributing-license) | How to cite and contribute | | |
| --- | |
| ## 1. Highlights | |
| - **Cohort-by-specification.** Plan trials by prevalence, size, lobe, and demographics β not by | |
| whatever a retrospective dataset happens to contain. | |
| - **Anatomically grounded synthesis.** Donor nodule masks are pasted into real host lung anatomy | |
| and rendered by **NodMAISI**, a ControlNet-conditioned diffusion model. | |
| - **13 trial modes**, from controlled-prevalence and size/location sensitivity curves to digital | |
| twins of real patients. | |
| - **Zero-shot VLM evaluation** β BiomedCLIP, LLaVA-Med, and MedGemma across 3 clinical tasks Γ | |
| 4 spatial-guidance conditions, on synthetic and real CT. | |
| - **Portable by construction.** All paths resolve from a single env var; the same code runs on a | |
| laptop, a workstation, or an HPC cluster. A CI portability gate enforces it. | |
| - **Reproducible reporting.** Frozen, checksummed evaluation splits and a documented reporting | |
| convention keep every published number tied to an exact, verifiable case set. | |
| --- | |
| ## 2. Architecture | |
| ``` | |
| itrialspace β trials β mask_inserter β synthesis β evaluation | |
| (nodule index + (cohort (donor mask (NodMAISI (VLM | |
| query + features) manifests) β host anatomy) CT volumes) zero-shot) | |
| β | |
| ββ nodulemap β interactive embedding-graph explorer | |
| ββ retriever β faceted search, similarity & donor matching + CT viewer | |
| ``` | |
| One installable package, `itrialspace`, with sub-packages for each stage. Configuration, I/O, and | |
| path resolution are centralized so nothing hardcodes a machine-specific path. Full component map: | |
| [blinded_doc/architecture.md](blinded_doc/architecture.md). | |
| --- | |
| ## 3. Installation | |
| ```bash | |
| # 1) Environment (conda/mamba) | |
| conda env create -f environment.yml && conda activate itrialspace | |
| # 2) Install the package with the extras you need | |
| pip install -e ".[all]" # or a subset β see the matrix | |
| ``` | |
| **Extras matrix** | |
| | Extra | Installs | For | | |
| |-------|----------|-----| | |
| | *(base)* | pandas, numpy, pyyaml | Index, query, trial planning | | |
| | `imaging` | nibabel, scipy, SimpleITK | Mask insertion, NIfTI handling | | |
| | `web` | fastapi, streamlit, faiss, umap | NoduleMap + Retriever UIs | | |
| | `synthesis` | monai, (torch) | NodMAISI CT synthesis ΒΉ | | |
| | `vlm` | transformers, accelerate, open_clip | VLM evaluation ΒΉ | | |
| | `dev` | pytest, ruff, black, pre-commit | Development | | |
| | `all` | imaging + web + vlm + dev | Everything bundled | | |
| ΒΉ PyTorch is platform-specific β install it per [blinded_doc/installation.md](blinded_doc/installation.md). | |
| A `docker/Dockerfile` is provided for a containerized setup. | |
| --- | |
| ## 4. Configuration | |
| Everything is driven by environment variables (loaded from a gitignored `.env`); nothing is | |
| hardcoded. | |
| ```bash | |
| cp .env.example .env # then edit: | |
| # ITRIALSPACE_DATA_DIR β the dataset root (raw_ct/ masks/ profiles/ β¦) | |
| # ITRIALSPACE_OUTPUT_DIR β where generated artifacts go (default: = data dir) | |
| # HF_TOKEN β HuggingFace token for gated VLMs (kept local; never committed) | |
| ``` | |
| Any config YAML may reference these with `${VAR}` interpolation. `its config` prints the resolved | |
| paths. Details: [blinded_doc/configuration.md](blinded_doc/configuration.md). | |
| --- | |
| ## 5. Quickstart | |
| ```bash | |
| conda activate itrialspace | |
| pip install -e ".[all]" | |
| cp .env.example .env # set ITRIALSPACE_DATA_DIR (+ HF_TOKEN for VLMs) | |
| pytest -m "not full_volume" # unit tests β no external data needed | |
| its config # verify resolved paths | |
| its index stats # build the nodule index + print stats (needs profiles/) | |
| ``` | |
| A guided first cohort is in [blinded_doc/walkthrough_mode1.md](blinded_doc/walkthrough_mode1.md). | |
| --- | |
| ## 6. The end-to-end pipeline | |
| Five stages take you from a raw nodule index to evaluated models. Each stage is a CLI command and | |
| a documented module. | |
| | Stage | What it does | Entry point | | |
| |-------|--------------|-------------| | |
| | **1. Index** | Harmonize 7 datasets into one nodule index with reinsertion features | `its index` | | |
| | **2. Trials** | Plan cohort **manifests** for the 13 trial modes (donor β host, location, scale) | `its-trials` | | |
| | **3. Mask insertion** | Paste donor nodule masks into host organ/lobe masks (nodule = label 23) | `its-insert` | | |
| | **4. Synthesis** | Render CT volumes from the combined masks with **NodMAISI** | `its` (synthesis) | | |
| | **5. Evaluation** | Score **VLMs** (zero-shot) under controlled conditions | `its-vlm` | | |
| Full walkthrough: [blinded_doc/pipeline.md](blinded_doc/pipeline.md) and | |
| [blinded_doc/running_the_pipeline.md](blinded_doc/running_the_pipeline.md). HPC orchestration scripts are under | |
| [`infra/slurm/`](infra/slurm/). | |
| --- | |
| ## 7. Data & release | |
| iTrialSpace harmonizes **7 public lung-CT datasets** (13,140 nodule profiles): | |
| | Dataset | Nodule profiles | Dataset | Nodule profiles | | |
| |---------|----------------:|---------|----------------:| | |
| | LUNA25 | 6,163 | LUNA16 | 1,186 | | |
| | DLCS24 | 2,487 | LNDbv4 | 768 | | |
| | IMDCT | 2,032 | NSCLCR | 421 | | |
| | LUNGx | 83 | **Total** | **13,140** | | |
| **What the release ships** (derived artifacts): nodule `profiles/`, `masks/`, cohort | |
| `manifests/`, combined `inserted_masks/`, the **synthetic CT volumes** (`generated_cts/` β | |
| **44,174** volumes across all 13 modes), and the **VLM evaluation dataset** (`vlm_dataset/` β | |
| **42,858** synthetic and **13,087** real evaluation cases). | |
| **What it does not ship.** The real CT **images** are not redistributed β download them from each | |
| provider under their own license and place them under `raw_ct/{DATASET}/`. The data contract, | |
| counts, ground-truth definitions, and assembly instructions are in | |
| [blinded_doc/dataset_card.md](blinded_doc/dataset_card.md) and [blinded_doc/data.md](blinded_doc/data.md). | |
| --- | |
| ## 8. Trial modes | |
| Thirteen cohort designs, each producing a manifest you can synthesize and evaluate: | |
| | # | Mode | Question it answers | | |
| |---|------|---------------------| | |
| | 1 | `controlled_prevalence` | How does performance change with cancer prevalence? | | |
| | 2 | `size_detection_curve` | Detection sensitivity vs. nodule size (FROC) | | |
| | 3 | `location_sensitivity` | Detection vs. anatomical lobe | | |
| | 4 | `demographic_stratification` | Performance across demographic strata | | |
| | 5 | `counterfactual` | The same patient, with vs. without a nodule | | |
| | 6 | `cross_dataset` | Generalization across acquisition sources | | |
| | 7 | `bootstrap_confidence` | Confidence intervals via resampled cohorts | | |
| | 8 | `algorithm_comparison` | Standardized head-to-head model comparison | | |
| | 9 | `screening_simulation` | Multi-round screening with prevalence decay | | |
| | 10 | `multi_nodule_realism` | Impact of companion nodules in context | | |
| | 11 | `digital_twin_isolation` | Each native nodule isolated within its host anatomy | | |
| | 12 | `digital_twin_complete` | All native nodules of a scan, reconstructed | | |
| | 13 | `digital_twin_cross` | Donor nodules placed in cross-patient host anatomy | | |
| Details and per-mode parameters: [blinded_doc/trial_modes.md](blinded_doc/trial_modes.md). | |
| --- | |
| ## 9. VLM evaluation (end to end) | |
| Evaluate **BiomedCLIP**, **LLaVA-Med**, and **MedGemma** on three zero-shot tasks β | |
| **presence** (binary), **lobe** (5-class), **size** (4-class) β under four image **conditions** | |
| (`plain`, `bbox`, `contour`, `bbox_contour`), on synthetic and real CT. | |
| The whole workflow is **three steps**, identical for a small demo and the full dataset (only the | |
| paths/env change): | |
| ```bash | |
| # 1) BUILD the 2-D eval dataset (slices + overlays + ground truth) | |
| python -m itrialspace.evaluation.vlm_eval.build_dataset --manifest β¦ --output-dir β¦ --overlays | |
| # (real CTs: itrialspace.evaluation.vlm_eval.build_real_dataset) | |
| # 2) RUN a model across all conditions Γ tasks | |
| python -m itrialspace.evaluation.vlm_eval.runners.run_conditions \ | |
| --model biomedclip --run-all-conditions --dataset-csv β¦/eval_dataset.csv --output-dir β¦ | |
| # 3) ANALYZE β tables, figures, statistics, report.md | |
| python -m itrialspace.evaluation.vlm_eval.eval_analysis --results β¦ --out analysis/ | |
| ``` | |
| On a cluster, the same three steps are env-driven SLURM jobs β | |
| `build_dataset.sub β run_vlm.sub β analyze.sub` β see | |
| [infra/slurm/vlm_eval/README.md](infra/slurm/vlm_eval/README.md). | |
| The **analysis suite** (`eval_analysis`) auto-discovers whatever models/conditions/tasks are | |
| present and emits accuracy and Ξ-vs-baseline tables, per-mode / per-dataset / per-size / per-lobe | |
| breakdowns, confusion matrices, per-class accuracy, **bootstrap confidence intervals**, **McNemar | |
| significance**, publication-style figures, and an assembled `report.md`. | |
| - User guide: [blinded_doc/vlm_eval.md](blinded_doc/vlm_eval.md) | |
| - Architecture & module reference: [blinded_doc/vlm_eval_implementation.md](blinded_doc/vlm_eval_implementation.md) | |
| - Headline results: [blinded_doc/vlm_results.md](blinded_doc/vlm_results.md) | |
| --- | |
| ## 10. Reproducibility | |
| - **Frozen splits.** Each result is reported on a checksummed case list (`vlm_dataset/splits/`): | |
| `release_v1` (the headline set) and `release_v1_full` (cases scored under all four conditions). | |
| `splits.json` records counts, SHA-256, and provenance β regenerate and the hash must match. | |
| - **One reporting N.** Accuracy is always computed on the cases scored in *every* | |
| (model Γ condition Γ task), keyed by a stable canonical slice id (not a positional index), so | |
| all reported numbers are directly comparable. | |
| - **Determinism & audit trails.** Every synthesis case carries an audit record; see | |
| [blinded_doc/reproducibility.md](blinded_doc/reproducibility.md). | |
| - **Quality gates.** CI runs lint (`ruff`/`black`), unit tests, and a portability check that | |
| fails on any hardcoded machine-specific path. | |
| --- | |
| ## 11. Apps: NoduleMap & Retriever | |
| - **NoduleMap** (`its-nodulemap`) β an interactive embedding-graph explorer of the nodule space. | |
| See [blinded_doc/nodulemap.md](blinded_doc/nodulemap.md). | |
| - **Retriever** (`its-retriever`) β faceted search, similarity and donor matching, with an | |
| integrated CT viewer. See [blinded_doc/retriever.md](blinded_doc/retriever.md). | |
| --- | |
| ## 12. Command reference | |
| | Command | Purpose | | |
| |---------|---------| | |
| | `its` | Umbrella CLI β index, query, config, synthesis subcommands | | |
| | `its-trials` | Generate cohort manifests for the 13 trial modes | | |
| | `its-insert` | Insert donor nodule masks into host anatomy from a manifest | | |
| | `its-vlm` | VLM evaluation utilities | | |
| | `its-nodulemap` | Launch the NoduleMap server | | |
| | `its-retriever` | Launch the Retriever API + UI | | |
| VLM modules: `β¦vlm_eval.build_dataset` Β· `β¦build_real_dataset` Β· `β¦runners.run_conditions` Β· | |
| `β¦make_split` Β· `β¦eval_analysis` Β· `β¦report`. | |
| --- | |
| ## 13. Project layout | |
| ``` | |
| itrialspace/ | |
| βββ src/itrialspace/ # the package | |
| β βββ core/ io/ index/ query/ site/ # nodule index, query, path resolution | |
| β βββ config/ # env-driven settings + ${VAR} interpolation | |
| β βββ trials/ # the 13 trial-mode cohort planners | |
| β βββ mask_inserter/ # donor mask β host anatomy | |
| β βββ synthesis/ # NodMAISI CT synthesis (code; weights external) | |
| β βββ nodulemap/ retriever/ # the two apps | |
| β βββ evaluation/ | |
| β βββ vlm_eval/ # build β run β analyze (incl. eval_analysis suite) | |
| βββ configs/ # example, env-interpolated configs | |
| βββ infra/slurm/ # cluster job scripts (env-driven) | |
| βββ blinded_doc/ # full documentation set (blinded) | |
| βββ tests/ docker/ | |
| βββ pyproject.toml environment.yml .env.example | |
| ``` | |
| --- | |
| ## 14. Citation, contributing, license | |
| - **Citation** β withheld for double-blind review. (Cite each underlying CT dataset you | |
| download into `raw_ct/` per its own terms.) | |
| - **Contribute** via [`CONTRIBUTING.md`](CONTRIBUTING.md) β all PRs run through CI (lint + tests + | |
| portability gate). | |
| - **License** β see [`LICENSE`](LICENSE) (being finalized). Research use only; not a medical | |
| device and not for clinical use. | |
| <div align="center"> | |
| <sub>iTrialSpace β specify the cohort, synthesize the data, evaluate with control.</sub> | |
| </div> | |