Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose intrinsic parameters #268

Merged
merged 2 commits into from
Jun 11, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Expose intrinsic parameters
eigenvivek committed Jun 11, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit ca392dc21cf7ab622e0299ad0454d7438f1f826b
7 changes: 6 additions & 1 deletion diffdrr/_modidx.py
Original file line number Diff line number Diff line change
@@ -15,9 +15,14 @@
'diffdrr/detector.py'),
'diffdrr.detector.Detector.calibration': ( 'api/detector.html#detector.calibration',
'diffdrr/detector.py'),
'diffdrr.detector.Detector.delx': ('api/detector.html#detector.delx', 'diffdrr/detector.py'),
'diffdrr.detector.Detector.dely': ('api/detector.html#detector.dely', 'diffdrr/detector.py'),
'diffdrr.detector.Detector.forward': ('api/detector.html#detector.forward', 'diffdrr/detector.py'),
'diffdrr.detector.Detector.intrinsic': ('api/detector.html#detector.intrinsic', 'diffdrr/detector.py'),
'diffdrr.detector.Detector.reorient': ('api/detector.html#detector.reorient', 'diffdrr/detector.py')},
'diffdrr.detector.Detector.reorient': ('api/detector.html#detector.reorient', 'diffdrr/detector.py'),
'diffdrr.detector.Detector.sdd': ('api/detector.html#detector.sdd', 'diffdrr/detector.py'),
'diffdrr.detector.Detector.x0': ('api/detector.html#detector.x0', 'diffdrr/detector.py'),
'diffdrr.detector.Detector.y0': ('api/detector.html#detector.y0', 'diffdrr/detector.py')},
'diffdrr.drr': { 'diffdrr.drr.DRR': ('api/drr.html#drr', 'diffdrr/drr.py'),
'diffdrr.drr.DRR.__init__': ('api/drr.html#drr.__init__', 'diffdrr/drr.py'),
'diffdrr.drr.DRR.forward': ('api/drr.html#drr.forward', 'diffdrr/drr.py'),
30 changes: 25 additions & 5 deletions diffdrr/detector.py
Original file line number Diff line number Diff line change
@@ -65,6 +65,26 @@ def __init__(
),
)

@property
def sdd(self):
return self._calibration[2, 2].item()

@property
def delx(self):
return self._calibration[0, 0].item()

@property
def dely(self):
return self._calibration[1, 1].item()

@property
def x0(self):
return self._calibration[0, -1].item()

@property
def y0(self):
return self._calibration[1, -1].item()

@property
def reorient(self):
return RigidTransform(self._reorient)
@@ -78,13 +98,13 @@ def calibration(self):
def intrinsic(self):
"""The 3x3 intrinsic matrix."""
return make_intrinsic_matrix(
self._calibration[2, 2].item(),
self._calibration[0, 0].item(),
self._calibration[1, 1].item(),
self.sdd,
self.delx,
self.dely,
self.height,
self.width,
self._calibration[0, -1].item(),
self._calibration[1, -1].item(),
self.x0,
self.y0,
).to(self.source)

# %% ../notebooks/api/02_detector.ipynb 6
30 changes: 25 additions & 5 deletions notebooks/api/02_detector.ipynb
Original file line number Diff line number Diff line change
@@ -121,6 +121,26 @@
" )\n",
"\n",
" @property\n",
" def sdd(self):\n",
" return self._calibration[2, 2].item()\n",
"\n",
" @property\n",
" def delx(self):\n",
" return self._calibration[0, 0].item()\n",
"\n",
" @property\n",
" def dely(self):\n",
" return self._calibration[1, 1].item()\n",
"\n",
" @property\n",
" def x0(self):\n",
" return self._calibration[0, -1].item()\n",
"\n",
" @property\n",
" def y0(self):\n",
" return self._calibration[1, -1].item()\n",
"\n",
" @property\n",
" def reorient(self):\n",
" return RigidTransform(self._reorient)\n",
"\n",
@@ -133,13 +153,13 @@
" def intrinsic(self):\n",
" \"\"\"The 3x3 intrinsic matrix.\"\"\"\n",
" return make_intrinsic_matrix(\n",
" self._calibration[2, 2].item(),\n",
" self._calibration[0, 0].item(),\n",
" self._calibration[1, 1].item(),\n",
" self.sdd,\n",
" self.delx,\n",
" self.dely,\n",
" self.height,\n",
" self.width,\n",
" self._calibration[0, -1].item(),\n",
" self._calibration[1, -1].item(),\n",
" self.x0,\n",
" self.y0,\n",
" ).to(self.source)"
]
},