Skip to content

Inquiry on Density Map #415

Closed
Closed

Description

@danielemolino

Hi, thanks for DiffDRR and nanodrr. We've used the former heavily for chest X-ray-to-CT work.

This is a question rather than a bug report. In diffdrr/data.py:

air = torch.where(volume <= -800)
...
density[air] = volume[soft_tissue].min()

every voxel at or below −800 HU is assigned the same scalar. Normal aerated lung parenchyma spans roughly −950 to −700 HU, so on chest CTs most of the lung lands on that floor and becomes indistinguishable from the air outside the patient.

nanodrr's hu_to_mu doesn't do this: it clamps at −1000 and applies a bilinear
water/bone model, so the variation is preserved.

I assume the DiffDRR behaviour is deliberate for the registration setting the library was built around, where bone carries the signal and NCC/MI are invariant to intensity rescaling. If that's right, would a one-line note in the docstring be welcome? It isn't obvious from the outside, and DiffDRR is still what most X-ray-to-CT work installs.

Happy to send a PR with just that.

Activity

  1. eigenvivek commented on Sep 8, 2026

    @eigenvivek
    Owner

    Hi @danielemolino thanks for trying out diffdrr! The thresholding ranges were a port from the behavior in deepdrr. I don't know if it actually makes a difference for registration, it's just a convention I adopted early in development. Absolutely feel free to make a PR (note the archaic nbdev structure used for diffdrr's docs, sorry about that).

    https://github.com/arcadelab/deepdrr/blob/cb2cb3ad1a1f68c09f79a11f4ce583bff9ff67bb/deepdrr/load_dicom.py#L132-L143

    I did want something more principled for nanodrr, so I just implemented #378 in that package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions