pitch = float(np.squeeze(np.array(f['pitch']))) n_elements = int(np.squeeze(np.array(f['n_elements']))) period = time_vec[-1] + samp_time probe_geometry = pitch * np.arange(n_elements) probe_geometry -= np.mean(probe_geometry) # extract locations of strong reflectors and corresponding echo locations across channels x_true = true_positions[0, :][-n_points:] z_true = true_positions[2, :][-n_points:] print("%d strong reflectors" % n_points) print("%d total reflectors" % true_positions.shape[1]) """ Crop and beamform """ # prepare data min_time = distance2time(min_depth, speed_sound) max_time = distance2time(max_depth, speed_sound) first_sample = int(np.floor(min_time / samp_time)) last_sample = int(np.ceil(max_time / samp_time)) t0 = samp_time * first_sample rf_data_trunc = rf_data[:, first_sample:last_sample] time_vec_trunc = time_vec[first_sample:last_sample] - t0 duration = time_vec_trunc[-1] - time_vec_trunc[0] + samp_time n_samples = rf_data_trunc.shape[1] # check that beamformed image is still alright scal_fact = 1e2 bf_data = das_beamform(rf_data_trunc, samp_freq, pitch, probe_geometry,
"No data available. Loading NDE data and recovering for each channel..." ) print() if run_sweep: # signed 16 bit integer [-128,127] ndt_rawdata = np.genfromtxt(os.path.join(os.path.dirname(__file__), '..', 'data', 'ndt_rawdata.csv'), delimiter=',') n_samples = len(ndt_rawdata) time_vec = np.arange(n_samples) / samp_freq depth = time_vec[-1] / 2 * speed_sound n_elem_tx = ndt_rawdata.shape[1] """ Select portion of recording """ min_samp = int(distance2time(min_depth, speed_sound) * samp_freq) t0 = time_vec[min_samp] max_samp = int(distance2time(max_depth, speed_sound) * samp_freq) tN = time_vec[max_samp] t_samp = time_vec[min_samp:max_samp] - t0 n_samples = len(t_samp) """ From FRI parameters, determine necessary sampling """ period = t_samp[-1] - t_samp[0] + 1 / samp_freq fs_ind_center = int(np.ceil(center_freq * period)) period = fs_ind_center / center_freq # adjust period K = n_points M = K * oversample_fact n_samples_fri = 2 * M + 1 # also number of FS coefficients # subsampling
center_freq = clk_verasonics / 12 samp_freq = clk_verasonics / 3 bw = 2 / 3 bwr = -6 n_cycles = 2.5 speed_sound = 1540 seed = 0 # user parameters n_diracs = 15 depth = 5e-2 # in meters viz = True """ Create FRI parameters """ period = distance2time(depth, speed_sound) ck, tk = create_pulse_param(n_diracs, period=period, seed=seed) """ Critical sampling """ M = n_diracs n_samples = 2 * M + 1 samp_bw = n_samples / period Ts = 1 / samp_bw y_samp, t_samp = sample_iq(ck, tk, period, samp_bw, center_freq, bw, n_cycles, bwr) """ Estimate FS coefficients of sum of diracs """ freqs_fft = np.fft.fftfreq(n_samples, Ts)
sub_idx = np.linspace(0, n_elem_tx - 1, n_elem_rx).astype(np.int) array_pos = probe_geometry[sub_idx] rx_echoes = rx_echoes[sub_idx] + t0 else: """ Subsample array """ sub_idx = np.linspace(0, n_elem_tx - 1, n_elem_rx).astype(np.int) array_pos = probe_geometry[sub_idx] """ Estimate TOFs with pulse stream recovery """ # determine region to sample min_samp = int(distance2time(min_depth, speed_sound) * samp_freq) t0 = time_vec[min_samp] max_samp = int(distance2time(max_depth, speed_sound) * samp_freq) tN = time_vec[max_samp] t_samp = time_vec[min_samp:max_samp] - t0 n_samples = len(t_samp) # FRI parameters period = t_samp[-1] - t_samp[0] fs_ind_center = int(np.ceil(center_freq * period)) period = fs_ind_center / center_freq K = n_points M = K * oversample_fact n_samples_fri = 2 * M + 1 # also number of FS coefficients # subsampling