(self, com, num_iter, size=(250, 250, 250))
return com
Refine com iteratively
        :param com: center of mass, in image coordinates (x,y,z), z in mm
        :param num_iter: number of iterations
        :param size: (x,y,z) extent of the source crop volume in mm
        :return: refined com
Refine com iteratively
        :param com: center of mass, in image coordinates (x,y,z), z in mm
        :param num_iter: number of iterations
        :param size: (x,y,z) extent of the source crop volume in mm
        :return: refined com
Refine com iteratively : param com : center of mass in image coordinates ( x y z ) z in mm : param num_iter : number of iterations : param size : ( x y z ) extent of the source crop volume in mm : return : refined com
def refineCoMIterative(self, com, num_iter, size=(250, 250, 250)):
        """
        Refine com iteratively
        :param com: center of mass, in image coordinates (x,y,z), z in mm
        :param num_iter: number of iterations
        :param size: (x,y,z) extent of the source crop volume in mm
        :return: refined com
        """
        for k in range(num_iter):
            # calculate boundaries
            xstart, xend, ystart, yend, zstart, zend = self.comToBounds(com, size)

            # crop
            cropped = self.getCrop(self.dpt, xstart, xend, ystart, yend, zstart, zend)

            com = self.calculateCoM(cropped)
            if numpy.allclose(com, 0.):
                com[2] = cropped[cropped.shape[0]//2, cropped.shape[1]//2]
            com[0] += max(xstart, 0)
            com[1] += max(ystart, 0)

        return com
def refineCoMIterative ( self , com , num_iter , size = ( 250 , 250 , 250 ) ) : for k in range ( num_iter ) : # calculate boundaries xstart , xend , ystart , yend , zstart , zend = self . comToBounds ( com , size ) # crop cropped = self . getCrop ( self . dpt , xstart , xend , ystart , yend , zstart , zend ) com = self . calculateCoM ( cropped ) if numpy . allclose ( com , 0. ) : com [ 2 ] = cropped [ cropped . shape [ 0 ] // 2 , cropped . shape [ 1 ] // 2 ] com [ 0 ] += max ( xstart , 0 ) com [ 1 ] += max ( ystart , 0 ) return com