예제 #1
0
    def SSFP(self, theta, row, col, te, tr, image_shape0, image_shape1, T2, T1,
             phantom, Gy, Start_up):

        Kspace_ssfp = np.zeros((image_shape0, image_shape1), dtype=np.complex_)

        if (Start_up == True):
            phantom = Fast.startup_cycle(phantom, theta / 2, te, tr, T2, T1,
                                         row, col, 1)

        phantom = Fast.startup_cycle(phantom, theta, te, tr, T2, T1, row, col,
                                     15)

        for r in range(Kspace_ssfp.shape[0]):  #rows
            theta = -theta
            phantom = Fast.rotate_decay(phantom, theta, te, T2, row, col)
            for c in range(Kspace_ssfp.shape[1]):
                Gx_step = ((2 * math.pi) / row) * r
                Gy_step = (Gy / col) * c
                for ph_row in range(row):
                    for ph_col in range(col):
                        Toltal_theta = (Gx_step * ph_row) + (Gy_step * ph_col)
                        Mag = math.sqrt(((phantom[ph_row, ph_col, 0]) *
                                         (phantom[ph_row, ph_col, 0])) +
                                        ((phantom[ph_row, ph_col, 1]) *
                                         (phantom[ph_row, ph_col, 1])))

                        Kspace_ssfp[r, c] = Kspace_ssfp[r, c] + (
                            Mag * np.exp(-1j * Toltal_theta))
                        QApplication.processEvents()

                QApplication.processEvents()

            print(theta)
            for ph_rowtr in range(row):
                for ph_coltr in range(col):
                    self.phantom[ph_rowtr, ph_coltr, 0] = 0
                    self.phantom[ph_rowtr, ph_coltr, 1] = 0
                    self.phantom[ph_rowtr, ph_coltr, 2] = (
                        (phantom[ph_rowtr, ph_coltr, 2]) *
                        np.exp(-tr / T1[ph_rowtr, ph_coltr])) + (
                            1 - np.exp(-tr / T1[ph_rowtr, ph_coltr]))

            QApplication.processEvents()
        iff = np.fft.ifft2(Kspace_ssfp)

        #print(iff)
        inverse_array = np.abs(iff)
        inverse_array = (inverse_array - np.amin(inverse_array)) * 255 / (
            np.amax(inverse_array) - np.amin(inverse_array))
        inverse_img = gray2qimage(inverse_array)
        imgreconstruction = inverse_img
        return imgreconstruction
예제 #2
0
    def GRE(self, theta, row, col, te, tr, image_shape0, image_shape1, T2, T1,
            phantom, Gy, Start_up):

        Kspace = np.zeros((image_shape0, image_shape1), dtype=np.complex_)

        if (Start_up == True):
            phantom = Fast.startup_cycle(phantom, theta, te, tr, T2, T1, row,
                                         col, 15)

        for r in range(Kspace.shape[0]):  #rows
            phantom = Fast.rotate_decay(phantom, theta, te, T2, row, col)

            for c in range(Kspace.shape[1]):  #columns
                Gx_step = ((2 * math.pi) / row) * r
                Gy_step = ((Gy) / col) * c
                for ph_row in range(row):
                    for ph_col in range(col):
                        Toltal_theta = (Gx_step * ph_row) + (Gy_step * ph_col)
                        Mag = math.sqrt(((phantom[ph_row, ph_col, 0]) *
                                         (phantom[ph_row, ph_col, 0])) +
                                        ((phantom[ph_row, ph_col, 1]) *
                                         (phantom[ph_row, ph_col, 1])))

                        Kspace[r,
                               c] = Kspace[r, c] + (Mag *
                                                    np.exp(-1j * Toltal_theta))
                        QApplication.processEvents()
                QApplication.processEvents()
            phantom = Fast.recovery(phantom, row, col, tr, T1)
            QApplication.processEvents()

        iff = np.fft.ifft2(Kspace)

        inverse_array = np.abs(iff)
        inverse_array = (inverse_array - np.amin(inverse_array)) * 255 / (
            np.amax(inverse_array) - np.amin(inverse_array))
        inverse_img = gray2qimage(inverse_array)
        imgreconstruction = inverse_img
        return imgreconstruction