Ejemplo n.º 1
0
    def predictContours(self):

        '''
        Method for pushing images loaded by _read_all_dicom_images through full learned network
        to predict the resulting contour
           STEPS: 1) Feedforward through CNN, followed by through SA, followed by calling AC model, giving final result

        :return:
        '''

        #images are slice * time * height * width
        self.predROIs = np.array([CNNpred(inputimages = self.images[s,:], batch_size=1,
                                          fine_tuned_params_path = '/Users/Peadar/Documents/KagglePythonProjects/AML/DataScienceBowl/data/fine_tune_paramsXnew.pickle')
                                  for s in range(0, len(self.slices))])


        self.imagesROIs = np.array([crop_ROI(images=self.images[s,:], roi=self.predROIs[s,:],
                                             roi_dim=(100,100), newsize=(64, 64))
                              for s in range(0, len(self.slices))])

        self.predSAContours = np.array([SApred(self.imagesROIs[s,:],
                                               trained_SA_path ='/Users/Peadar/Documents/KagglePythonProjects/AML/DataScienceBowl/data/SA_XPHmodel')
                                        for s in range(0, len(self.slices))])

        self.predACContours = np.array([[AC.evolve_contour(lv = self.predSAContours[s,t], roi=self.imagesROIs[s,t],alpha3=0)
                                         for t in range(0, len(self.time))] for s in range(0, len(self.slices))])
Ejemplo n.º 2
0
    def predictContours(self):
        '''
        Method for pushing images loaded by _read_all_dicom_images through full learned network
        to predict the resulting contour
           STEPS: 1) Feedforward through CNN, followed by through SA, followed by calling AC model, giving final result

        :return:
        '''

        #images are slice * time * height * width
        self.predROIs = np.array([
            CNNpred(
                inputimages=self.images[s, :],
                batch_size=1,
                fine_tuned_params_path=
                '/Users/Peadar/Documents/KagglePythonProjects/AML/DataScienceBowl/data/fine_tune_paramsXnew.pickle'
            ) for s in range(0, len(self.slices))
        ])

        self.imagesROIs = np.array([
            crop_ROI(images=self.images[s, :],
                     roi=self.predROIs[s, :],
                     roi_dim=(100, 100),
                     newsize=(64, 64)) for s in range(0, len(self.slices))
        ])

        self.predSAContours = np.array([
            SApred(
                self.imagesROIs[s, :],
                trained_SA_path=
                '/Users/Peadar/Documents/KagglePythonProjects/AML/DataScienceBowl/data/SA_XPHmodel'
            ) for s in range(0, len(self.slices))
        ])

        self.predACContours = np.array([[
            AC.evolve_contour(lv=self.predSAContours[s, t],
                              roi=self.imagesROIs[s, t],
                              alpha3=0) for t in range(0, len(self.time))
        ] for s in range(0, len(self.slices))])
Ejemplo n.º 3
0
    def predictContours(self):

        '''
        Method for pushing images loaded by _read_all_dicom_images through full learned network
        to predict the resulting contour
           STEPS: 1) Feedforward through CNN, followed by through SA, followed by calling AC model, giving final result

        :return:
        '''

        #images are slice * time * height * width
        #############################################
        # PREDICT ROI MASKS
        # IMPORTANT: Change fine_tuned_params_path file to fine_tune_paramsX_big.pickle and .._small.pickle respectively

        # self.big_images and self.small_images are both lists of lists of arrays
        b = len(self.big_images)
        s = len(self.small_images)
        # CNN should return list of arrays
        self.pred_big_ROIs = [CNNpred(inputimages = self.big_images[s], batch_size=1,
                                      fine_tuned_params_path = '/home/odyss/Desktop/dsb/AML/DataScienceBowl/data/fine_tune_paramsXlarge.pickle')
                              for s in range(0, len(self.big_slices))]
        self.pred_small_ROIs = [CNNpred(inputimages = self.small_images[s], batch_size=1,
                                        fine_tuned_params_path = '/home/odyss/Desktop/dsb/AML/DataScienceBowl/data/fine_tune_paramsXsmall.pickle')
                                for s in range(0, len(self.small_slices))]

        """
        self.predROIs = np.array([CNNpred(inputimages = self.images[s,:], batch_size=1,
                                          fine_tuned_params_path = '/Users/mh/AML/DataScienceBowl/data/fine_tune_paramsXnew.pickle')
                                  for s in range(0, len(self.slices))])
        """
        #############################################
        # CROP IMAGES TO ROIs
        # crop ROI should return list of arrays
        self.imagesROIs_big = [crop_ROI(images=self.big_images[s], roi=self.pred_big_ROIs[s],
                                        roi_dim=(100,100), newsize=(64, 64))
                                        for s in range(0, len(self.big_slices))]
        self.imagesROIs_small = [crop_ROI(images=self.small_images[s], roi=self.pred_small_ROIs[s],
                                          roi_dim=(100,100), newsize=(64, 64))
                                        for s in range(0, len(self.small_slices))]

        """
        self.imagesROIs = np.array([crop_ROI(images=self.images[s,:], roi=self.predROIs[s,:],
                                             roi_dim=(100,100), newsize=(64, 64))
                              for s in range(0, len(self.slices))])
        """
        #############################################
        # PREDICT CONTOUR USING SA
        # IMPORTANT: Change trained_SA_path to ../SA_Xmodel_big and ../SA_Xmodel_small, respectively


        self.predSAbigContours = np.array([SApred(self.imagesROIs_big[s],
                                               trained_SA_path ='/home/odyss/Desktop/dsb/AML/DataScienceBowl/data/SA_RLUmodel_large')
                                        for s in range(0, len(self.big_slices))])
        self.predSAsmallContours = np.array([SApred(self.imagesROIs_small[s],
                                               trained_SA_path ='/home/odyss/Desktop/dsb/AML/DataScienceBowl/data/SA_RLUmodel_small')
                                        for s in range(0, len(self.small_slices))])

        """
        self.predSAContours = np.array([SApred(self.imagesROIs[s,:],
                                               trained_SA_path ='/Users/mh/AML/DataScienceBowl/data/SA_Xmodel')
                                        for s in range(0, len(self.slices))])
        """
        #############################################
        # ACTIVE CONTOUR

        self.predACContours_big = np.array([[AC.evolve_contour(lv = self.predSAbigContours[s][t], roi=self.imagesROIs_big[s][t]
                                                               , alpha1=2, alpha2=1.5, alpha3=0.002)
                                         for t in range(0, len(self.time))] for s in range(0, len(self.big_slices))])
        self.predACContours_small = np.array([[AC.evolve_contour(lv = self.predSAsmallContours[s][t], roi=self.imagesROIs_small[s][t]
                                                                 , alpha1=2, alpha2=1.5, alpha3=0.007)
                                         for t in range(0, len(self.time))] for s in range(0, len(self.small_slices))])

        """
Ejemplo n.º 4
0
    def predictContours(self):

        '''
        Method for pushing images loaded by _read_all_dicom_images through full learned network
        to predict the resulting contour
           STEPS: 1) Feedforward through CNN, followed by through SA, followed by calling AC model, giving final result

        :return:
        '''

        #images are slice * time * height * width
        #############################################
        # PREDICT ROI MASKS
        # IMPORTANT: Change fine_tuned_params_path file to fine_tune_paramsX_big.pickle and .._small.pickle respectively

        # self.big_images and self.small_images are both lists of lists of arrays
        b = len(self.big_images)
        s = len(self.small_images)
        # CNN should return list of arrays
        self.pred_big_ROIs = [CNNpred(inputimages = self.big_images[s], batch_size=1,
                                      fine_tuned_params_path = '/home/odyss/Desktop/dsb/AML/DataScienceBowl/data/fine_tune_paramsXlarge.pickle')
                              for s in range(0, len(self.big_slices))]
        self.pred_small_ROIs = [CNNpred(inputimages = self.small_images[s], batch_size=1,
                                        fine_tuned_params_path = '/home/odyss/Desktop/dsb/AML/DataScienceBowl/data/fine_tune_paramsXsmall.pickle')
                                for s in range(0, len(self.small_slices))]

        """
        self.predROIs = np.array([CNNpred(inputimages = self.images[s,:], batch_size=1,
                                          fine_tuned_params_path = '/Users/mh/AML/DataScienceBowl/data/fine_tune_paramsXnew.pickle')
                                  for s in range(0, len(self.slices))])
        """
        #############################################
        # CROP IMAGES TO ROIs
        # crop ROI should return list of arrays
        self.imagesROIs_big = [crop_ROI(images=self.big_images[s], roi=self.pred_big_ROIs[s],
                                        roi_dim=(100,100), newsize=(64, 64))
                                        for s in range(0, len(self.big_slices))]
        self.imagesROIs_small = [crop_ROI(images=self.small_images[s], roi=self.pred_small_ROIs[s],
                                          roi_dim=(100,100), newsize=(64, 64))
                                        for s in range(0, len(self.small_slices))]

        """
        self.imagesROIs = np.array([crop_ROI(images=self.images[s,:], roi=self.predROIs[s,:],
                                             roi_dim=(100,100), newsize=(64, 64))
                              for s in range(0, len(self.slices))])
        """
        #############################################
        # PREDICT CONTOUR USING SA
        # IMPORTANT: Change trained_SA_path to ../SA_Xmodel_big and ../SA_Xmodel_small, respectively


        self.predSAbigContours = np.array([SApred(self.imagesROIs_big[s],
                                               trained_SA_path ='/home/odyss/Desktop/dsb/AML/DataScienceBowl/data/SA_RLUmodel_large')
                                        for s in range(0, len(self.big_slices))])
        self.predSAsmallContours = np.array([SApred(self.imagesROIs_small[s],
                                               trained_SA_path ='/home/odyss/Desktop/dsb/AML/DataScienceBowl/data/SA_RLUmodel_small')
                                        for s in range(0, len(self.small_slices))])

        """
        self.predSAContours = np.array([SApred(self.imagesROIs[s,:],
                                               trained_SA_path ='/Users/mh/AML/DataScienceBowl/data/SA_Xmodel')
                                        for s in range(0, len(self.slices))])
        """
        #############################################
        # ACTIVE CONTOUR

        self.predACContours_big = np.array([[AC.evolve_contour(lv = self.predSAbigContours[s][t], roi=self.imagesROIs_big[s][t]
                                                               , alpha1=2, alpha2=1.5, alpha3=0.002)
                                         for t in range(0, len(self.time))] for s in range(0, len(self.big_slices))])
        self.predACContours_small = np.array([[AC.evolve_contour(lv = self.predSAsmallContours[s][t], roi=self.imagesROIs_small[s][t]
                                                                 , alpha1=2, alpha2=1.5, alpha3=0.007)
                                         for t in range(0, len(self.time))] for s in range(0, len(self.small_slices))])

        """