ymli39 / DeepSEED-3D-ConvNets-for-Pulmonary-Nodule-Detection

DeepSEED: 3D Squeeze-and-Excitation Encoder-Decoder ConvNets for Pulmonary Nodule Detection
MIT License
106 stars 32 forks source link

Need some explanation on the variable "coord" #17

Closed shakjm closed 4 years ago

shakjm commented 4 years ago

Hi there Mr. Li, I have trouble understanding some of the codes you've written and could not find out an explanation to them.

For example,

start = []
        for i in range(3):
            if not isRand:
                r = target[3] / 2
                s = np.floor(target[i] - r) + 1 - bound_size
                e = np.ceil(target[i] + r) + 1 + bound_size - crop_size[i]
            else:
                s = np.max([imgs.shape[i + 1] - crop_size[i] / 2, imgs.shape[i + 1] / 2 + bound_size])
                e = np.min([crop_size[i] / 2, imgs.shape[i + 1] / 2 - bound_size])
                target = np.array([np.nan, np.nan, np.nan, np.nan])
            if s > e:
                start.append(int(np.random.randint(e, s)))  # !
            else:
                start.append(int(target[i] - crop_size[i] / 2 + np.random.randint(-bound_size / 2, bound_size / 2)))

        normstart = np.array(start).astype('float32') / np.array(imgs.shape[1:]) - 0.5
        normsize = np.array(crop_size).astype('float32') / np.array(imgs.shape[1:])
        xx, yy, zz = np.meshgrid(np.linspace(normstart[0], normstart[0] + normsize[0], self.crop_size[0] / self.stride),
                                 np.linspace(normstart[1], normstart[1] + normsize[1], self.crop_size[1] / self.stride),
                                 np.linspace(normstart[2], normstart[2] + normsize[2], self.crop_size[2] / self.stride),
                                 indexing='ij')
        coord = np.concatenate([xx[np.newaxis, ...], yy[np.newaxis, ...], zz[np.newaxis, :]], 0).astype('float32')

This particular set of codes is from the data_loader.py file, under the Crop class. I was wondering what does s & e stands for, and what is the reason you're doing this particular set of codings? Why do you utilize the meshgrid function to generate a new set of coords?

Another thing I would like some clarifications on is based on the res18_se.py file, where you concatenated the coord variable to comb2 variable, in the forward function.

       rev2 = self.path2(comb3)
        comb2 = self.back2(torch.cat((rev2, out2, coord), 1))

Why do you concatenate coord to the network?

Hope to get some explanation on my confusion. Hope to hear from you soon. Thank you.

shakjm commented 4 years ago

Hi Mr Li,

Just wanted to send a reminder in case you have forgotten to check back on this. Would really appreciate it if you could share your knowledge on this with me.

Have a great day ahead!

ymli39 commented 4 years ago

Sorry about late response, s and e stands for start and end, this is just a way to select the lung region to create the input images. Coord is use as input to the model for training purposes, we adopted this backbone from another two references literature (3D RPN and deeplung in the paper for reference). You could remove it if you do not want this input.

shakjm commented 4 years ago

Mr Li,

So sorry for the late reply. Thank you for the clarification. Hope you and your family is safe and sound given the current pandemic situation. Take care!