コード例 #1
0
}
gy = maketrapezoid(kwargs_for_gy)

flip = 180 * pi / 180
kwargs_for_sinc = {"flip_angle": flip, "system": system, "duration": 500e-6}
rf180 = makeblockpulse(kwargs_for_sinc)
kwargs_for_gz_spoil = {
    "channel": 'z',
    "system": system,
    "area": gz.area * 2,
    "duration": 3 * pre_time
}
gz_spoil = maketrapezoid(kwargs_for_gz_spoil)

duration_to_center = (Nx / 2 +
                      0.5) * calcduration(gx) + Ny / 2 * calcduration(gy)
delayTE1 = TE / 2 - calcduration(gz) / 2 - pre_time - calcduration(
    gz_spoil) - calcduration(rf180) / 2
delayTE2 = TE / 2 - calcduration(rf180) / 2 - calcduration(
    gz_spoil) - duration_to_center
delay1 = makedelay(delayTE1)
delay2 = makedelay(delayTE2)

seq.add_block(rf, gz)
seq.add_block(gx_pre, gy_pre, gz_reph)
seq.add_block(delay1)
seq.add_block(gz_spoil)
seq.add_block(rf180)
seq.add_block(gz_spoil)
seq.add_block(delay2)
for i in range(Ny):
コード例 #2
0
    def make_se_epi(self):
        kwargs_for_opts = {"max_grad": self.max_grad, "grad_unit": "mT/m", "max_slew": self.max_slew,
                           "slew_unit": "T/m/s", "rf_dead_time": 10e-6, "adc_dead_time": 10e-6}
        system = Opts(kwargs_for_opts)
        seq = Sequence(system)

        slice_thickness = 3e-3

        flip = 90 * pi / 180
        kwargs_for_sinc = {"flip_angle": flip, "system": system, "duration": 3e-3, "slice_thickness": slice_thickness,
                           "apodization": 0.5, "time_bw_product": 4}
        rf, gz = makesincpulse(kwargs_for_sinc, 2)
        # plt.plot(rf.t[0], rf.signal[0])
        # plt.show()

        delta_k = 1 / self.fov
        k_width = self.Nx * delta_k
        readout_time = 3.2e-4
        kwargs_for_gx = {"channel": 'x', "system": system, "flat_area": k_width, "flat_time": readout_time}
        gx = maketrapezoid(kwargs_for_gx)
        kwargs_for_adc = {"num_samples": self.Nx, "system": system, "duration": gx.flat_time, "delay": gx.rise_time}
        adc = makeadc(kwargs_for_adc)

        pre_time = 8e-4
        kwargs_for_gxpre = {"channel": 'x', "system": system, "area": -gx.area / 2, "duration": pre_time}
        gx_pre = maketrapezoid(kwargs_for_gxpre)
        kwargs_for_gz_reph = {"channel": 'z', "system": system, "area": -gz.area / 2, "duration": pre_time}
        gz_reph = maketrapezoid(kwargs_for_gz_reph)
        kwargs_for_gy_pre = {"channel": 'y', "system": system, "area": -self.Ny / 2 * delta_k, "duration": pre_time}
        gy_pre = maketrapezoid(kwargs_for_gy_pre)

        dur = ceil(2 * sqrt(delta_k / system.max_slew) / 10e-6) * 10e-6
        kwargs_for_gy = {"channel": 'y', "system": system, "area": delta_k, "duration": dur}
        gy = maketrapezoid(kwargs_for_gy)

        flip = 180 * pi / 180
        kwargs_for_sinc = {"flip_angle": flip, "system": system, "duration": 500e-6}
        rf180 = makeblockpulse(kwargs_for_sinc)
        kwargs_for_gz_spoil = {"channel": 'z', "system": system, "area": gz.area * 2, "duration": 3 * pre_time}
        gz_spoil = maketrapezoid(kwargs_for_gz_spoil)

        TE = self.te
        duration_to_center = (self.Nx / 2 + 0.5) * calcduration(gx) + self.Ny / 2 * calcduration(gy)
        delayTE1 = TE / 2 - calcduration(gz) / 2 - pre_time - calcduration(gz_spoil) - calcduration(rf180) / 2
        delayTE2 = TE / 2 - calcduration(rf180) / 2 - calcduration(gz_spoil) - duration_to_center
        delay1 = makedelay(delayTE1)
        delay2 = makedelay(delayTE2)

        seq.add_block(rf, gz)
        seq.add_block(gx_pre, gy_pre, gz_reph)
        seq.add_block(delay1)
        seq.add_block(gz_spoil)
        seq.add_block(rf180)
        seq.add_block(gz_spoil)
        seq.add_block(delay2)
        for i in range(self.Ny):
            seq.add_block(gx, adc)
            seq.add_block(gy)
            gx.amplitude = -gx.amplitude
        seq.add_block(makedelay(1))

        return seq
コード例 #3
0
    "system": system,
    "area": -gx.area / 2,
    "duration": 2.5e-3
}
gx_pre = maketrapezoid(kwargs_for_gxpre)
kwargs_for_gz_reph = {
    "channel": 'z',
    "system": system,
    "area": -gz.area / 2,
    "duration": 2.5e-3
}
gz_reph = maketrapezoid(kwargs_for_gz_reph)
phase_areas = np.array(([x for x in range(0, Ny)]))
phase_areas = (phase_areas - Ny / 2) * delta_k

delayTE = TE - calcduration(
    gx_pre) - calcduration(rf) / 2 - calcduration(gx) / 2
delayTR = TR - calcduration(gx_pre) - calcduration(rf) - calcduration(
    gx) - delayTE
delay1 = makedelay(delayTE)
delay2 = makedelay(delayTR)

for i in range(Ny):
    seq.add_block(rf, gz)
    kwargsForGyPre = {
        "channel": 'y',
        "system": system,
        "area": phase_areas[i],
        "duration": 2.5e-3
    }
    gyPre = maketrapezoid(kwargsForGyPre)
    seq.add_block(gx_pre, gyPre, gz_reph)
コード例 #4
0
gx = maketrapezoid(kwargs_for_gx)
kwargs_for_adc = {"num_samples": Nx, "system": system, "duration": gx.flat_time, "delay": gx.rise_time}
adc = makeadc(kwargs_for_adc)

kwargs_for_gxpre = {"channel": 'x', "system": system, "area": -gx.area / 2, "duration": 2.5e-3}
gx_pre = maketrapezoid(kwargs_for_gxpre)
kwargs_for_gz_reph = {"channel": 'z', "system": system, "area": -gz.area / 2, "duration": 2.5e-3}
gz_reph = maketrapezoid(kwargs_for_gz_reph)

flip = 180 * pi / 180
kwargs_for_sinc = {"flip_angle": flip, "system": system, "duration": 2.5e-3, "slice_thickness": slice_thickness,
                   "apodization": 0.5, "time_bw_product": 4}
rf180, gz180 = makesincpulse(kwargs_for_sinc, 2)


delayTE1 = TE / 2 - calcduration(gz_reph) - calcduration(rf) - calcduration(rf180) / 2
delayTE2 = TE / 2 - calcduration(gx) / 2 - calcduration(rf180) / 2
delayTE3 = TR - TE - calcduration(gx)
delay1 = makedelay(delayTE1)
delay2 = makedelay(delayTE2)
delay3 = makedelay(delayTE3)

phase_areas = np.array(([x for x in range(0, Ny)]))
phase_areas = (phase_areas - Ny / 2) * delta_k

for i in range(Ny):
    seq.add_block(rf, gz)
    kwargsForGyPre = {"channel": 'y', "system": system, "area": phase_areas[i], "duration": 2.5e-3}
    gyPre = maketrapezoid(kwargsForGyPre)
    seq.add_block(gx_pre, gyPre, gz_reph)
    seq.add_block(delay1)
コード例 #5
0
ファイル: GenSeq_GPI.py プロジェクト: Vajuvalli/IMRI-MIRC
    def set_plot_outputs(self):
        t0, time_range = 0, [0, np.inf]
        adc_values = [[], []]
        rf_mag_values = [[], []]
        rf_phase_values = [[], []]
        t_x_values = [[], []]
        t_y_values = [[], []]
        t_z_values = [[], []]

        for iB in range(1, len(self.seq.block_events)):
            block = self.seq.get_block(iB)
            is_valid = time_range[0] <= t0 <= time_range[1]
            if is_valid:
                if block is not None:
                    if 'adc' in block:
                        adc = block['adc']
                        t = adc.delay + [
                            (x * adc.dwell)
                            for x in range(0, int(adc.num_samples))
                        ]
                        adc_values[0].extend(t0 + t)
                        adc_values[1].extend(np.ones(len(t)))
                    if 'rf' in block:
                        rf = block['rf']
                        t = rf.t
                        rf_mag_values[0].extend(t0 + t[0])
                        rf_mag_values[1].extend(abs(rf.signal))
                        rf_phase_values[0].extend(t0 + t[0])
                        rf_phase_values[1].extend(np.angle(rf.signal))
                    grad_channels = ['gx', 'gy', 'gz']
                    for x in range(0, len(grad_channels)):
                        if grad_channels[x] in block:
                            grad = block[grad_channels[x]]
                            if grad.type == 'grad':
                                t = grad.t
                                waveform = 1e-3 * grad.waveform
                            else:
                                t = np.cumsum([
                                    0, grad.rise_time, grad.flat_time,
                                    grad.fall_time
                                ])
                                waveform = [
                                    1e-3 * grad.amplitude * x
                                    for x in [0, 1, 1, 0]
                                ]
                                if grad.channel == 'x':
                                    t_x_values[0].extend(t0 + t)
                                    t_x_values[1].extend(waveform)
                                elif grad.channel == 'y':
                                    t_y_values[0].extend(t0 + t)
                                    t_y_values[1].extend(waveform)
                                elif grad.channel == 'z':
                                    t_z_values[0].extend(t0 + t)
                                    t_z_values[1].extend(waveform)
            t0 += calcduration(block)

        # Setting outputs
        # ADC
        adc_output = np.array(adc_values)
        adc_output = adc_output.transpose()
        self.setData('adc_output', adc_output)

        # RF Mag
        rf_mag_output = np.array(rf_mag_values)
        rf_mag_output = rf_mag_output.transpose()
        self.setData('rf_mag_output', rf_mag_output)

        # RF Phase
        rf_ph_output = np.array(rf_phase_values)
        rf_ph_output = rf_ph_output.transpose()
        self.setData('rf_phase_output', rf_ph_output)

        # TrapX
        t_x_output = np.array(t_x_values)
        t_x_output = t_x_output.transpose()
        self.setData('trap_x_output', t_x_output)

        # TrapY
        t_y_output = np.array(t_y_values)
        t_y_output = t_y_output.transpose()
        self.setData('trap_y_output', t_y_output)

        # TrapZ
        t_z_output = np.array(t_z_values)
        t_z_output = t_z_output.transpose()
        self.setData('trap_z_output', t_z_output)