20.03.2021 Views

Deep-Learning-with-PyTorch

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

374 CHAPTER 13 Using segmentation to find suspected nodules

After the loop, we do a bit of cleanup by taking the intersection between the

bounding-box mask and the tissue that’s denser than our threshold of –700 HU (or 0.3

g/cc). That’s going to clip off the corners of our boxes (at least, the ones not embedded

in the lung wall), and make it conform to the contours of the nodule a bit better.

Listing 13.4

dsets.py:127, Ct.buildAnnotationMask

Starts with an all-False tensor

of the same size as the CT

Restricts

the mask to

voxels above

our density

threshold

def buildAnnotationMask(self, positiveInfo_list, threshold_hu = -700):

boundingBox_a = np.zeros_like(self.hu_a, dtype=np.bool)

for candidateInfo_tup in positiveInfo_list:

# ... line 169

boundingBox_a[

ci - index_radius: ci + index_radius + 1,

cr - row_radius: cr + row_radius + 1,

cc - col_radius: cc + col_radius + 1] = True

mask_a = boundingBox_a & (self.hu_a > threshold_hu)

return mask_a

Loops over the nodules. As a reminder

that we are only looking at nodules,

we call the variable positiveInfo_list.

After we get the nodule

radius (the search itself

is left out), we mark

the bounding box.

Let’s take a look at figure 13.11 to see what these masks look like in practice. Additional

images in full color can be found in the p2ch13_explore_data.ipynb notebook.

The bottom-right nodule mask demonstrates a limitation of our rectangular

bounding-box approach by including a portion of the lung wall. It’s certainly something

0

positive mask

100

200

300

400

500

0 100 200 300 400 500

Figure 13.11 Three nodules from

ct.positive_mask, highlighted

in white

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!