Skip to content

About

This C# program will compare folders of Dicom Dose files. This relies on EvilDICOM and is distributed under the MIT licence.

Resources

Contributing

Stars

6 stars

Watchers

1 watching

Forks

Repository files navigation

DicomStrictCompare

DicomStrictCompare is a tool for comparing two folders of DICOM RT Dose files in one batch. It was written for treatment planning system (TPS) commissioning and upgrade work: you calculate the same plans two ways (for example, an old and a new algorithm version) and want a quick, numerical answer to "how different are these dose distributions, beam by beam?" without opening every pair by hand.

While it was written for a specific use case, please don't hesitate to suggest improvements you would like to see.

The user guide is at https://dicomstrictcompare.readthedocs.io/.

What it does

You give it two folders:

  • Reference (the measured data, or the earlier calculation: known good) and
  • Evaluated (the calculation being checked).

Each folder holds RT Dose (RD) files and the RT Plan (RP) files they came from. The plan is needed because a dose file on its own does not say which field it belongs to: the tool reads the plan to turn each dose file's referenced beam number into a plan label and beam name.

The tool then:

  1. Finds every DICOM file in each folder (sub-folders included) and sorts them into dose and plan files.

  2. Pairs each evaluated dose with the reference dose that has the same key. You choose the key:

    • plan label and beam name (the default): the same plan label and beam name under any patient;
    • patient, plan label and beam name;
    • beam parameters (a prototype, --match params): what each beam delivers, whatever it is called. Parameters… chooses which of image set, energy, applicator, wedge, blocks, angles, jaws, leaves, isocentre, isocentre depth on the central axis (for doses planned on different image sets), MU, grid, algorithm, machine, plan label and beam name are used, each one's tolerance (MU ±1 MU, leaves ±1 mm by default), and which must match. A dose that pairs with nothing is tried again without the lowest parameter that needn't match, and its row says what was left out. Many to one gives each evaluated dose its closest reference dose; many to many gives every matching combination, and can pair a reference field shaped by the jaws with an evaluated field shaped by the MLC to the same opening. Scale the evaluated dose by the MU ratio when MU differ (off by default) multiplies the evaluated dose by reference MU / evaluated MU before comparing; the row's key says "scaled × 1.0101 (MU 100/99)" and the CSV's DoseScale gives the factor. Doses are never normalized to a point or their maximum (TG-218's relative mode): the MU ratio is a known correction, not that;
    • plan UID and beam name, on the command line only (--match uid): the same plan, by its UID less Eclipse's save time, and the beam by name, so a renumbered beam still pairs.

    Two TPS systems give the same plans different UIDs, so their folders pair only by label.

    Doses with no match are listed rather than silently skipped.

    Every key also carries the dose's algorithm, so AAA pairs only with AAA. Eclipse's exports don't record the algorithm, so it's read from the plan label and beam name: Settings, Algorithm names, by default AAA = AAA; AXB = AXB, Acuros; eMC = eMC, each token matched anywhere in a name, ignoring case. When the names name none, the folder's Algorithm box is used. A dose with no algorithm, or names that give two, pairs only with others that have none, as every dose did before 2026-11-16. The library's pairing rules that rewrite to {algorithm} pair across algorithms and leave it out of the key.

    When several doses share a key on either side (two copies of a plan, or a recalculation kept beside the original), none is picked. Every reference x evaluated pairing of that key is compared, and for each criterion only the worst is kept: a pairing that fails to load or compare first, then the lowest pass rate, then the most failed points. The row names the two files that gave it, and Ambiguous (CSV column Candidates) says how many pairings it was chosen from. The doses are also listed as ambiguous. Before 2026-11-16 such a key was left out of the comparison entirely, so a folder with duplicates now gives more rows, and stricter ones.

  3. For each pair, and for each set of criteria you have added, counts the voxels above a dose threshold and how many of them fail a dose-difference / distance-to-agreement (DTA) test.

  4. Shows the results in a table, and writes them as CSV (Export), each row naming the build that wrote it.

Export one dose file per beam if you want each beam analyzed separately.

The comparison

Reference and evaluated are compared point by point over the region where their dose grids overlap, sampled on the coarser of the two grids.

  1. Low-dose threshold. A point is evaluated only if the reference dose is at least Threshold % of the global reference dose. The evaluated dose plays no part in this, so an evaluated dose that drops far below the reference is counted as a failure, not skipped. The threshold follows the gamma convention (TG-218 recommends 10%). TRS-430, TG-53 and MPPG 5.a instead give the low-dose region its own, looser criterion, so a DSC pass rate isn't comparable with their tables.
  2. Dose difference. The point passes if |evaluated − reference| is within the allowed difference:
    • Global (% of Global reference dose): Dose difference % of the global reference dose. With a 100 Gy maximum and 3%, a point of 12.1 Gy in the reference and 15.0 Gy in the evaluated dose passes (2.9 Gy ≤ 3 Gy).
    • Local (% of Each point): Dose difference % of the reference dose at that point. The same point fails (2.9 Gy > 0.363 Gy).
  3. Distance to agreement (DTA). If the dose test fails and a DTA distance in mm is set, the point still passes when the evaluated dose lies between the lowest and highest reference doses found that distance away along ±x, ±y and ±z. Neighbours outside the compared region are ignored. This is a deliberately fast approximation, not a full search of the sphere around the point.
  4. Otherwise the point fails.

DTA distances are in mm. Voxel-based distances are reserved for a future feature: if a criterion is set to voxels, the dose difference alone decides pass or fail and the DTA distance is ignored.

The result for each pair is the percentage of evaluated points that failed: 0% means the distributions agree everywhere under your criteria, 100% means no point agreed.

Byte-identical pairs skip the comparison. As each pair is read, before it is queued for comparison, its two grids are compared byte for byte: the same geometry and every dose the same bits. An identical pair passes every criterion, gamma included, with every voxel counted as compared and none failed, and no engine runs; its Checks cell says "identical, byte for byte". With Evaluated box only, an evaluated dose that matches wherever it was read is then read whole and checked again, so only pairs that look identical pay for the full read. The CSV's Identical column says which rows these are.

Diagrams of the whole flow, from folders to CSV rows and point by point: design/data-flow.md.

The same rules, several engines. The comparison can run on different engines, chosen as a setting:

  • HandWrittenComparer: the original, one thread, every point. This is the default and the reference.
  • SingleThreadComparer and MultiThreadComparer: the same rules, skipping points that cannot reach the threshold (see below), on one thread or several.
  • OpenClComparer: the same rules on a GPU, in double, written in OpenCL. Only the part of each grid the calculation needs is uploaded. An ILGPU engine was dropped for 2.0; a settings file that names it now runs OpenCL.

Every engine gives exactly the reference's counts; the library's tests check this on every reference file and on random edge cases.

In the window's Settings tab they are listed by plain name, with a line describing the chosen one: Reference: every point, one thread (HandWritten), CPU, one thread, CPU, several threads and Graphics card (OpenCL). settings.json keeps the code names. Hover text on the criteria, the result columns and the settings says what each means; it is kept in one place, apps/DSC.Shared/HelpText.cs.

Float, on GPUs only, by choice. Many consumer GPUs run double precision far slower than float, for example NVIDIA GeForce RTX 20 series at about 1/32 of the float rate and RTX 30 and 40 series at about 1/64 (vendor figures; check your card). For those, the GPU engines offer float. It may differ from the reference by a few points out of millions, where a point sits within rounding of a tolerance or the threshold.

Each pair is loaded once. Every criterion runs on a pair's grids once they're loaded, with one global reference dose and one edge check. A GPU engine also uploads the pair once for all its criteria: the part of each grid that any of them needs. A result's elapsed time is therefore the pair's, shared by all its rows.

Applies to. Each criterion can be limited to photon or electron beams, by the reference plan's RadiationType, or left at Both. A dose with no reference plan is compared only by Both criteria. The CSVs have an AppliesTo column.

Threads use physical cores only. Every default thread count is one per physical core: SMT siblings are ignored, and so are Intel's low-power E-cores (a core with no L3 cache when other cores have one). The operating system schedules the threads; they aren't pinned to cores. On a 4 P + 8 E + 4 LP-E laptop, pinning 12 threads would be 13–44% faster (design/core-selection.md), but letting the OS schedule is the goal. The Threads list (Settings tab) runs from 1 to every logical processor, in steps of 1 to 4, then 2 to 12, then 4, and defaults to that count, marked "(recommended)". The L3 rule is a stand-in under review: design/core-selection.md.

Reading, neither changes a count (on in the apps by default, agreed 2026-11-15; off in the library unless set):

  • Evaluated box only: each evaluated dose is read only where the criteria and the edge check use it, which is the box at the lowest threshold among the criteria. A pair with a gamma criterion reads its evaluated dose whole.
  • Read queue: Readers files (4 by default) are read at once into a queue of Held loaded pairs while the workers compare. Fewer readers run if the queued pairs wouldn't fit in half the free memory. 0 readers has each worker read its own pair.

Settings. Engine, Threads, pairs at once and the reading options belong to the machine: the apps' Settings tab (a top tab of its own) keeps them in settings.json under the user's application data folder (%APPDATA%\DicomStrictCompare on Windows, ~/.config/DicomStrictCompare on Linux). The global reference dose and GPU float, which can change results, belong to the comparison and aren't kept there.

Pairs at once. Several pairs can run side by side as well. Left at 0, the number is chosen from free memory: as many as half of it holds, up to the physical core count, or 2 for the multi-thread and GPU engines.

Global reference dose. The threshold and the global dose difference are percentages of a global reference dose. Nothing is rescaled: neither dose is normalized to the other, and the global reference dose only sets what 100% is. It is the reference's volume maximum, or the central-axis maximum (the highest axis dose, averaged over 3 × 3 voxels; for an arc, about the isocentre), used only when the plan's jaws are on axis. Global gamma uses the same dose; local gamma uses each reference voxel's. Each result says which it used (Global ref. dose). TG-218, which calls this global normalization, recommends a point in a low-gradient region near the maximum; the central-axis maximum of an open field is such a point, and the volume maximum is the maximum itself.

Edge check. For static flattened photon fields, each dose's 50% edges at 10 cm depth are compared with its plan's jaws, and a difference over 2 mm is reported on the result. Wedged, MLC-shaped, FFF and electron fields are not checked yet.

Checks. Before any dose is compared, each pair's two headers and plans are compared, and the Checks column says what differs. These are marked ⚠ and highlighted, because they change what the row's numbers mean:

  • grid spacing 1.5× or more apart on any axis (for example 1 mm against 2.5 mm), since the pair is compared on the coarser grid;
  • dose units, type or summation;
  • any beam setting the plans disagree on: MU, energy, jaws, MLC, angles, wedges, applicator, isocentre, SSD.

Different grid extents, offset voxel centres, smaller spacing changes, the machine's name, a plan that could not be checked, and the heterogeneity correction (TissueHeterogeneityCorrection) are described but not highlighted. The heterogeneity tag records an HU override but not a material one, so it neither shows nor rules out a difference. A byte-identical pair is never highlighted: its findings are described, since nothing in the headers changed the dose. The grid and the heterogeneity correction are set per plan, so the Checks column only names them (plan: grid), and the Plans tab says each once per plan pair, with how many of its field pairs show it and how many were identical. Only flagged rows above the table shows just the highlighted rows. That row also filters by plan, criterion, outcome (Show) and words (Find), as the scans tabs do; and the status line counts the flagged pairs by check. The CSV has Checks, ChecksFlagged and Identical, plus Grid, GridSpacingRatio and GridFlagged.

Points that cannot reach the threshold are skipped. An interpolated dose is a weighted average of the voxels around it, so a point can only reach the threshold if one of those voxels does. The faster engines therefore look only inside the bounding box of reference voxels at or above the threshold (plus a margin). This changes no result: every point is still counted.

This strict test is the composite dose-difference / distance-to-agreement (DTA) test of Harms et al. (TG-218 §2.D), applied point by point, with a fast stand-in for the DTA search: the evaluated dose must lie between the lowest and highest reference doses found at the DTA distance along each axis. TG-218 notes that gamma is slightly more forgiving than the composite test (§2.E). It is not gamma.

Gamma is a separate choice per criterion (the Gamma column): GammaShell, a port of pymedphys' gamma. On 2026-11-15 it gave pymedphys 0.41.0's counts exactly in all 70 cases of a sweep: 7 E##V## pairs, 0.1%/0.1 mm to 10%/10 mm, global and local, run by an agent that never saw this code. At the edge of a phantom, a reference point whose search can't reach any evaluation point is not analyzed, as in pymedphys: it is left out, not failed (GammaResult.NotReached counts them).

The methods' origins:

  • Distance to agreement: J. Van Dyk, R. B. Barnett, J. E. Cygler and P. C. Shragge, Commissioning and quality assurance of treatment planning computers, Int. J. Radiat. Oncol. Biol. Phys. 26(2), 261–273 (1993).
  • The composite dose-difference and DTA test: W. B. Harms, D. A. Low, J. W. Wong and J. A. Purdy, A software tool for the quantitative evaluation of 3D dose calculation algorithms, Med. Phys. 25(10), 1830–1836 (1998).
  • Gamma: D. A. Low, W. B. Harms, S. Mutic and J. A. Purdy, A technique for the quantitative evaluation of dose distributions, Med. Phys. 25(5), 656–661 (1998); the implementation follows pymedphys (see THIRD-PARTY-NOTICES.md).

Criteria you can set

Field Meaning
Dose difference % The dose-difference criterion at each point
DTA mm The distance-to-agreement criterion in mm; 0 means dose difference only
Threshold % The low-dose threshold: percentage of the global reference dose below which voxels are not compared
% of Global reference dose, or Each point (local): what the dose difference is a percentage of
Gamma Gamma (pymedphys' method) in place of the strict test, with the same dose difference, DTA and threshold
Applies to Photons, Electrons, or Photons and electrons: which beams the criterion compares

The criteria list shows one line per criterion; choosing a line shows its settings below it, and every setting has hover text. The library can also trim voxels off the edge of the overlap; the window doesn't offer it.

The window starts with 0.1%/0 mm global, 3%/2 mm local, and 3%/2 mm global gamma, all with a 10% threshold, and the global reference dose set to the central-axis maximum (crcrewso, 2026-11-18), which falls back to the volume maximum where the jaws aren't on the axis.

The difference viewer

Shows where two doses disagree, in 3D. It's the 3D viewer tab inside Doses vs doses (a top tab of its own until 2026-12-01), View difference on a result row's right-click menu, or --viewer REFERENCE EVALUATED on the command line.

  • The row's own comparison: View difference fills in the row's dose difference, DTA, threshold, gamma or strict test, global or local, and global reference dose, and computes with them, so the viewer's counts are the row's. It works while a run is still going. The page's header lists every parameter. Its state is in ViewerViewModel.
  • The maps: gamma (capped at 3) or the strict test's failures, and the signed difference (evaluated minus reference, as a % of the maximum used, or of each reference point for a local criterion), on the reference grid, with the reference dose underneath. The strict test runs on the comparison's own sample points, so each voxel shows its nearest one. Written as NIfTI, a format most medical imaging tools read.
  • Byte-identical pairs count every voxel in the comparison and only those above the threshold in the viewer.
  • The frame is the beam's: x along the collimator-0 X jaws, y along the Y jaws, z along the beam axis toward the source. The origin is the isocentre for an arc and the phantom's centre for a static gantry. Head first supine at couch 0 only; a patient position the plan doesn't state (missing, or UNKNOWN) is taken as head first supine and the frame's note says so; anything else is refused. The Doses vs scans tab does the same.
  • Shown by NiiVue (BSD-2, bundled) in the window's web view: linked slices and a 3D render. Each slice fills its quarter of the pane, outlined at the edge of the dose grid, so the slices don't share one mm scale. Hide below hides values whose size is below it (at 1: gamma under 1, and differences between −1% and +1%). Cut removes everything on one side of a plane through the crosshair. A click reads out the position, dose, gamma and difference. Open in browser shows the same page in the system browser; its address keeps the settings and the 3D angle (?show=&threshold=&top=&view=&azimuth=&elevation=), so a view can be linked. The 3D view opens at azimuth 225°, elevation 20° (crcrewso, 2026-12-02) unless the address gives an angle.
  • Print / PDF (UX8, crcrewso, 2026-12-02): PDF of this view, the failures (gamma or the strict test), the % difference, or both, each drawn at the current view and angle, captured from the canvas and printed as its own landscape page with the pair's files, criterion, counts and view settings; the browser's Save as PDF writes the file. ?print=both (or current, gamma, percent) in the address opens it.
  • The page is served from this computer only (127.0.0.1); nothing leaves it.
  • Details and checks: design/difference-viewer.md.

Water-tank scans against each other

The Scans vs scans tab compares two folders of PTW scans: a baseline against a later measurement, or one detector or tank against another.

  • Pairing. A scan of set A pairs with every scan of set B of the same beam and the same curve:

    • the beam: modality, energy, FFF, field, SSD, gantry, collimator and wedge;
    • the curve: depth dose or profile, depth, off-axis position and angle.

    Both are compared after rounding, so files that spell a number differently still pair. A curve that set B measured more than once gives a row for each, marked Ambiguous. An unpaired scan says why, naming what differs from the nearest beam the other set did measure ("set A has it at SSD 1000 mm, not at SSD 950 mm").

  • The comparison is the Doses vs scans one, with set B read by linear interpolation in place of the dose:

    • only where the two scans overlap;
    • normalized by the same rule;
    • gamma or the strict test, global or local;
    • constancy in the central field, and each set's profile or depth-dose metrics.

    Set A is the reference unless Reference set says B. Depth shift fits B's depth dose deeper or shallower, for detectors with different effective points of measurement. A pair passes when at least Pass rate limit % of its points pass (95% by default).

  • Results: the table with energy, field, curve and Find filters, the figure (the sides named by the sets' names), saved plots, and Export:

    • scans-results.csv: each pair's counts, constancy, depth shift, and each metric for both sets with B − A;
    • scans-unpaired.csv;
    • the chosen plots in scans-plots/.

Water-tank scans against a calculated dose

tools/DSC.Profiles compares PTW water-tank scans (.mcc) with RT Doses, so commissioning measurements can be checked against the planning system's beam model:

dotnet run --project DicomStrictCompare/tools/DSC.Profiles -- <scansDir> <dosesDir> <outputDir> --dose 2 --distance 2
  • Pairing. Each scan is paired with a dose whose plan beam is the same field. They must agree on:

    • modality, energy and FFF;
    • the field's size and centre along the tank's two axes, within 0.5 mm. The plan's jaws are turned by its collimator; for electrons, the applicator is used (A10X6 is 10 cm along X by 6 cm along Y). An electron dose with a custom cutout is skipped: any block other than an aperture the applicator's own size. The unpaired list names each one with its cutout's size (crcrewso, 2026-12-01; before, an open-applicator scan paired with every cutout on its applicator);
    • the wedge angle and IN/OUT. When a scan's header gives the angle but no direction, the direction is taken from its COMMENT ("Y1 IN", as PTW's EDW scans write it), else, for an inplane profile at collimator 0, from its slope (IN falls toward +inplane), and the row's notes say which (MP5, crcrewso, 2026-12-01; before, such a scan didn't pair). A slope can't tell a mirrored session from the other direction, so a header fix wins over both;
    • the SSD, where the plan states one.

    Names aren't used. Of the doses that match, a scan pairs with the finest grid of each algorithm (crcrewso, 2026-12-01): AAA and AXB give two rows, and the Algorithm filter lists either. A coarser grid, or a dose on the same grid whose file name sorts later, is listed under Unpaired as not used. Before 2026-12-01, every matching dose gave a row. A header fix takes effect when it's saved: that scan, or every scan in its file, is recalculated at once.

  • Header check. Pairing trusts each scan's header, so each crossplane and inplane scan's curve is first checked against it (ScanHeaderCheck). A scan is flagged when:

    • its field, measured between the steepest points of its two penumbrae and projected to the SSD, is more than 15% off the header's (the steepest point, not 50% of the axis dose, so FFF and wedged fields measure true);
    • or the header says no wedge but a photon field slopes more than 3% from side to side. Not checked for electrons, fields under 3 cm, or fields centred off the axis, none of which is level;
    • or, for a wedged pair, the measured and calculated doses slope opposite ways, each by more than 3% over the central 80% of the field: the scan looks mirrored (the tank, or its software, set up the other way round, or the wedge's IN and OUT swapped). This one is per pair, so it shows only in Doses vs scans.
  • Header fixes. A wrong header can be corrected per scan, or for every scan in a file: energy, FFF, field size, wedge, a profile's direction (inplane, crossplane or diagonal), and Mirrored inplane or crossplane, for a scan taken with the tank or its software the other way round along that axis (its positions and that axis's offsets change sign). Fixes are kept in dsc-header-fixes.json in the scans folder (ScanHeaderFixes); the scan files are never changed. Each scan is read as if its header had said the fixed values, so pairing and the header check use them (a right fix clears the check's flag), and every row it gives says what was fixed and what the file said (the results' header_fix column; the settings file names the fixes file). DSC.Profiles uses the scans folder's file when there is one; --header-fixes FILE names another, --no-header-fixes ignores them. In the window, Fix scan header… (also on a row's right-click menu) opens a form filled from the scan's header.

    On the TrueBeamA 10 MV low res wedges scans, fixes giving each one's wedge and field (taken from the 17 June EDW scans' order and shapes) clear every flag, and the scans pass 90 to 100% at 1%/1 mm against the EDW doses, apart from the 45 and 60 degree scans at 5 cm (54 to 68%); the same fixes with the 60 degree directions swapped pass 0 to 3%.

    A header-check flag changes nothing else: the scan is still paired and compared as its header says. It is written in the results' header_check column (with header_field_mm, scan_field_mm and scan_slope_percent) and the unpaired file. On the TrueBeamA scans it flags every "low res wedges" scan (wedged, headers say open 10 x 10) and one 15 MV scan whose header says 8 x 8 but which is 6 x 6. (It also flagged every 40 x 40 scan as about 50 cm wide: those are diagonals, which 2.0 read as axis profiles until MP6. A diagonal isn't field-checked.)

  • Geometry. Only head-first supine at gantry and couch 0. The beam axis is the isocentre's x and z, and the beam runs along +y.

    • The water surface is the plan's surface entry point, else its SSD, else the scan's SSD, placed from the source at isocentre y minus SAD.
    • The dose's own surface is always checked against it.
    • Crossplane runs along +x (toward the patient's left). Inplane runs away from the gantry, toward the feet (-z): PTW's GUN_TARGET, as a tank is normally set up (crcrewso, 2026-12-01). EDW scans settle the inplane sign: IN falls along +inplane in four sessions at three sites (TrueBeamB 2013, TrueBeamC 2022, TrueBeamD 2023, TrueBeamA 17 June 2026). Nothing in the data settles crossplane; it assumes PTW's axes are right-handed. A half-field scan can't settle either: it pairs by its header's offset, which follows the tank's axes, so it matches whichever way round the tank is. Before 2026-12-01 inplane ran along +z, so every wedge and asymmetric inplane comparison was mirrored; a symmetric field's results don't change.
    • Diagonals (MP6, 2026-12-02) run through the axis at the scan's depth, 45° between crossplane and inplane, with positions along the diagonal. PTW writes one as SCAN_DIAGONAL=FIRST_DIAGONAL or as SCAN_ANGLE=45, the curve type still saying crossplane or inplane. A crossplane label is read as the crossplane axis turned 45° toward +inplane, an inplane label as the inplane axis turned the same way, so the two labels are the two diagonals. SECOND_DIAGONAL or -45° swaps them, and any other angle goes unpaired. Which label is which diagonal is unconfirmed: an open square field reads the same along either (to 0.01% on TrueBeamA 40 x 40). The field-size, wedge-slope and mirror checks are for axis profiles and skip a diagonal; a diagonal's field size is its own 50% width along the diagonal. Mirrored on one axis turns a diagonal into the other one.
      • Measured: the TrueBeamA 40 x 40 diagonals (5 energies, 3 to 4 depths, both diagonals) pass 92.9 to 100% at 2%/2 mm gamma against E18V15 STBjawAAA; read as axis profiles, as 2.0 did before, 10 MV passed 55 to 74%.
  • Scans are compared as dose. DSC doesn't convert depth ionization to dose: an electron depth scan is taken to have been converted already (in the scanning software, or measured with a detector that needs none), and its R50 is the R50 of dose, not R50,ion (TRS-398 §7.3.2). Check how your scans were exported.

  • Normalization. A depth dose goes to its maximum. A profile goes to its central axis, or to its maximum when either side's central-axis value is under 80% of its maximum (an off-axis field).

  • Tests:

    • Gamma (GammaShell, the pymedphys port, in one dimension). The port takes only evenly spaced points, so a measured evaluated curve is put on an even grid whose step lands on every measured point: gamma follows the scan exactly, and two identical scans give gamma 0. Before 2026-12-01 the step was the scan's finest, which could miss points where the tank's steps change, and gamma rose to about 0.4 at a steep penumbra (release to-do FX6).
    • or the strict rule of the dose comparison above, along the scan. A distance of 0 makes it a dose difference.
    • The measurement is the reference by default (--reference calculated swaps them). The low-dose threshold is a percentage of the reference maximum.
    • A pair passes when every evaluated point passes. In the window, it passes when at least Pass rate limit % of its evaluated points pass: 95% by default (crcrewso, 2026-11-30). A pair with no evaluated point fails either way.
  • Also reported:

    • constancy: the mean relative difference over the central 80% of the reference field;
    • FauxPID's profile metrics for both sides, the ones chosen with Profile metrics… beside the export (--metrics): by default field width, CAX offset, flatness by variance and symmetry by CAX point difference;
    • depth-dose metrics (dmax, PDD(10 cm), PDD(20 cm), R50) for both sides;
    • an optional depth-dose shift search (--depth-shift 3,0.1), off by default: the calculation read at depth + s, each curve to its own maximum, and the s with the smallest mean squared difference over measured depths 5 to 50 mm (crcrewso, 2026-12-02; before, it was fitted beyond dmax to the scan's end).
    • optional scaling by the session's PDD (--session-pdd, Scale by session PDD on Doses vs scans; off by default; crcrewso, 2026-12-04). Normally each curve is normalized on its own: a depth dose to its maximum, a profile at its central axis, so a profile whose level is off at its depth still looks right. With this, the curves of one measuring session (the same folder, day, detector and beam) share one scale instead: the scans are divided by the session PDD's reading at dmax (the top of a parabola through its points within 5 mm of the highest), the doses by their 3 × 3 central-axis dose at that depth. A session with no PDD on the axis, or more than one, keeps the usual normalization and its rows say so. With the depth shift on too, the session PDD's shift applies to its profiles: they read the dose that much deeper. Water-tank scans are relative measurements, so one point per session is normalized; doses against doses are never normalized at all.
  • Output:

    • <stem>-results.csv: one row per scan and dose;
    • <stem>-unpaired.csv: each scan with no dose, with the reason;
    • <stem>-curves.csv, with --curves;
    • <stem>-settings.txt;
    • with --plots, an image of every compared pair in <stem>-plots/, or with --plots-failing only pairs with a failed point. Each is named after its results row (0012 ...png), which its plot column also gives. --plot-format svg and --plot-size 1600x1200 change the format and size (PNG, 1200 x 900 by default).
  • Plots. The figure (DSC.Plots/ProfilePlot) has two parts:

    • above, the measured and calculated curves as compared, normalized, with the threshold line and a box of both sides' metrics;
    • below, each evaluated point: gamma with its pass line at 1, or for the strict test the dose difference with the dose-difference band. Points are marked pass or fail; a strict point outside the band can still pass on distance.
  • In the window. The window has a tab at the top for each kind of comparison, each with its own inputs and results: Doses vs doses, the comparison above, with the difference viewer as its 3D viewer tab; Doses vs scans, which runs this same batch; and Scans vs scans. A last top tab, Settings, holds this machine's engine, threads and reading options, which serve every tab that compares doses, the theme (System, Light or Dark), where the scans tabs put their table (beside the figure, or above it with the two plots side by side), and GPU float, which belongs to the comparison. Its settings, GPU float included, are saved as they change and reloaded at the next start. Reset all settings to default puts the whole tab back. Every table has a right-click menu to copy a value or a row, and columns resize by dragging.

    • The Doses vs scans tab has its own Doses and Scans folders, plan-label filter and folders to skip. Until a doses folder is chosen there, it takes the Doses vs doses reference folder.

    • Its criterion is 1%/1 mm gamma with the measurement as reference by default. The test, the reference, local dose difference, the threshold, the pass rate (95%) and the depth-dose shift search can be changed. A change shows only after Run.

    • The table lists every pair by its results row. Filters:

      • Energy and Field: dropdowns of check boxes with All and None, any number ticked. Field offers only the field sizes measured at the ticked energies.
      • Curve, and Show: all pairs, failing, not compared, or those whose scan disagrees with its header (the table's Header column says "check"; the row's details say what disagrees).
      • Find: words every listed row must contain anywhere in its scan path, energy, field, curve, depth, dose, plan, beam or outcome, ignoring case and spaces; numbers match whole. "10FFF 6x6" lists the 10FFF folder's 6 x 6 scans.

      Unpaired lists the scans no dose pairs with, and why. The chosen pair's figure is drawn beside the table. Ctrl or Shift click chooses several pairs, drawn together as the Graphs tab draws depths: one colour each, measured solid and calculated dashed, and below, each pair's evaluated points, a failing one crossed (crcrewso, 2026-12-02).

    • Save plot writes the figure shown as PNG or SVG; for several pairs, the file is named after the first, with "+N". Save plots of listed pairs writes one for every pair the filters list.

    • Export results (CSV) writes the files DSC.Profiles writes (stem profiles), with no plots, the failing pairs' plots or all of them.

    • --scans DIR (and --doses DIR, else --reference) on a window's command line opens this tab and runs it; --exclude REGEX fills its folders to skip.

Assumptions and limitations

  • Dose files are calculated head first supine and as absolute dose. Relative dose distributions have not been tested.
  • The code assumes the dose volume is a phantom used in TPS commissioning. Nothing in the method should stop it working on patient datasets, but that is not its tested purpose.
  • Reference and evaluated are compared only over the region where their dose grids overlap, at the coarser of the two grid resolutions.

Requirements

  • The comparison library (DSC.Library), its tests and the window run on Windows and Linux. macOS is not built or tested for 2.0.
  • .NET 10 SDK to build.
  • NuGet packages restored automatically on build, including EvilDICOM (dose grids and headers are now read by the library's own reader), MathNet.Numerics, ScottPlot for the plots, Silk.NET.OpenCL for the GPU engine, and Avalonia 12 for the window.
  • For the difference viewer: a web view with WebGL2. Windows has WebView2. On Linux, WebKitGTK (the window sets GDK_BACKEND=x11 so GTK can embed it).
  • For the GPU engines only: an OpenCL driver for the GPU. On Windows it comes with the graphics driver. On Linux the vendor's OpenCL package is needed (for example intel-opencl-icd).

Build, run and test

From the repository root:

# Library tests (any OS)
dotnet test DicomStrictCompare/DSC.Library.Tests/DSC.Library.Tests.csproj

# The window (any OS)
dotnet run --project DicomStrictCompare/apps/DSC.AvaloniaApp

It takes a command line, so a run can be repeated from a script: --reference DIR --evaluated DIR, --run, --export DIR, --gamma, --gpu-float, --scans DIR, --viewer REFERENCE EVALUATED and others (apps/DSC.Shared/LaunchOptions.cs lists them).

DSC.Library.Tests/ComparisonRulesTests.cs checks each comparison rule above on small synthetic grids. Both test suites pass in full: dotnet test DicomStrictCompare/DicomStrictCompare.slnx (436 library and 39 shared tests at 2.0's start).

DicomStrictCompare/DicomStrictCompare.slnx holds every project in use, and builds clean on any OS.

User documentation is in docs/ (Sphinx with MyST Markdown, for Read the Docs): the results and command-line references, and the release notes. Build it with uv run --with-requirements docs/requirements.txt sphinx-build -W docs docs/_build/html. The programs carry it (RD13): a build after that embeds docs/_build/html in DSC.Shared, and Help (F1) (top right of every tab, and on Settings) or F1 opens it in the browser at the current tab's part, served from 127.0.0.1 (Help/HelpServer). The release script builds the guide first; a build without it serves a page saying how to add it.

Release files (2.0 on): pwsh DicomStrictCompare/packaging/Publish-Release.ps1 -VersionSuffix beta.1 writes a single-file exe on Windows, or an AppImage on Linux (with appimagetool installed; without it, the AppDir folder), and SHA256SUMS.txt. The AppImage carries the AppImage runtime, pinned: pass the file with -AppImageRuntime, and re-pin it at each release prep (the workflow checks the same file's SHA-256). It's named DSC-v2-Beta, set by -ReleaseName; the version is inside the program. Beside it go LICENSE.txt, LICENSE-AGPL-FALLBACK.md, LICENSE-AGPL-3.0.txt, THIRD-PARTY-NOTICES.md and THIRD-PARTY-LICENSES.txt: every package's licence as the program carries it, from the NuGet cache, with the standard texts kept in packaging/licenses/; the AppImage carries its own in usr/share/doc. The Release build workflow does the same on GitHub's machines, run by hand, and attaches build provenance. Neither publishes a release or creates a tag. The old Windows Forms GUI, DSCcore, was removed for 2.0; the v0.3 tag keeps it. The Eto window was dropped on 2026-12-04, before 2.0's release: its Windows backends need the Windows API Code Pack, whose terms clash with the AGPL fallback. Commit fa8ed19 is the last with it.

The project page is site/ (one HTML page and its stylesheet), published to GitHub Pages by the Pages workflow on a push to main that changes it; the screenshots and icon are copied in from docs/images/ and apps/Assets/.

The tests use real RT Dose and RT Plan files of a test phantom, and a PTW scan, stored once in DicomStrictCompare/resources/ and read at run time. The RT Dose grids (about 660 MB) are in Git LFS: install git-lfs before cloning, or run git lfs pull after, or the tests find pointer files.

Using it

The window has these tabs:

  • Doses vs doses: choose the Reference and Evaluated folders, edit the criteria, and Run. Results, unpaired doses, a log and graphs appear in the tabs beside them. Export results writes them as CSV. Match first, if you like: it reads only the headers and pairs the doses as a run would, and says how many pairs and result rows the run will give, and what doesn't pair. Seconds, where a run can take hours. Graphs draws a pair's depth dose and profiles, with depth from the water surface placed as on Doses vs scans, or from the isocentre plane where that can't be placed; its status line says which. 3D viewer is the difference viewer (above).
  • Doses vs scans: calculated doses against water-tank scans (above).
  • Scans vs scans: two folders of water-tank scans against each other (above).
  • Settings: this machine's engine, threads and reading, kept per machine.

Repository layout

DicomStrictCompare/
  DicomStrictCompare.slnx  the one solution
  DSC.Library/             comparison maths: dose matrix, DTA criteria, comparison results, profile tools
  DSC.Library.Tests/       MSTest tests for the library
  DSC.Plots/               figures of the library's results (ScottPlot 5), shared by the window and the tools
  apps/                    the window (DSC.AvaloniaApp), its view models and runners (DSC.Shared, including
                           Viewer/ with the bundled NiiVue), and their tests
  tools/                   command-line tools: DSC.Profiles (water-tank scans against doses), DSC.Resample (resampling)
  benchmarks/              the GPU benchmark and its runner, with its own Benchmarks.slnx
  resources/               the test data: RT Plan and RT Dose of test phantoms, and PTW scans
design/                    design notes, and the data-flow diagrams (data-flow.md)

Status

Maintained. 2.0, a portable single-file release for Windows and Linux, is in preparation on releases/2.0. A Python reimplementation, crcrewso/Py142, is retired; DicomStrictCompare is the maintained tool. Questions go in Discussions, bugs in issues; the maintainer is also u/crcrewso on Reddit.

Licence

DicomStrictCompare is distributed under the PolyForm Shield License 1.0.0. Anyone may use, change and share it, for any purpose, paid clinical work such as commissioning included, except to offer a product that competes with it: selling it, or a reskin of it, is not allowed. If the project goes 36 months with no new commit or release, every version is also licensed under the GNU Affero General Public License, version 3 or later; see LICENSE-AGPL-FALLBACK.md. PolyForm Shield is source-available, not an OSI open-source licence. 0.x, up to commit aefe49a (the releases/0.x branch), remains under the GNU Lesser General Public License v3.0. Outside contributions are MIT-licensed by their authors (see CONTRIBUTING.md).

It uses EvilDICOM, which has its own licence. The difference viewer bundles NiiVue 0.69.0 (BSD 2-Clause; apps/DSC.Shared/Viewer/assets/NIIVUE-LICENSE.txt).

About

This C# program will compare folders of Dicom Dose files. This relies on EvilDICOM and is distributed under the MIT licence.

Resources

Contributing

Stars

6 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages