Skip to content

Commit

Permalink
Simplification of crop effect
Browse files Browse the repository at this point in the history
  • Loading branch information
rbumm committed Apr 3, 2021
1 parent 0c32807 commit f3fa295
Showing 1 changed file with 24 additions and 61 deletions.
85 changes: 24 additions & 61 deletions LungCTSegmenter/LungCTSegmenter.py
Original file line number Diff line number Diff line change
Expand Up @@ -696,50 +696,13 @@ def trimSegmentWithCube(self, id,r,a,s,offs_r,offs_a,offs_s) :

effect.self().fiducialPlacementToggle.placeButton().click()

_sv = 30

if "dorsal" in id:
right_safety = _sv
left_safety = _sv
anterior_safety = _sv
posterior_safety = 0
superior_safety = _sv
inferior_safety = _sv
if "ventral" in id:
right_safety = _sv
left_safety = _sv
anterior_safety = 0
posterior_safety = _sv
superior_safety = _sv
inferior_safety = _sv
if "upper" in id:
right_safety = _sv
left_safety = _sv
anterior_safety = _sv
posterior_safety = _sv
superior_safety = 0
inferior_safety = _sv
if "middle" in id:
right_safety = _sv
left_safety = _sv
anterior_safety = _sv
posterior_safety = _sv
superior_safety = 0
inferior_safety = 0
if "lower" in id:
right_safety = _sv
left_safety = _sv
anterior_safety = _sv
posterior_safety = _sv
superior_safety = _sv
inferior_safety = 0

# trim with cube

points =[[r-offs_r-left_safety, a+offs_a+anterior_safety, s+offs_s+superior_safety], [r+offs_r+right_safety, a+offs_a+anterior_safety, s+offs_s+superior_safety],
[r+offs_r+right_safety, a+offs_a+anterior_safety, s-offs_s-inferior_safety], [r-offs_r-left_safety, a+offs_a+anterior_safety, s-offs_s-inferior_safety],
[r-offs_r-left_safety, a-offs_a-posterior_safety, s+offs_s+superior_safety], [r+offs_r+right_safety, a-offs_a-posterior_safety, s+offs_s+superior_safety],
[r+offs_r+right_safety, a-offs_a-posterior_safety, s-offs_s-inferior_safety], [r-offs_r-left_safety, a-offs_a-posterior_safety, s-offs_s-inferior_safety],
points =[[r-offs_r, a+offs_a, s+offs_s], [r+offs_r, a+offs_a, s+offs_s],
[r+offs_r, a+offs_a, s-offs_s], [r-offs_r, a+offs_a, s-offs_s],
[r-offs_r, a-offs_a, s+offs_s], [r+offs_r, a-offs_a, s+offs_s],
[r+offs_r, a-offs_a, s-offs_s], [r-offs_r, a-offs_a, s-offs_s],
]

for p in points:
Expand Down Expand Up @@ -832,26 +795,26 @@ def createDetailedMasks(self):
####### ventral

r = centroid_ras[0]
a = centroid_ras[1] - (sagittalLungDiameter/4.)
a = centroid_ras[1] - (sagittalLungDiameter/2.)
s = centroid_ras[2]


crop_r = (axialLungDiameter/2.)
crop_a = (sagittalLungDiameter/4.)
crop_s = (coronalLungDiameter/2.)
crop_r = axialLungDiameter
crop_a = (sagittalLungDiameter/2.)
crop_s = coronalLungDiameter

self.showStatusMessage(' Cropping ventral mask ...')
self.trimSegmentWithCube(ventral.GetName(),r,a,s,crop_r,crop_a,crop_s)

####### dorsal

r = centroid_ras[0]
a = centroid_ras[1] + (sagittalLungDiameter/4.)
a = centroid_ras[1] + (sagittalLungDiameter/2.)
s = centroid_ras[2]

crop_r = (axialLungDiameter/2.)
crop_a = (sagittalLungDiameter/4.)
crop_s = (coronalLungDiameter/2.)
crop_r = axialLungDiameter
crop_a = (sagittalLungDiameter/2.)
crop_s = coronalLungDiameter

self.showStatusMessage(' Cropping dorsal mask ...')
self.trimSegmentWithCube(dorsal.GetName(),r,a,s,crop_r,crop_a,crop_s)
Expand All @@ -860,11 +823,11 @@ def createDetailedMasks(self):

r = centroid_ras[0]
a = centroid_ras[1]
s = coronalApex - ((coronalLungDiameter/3.)*2.)
s = coronalApex - coronalLungDiameter

crop_r = (axialLungDiameter/2.)
crop_a = (sagittalLungDiameter/2.)
crop_s = (coronalLungDiameter/3.)
crop_r = axialLungDiameter
crop_a = sagittalLungDiameter
crop_s = (coronalLungDiameter/3.) * 2.

self.showStatusMessage(' Cropping upper mask ...')
self.trimSegmentWithCube(upper.GetName(),r,a,s,crop_r,crop_a,crop_s)
Expand All @@ -877,8 +840,8 @@ def createDetailedMasks(self):
s = coronalApex


crop_r = (axialLungDiameter/2.)
crop_a = (sagittalLungDiameter/2.)
crop_r = axialLungDiameter
crop_a = sagittalLungDiameter
crop_s = (coronalLungDiameter/3.)

self.showStatusMessage(' Cropping middle mask ...')
Expand All @@ -889,8 +852,8 @@ def createDetailedMasks(self):
a = centroid_ras[1]
s = coronalApex - coronalLungDiameter

crop_r = (axialLungDiameter/2.)
crop_a = (sagittalLungDiameter/2.)
crop_r = axialLungDiameter
crop_a = sagittalLungDiameter
crop_s = (coronalLungDiameter/3.)

self.trimSegmentWithCube(middle.GetName(),r,a,s,crop_r,crop_a,crop_s)
Expand All @@ -899,12 +862,12 @@ def createDetailedMasks(self):

r = centroid_ras[0]
a = centroid_ras[1]
s = coronalApex - (coronalLungDiameter/3.)
s = coronalApex


crop_r = (axialLungDiameter/2.)
crop_a = (sagittalLungDiameter/2.)
crop_s = (coronalLungDiameter/3.)
crop_r = axialLungDiameter
crop_a = sagittalLungDiameter
crop_s = (coronalLungDiameter/3.)*2.

self.showStatusMessage(' Cropping lower mask ...')
self.trimSegmentWithCube(lower.GetName(),r,a,s,crop_r,crop_a,crop_s)
Expand Down

0 comments on commit f3fa295

Please sign in to comment.