def test_duration_val(self): with self.assertRaises(ValueError): make_slr_rf(flip_angle=90, slice_thickness=10, time_bw_product=8, duration=0, ncycles=0, system=system)
def test_flip_angle_range(self): with self.assertRaises(ValueError): make_slr_rf(flip_angle=-10, slice_thickness=10, time_bw_product=1.5, duration=1e-3, ncycles=0, system=system) with self.assertRaises(ValueError): make_slr_rf(flip_angle=500, slice_thickness=10, time_bw_product=1.5, duration=1e-3, ncycles=0, system=system)
def test_flip_angle(self): flip_in = 90 rf, _ = make_slr_rf(flip_angle=flip_in, slice_thickness=10, time_bw_product=1.5, duration=1e-3, ncycles=0, system=system)
def test_tbw_product(self): rf, _ = make_slr_rf(flip_angle=90, slice_thickness=10, time_bw_product=8, duration=1e-3, ncycles=0, system=system) # TODO: Is there a way to calculate the bandwidth from the RF waveform? '''dur1 = rf.shape[1] * 10e-6
def test_duration(self): dur_in = 1 rf, _ = make_slr_rf(flip_angle=90, slice_thickness=10, time_bw_product=8, duration=dur_in, ncycles=0, system=system) dur_out = rf.shape[0] * system['rf_raster_time'] self.assertEqual(dur_in, np.round(dur_out, 3))
def test_slice_thickness(self): sl_thick_in = 10e-3 tbwp = 8 dur = 1e-3 rf, gss = make_slr_rf(flip_angle=90, slice_thickness=sl_thick_in, time_bw_product=tbwp, duration=dur, ncycles=0, system=system) gplat = gss.max() # Hz/m sl_thick_out = tbwp / dur / gplat self.assertEqual(sl_thick_in, np.round(sl_thick_out, 3))
def test_makeslrpulse_matlabvspython(self): rf_mat = sio.loadmat('testing_assets/rf_slr.mat' )['rf'] * system['gamma'] / 10000 # from G to Hz gss_mat = sio.loadmat('testing_assets/gss_slr.mat')['gex'] * system[ 'gamma'] / 100 # from G/cm to Hz/m systemmat = { 'gamma': 42576000, 'max_grad': 32, 'grad_unit': 'mT/m', 'max_slew': 130, 'slew_unit': 'T/m/s', 'grad_raster_time': 4e-6, 'rf_raster_time': 4e-6 } rf_pyth, gss_pyth = make_slr_rf(flip_angle=10, slice_thickness=0.144, time_bw_product=8, duration=1e-3, ncycles=0, system=systemmat) self.assertAlmostEqual(rf_mat.all(), rf_pyth.all()) self.assertEqual(gss_mat.all(), gss_pyth.all())
system = Opts(max_grad=sys['max_grad'], grad_unit=sys['grad_unit'], max_slew=sys['max_slew'], slew_unit=sys['slew_unit'], grad_raster_time=sys['grad_raster_time'], rf_raster_time=sys['rf_raster_time']) seq = Sequence(system) ### # 2. Generate the RF and gradient waveforms ### ''' Fat Saturation Module ''' slThick = 10 # dummy value [m] rf_fs_wav, _ = make_slr_rf(rf_fatsat['flip'], slThick, rf_fatsat['tbw'], rf_fatsat['dur'], 0, sys_gen) rf_fs_wav = makeSystemlength(rf_fs_wav, sys_gen['rf_raster_time']) rf_fs_wav = rf_interpolate(rf_fs_wav, sys_acq['rf_raster_time']) ''' Slab selective excitation module and PRESTO gradients (Tip down module) ''' # RF pulse nCyclesSpoil = 0 rf_td_wav, g_td_wav = make_slr_rf(rf_tipdown['flip'], rf_tipdown['slab_thickness'], rf_tipdown['tbw'], rf_tipdown['dur'], nCyclesSpoil, sys_gen) # Spoiler gradients gspoil1 = make_crusher(fmri['nCyclesSpoil'], acq_params['dz'], 0, sys_gen['max_grad'],