def solve(self, field_pos=None):

        field = self._field
        pulse = self._pulse
        fs = self.fs
        tx_apertures = self._tx_apertures
        rx_apertures = self._rx_apertures
        result = self.result

        if field_pos is None:
            field_pos = self.field_pos
        field_pos = np.atleast_2d(field_pos)

        # iterate over field positions
        pos_rf = []
        pos_t0s = []

        for i, pos in enumerate(field_pos):

            # determine sum of transmit spatial impulse responses
            tx_sir = []
            tx_t0 = []

            for tx in tx_apertures:
                _tx_sir, _tx_t0 = field.calc_h(tx, pos)
                tx_sir.append(_tx_sir)
                tx_t0.append(_tx_t0)

            tx_sir, tx_t0 = util.sum_with_padding(tx_sir, tx_t0, fs)

            # determine sum of receive impulse responses
            rx_sir = []
            rx_t0 = []

            for rx in rx_apertures:
                _rx_sir, _rx_t0 = field.calc_h(rx, pos)
                rx_sir.append(_rx_sir)
                rx_t0.append(_rx_t0)

            rx_sir, rx_t0 = util.sum_with_padding(rx_sir, rx_t0, fs)

            # calculate pulse-echo response by convolving transmit and receive spatial impulse responses
            # _pos_rf = np.convolve(tx_sir.squeeze(), rx_sir.squeeze()) / fs
            _pos_t0 = tx_t0 + rx_t0
            _pos_rf = _convolver(pulse, tx_sir, rx_sir, pulse, fs=fs)

            pos_rf.append(_pos_rf)
            pos_t0s.append(_pos_t0)

        # result['rf'] = pos_rf, pos_t0s

        rf_data, t0 = util.concatenate_with_padding(pos_rf,
                                                    pos_t0s,
                                                    fs,
                                                    axis=0)
        times = t0 + np.arange(rf_data.shape[1]) / fs

        result['rf_data'] = rf_data
        result['times'] = times
Example #2
0
    def solve(self, field_pos=None):

        field = self._field
        rect_info = self.rectangles_info
        pulse = self._pulse
        use_element_factor = self.use_element_factor
        interpolator = self._interpolator
        fs = self.fs
        result = self.result

        if field_pos is None:
            field_pos = self.field_pos
        field_pos = np.atleast_2d(field_pos)

        array_rf = []
        array_t0s = []

        for info in rect_info:

            rx_info = info['rx_info']
            rx_rectangles = rx_info['rectangles']
            rx_centers = rx_info['centers']
            rx_delays = rx_info['delays']
            rx_apod = rx_info['apodizations']
            rx_ele_delays = rx_info['ele_delays']

            # create receive aperture and set aperture parameters
            rx = field.xdc_rectangles(rx_rectangles, rx_centers,
                                      np.array([[0, 0, 300]]))
            field.xdc_impulse(rx, pulse)
            field.xdc_excitation(rx, np.array([1]))
            field.xdc_focus_times(rx, np.zeros((1, 1)), rx_delays)
            field.xdc_apodization(rx, np.zeros((1, 1)), rx_apod)

            # set mathematical element delays
            field.ele_delay(rx,
                            np.arange(len(rx_ele_delays)) + 1, rx_ele_delays)

            pos_rf = []
            pos_t0s = []

            for i, pos in enumerate(field_pos):

                if use_element_factor:

                    # calculate element factor corrections
                    r_rx = np.atleast_2d(pos) - np.atleast_2d(rx_centers)
                    r, a, b = util.cart2sec(r_rx).T
                    rx_correction = interpolator(np.rad2deg(np.abs(a)),
                                                 np.rad2deg(np.abs(b)))
                    # apply correction as apodization
                    field.xdc_apodization(rx, np.zeros((1, 1)),
                                          rx_apod * rx_correction)

                _rf, _t0 = field.calc_hp(rx, pos)

                pos_rf.append(_rf)
                pos_t0s.append(_t0)

            _array_rf, _array_t0 = util.concatenate_with_padding(
                pos_rf, pos_t0s, fs)

            array_rf.append(_array_rf)
            array_t0s.append(_array_t0)

            field.xdc_free(rx)

        rf_data, t0 = util.sum_with_padding(array_rf, array_t0s, fs)
        times = t0 + np.arange(rf_data.shape[1]) / fs

        result['rf_data'] = rf_data
        result['times'] = times
Example #3
0
    def solve(self, field_pos=None):

        field = self._field
        rect_info = self.rectangles_info
        pulse = self._pulse
        fs = self.fs
        result = self.result

        if field_pos is None:
            field_pos = self.field_pos
        field_pos = np.atleast_2d(field_pos)

        # read rect_info and create list of transmit and receive apertures
        tx_apertures = []
        rx_apertures = []

        for info in rect_info:

            tx_info = info['tx_info']
            rx_info = info['rx_info']

            if tx_info is not None:

                tx_rectangles = tx_info['rectangles']
                tx_centers = tx_info['centers']
                tx_delays = tx_info['delays']
                tx_apod = tx_info['apodizations']
                tx_ele_delays = tx_info['ele_delays']

                # create transmit aperture and set aperture parameters
                tx = field.xdc_rectangles(tx_rectangles, tx_centers, np.array([[0, 0, 300]]))
                field.xdc_impulse(tx, pulse)
                field.xdc_excitation(tx, np.array([1]))
                field.xdc_focus_times(tx, np.zeros((1, 1)), tx_delays)
                field.xdc_apodization(tx, np.zeros((1, 1)), tx_apod)

                # set mathematical element delays
                field.ele_delay(tx, np.arange(len(tx_ele_delays)) + 1, tx_ele_delays)

                # add aperture to list
                tx_apertures.append(tx)

            if rx_info is not None:

                rx_rectangles = rx_info['rectangles']
                rx_centers = rx_info['centers']
                rx_delays = rx_info['delays']
                rx_apod = rx_info['apodizations']
                rx_ele_delays = rx_info['ele_delays']

                # create receive aperture and set aperture parameters
                rx = field.xdc_rectangles(rx_rectangles, rx_centers, np.array([[0, 0, 300]]))
                field.xdc_impulse(rx, pulse)
                field.xdc_excitation(rx, np.array([1]))
                field.xdc_focus_times(rx, np.zeros((1, 1)), rx_delays)
                field.xdc_apodization(rx, np.zeros((1, 1)), rx_apod)

                # set mathematical element delays
                field.ele_delay(rx, np.arange(len(rx_ele_delays)) + 1, rx_ele_delays)

                # add aperture to list
                rx_apertures.append(rx)

        # iterate over field positions
        pos_rf = []
        pos_t0s = []

        for i, pos in enumerate(field_pos):

            # determine sum of transmit spatial impulse responses
            tx_sir = []
            tx_t0 = []

            for tx in tx_apertures:
                _tx_sir, _tx_t0 = field.calc_h(tx, pos)
                tx_sir.append(_tx_sir)
                tx_t0.append(_tx_t0)

            tx_sir, tx_t0 = util.sum_with_padding(tx_sir, tx_t0, fs)

            # determine sum of receive impulse responses
            rx_sir = []
            rx_t0 = []

            for rx in rx_apertures:
                _rx_sir, _rx_t0 = field.calc_h(rx, pos)
                rx_sir.append(_rx_sir)
                rx_t0.append(_rx_t0)

            rx_sir, rx_t0 = util.sum_with_padding(rx_sir, rx_t0, fs)

            # calculate pulse-echo response by convolving transmit and receive spatial impulse responses
            # _pos_rf = np.convolve(tx_sir.squeeze(), rx_sir.squeeze()) / fs
            _pos_t0 = tx_t0 + rx_t0
            _pos_rf = _convolver(pulse, tx_sir, rx_sir, pulse, fs=fs)

            pos_rf.append(_pos_rf)
            pos_t0s.append(_pos_t0)

        result['rf'] = pos_rf, pos_t0s

        rf_data, t0 = util.concatenate_with_padding(pos_rf, pos_t0s, fs, axis=0)
        times = t0 + np.arange(rf_data.shape[1]) / fs

        # free apertures from memory
        for tx in tx_apertures:
            field.xdc_free(tx)
        for rx in rx_apertures:
            field.xdc_free(rx)

        result['rf_data'] = rf_data
        result['times'] = times