Skip to content

Commit

Permalink
Update API
Browse files Browse the repository at this point in the history
  • Loading branch information
eigenvivek committed Oct 4, 2023
1 parent 4aa3d4c commit 5cf096a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion diffdrr/drr.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def __init__(
self.air = torch.where(self.volume <= -800)
self.soft_tissue = torch.where((-800 < self.volume) & (self.volume <= 350))
self.bone = torch.where(350 < self.volume)
self.set_bone_attenuation_multiplier(bone_attenuation_multiplier)
self.bone_attenuation_multiplier = bone_attenuation_multiplier

def reshape_transform(self, img, batch_size):
if self.reshape:
Expand Down Expand Up @@ -104,6 +104,8 @@ def forward(
bone_attenuation_multiplier: float = None, # Contrast ratio of bone to soft tissue
):
"""Generate DRR with rotational and translational parameters."""
if not hasattr(self, "density"):
self.set_bone_attenuation_multiplier(self.bone_attenuation_multiplier)
if bone_attenuation_multiplier is not None:
self.set_bone_attenuation_multiplier(bone_attenuation_multiplier)

Expand Down
4 changes: 3 additions & 1 deletion notebooks/api/00_drr.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@
" self.air = torch.where(self.volume <= -800)\n",
" self.soft_tissue = torch.where((-800 < self.volume) & (self.volume <= 350))\n",
" self.bone = torch.where(350 < self.volume)\n",
" self.set_bone_attenuation_multiplier(bone_attenuation_multiplier) \n",
" self.bone_attenuation_multiplier = bone_attenuation_multiplier \n",
"\n",
" def reshape_transform(self, img, batch_size):\n",
" if self.reshape:\n",
Expand Down Expand Up @@ -220,6 +220,8 @@
" bone_attenuation_multiplier: float = None, # Contrast ratio of bone to soft tissue\n",
"):\n",
" \"\"\"Generate DRR with rotational and translational parameters.\"\"\"\n",
" if not hasattr(self, \"density\"):\n",
" self.set_bone_attenuation_multiplier(self.bone_attenuation_multiplier)\n",
" if bone_attenuation_multiplier is not None:\n",
" self.set_bone_attenuation_multiplier(bone_attenuation_multiplier)\n",
" \n",
Expand Down

0 comments on commit 5cf096a

Please sign in to comment.