示例#1
0
文件: block.py 项目: agramfort/PyMP
    def computeTransform(self, startingFrame=1 , endFrame = -1):
        if self.wLong is None:
            self.initialize()
            
        if endFrame <0:
            endFrame = self.frameNumber -1
        
        if startingFrame<1:
            startingFrame = 1
        
        startingFrame=1 
        endFrame = self.frameNumber -1
        
        L = self.scale
        K = L/2
#        T = K/2
#        normaCoeffs = sqrt(2/float(K))
#        print startingFrame , endFrame
        for l in range(-K/2,K/2,1):
            parallelProjections.project(self.enframedDataMatrix, 
                                                 self.bestScoreTree[l+K/2],
                                                 self.projectionMatrix[l+K/2] , 
                                                 self.locCoeff , 
                                                 self.post_twidVec ,
                                                 startingFrame,
                                                 endFrame,
                                                 self.scale ,l)
示例#2
0
文件: block.py 项目: agramfort/PyMP
    def computeTransform(self, startingFrame=1 , endFrame = -1):
        """ inner product computation through MDCT """
        if self.wLong is None:
            self.initialize()
            
        if endFrame <0:
            endFrame = self.frameNumber -1
        
        # debug -> changed from 1: be sure signal is properly zero -padded
        if startingFrame<1:
            startingFrame = 1
    
        
        # Wrapping C code call for fast implementation
        if self.useC:     
            try:              
                parallelProjections.project(self.enframedDataMatrix, self.bestScoreTree,
                                                 self.projectionMatrix , 
                                                 self.locCoeff , 
                                                 self.post_twidVec ,
                                                 startingFrame,
                                                 endFrame,
                                                 self.scale ,0)

            except SystemError:
                print sys.exc_info()[0]
                print sys.exc_info()[1]
                raise
            except:
                print "Unexpected error:", sys.exc_info()[0]
                raise
        else:
            try:
                import fftw3
            except ImportError:
                print '''Impossible to load fftw3, you need to use the C extension library or have
                        a local installation of the python fftw3 wrapper '''
                return    
        # create a forward fft plan, since fftw is not faster for computing DCT's no need to use it for that
            L = self.scale
            K = L/2
            T = K/2
            normaCoeffs = sqrt(2/float(K))
            if self.fft is None:
                self.inputa = self.enframedDataMatrix[K - T: K + L - T].astype(complex)
                self.outputa = None
                self.fft = fftw3.Plan(self.inputa,self.outputa, direction='forward', flags=['estimate'])                 
                            
            self.project(startingFrame,endFrame, L , K , T , normaCoeffs)
        
        if self.HF:
            for i in range(startingFrame , endFrame):
                self.bestScoreHFTree[i] = abs(self.projectionMatrix[(i+self.HFlimit)*self.scale/2 : (i+1)*self.scale/2]).max()
示例#3
0
文件: block.py 项目: agramfort/PyMP
    def computeTransform(self,   startingFrame=1 , endFrame = -1 ):
        if self.wLong is None:
            self.initialize()
            
        if endFrame <0:
            endFrame = self.frameNumber -2
        
        if startingFrame<2:
            startingFrame = 2
#        L = self.scale
#        K = L/2;
        
        ############" changes  ##############
#        T = K/2 + self.currentTS
        # new version with C calculus
        parallelProjections.project(self.enframedDataMatrix, self.bestScoreTree,
                                                 self.projectionMatrix , 
                                                 self.locCoeff , 
                                                 self.post_twidVec ,
                                                 startingFrame,
                                                 endFrame,
                                                 self.scale ,
                                                 int(self.currentTS))
示例#4
0
projectionMatrix_comp = np.zeros((N, 1), complex)
scoreTree = np.zeros((P, 1))
pre_twidVec = np.array([exp(n * (-1j) * pi / L) for n in range(L)]).reshape(L, 1)
post_twidVec = np.array([exp((float(n) + 0.5) * -1j * pi * (L / 2 + 1) / L) for n in range(L / 2)]).reshape(L / 2, 1)

print scoreTree.shape, pre_twidVec.shape, post_twidVec.shape

i = 1
j = 10
takeReal = 1

# print "Testing Bad call:"
# computeMCLT.project(input_data )

print " ---Testing good call"
parallelProjections.project(input_data, scoreTree, projectionMatrix_real, pre_twidVec, post_twidVec, i, j, L, 0)

# if parallelFFT.clean_plans() != 1:
#    print "Cleaning Stage Failed"
###
##print  projectionMatrix_real
print scoreTree
print "--- OK"
#
#
# if computeMCLT.initialize_plans(np.array([L])) != 1:
#    print "Initiliazing Stage Failed"

print "---Testing good call: complex"
res = parallelProjections.project_mclt(input_data, scoreTree, projectionMatrix_comp, pre_twidVec, post_twidVec, i, j, L)
print scoreTree