def plot(self, axis1, axis2, axis3=None, axis4=None): # Display results import framework.mypylab as pl from framework.mynumpy import abs, db, mean, sin, cos, pi self.interpolateData() if VERBOSE: print 'Start plotting...' theta,rad = np.meshgrid(self.angles_intrp, self.ranges_intrp) x = 1000 * rad * sin(theta) y = 1000 * rad * cos(theta) ## Start Plotting if (axis1 == 0): # stand alone plotting pl.figure() pl.subplot(1,2,1, aspect=1) pl.pcolormesh(x, y, self.img_das_detected, cmap=pl.cm.gray, vmin=self.minDynRange.value, vmax=self.maxDynRange.value) pl.gca().invert_yaxis() else: # Plotting in given axis axis1.pcolormesh(x, y, self.img_das_detected, cmap=pl.cm.gray, vmin=self.minDynRange.value, vmax=self.maxDynRange.value) axis1.set_title('Delay-and-sum', fontsize='large') axis1.set_xlabel('Width [mm]', fontsize='large') axis1.set_ylabel('Depth [mm]', fontsize='large') axis1.set_xlim(x.min(), x.max()) axis1.set_ylim(y.max(), y.min()) if (axis2 == 0): ax = 0 pl.subplot(1,2,2, aspect=1) pl.pcolormesh(x, y, self.img_cap_detected, cmap=pl.cm.gray, vmin=self.minDynRangeCapon.value, vmax=self.maxDynRangeCapon.value) pl.gca().invert_yaxis() pl.show() else: ax = axis2.pcolormesh(x, y, self.img_cap_detected, cmap=pl.cm.gray, vmin=self.minDynRangeCapon.value, vmax=self.maxDynRangeCapon.value) if self.Nb.value > 0: axis2.set_title('BS-Capon', fontsize='large') else: axis2.set_title('ES-Capon', fontsize='large') axis2.set_xlabel('Width [mm]', fontsize='large') axis2.set_ylabel('Depth [mm]', fontsize='large') axis2.set_xlim(x.min(), x.max()) axis2.set_ylim(y.max(), y.min()) if axis3 is not None: # plot axial profile #profile_angle = np.arctan( self.profilePos[0] / self.profilePos[1] ) #if profile_angle < self.angles_intrp[-1] and profile_angle > self.angles_intrp[0]: # range_slice_idx = round(self.angles_intrp.shape[0] * (profile_angle-self.angles_intrp[0]) / (self.angles_intrp[-1]-self.angles_intrp[0])) # img_das_rslice = img_das_detected[:, range_slice_idx] # img_cap_rslice = img_cap_detected[:, range_slice_idx] # # axis3.plot(y[:,range_slice_idx], img_das_rslice, label='DAS') # axis3.plot(y[:,range_slice_idx], img_cap_rslice, '-r', label='Capon') # # axis3.set_ylim([self.minDynRange.value, self.maxDynRange.value]) # # axis3.set_title('Radial intensity at %d degrees'%round(profile_angle*180/np.pi)) # axis3.set_xlabel('Depth [mm]') # axis3.set_ylabel('Radial intensity [dB]') # axis3.legend(loc=3, markerscale=0.5) # Plot beampatterns and power spectrums profile_range = np.sqrt( self.profilePos[0]**2 + self.profilePos[1]**2 ) / 1000.0 profile_angle = np.arctan( self.profilePos[0] / self.profilePos[1] ) if profile_range < self.ranges_intrp[-1] and profile_range > self.ranges_intrp[0] and profile_angle < self.angles_intrp[-1] and profile_angle > self.angles_intrp[0]: range = round(self.ranges_intrp.shape[0] * (profile_range-self.ranges_intrp[0]) / (self.ranges_intrp[-1]-self.ranges_intrp[0])) angle = round(self.angles_intrp.shape[0] * (profile_angle-self.angles_intrp[0]) / (self.angles_intrp[-1]-self.angles_intrp[0])) spacing = 0.5 # plot beamspace data x_data = self.Xd_i[angle / (2*self.Kx.value), range / (1*self.Ky.value), :] das_beams = self.calcBeamPatternLinearArray(x_data, self.Nm, spacing, self.angles_intrp, self.angles_intrp[angle], takePowerAndNormalize=True) axis3.plot(x[range,:], 10*np.log10(das_beams) + self.maxDynRange.value, label='DAS Sample Spectrum') # make Capon beam pattern w_capon = self.capon_weights[angle / (2*self.Kx.value), range / (1*self.Ky.value), :] W_capon = self.calcBeamPatternLinearArray(w_capon, self.L.value, spacing, self.angles_intrp, self.angles_intrp[angle]) W_capon = abs(W_capon*W_capon.conj()) W_capon = W_capon / W_capon[angle] axis3.plot(x[range,:], 10*np.log10(W_capon) + self.maxDynRange.value - 10 , label='Capon Beampattern') # make DAS beam pattern for subarrays W_das = self.calcBeamPatternLinearArray(self.das_w_sub, self.L.value, spacing, self.angles_intrp, self.angles_intrp[angle], takePowerAndNormalize=True) axis3.plot(x[range,:], 10*np.log10(W_das) + self.maxDynRange.value - 10, label='DAS Beampattern') # make total Capon beam pattern for the whole system (tx and rx)? # plot selected direction/angle axis3.plot([x[range,angle], x[range,angle]], [self.minDynRange.value, self.maxDynRange.value], label='Steering angle') axis3.set_ylim([self.minDynRange.value, self.maxDynRange.value]) axis3.set_title('Beam pattern at %d degrees and %d mm range'%(round(profile_angle*180/np.pi), round(profile_range*1000)), fontsize='large') axis3.set_xlabel('Width [mm]', fontsize='large') axis3.set_ylabel('Intensity/Gain [dB]', fontsize='large') if self.show_legends.value is 1: axis3.legend(loc=3, markerscale=0.5) if axis4 is not None: profile_range = np.sqrt(self.profilePos[0]**2 + self.profilePos[1]**2) / 1000.0 if profile_range < self.ranges_intrp[-1] and profile_range > self.ranges_intrp[0]: angle_slice_idx = round(self.ranges_intrp.shape[0] * (profile_range-self.ranges_intrp[0]) / (self.ranges_intrp[-1]-self.ranges_intrp[0])) self.img_das_aslice = self.img_das_detected[angle_slice_idx, :] self.img_cap_aslice = self.img_cap_detected[angle_slice_idx, :] self.x_aslice = x[angle_slice_idx,:] axis4.plot(self.x_aslice, self.img_das_aslice, label='DAS') if (self.Nb.value > 0): axis4.plot(self.x_aslice, self.img_cap_aslice, '-r', label='BS-Capon') else: axis4.plot(self.x_aslice, self.img_cap_aslice, '-r', label='ES-Capon') axis4.set_ylim([self.minDynRange.value, self.maxDynRange.value]) axis4.set_title('Lateral intensity at %d mm range'%round(profile_range*1000), fontsize='large') axis4.set_xlabel('Width [mm]', fontsize='large') axis4.set_ylabel('Lateral intensity [dB]', fontsize='large') if self.show_legends.value is 1: axis4.legend(loc=3, markerscale=0.5) if VERBOSE: print 'done' return ax
def plot_slices_invivo(legendOn=True): datatag = 'Vingmed data cardiac 2STB 1' #datatag = 'motion phantom 16x' #datatag.append('Vingmed data liver 2STB 1') #datatag.append('Vingmed data liver 2STB 2') #datatag.append('Vingmed data cardiac 2STB 1') #datatag.append('Vingmed data cardiac 4MLA 1') multiFile = True capon = CaponProcessor(datatag, multiFile) capon.sliceRangeStart.mvToMin() capon.sliceAngleStart.mvToMin() capon.sliceRangeEnd.mvToMax() capon.sliceAngleEnd.mvToMax() # set parameters for capon processor capon.image_idx.updateValue(0) capon.Ky.updateValue(2) # incoherent interpolation in range capon.Kx.updateValue(1) # in azimuth #capon.L.updateValue() capon.K.updateValue(2) capon.minDynRange.updateValue(-20) capon.maxDynRange.updateValue(20) capon.minDynRangeCapon.updateValue(-20) capon.maxDynRangeCapon.updateValue(20) capon.show_legends.updateValue(1) capon.apod.updateValue(0) #'Apodization: 0=uniform, 1=hamming' # position profile capon.profilePos = [-13.83174473246271, 96.50653026882506, 0.0] ax = [] for i in range(4): figure = pl.figure() ax.append(figure.add_subplot(1, 1, 1)) Nbs = [0, 3] for Nb in Nbs: capon.Nb.updateValue(Nb) if capon.Nb.value > 0: capon.d.updateValue(d_BS) else: capon.d.updateValue(d_ES) capon.processData() capon.plot(ax[0], ax[1], ax[2], ax[3]) if Nb == 0: x = capon.x_aslice das_profile = capon.img_das_aslice capon_profile = capon.img_cap_aslice else: capon_bs_profile = capon.img_cap_aslice fig = pl.figure() ax = fig.add_subplot(1, 1, 1) ax.plot(x, das_profile, c=(0.25, 0.25, 1.00), ls=':', lw=2.0, label='DAS') ax.plot(x, capon_profile, c=(1.00, 0.25, 0.25), ls='-.', lw=2.0, label='ES-Capon') ax.plot(x, capon_bs_profile, c=(0.0, 0.0, 0.0), ls='-', lw=2.0, label='BS-Capon') ax.set_ylim([capon.minDynRange.value, capon.maxDynRange.value]) ax.set_title('Lateral intensity at %d mm range' % capon.profilePos[1], fontsize='large') ax.set_xlabel('Width [mm]', fontsize='large') ax.set_ylabel('Lateral intensity [dB]', fontsize='large') if legendOn: ax.legend(loc=1, markerscale=0.5) #fig.savefig('invivo_slice', bbox_inches='tight', pad_inches=0.5) fig.savefig('invivo_slice.png', dpi=300, bbox_inches='tight', pad_inches=0.5)
def runTradoffAnalysis(): datatag = 'motion phantom 16x 3.4 MHz 20dB30dB' #filename = 'motion_phantom_16x' #datatag.append('Vingmed data liver 2STB 1') #datatag.append('Vingmed data liver 2STB 2') #datatag.append('Vingmed data cardiac 2STB 1') #datatag.append('Vingmed data cardiac 4MLA 1') multiFile = True capon = CaponProcessor(datatag, multiFile) # set parameters for capon processor capon.image_idx.updateValue(0) capon.sliceRangeStart.updateValue(120) #(100) capon.sliceAngleStart.updateValue(195) #(350)#200 capon.sliceRangeEnd.updateValue(145) #(120)#0 capon.sliceAngleEnd.updateValue(780) #(600) capon.Ky.updateValue(4) # incoherent interpolation in range capon.Kx.updateValue(4) # in azimuth capon.Nb.updateValue(0) #capon.L.updateValue() capon.K.updateValue(2) capon.minDynRange.updateValue(-20) capon.maxDynRange.updateValue(35) capon.minDynRangeCapon.updateValue(-20) capon.maxDynRangeCapon.updateValue(35) #capon.apod.updateValue(0) #'Apodization: 0=uniform, 1=hamming' # position profile #capon.profilePos = [0.0, 93.0, 0.0] #Nb_L_range = range(32, 2, -1) Nb_L_range = range(31, 0, -2) fps = 25.0 p_depth = 90.0 #93.0 #mm #p_depth += 0.2148 # add 1/4 of the pulse length p_depth += 0.1388 #compensate for extra travel distance in elevation frames = range(7, 30) res_limit = 6.0 fig = pl.figure() ax = fig.add_subplot(1, 1, 1) for b in [True, False]: resolution = [] if not b: capon.L.resetValue() capon.d.updateValue(-1) #1) else: capon.d.updateValue(-1) #1) for v in Nb_L_range: print 'Value is: ', v, ' b is:', b if b: capon.L.updateValue(v) else: capon.Nb.updateValue(v) #capon.d.updateValue((1.0/30.0)*v - 61.0/30.0) # make d go from 0.1 at Nb=31 to 0.01 at Nb=1 resolution.append( findResolution(capon, frames, res_limit, p_depth, fps, highres=True)) if b: ax.plot(Nb_L_range, resolution, c=(0.0, 0.0, 0.0), ls='-', marker='o', lw=2.0, label='Reducing subarrays') else: ax.plot(Nb_L_range, resolution, c=(0.2, 0.2, 0.2), ls='-', marker='s', lw=2.0, label='Reducing beamspace') das_res = findResolution(capon, frames, res_limit, p_depth, fps, highres=False) ax.plot(Nb_L_range, das_res * np.ones(len(Nb_L_range)), c=(0.4, 0.4, 0.4), ls='--', lw=2.0, label='Delay-and-sum') #ax.set_ylim(ax.get_ylim()[0]-0.1, ax.get_ylim()[1]+0.1) ax.set_ylim(ax.get_ylim()[0], ax.get_ylim()[1] + 0.1) ax.set_xlim([Nb_L_range[0], Nb_L_range[-1]]) ax.set_title('Trading resolution for speed', fontsize='x-large') ax.set_xlabel('$L$ or $N_b$', fontsize='large') ax.set_ylabel('Resolution [mm]', fontsize='large') ax.legend(loc=2, markerscale=0.5) fig.savefig('speed_res_trade.png', dpi=300, bbox_inches='tight', pad_inches=0.5)
def process_and_plot_invivo_image(Nb=0): datatag = 'Vingmed data cardiac 2STB 1' multiFile = True capon = CaponProcessor(datatag, multiFile) # set parameters for capon processor #capon.image_idx.updateValue(15) capon.sliceRangeStart.mvToMin() capon.sliceAngleStart.mvToMin() capon.sliceRangeEnd.mvToMax() capon.sliceAngleEnd.mvToMax() capon.Ky.updateValue(2) # incoherent interpolation in range capon.Kx.updateValue(1) # in azimuth capon.Nb.updateValue(Nb) if capon.Nb.value > 0: capon.d.updateValue(d_BS) else: capon.d.updateValue(d_ES) #capon.L.updateValue() capon.K.updateValue(2) capon.minDynRange.updateValue(-20) capon.maxDynRange.updateValue(20) capon.minDynRangeCapon.updateValue(-20) capon.maxDynRangeCapon.updateValue(20) capon.show_legends.updateValue(1) capon.apod.updateValue(0) #'Apodization: 0=uniform, 1=hamming' # position profile capon.profilePos = [-13.83174473246271, 96.50653026882506, 0.0] capon.processData() fig = [] ax = [] filename = [] if Nb == 0: filename = ['das_invivo', 'capon_invivo', 'ax1_invivo', 'ax2_invivo'] else: filename = [ 'das_invivo', 'capon_bs_invivo', 'ax1_bs_invivo', 'ax2_bs_invivo' ] for i in range(4): figure = pl.figure() ax.append(figure.add_subplot(1, 1, 1)) fig.append(figure) axc = capon.plot(ax[0], ax[1], ax[2], ax[3]) #for i in range(2): #ax[i].invert_yaxis() #fig[i].tight_layout() from datetime import datetime d = datetime.time(datetime.now()) for i in range(4): if i is 1 and Nb is not 0: colorBarFig = pl.figure() cbar = colorBarFig.colorbar( axc, ticks=[capon.minDynRange.value, 0, capon.maxDynRange.value], orientation='vertical') #, shrink=0.5) cbar.ax.set_yticklabels([ r'$\leq$%d dB' % capon.minDynRange.value, '0 dB', r'$\geq$%d dB' % capon.maxDynRange.value ]) colorBarFig.savefig('colorBarInvivo.png', dpi=300, bbox_inches='tight', pad_inches=0.5) if i < 2: ax[i].set_aspect('equal') #, 'datalim') #fig[i].savefig('%s_axes%d_%d%d%d%d'%(filename, i, d.hour, d.minute, d.second, d.microsecond), bbox_inches='tight', pad_inches=0.5) fig[i].savefig('%s.png' % (filename[i]), dpi=300, bbox_inches='tight', pad_inches=0.5)
def process_and_plot_invivo_image(Nb=0): datatag = 'Vingmed data cardiac 2STB 1' multiFile = True capon = CaponProcessor(datatag, multiFile) # set parameters for capon processor #capon.image_idx.updateValue(15) capon.sliceRangeStart.mvToMin() capon.sliceAngleStart.mvToMin() capon.sliceRangeEnd.mvToMax() capon.sliceAngleEnd.mvToMax() capon.Ky.updateValue(2) # incoherent interpolation in range capon.Kx.updateValue(1) # in azimuth capon.Nb.updateValue(Nb) if capon.Nb.value > 0: capon.d.updateValue(d_BS) else: capon.d.updateValue(d_ES) #capon.L.updateValue() capon.K.updateValue(2) capon.minDynRange.updateValue(-20) capon.maxDynRange.updateValue(20) capon.minDynRangeCapon.updateValue(-20) capon.maxDynRangeCapon.updateValue(20) capon.show_legends.updateValue(1) capon.apod.updateValue(0) #'Apodization: 0=uniform, 1=hamming' # position profile capon.profilePos = [-13.83174473246271, 96.50653026882506, 0.0] capon.processData() fig = [] ax = [] filename = [] if Nb == 0: filename = ['das_invivo', 'capon_invivo', 'ax1_invivo', 'ax2_invivo'] else: filename = ['das_invivo', 'capon_bs_invivo', 'ax1_bs_invivo', 'ax2_bs_invivo'] for i in range(4): figure = pl.figure() ax.append(figure.add_subplot(1,1,1)) fig.append(figure) axc = capon.plot(ax[0],ax[1],ax[2], ax[3]) #for i in range(2): #ax[i].invert_yaxis() #fig[i].tight_layout() from datetime import datetime d = datetime.time(datetime.now()) for i in range(4): if i is 1 and Nb is not 0: colorBarFig = pl.figure() cbar = colorBarFig.colorbar(axc, ticks=[capon.minDynRange.value, 0, capon.maxDynRange.value], orientation='vertical')#, shrink=0.5) cbar.ax.set_yticklabels([r'$\leq$%d dB'%capon.minDynRange.value, '0 dB', r'$\geq$%d dB'%capon.maxDynRange.value]) colorBarFig.savefig('colorBarInvivo.png', dpi=300, bbox_inches='tight', pad_inches=0.5) if i < 2: ax[i].set_aspect('equal')#, 'datalim') #fig[i].savefig('%s_axes%d_%d%d%d%d'%(filename, i, d.hour, d.minute, d.second, d.microsecond), bbox_inches='tight', pad_inches=0.5) fig[i].savefig('%s.png'%(filename[i]), dpi=300, bbox_inches='tight', pad_inches=0.5)
def runTradoffAnalysis(): datatag = 'motion phantom 16x 3.4 MHz 20dB30dB' #filename = 'motion_phantom_16x' #datatag.append('Vingmed data liver 2STB 1') #datatag.append('Vingmed data liver 2STB 2') #datatag.append('Vingmed data cardiac 2STB 1') #datatag.append('Vingmed data cardiac 4MLA 1') multiFile = True capon = CaponProcessor(datatag, multiFile) # set parameters for capon processor capon.image_idx.updateValue(0) capon.sliceRangeStart.updateValue(120)#(100) capon.sliceAngleStart.updateValue(195)#(350)#200 capon.sliceRangeEnd.updateValue(145)#(120)#0 capon.sliceAngleEnd.updateValue(780)#(600) capon.Ky.updateValue(4) # incoherent interpolation in range capon.Kx.updateValue(4) # in azimuth capon.Nb.updateValue(0) #capon.L.updateValue() capon.K.updateValue(2) capon.minDynRange.updateValue(-20) capon.maxDynRange.updateValue(35) capon.minDynRangeCapon.updateValue(-20) capon.maxDynRangeCapon.updateValue(35) #capon.apod.updateValue(0) #'Apodization: 0=uniform, 1=hamming' # position profile #capon.profilePos = [0.0, 93.0, 0.0] #Nb_L_range = range(32, 2, -1) Nb_L_range = range(31, 0, -2) fps = 25.0 p_depth = 90.0#93.0 #mm #p_depth += 0.2148 # add 1/4 of the pulse length p_depth += 0.1388#compensate for extra travel distance in elevation frames = range(7, 30) res_limit = 6.0 fig = pl.figure() ax = fig.add_subplot(1,1,1) for b in [True, False]: resolution = [] if not b: capon.L.resetValue() capon.d.updateValue(-1)#1) else: capon.d.updateValue(-1)#1) for v in Nb_L_range: print 'Value is: ', v, ' b is:', b if b: capon.L.updateValue(v) else: capon.Nb.updateValue(v) #capon.d.updateValue((1.0/30.0)*v - 61.0/30.0) # make d go from 0.1 at Nb=31 to 0.01 at Nb=1 resolution.append(findResolution(capon, frames, res_limit, p_depth, fps, highres=True)) if b: ax.plot(Nb_L_range, resolution, c=(0.0,0.0,0.0), ls='-', marker='o', lw=2.0, label='Reducing subarrays') else: ax.plot(Nb_L_range, resolution, c=(0.2,0.2,0.2), ls='-', marker='s', lw=2.0, label='Reducing beamspace') das_res = findResolution(capon, frames, res_limit, p_depth, fps, highres=False) ax.plot(Nb_L_range, das_res*np.ones(len(Nb_L_range)), c=(0.4,0.4,0.4), ls='--', lw=2.0, label='Delay-and-sum') #ax.set_ylim(ax.get_ylim()[0]-0.1, ax.get_ylim()[1]+0.1) ax.set_ylim(ax.get_ylim()[0], ax.get_ylim()[1]+0.1) ax.set_xlim([Nb_L_range[0], Nb_L_range[-1]]) ax.set_title('Trading resolution for speed', fontsize='x-large') ax.set_xlabel('$L$ or $N_b$', fontsize='large') ax.set_ylabel('Resolution [mm]', fontsize='large') ax.legend(loc=2, markerscale=0.5) fig.savefig('speed_res_trade.png', dpi=300, bbox_inches='tight', pad_inches=0.5)
def plot_slices_invivo(legendOn=True): datatag = 'Vingmed data cardiac 2STB 1' #datatag = 'motion phantom 16x' #datatag.append('Vingmed data liver 2STB 1') #datatag.append('Vingmed data liver 2STB 2') #datatag.append('Vingmed data cardiac 2STB 1') #datatag.append('Vingmed data cardiac 4MLA 1') multiFile = True capon = CaponProcessor(datatag, multiFile) capon.sliceRangeStart.mvToMin() capon.sliceAngleStart.mvToMin() capon.sliceRangeEnd.mvToMax() capon.sliceAngleEnd.mvToMax() # set parameters for capon processor capon.image_idx.updateValue(0) capon.Ky.updateValue(2) # incoherent interpolation in range capon.Kx.updateValue(1) # in azimuth #capon.L.updateValue() capon.K.updateValue(2) capon.minDynRange.updateValue(-20) capon.maxDynRange.updateValue(20) capon.minDynRangeCapon.updateValue(-20) capon.maxDynRangeCapon.updateValue(20) capon.show_legends.updateValue(1) capon.apod.updateValue(0) #'Apodization: 0=uniform, 1=hamming' # position profile capon.profilePos = [-13.83174473246271, 96.50653026882506, 0.0] ax = [] for i in range(4): figure = pl.figure() ax.append(figure.add_subplot(1,1,1)) Nbs = [0, 3] for Nb in Nbs: capon.Nb.updateValue(Nb) if capon.Nb.value > 0: capon.d.updateValue(d_BS) else: capon.d.updateValue(d_ES) capon.processData() capon.plot(ax[0],ax[1],ax[2], ax[3]) if Nb == 0: x = capon.x_aslice das_profile = capon.img_das_aslice capon_profile = capon.img_cap_aslice else: capon_bs_profile = capon.img_cap_aslice fig = pl.figure() ax = fig.add_subplot(1,1,1) ax.plot(x, das_profile, c=(0.25,0.25,1.00), ls=':', lw=2.0, label='DAS') ax.plot(x, capon_profile, c=(1.00,0.25,0.25), ls='-.', lw=2.0, label='ES-Capon') ax.plot(x, capon_bs_profile, c=(0.0,0.0,0.0), ls='-', lw=2.0, label='BS-Capon') ax.set_ylim([capon.minDynRange.value, capon.maxDynRange.value]) ax.set_title('Lateral intensity at %d mm range'%capon.profilePos[1], fontsize='large') ax.set_xlabel('Width [mm]', fontsize='large') ax.set_ylabel('Lateral intensity [dB]', fontsize='large') if legendOn: ax.legend(loc=1, markerscale=0.5) #fig.savefig('invivo_slice', bbox_inches='tight', pad_inches=0.5) fig.savefig('invivo_slice.png', dpi=300, bbox_inches='tight', pad_inches=0.5)
def plot(self, axis1, axis2, axis3=None, axis4=None): # Display results import framework.mypylab as pl from framework.mynumpy import abs, db, mean, sin, cos, pi self.interpolateData() if VERBOSE: print 'Start plotting...' theta, rad = np.meshgrid(self.angles_intrp, self.ranges_intrp) x = 1000 * rad * sin(theta) y = 1000 * rad * cos(theta) ## Start Plotting if (axis1 == 0): # stand alone plotting pl.figure() pl.subplot(1, 2, 1, aspect=1) pl.pcolormesh(x, y, self.img_das_detected, cmap=pl.cm.gray, vmin=self.minDynRange.value, vmax=self.maxDynRange.value) pl.gca().invert_yaxis() else: # Plotting in given axis axis1.pcolormesh(x, y, self.img_das_detected, cmap=pl.cm.gray, vmin=self.minDynRange.value, vmax=self.maxDynRange.value) axis1.set_title('Delay-and-sum', fontsize='large') axis1.set_xlabel('Width [mm]', fontsize='large') axis1.set_ylabel('Depth [mm]', fontsize='large') axis1.set_xlim(x.min(), x.max()) axis1.set_ylim(y.max(), y.min()) if (axis2 == 0): ax = 0 pl.subplot(1, 2, 2, aspect=1) pl.pcolormesh(x, y, self.img_cap_detected, cmap=pl.cm.gray, vmin=self.minDynRangeCapon.value, vmax=self.maxDynRangeCapon.value) pl.gca().invert_yaxis() pl.show() else: ax = axis2.pcolormesh(x, y, self.img_cap_detected, cmap=pl.cm.gray, vmin=self.minDynRangeCapon.value, vmax=self.maxDynRangeCapon.value) if self.Nb.value > 0: axis2.set_title('BS-Capon', fontsize='large') else: axis2.set_title('ES-Capon', fontsize='large') axis2.set_xlabel('Width [mm]', fontsize='large') axis2.set_ylabel('Depth [mm]', fontsize='large') axis2.set_xlim(x.min(), x.max()) axis2.set_ylim(y.max(), y.min()) if axis3 is not None: # plot axial profile #profile_angle = np.arctan( self.profilePos[0] / self.profilePos[1] ) #if profile_angle < self.angles_intrp[-1] and profile_angle > self.angles_intrp[0]: # range_slice_idx = round(self.angles_intrp.shape[0] * (profile_angle-self.angles_intrp[0]) / (self.angles_intrp[-1]-self.angles_intrp[0])) # img_das_rslice = img_das_detected[:, range_slice_idx] # img_cap_rslice = img_cap_detected[:, range_slice_idx] # # axis3.plot(y[:,range_slice_idx], img_das_rslice, label='DAS') # axis3.plot(y[:,range_slice_idx], img_cap_rslice, '-r', label='Capon') # # axis3.set_ylim([self.minDynRange.value, self.maxDynRange.value]) # # axis3.set_title('Radial intensity at %d degrees'%round(profile_angle*180/np.pi)) # axis3.set_xlabel('Depth [mm]') # axis3.set_ylabel('Radial intensity [dB]') # axis3.legend(loc=3, markerscale=0.5) # Plot beampatterns and power spectrums profile_range = np.sqrt(self.profilePos[0]**2 + self.profilePos[1]**2) / 1000.0 profile_angle = np.arctan(self.profilePos[0] / self.profilePos[1]) if profile_range < self.ranges_intrp[ -1] and profile_range > self.ranges_intrp[ 0] and profile_angle < self.angles_intrp[ -1] and profile_angle > self.angles_intrp[0]: range = round(self.ranges_intrp.shape[0] * (profile_range - self.ranges_intrp[0]) / (self.ranges_intrp[-1] - self.ranges_intrp[0])) angle = round(self.angles_intrp.shape[0] * (profile_angle - self.angles_intrp[0]) / (self.angles_intrp[-1] - self.angles_intrp[0])) spacing = 0.5 # plot beamspace data x_data = self.Xd_i[angle / (2 * self.Kx.value), range / (1 * self.Ky.value), :] das_beams = self.calcBeamPatternLinearArray( x_data, self.Nm, spacing, self.angles_intrp, self.angles_intrp[angle], takePowerAndNormalize=True) axis3.plot(x[range, :], 10 * np.log10(das_beams) + self.maxDynRange.value, label='DAS Sample Spectrum') # make Capon beam pattern w_capon = self.capon_weights[angle / (2 * self.Kx.value), range / (1 * self.Ky.value), :] W_capon = self.calcBeamPatternLinearArray( w_capon, self.L.value, spacing, self.angles_intrp, self.angles_intrp[angle]) W_capon = abs(W_capon * W_capon.conj()) W_capon = W_capon / W_capon[angle] axis3.plot(x[range, :], 10 * np.log10(W_capon) + self.maxDynRange.value - 10, label='Capon Beampattern') # make DAS beam pattern for subarrays W_das = self.calcBeamPatternLinearArray( self.das_w_sub, self.L.value, spacing, self.angles_intrp, self.angles_intrp[angle], takePowerAndNormalize=True) axis3.plot(x[range, :], 10 * np.log10(W_das) + self.maxDynRange.value - 10, label='DAS Beampattern') # make total Capon beam pattern for the whole system (tx and rx)? # plot selected direction/angle axis3.plot([x[range, angle], x[range, angle]], [self.minDynRange.value, self.maxDynRange.value], label='Steering angle') axis3.set_ylim([self.minDynRange.value, self.maxDynRange.value]) axis3.set_title( 'Beam pattern at %d degrees and %d mm range' % (round( profile_angle * 180 / np.pi), round(profile_range * 1000)), fontsize='large') axis3.set_xlabel('Width [mm]', fontsize='large') axis3.set_ylabel('Intensity/Gain [dB]', fontsize='large') if self.show_legends.value is 1: axis3.legend(loc=3, markerscale=0.5) if axis4 is not None: profile_range = np.sqrt(self.profilePos[0]**2 + self.profilePos[1]**2) / 1000.0 if profile_range < self.ranges_intrp[ -1] and profile_range > self.ranges_intrp[0]: angle_slice_idx = round( self.ranges_intrp.shape[0] * (profile_range - self.ranges_intrp[0]) / (self.ranges_intrp[-1] - self.ranges_intrp[0])) self.img_das_aslice = self.img_das_detected[angle_slice_idx, :] self.img_cap_aslice = self.img_cap_detected[angle_slice_idx, :] self.x_aslice = x[angle_slice_idx, :] axis4.plot(self.x_aslice, self.img_das_aslice, label='DAS') if (self.Nb.value > 0): axis4.plot(self.x_aslice, self.img_cap_aslice, '-r', label='BS-Capon') else: axis4.plot(self.x_aslice, self.img_cap_aslice, '-r', label='ES-Capon') axis4.set_ylim( [self.minDynRange.value, self.maxDynRange.value]) axis4.set_title('Lateral intensity at %d mm range' % round(profile_range * 1000), fontsize='large') axis4.set_xlabel('Width [mm]', fontsize='large') axis4.set_ylabel('Lateral intensity [dB]', fontsize='large') if self.show_legends.value is 1: axis4.legend(loc=3, markerscale=0.5) if VERBOSE: print 'done' return ax