Skip to content

Commit

Permalink
Add spacings
Browse files Browse the repository at this point in the history
  • Loading branch information
notmatthancock committed Jul 27, 2018
1 parent b9f7a46 commit 9770639
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
8 changes: 5 additions & 3 deletions pylidc/Annotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -904,15 +904,17 @@ def update(_):
txt = 'Z: %.3f'
txt = txt % float(images[current_slice].ImagePositionPatient[-1])
sslice.label.set_text(txt)

if contour_checkbox.is_checked:
for i,c in enumerate(contour_lines):
flag = (index_of_contour[i] == current_slice)
flag = flag and (current_slice >= min_slice)
flag = flag and (current_slice <= max_slice)
flag = ((index_of_contour[i] == current_slice) and
(current_slice >= min_slice) and
(current_slice <= max_slice))
# Set contour visible if flag is True.
c.set_visible(flag)
else:
for c in contour_lines: c.set_visible(False)

fig.canvas.draw_idle()

def update_contours(_):
Expand Down
11 changes: 11 additions & 0 deletions pylidc/Scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,7 @@ def update(_):
sslice.on_changed(update)
update(None)
plt.show()
return sslice

@property
def slice_zvals(self):
Expand All @@ -594,6 +595,16 @@ def slice_spacing(self):
"""
return np.median(np.diff(self.slice_zvals))

@property
def spacings(self):
"""
The spacings in the i, j, k image coordinate directions, as a
length 3 array.
"""
return np.array([self.pixel_spacing,
self.pixel_spacing,
self.slice_spacing])

def to_volume(self, verbose=True):
"""
Return the scan as a 3D numpy array volume.
Expand Down

0 comments on commit 9770639

Please sign in to comment.