Ejemplo n.º 1
0
    def process(self, recondata):

        print(np.shape(recondata[0].data.data))

        image = cifftn(recondata[0].data.data, axes=(0, 1, 2))
        image = np.reshape(
            image,
            (image.shape[0], image.shape[1], image.shape[2], image.shape[3]))

        #Create a new image header and transfer value
        acq = np.ravel(recondata[0].data.headers)[0]

        img_head = ismrmrd.ImageHeader()

        img_head.channels = acq.active_channels
        img_head.slice = acq.idx.slice
        img_head.matrix_size = (image.shape[0], image.shape[1], image.shape[2])
        img_head.position = acq.position
        img_head.read_dir = acq.read_dir
        img_head.phase_dir = acq.phase_dir
        img_head.slice_dir = acq.slice_dir
        img_head.patient_table_position = acq.patient_table_position
        img_head.acquisition_time_stamp = acq.acquisition_time_stamp
        img_head.image_index = 0
        img_head.image_series_index = 0
        img_head.data_type = ismrmrd.DATATYPE_CXFLOAT

        #Return image to Gadgetron
        self.put_next(img_head, image)
        print("Slice ", img_head.slice)
        print("----------------------------------------------")
        return 0
    def crop_acquisition(acquisition):
        x_space = cifftn(acquisition.data, axes=[1])
        x_space = x_space[:, x0:x1]
        acquisition.resize(number_of_samples=x_space.shape[1],
                           active_channels=x_space.shape[0])
        acquisition.center_sample = recon_space.x // 2
        acquisition.data[:] = cfftn(x_space, axes=[1])

        return acquisition
Ejemplo n.º 3
0
    def process(self, acq, data, *args):
        if self.myBuffer is None:
            channels = acq.active_channels
            if self.enc.encodingLimits.slice != None:
                nslices = self.enc.encodingLimits.slice.maximum + 1
            else:
                nslices = 1
            eNz = self.enc.encodedSpace.matrixSize.z
            eNy = self.enc.encodedSpace.matrixSize.y
            eNx = self.enc.encodedSpace.matrixSize.x

            self.myBuffer = np.zeros(
                (int(eNx / 2), eNy, eNz, nslices, channels),
                dtype=np.complex64)

        line_offset = self.enc.encodedSpace.matrixSize.y / 2 - self.enc.encodingLimits.kspace_encoding_step_1.center
        self.myBuffer[:,
                      int(acq.idx.kspace_encode_step_1 + line_offset),
                      int(acq.idx.kspace_encode_step_2),
                      int(acq.idx.slice), :] = data

        if (acq.flags & (1 << 7)):  #Is this the last scan in slice
            image = cifftn(self.myBuffer, axes=(0, 1, 2))
            image = image * np.product(
                image.shape) * 100  #Scaling for the scanner
            #Create a new image header and transfer value
            img_head = ismrmrd.ImageHeader()
            img_head.channels = acq.active_channels
            img_head.slice = acq.idx.slice
            img_head.matrix_size[0] = self.myBuffer.shape[0]
            img_head.matrix_size[1] = self.myBuffer.shape[1]
            img_head.matrix_size[2] = self.myBuffer.shape[2]
            img_head.position = acq.position
            img_head.read_dir = acq.read_dir
            img_head.phase_dir = acq.phase_dir
            img_head.slice_dir = acq.slice_dir
            img_head.patient_table_position = acq.patient_table_position
            img_head.acquisition_time_stamp = acq.acquisition_time_stamp
            img_head.image_index = self.myCounter
            img_head.image_series_index = self.mySeries
            img_head.data_type = ismrmrd.DATATYPE_CXFLOAT
            self.myCounter += 1
            if self.myCounter > 5:
                self.mySeries += 1
                self.myCounter = 1

            #Return image to Gadgetron
            self.put_next(img_head, image.astype('complex64'), *args)

        #print "Returning to Gadgetron"
        return 0  #Everything OK
    def process(self, acq, data):
        orig_size = list(data.shape)
        data2 = data.reshape([data.shape[0], int(data.size / data.shape[0])])
        new_length = data2.shape[0] // 2
        data2 = cfftn(cifftn(data2, axes=[
            0
        ])[(0 + (new_length // 2)):(new_length + (new_length // 2)), :],
                      axes=[0])
        orig_size[0] = new_length
        data2.reshape(tuple(orig_size))
        acq.samples = new_length

        self.put_next(acq, data2)
        return 0
Ejemplo n.º 5
0
    def process(self, recondata):

        print(np.shape(recondata[0].data.data))

        image = cifftn(recondata[0].data.data, axes=(0, 1, 2))
        image = np.reshape(
            image,
            (image.shape[0], image.shape[1], image.shape[2], image.shape[3]))

        #Create a new image header and transfer value
        acq = np.ravel(recondata[0].data.headers)[0]

        img_head = ismrmrd.ImageHeader()
        img_head.version = 1
        img_head.measurement_uid = acq.measurement_uid
        img_head.channels = acq.active_channels
        img_head.slice = acq.idx.slice
        img_head.matrix_size = (image.shape[0], image.shape[1], image.shape[2])
        img_head.field_of_view = (self.enc.reconSpace.fieldOfView_mm.x,
                                  self.enc.reconSpace.fieldOfView_mm.y,
                                  self.enc.reconSpace.fieldOfView_mm.z)
        img_head.position = acq.position
        img_head.read_dir = acq.read_dir
        img_head.phase_dir = acq.phase_dir
        img_head.slice_dir = acq.slice_dir
        img_head.patient_table_position = acq.patient_table_position
        img_head.acquisition_time_stamp = acq.acquisition_time_stamp
        img_head.average = acq.idx.average
        img_head.slice = acq.idx.slice
        img_head.contrast = acq.idx.contrast
        img_head.phase = acq.idx.phase
        img_head.repetition = acq.idx.repetition
        img_head.set = acq.idx.set
        img_head.image_index = next(self.image_indices)
        img_head.image_series_index = 0
        img_head.data_type = ismrmrd.DATATYPE_CXFLOAT

        #Return image to Gadgetron
        self.put_next(img_head, image)
        print("Slice ", img_head.slice)
        print("----------------------------------------------")
        return 0
    def reconstruct_image(kspace_data):
        # Reconstruction is an inverse fft in this case.

        return cifftn(kspace_data, axes=[1, 2, 3])