Build a Private DICOM Explorer¶
| Category | Creative & Real-World AI Builds |
| Status | ๐ก Partially completed |
| Repo | nextwork-build-a-private-dicom-explorer |
| Original NextWork guide | nextwork.ai |
Learning project
Practice work following a NextWork guide, separate from my production projects.
๐ NextWork learning project. This is a practice project I built while working through NextWork's Build a Private DICOM Explorer guide. It is part of my Learning portfolio and is fully separate from my production projects.
Category: Learning โบ Creative & Real-World AI Builds
Status: ๐ก Partially completed
Overview¶
Medical scans carry identifiers in their headers. This viewer opens a scan folder only through the browser's own file picker, so nothing is uploaded. The coding agent is fenced off from the scan folders by permission rules. It renders three anatomical planes plus a rotatable 3D volume, and shows geometry without identifying fields.
Summary¶
My local DICOM explorer runs on Vite 8.3.5, Cornerstone3D 5.15.2 and dicom-parser 1.8.21, and was browser-tested by handing a folder to the page's folder input. A 64-slice series fills the axial, sagittal, coronal and experimental 3D panels. Window/level, the millimetre ruler (90.9 mm), 3D rotation and preset switching all work. The geometry panel shows only modality, slice count, matrix, spacing and thickness, and the only host requested is localhost. A scrubbed copy passes my count-only audit and loads too. Secret mission: the real Claude Code CLI denied a Read of the protected folder under my .claude/settings.json, while the browser still rendered that series. Partial because Claude Code didn't write the app, and there's no Mac/Safari or real scan.
The checks behind this are in docs/verification.txt.
Skills & tools¶
Cornerstone3D, DICOM, Vite, Browser File API, Privacy engineering, pydicom / deid, Claude Code permissions
What I built¶
- Privacy boundary:
.claude/settings.json(deny reads of~/Documents/Private-DICOM/**and the scrubbed folder, block reads outside the workspace, no bypass or auto mode),CLAUDE.md(my rules for any coding agent), and.gitignoreexcluding*.dcmand scan folders. - App (my own code, rewritten 3 Dec):
src/headers.jsreads only the needed header tags (never identifying ones).src/series.jsgroups slices into stacks by series, frame of reference, orientation and matrix, picks the largest, orders it by position along the slice normal (falling back to instance number), and builds the five-field geometry summary.src/viewer.jssets up Cornerstone3D (3 orthographic planes + VOLUME_3D, tool groups, presets, preload before the volume is built).src/main.jswires up the page.index.html+src/style.cssare the dark 2ร2 shell. vite.config.js(my fix): Vite 8 externalizes Node'sevents, which a Cornerstone dependency extends, so initialization failed. Aliasing the browsereventspackage fixes it.npm run devstalls while preloading on this box, so the tests usenpm run build+vite preview.tools/make_phantom.py: writes a synthetic 64-slice 128ร128 CT phantom with fictional identifiers, since there are no real scans here.tools/browser_check.mjs(headless Chrome): checks the load status, the stats, that the controls are enabled, window/level, the ruler (90.9 mm), 3D rotation and a switch to CT-MIP, with no page errors and no non-local hosts. It prints counts only. Screenshots:docs/viewer-loaded.png,docs/window-level.png,docs/ruler.png,docs/volume-3d-rotated-ct-mip.png.- Scrubbed copy:
deid 0.4.13+pydicom 3.0.2and mytools/audit_deid.py, which prints counts only and fails closed. deid's default recipe dropped the SOP class, so the audit read 0 images and failed. My recipe (tools/deid.dicom) gives 64/64 read, 0 holding an original value and 64 flaggedPatientIdentityRemoved=YES(docs/audit-deid*.txt,docs/deid-findings.md,docs/scrubbed-copy-loaded.png). - Secret mission (
docs/secret-mission-claude-code.md, rerun 3 Dec under my rewritten settings): the real Claude Code 2.1.335 CLI with a scripted stand-in model (tools/mock_model.py) requestedRead(~/Documents/Private-DICOM/IM0001.dcm). Claude Code refused ("File is in a directory that is denied by your permission settings"), even with Read pre-allowed. The control read ofindex.htmlwas ALLOWED.
How to run¶
npm install
python3 tools/make_phantom.py ~/Documents/Private-DICOM # or use your own scan folder
npm run build && npx vite preview # open the printed localhost URL, click Load DICOM folder
node tools/browser_check.mjs http://localhost:4173/ ~/Documents/Private-DICOM /tmp/shots
# scrubbed copy + audit (separate terminal, never inside Claude Code)
deid --overwrite --outfolder ~/Documents/Deidentified-DICOM identifiers --action all --deid tools/deid.dicom --input ~/Documents/Private-DICOM
python3 tools/audit_deid.py ~/Documents/Private-DICOM ~/Documents/Deidentified-DICOM
Verification¶
I ran the verification command on 2026-12-03. The full output is in docs/verification.txt.
PY=$HOME/.nw-dicom-venv/bin/python; P=$PWD; T=$(mktemp -d) && mkdir -p $T/clean && $PY tools/make_phantom.py $T/orig 16 64 && (cd $T && $HOME/.nw-dicom-venv/bin/deid --overwrite --outfolder $T/clean identifiers --action all --deid $P/tools/deid.dicom --input $T/orig >/dev/null 2>&1) && $PY tools/audit_deid.py $T/orig $T/clean && grep -q 'denied by your permission settings' docs/secret-mission-claude-code.md && grep -q 'ALLOWED' docs/secret-mission-claude-code.md && grep -q 'Private-DICOM' .claude/settings.json && node -e "const p=require('./package.json');if(p.dependencies['@cornerstonejs/core']!=='5.15.2'||p.devDependencies.vite!=='8.3.5')process.exit(1)" && echo DICOM OK
Notes¶
Rewritten 3 Dec 2026: the earlier src/main.js, tools/audit_deid.py and CLAUDE.md followed the guide's reference. They are now my own code and words, and every check (browser, audit, Claude Code denial) was rerun.
What isn't done, and why¶
The intended workflow has Claude Code build the app on a Mac and test it in Safari with a real scan. I wrote the app myself, because local models can't drive that multi-step Claude Code build, and tested it in headless Chrome on Linux with a synthetic phantom series. There are no real scans and no personal data. The secret mission's denial is genuine Claude Code permission enforcement, but the model making the request is scripted.
Original project: https://nextwork.ai/projects/4b262351-63f1-453e-afbf-985f9ba383b2 ยท Part of my NextWork Learning portfolio (hub).
Verification output¶
From docs/verification.txt:
$ PY=$HOME/.nw-dicom-venv/bin/python; P=$PWD; T=$(mktemp -d) && mkdir -p $T/clean && $PY tools/make_phantom.py $T/orig 16 64 && (cd $T && $HOME/.nw-dicom-venv/bin/deid --overwrite --outfolder $T/clean identifiers --action all --deid $P/tools/deid.dicom --input $T/orig >/dev/null 2>&1) && $PY tools/audit_deid.py $T/orig $T/clean && grep -q 'denied by your permission settings' docs/secret-mission-claude-code.md && grep -q 'ALLOWED' docs/secret-mission-claude-code.md && grep -q 'Private-DICOM' .claude/settings.json && node -e "const p=require('./package.json');if(p.dependencies['@cornerstonejs/core']!=='5.15.2'||p.devDependencies.vite!=='8.3.5')process.exit(1)" && echo DICOM OK
wrote 16 synthetic CT slices (64x64) to /tmp/tmp.WLO8qtihEU/orig
original images read: 16 (skipped 0)
scrubbed images read: 16 (skipped 0)
scrubbed images still holding an original value: 0
scrubbed images marked PatientIdentityRemoved=YES: 16
Counts only. A pass here is necessary, not sufficient, for a safe copy.
DICOM OK
[exit code 0]