Example #1
0
    def processData(self):

        if VERBOSE:
            print 'Start processing image...'

        if self.multiFile:
            self.s = System(self.dataTag + ' %d' % (self.image_idx.value + 1))
            self.Xd_i = self.s.data.Xd
        else:
            self.Xd_i = self.Xd[self.image_idx.value, :, :, :].copy()

        self.Xd_i = self.Xd_i[self.sliceAngleStart.value:self.sliceAngleEnd.
                              value:self.sliceAngleStep.value,
                              self.sliceRangeStart.value:self.sliceRangeEnd.
                              value:self.sliceRangeStep.value,
                              self.sliceElementStart.value:self.sliceElementEnd
                              .value:self.sliceElementStep.value]
        self.Nx = self.Xd_i.shape[0]  # No. beams
        self.Ny = self.Xd_i.shape[1]  # No. range samples
        self.Nm = self.Xd_i.shape[2]  # No. channels

        self.angles = self.s.data.angles.squeeze()
        self.angles = self.angles[self.sliceAngleStart.value:self.sliceAngleEnd
                                  .value:self.sliceAngleStep.value]
        self.ranges = self.s.data.ranges.squeeze()
        self.ranges = self.ranges[self.sliceRangeStart.value:self.sliceRangeEnd
                                  .value:self.sliceRangeStep.value]

        # Make delay and sum image
        if self.apod.value is 1:
            self.das_w = np.hamming(self.Nm)
            self.das_w_sub = np.hamming(self.L.value)
        else:
            self.das_w = np.ones(self.Nm)
            self.das_w_sub = np.ones(self.L.value)

        self.img_das = np.dot(self.Xd_i, self.das_w) / self.Nm
        if self.K.value > 0:
            self.img_das = self.img_das[:, self.K.value:-self.K.
                                        value]  # truncate to get equal dim on das and capon image

        # init sub/beam-space matrix
        if self.Nb.value > 0:
            self.B = np.ones((self.Nb.value, self.L.value))
        else:
            self.B = np.array([0])

        # Make capon image
        res_gpu = getCaponCUDA.getCaponCUDAPy(self.Xd_i, 10.0**self.d.value,
                                              self.L.value, self.K.value,
                                              self.B, False, False)
        self.img_capon = res_gpu[0]
        self.capon_weights = res_gpu[2]
        #self.img_capon = self.img_das

        if VERBOSE:
            print 'getCaponCUDA return code: ', res_gpu[3]
            print 'done.'
Example #2
0
   def processData(self):
   
      if VERBOSE:
         print 'Start processing image...'
   
      if self.multiFile:
         self.s = System(self.dataTag + ' %d'%(self.image_idx.value+1))
         self.Xd_i = self.s.data.Xd
      else:
         self.Xd_i = self.Xd[self.image_idx.value, :, :, :].copy()
         
      self.Xd_i = self.Xd_i[self.sliceAngleStart.value:self.sliceAngleEnd.value:self.sliceAngleStep.value, 
                            self.sliceRangeStart.value:self.sliceRangeEnd.value:self.sliceRangeStep.value, 
                            self.sliceElementStart.value:self.sliceElementEnd.value:self.sliceElementStep.value];
      self.Nx = self.Xd_i.shape[0]     # No. beams
      self.Ny = self.Xd_i.shape[1]     # No. range samples
      self.Nm = self.Xd_i.shape[2]     # No. channels
      
      self.angles = self.s.data.angles.squeeze()
      self.angles = self.angles[self.sliceAngleStart.value:self.sliceAngleEnd.value:self.sliceAngleStep.value]
      self.ranges = self.s.data.ranges.squeeze()
      self.ranges = self.ranges[self.sliceRangeStart.value:self.sliceRangeEnd.value:self.sliceRangeStep.value]
   
      # Make delay and sum image
      if self.apod.value is 1:
         self.das_w = np.hamming(self.Nm)
         self.das_w_sub = np.hamming(self.L.value)
      else:
         self.das_w = np.ones(self.Nm)
         self.das_w_sub = np.ones(self.L.value)
      
      self.img_das = np.dot(self.Xd_i, self.das_w) / self.Nm
      if self.K.value > 0:
         self.img_das = self.img_das[:,self.K.value:-self.K.value]# truncate to get equal dim on das and capon image
         
      # init sub/beam-space matrix
      if self.Nb.value > 0:
         self.B = np.ones((self.Nb.value, self.L.value))
      else:
         self.B = np.array([0])

      # Make capon image
      res_gpu = getCaponCUDA.getCaponCUDAPy(self.Xd_i, 10.0**self.d.value, self.L.value, self.K.value, self.B, False, False)
      self.img_capon = res_gpu[0]
      self.capon_weights = res_gpu[2]
      #self.img_capon = self.img_das
      
      if VERBOSE:
         print 'getCaponCUDA return code: ', res_gpu[3]
         print 'done.'
Example #3
0
 def testIterativBuildRinv(self):
    
    M = self.sonardata_n
    L = 24
    Yavg = 5
    d = 0 # diagonal loading as a function of matrix trace is not supported. Use the squared sum of channel data (i.e. the total energy)
    
    invR = wb.iterativeBuildRinv(self.sonardata_ar, M, L, Yavg, d)
    invRa = mynp.dot(invR, self.sonardata_a)
    self.assertMatrixAlmosteEqual(self.sonardata_Ria, invRa, 7)
    
    x = mynp.ones(M, dtype=complex)
    invR = wb.iterativeBuildUpRinv(invR, x, M, L)
    invR = wb.iterativeBuildDownRinv(invR, x, M, L)
    invRa = mynp.dot(invR, self.sonardata_a)
    self.assertMatrixAlmosteEqual(self.sonardata_Ria, invRa, 7) 
Example #4
0
    def testComplexCholeskySolver(self):

        N = 32
        x = np.random.normal(loc=0.0, scale=1.0, size=(N,)) + 1j * np.random.normal(loc=0.0, scale=1.0, size=(N,))
        A = np.outer(x, x.conj()).astype("complex128")
        A = A + 0.5 * np.eye(N)
        b = np.ones(N, dtype=np.complex128)

        #      A = np.array([[3+0j,5+1j],[5-1j,14+0j]])
        #      b = np.array([1+0j,1+0j])

        yi = mklcSolveCholeskyC(A, b)

        print yi

        print "Numpy reference:"

        C = np.linalg.solve(A, b)
        print C

        print "hello"
Example #5
0
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)
Example #6
0
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)