Skip to content

Commit

Permalink
middle of something
Browse files Browse the repository at this point in the history
  • Loading branch information
jrkerns committed Feb 14, 2016
1 parent 28d6a7a commit c16601c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
5 changes: 5 additions & 0 deletions pylinac/core/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,11 @@ def center(self):
y_center = self.shape[0] / 2
return Point(x_center, y_center)

@property
def physical_shape(self):
"""The physical size of the image in mm."""
return (self.shape[0] / self.dpmm, self.shape[1] / self.dpmm)

def plot(self, ax=None, show=True, clear_fig=False):
"""Plot the image."""
if ax is None:
Expand Down
16 changes: 9 additions & 7 deletions pylinac/picketfence.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ def __init__(self, filename, filter=None, log=None):
self.image.check_inversion()
if log is not None:
self.load_log(log)
else:
self._log_fits = None

@classmethod
def from_url(cls, url, filter=None):
Expand Down Expand Up @@ -171,15 +173,15 @@ def _adjust_for_sag(self, sag):
def load_log(self, log):
"""Load a machine log that corresponds to the picket fence delivery."""
mlog = MachineLog(log)
fl = mlog.fluence.actual.calc_map(equal_aspect=True)
fli = Image.load(fl, dpi=254)
fl = mlog.fluence.expected.calc_map(equal_aspect=True)
fli = Image.load(fl, dpi=254) # 254 pix/in => 1 pix/0.1mm (default fluence calc)
# crop fluence array to same physical size as EPID
# self.image.physical_shape
hdiff = fli.physical_shape[0] - self.image.physical_shape[0]
wdiff = fli.physical_shape[1] - self.image.physical_shape[1]
fli.remove_edges(int(min(hdiff, wdiff) * fli.dpmm / 2 + 2))
new_array = Image.load(fli.array, dpi=254)
pf = PicketFence(new_array)
pf = PicketFence.from_demo_image()
pf.image = new_array
pf.analyze()
self._log_fits = cycle([p.fit for p in pf.pickets])
# resize image
Expand Down Expand Up @@ -437,7 +439,7 @@ def __init__(self, orientation, tolerance, action_tolerance, hdmlc, image, log_f
self.image = image
self.dpmm = image.dpmm
self.mmpd = 1/image.dpmm
self.image_center = image.cax
self.image_center = image.center
self.log_fits = log_fits

@property
Expand Down Expand Up @@ -489,10 +491,10 @@ def leaf_centers(self):

# now adjust them to align with the iso
if self.orientation == UP_DOWN:
leaf30_center = self.image.cax.y - self.small_leaf_width / 2
leaf30_center = self.image_center.y - self.small_leaf_width / 2
edge = self.image.shape[0]
else:
leaf30_center = self.image.cax.x - self.small_leaf_width / 2
leaf30_center = self.image_center.x - self.small_leaf_width / 2
edge = self.image.shape[1]
adjustment = leaf30_center - leaf_centers[29]
leaf_centers += adjustment
Expand Down

0 comments on commit c16601c

Please sign in to comment.