コード例 #1
0
	plt.plot(time,signal,'k')
	plt.plot(time,sum(book['reconstruction']).real , 'r')

	plt.subplot(4,1,2)
	plt.plot(time,book['reconstruction'][0].real , 'r')

	plt.subplot(4,1,3)
	plt.plot(time,book['reconstruction'][1].real , 'r')

	plt.subplot(4,1,4)
	plt.plot(time,book['reconstruction'][2].real , 'r')
	
	plt.show()

# draw standard t-f map
	(T,F,TFmap) = calculateTFMap(book,time,config['samplingFrequency'],0)

	gs = gridspec.GridSpec(3,1,height_ratios=[3,1,1])
		
	fig = plt.figure()

	ax0 = plt.subplot(gs[0])
	m   = ax0.imshow(np.abs(TFmap) , aspect='auto' , origin='lower' , extent=[0.0,numberOfSamples/samplingFrequency , 0.0,samplingFrequency/2])
	ax0.set_xlabel(r'Time [s]')
	ax0.set_ylabel(r'Frequency [Hz]')
	# ax0.set_ylim(config['mapFreqRange'])
	
	ax1 = plt.subplot(gs[1])
	ax1.plot(time,signal)
	ax1.set_xlabel(r'Time [s]')
	ax1.set_ylabel(r'Amplitude [uV]')
コード例 #2
0
	def replot(self):
		time     = np.arange(0,self.books[self.nameOfBook]['originalData'].shape[2]) / self.books[self.nameOfBook]['config']['samplingFrequency']
		tmp_time = np.arange(0,self.books[self.nameOfBook]['originalData'].shape[2])

		x_fromWhere = 0
		x_toWhere   = self.books[self.nameOfBook]['originalData'].shape[2] / self.books[self.nameOfBook]['config']['samplingFrequency']
		
		if self.flags['channel'] == 1 or self.flags['trial'] == 1:
			self.decompositionPlot.ax1.plot(time , np.squeeze(self.books[self.nameOfBook]['originalData'][self.trialsCalculated[self.trial]-1,self.channelsCalculated[self.channel]-1,:]) , 'k')
			self.decompositionPlot.ax1.set_title('Original signal')
			self.decompositionPlot.ax1.hold(False)
			self.decompositionPlot.ax1.set_ylabel(r'Amplitude [au]')
			self.decompositionPlot.ax1.set_xlim([x_fromWhere , x_toWhere])
			(y_fromWhere,y_toWhere) = self.decompositionPlot.ax1.get_ylim()

			limits = self.integrateLimits()
			reconstruction = getReconstruction(self.books[self.nameOfBook]['book'][self.trial,self.channel] , tmp_time , limits)

			self.decompositionPlot.ax2.plot(time , reconstruction , 'k')
			self.decompositionPlot.ax2.set_xlim([x_fromWhere , x_toWhere])
			self.decompositionPlot.ax2.set_ylim([y_fromWhere , y_toWhere])
			self.decompositionPlot.ax2.set_title('Decomposition')
			self.decompositionPlot.ax2.hold(False)
			self.decompositionPlot.ax2.set_ylabel(r'Amplitude [au]')

		if self.flags['atom'] == 1:
			func = getAtomReconstruction(self.books[self.nameOfBook]['book'][self.trial,self.channel].iloc[self.atom] , tmp_time)
			self.decompositionPlot.ax3.plot(time , func , 'k')
			self.decompositionPlot.ax3.set_xlim([x_fromWhere , x_toWhere])
			(y_fromWhere,y_toWhere) = self.decompositionPlot.ax1.get_ylim()
			self.decompositionPlot.ax3.set_ylim([y_fromWhere , y_toWhere])
			self.decompositionPlot.ax3.set_title('Single function')
			self.decompositionPlot.ax3.hold(False)
			self.decompositionPlot.ax3.set_ylabel(r'Amplitude [au]')
			self.decompositionPlot.ax3.set_xlabel(r'Time [s]')
		
		self.decompositionPlot.draw()

		if self.flags['channel'] == 1 or self.flags['trial'] == 1:
			(self.T,self.F,self.TFmap) = calculateTFMap(self.books[self.nameOfBook]['book'][self.trial,self.channel] , tmp_time , self.books[self.nameOfBook]['config']['samplingFrequency'] , 0)

			self.amplitudeMapPlot.ax0.imshow(np.abs(self.TFmap) , aspect='auto' , origin='lower' , extent=[x_fromWhere,x_toWhere , 0.0,self.books[self.nameOfBook]['config']['samplingFrequency']/2.])
			self.amplitudeMapPlot.ax0.hold(False)
			self.amplitudeMapPlot.ax0.set_ylabel(r'Frequency [Hz]')

			self.amplitudeMapPlot.ax1.clear()
			self.amplitudeMapPlot.ax1.plot(time , np.squeeze(self.books[self.nameOfBook]['originalData'][self.trialsCalculated[self.trial]-1,self.channelsCalculated[self.channel]-1,:]) , 'k')
			self.amplitudeMapPlot.ax1.plot(time , reconstruction , 'r')
			self.amplitudeMapPlot.ax1.set_xlim([x_fromWhere , x_toWhere])
			self.amplitudeMapPlot.ax1.set_ylabel(r'Amplitude [au]')
			(y_fromWhere,y_toWhere) = self.amplitudeMapPlot.ax1.get_ylim()

		if self.flags['atom'] == 1:
			self.amplitudeMapPlot.ax2.plot(time , func , 'r')
			self.amplitudeMapPlot.ax2.set_xlim([x_fromWhere , x_toWhere])
			self.amplitudeMapPlot.ax2.set_ylim([y_fromWhere , y_toWhere])
			self.amplitudeMapPlot.ax2.hold(False)
			self.amplitudeMapPlot.ax2.set_xlabel(r'Time [s]')
			self.amplitudeMapPlot.ax2.set_ylabel(r'Amplitude [au]')

		self.amplitudeMapPlot.draw()
		self.flags['atom']    = 0
		self.flags['channel'] = 0
		self.flags['trial']   = 0
コード例 #3
0
    plt.plot(time, signal, 'k')
    plt.plot(time, sum(book['reconstruction']).real, 'r')

    plt.subplot(4, 1, 2)
    plt.plot(time, book['reconstruction'][0].real, 'r')

    plt.subplot(4, 1, 3)
    plt.plot(time, book['reconstruction'][1].real, 'r')

    plt.subplot(4, 1, 4)
    plt.plot(time, book['reconstruction'][2].real, 'r')

    plt.show()

    # draw standard t-f map
    (T, F, TFmap) = calculateTFMap(book, time, config['samplingFrequency'], 0)

    gs = gridspec.GridSpec(3, 1, height_ratios=[3, 1, 1])

    fig = plt.figure()

    ax0 = plt.subplot(gs[0])
    m = ax0.imshow(np.abs(TFmap),
                   aspect='auto',
                   origin='lower',
                   extent=[
                       0.0, numberOfSamples / samplingFrequency, 0.0,
                       samplingFrequency / 2
                   ])
    ax0.set_xlabel(r'Time [s]')
    ax0.set_ylabel(r'Frequency [Hz]')
コード例 #4
0
    def replot(self):
        time = np.arange(
            0, self.books[self.nameOfBook]['originalData'].shape[2]
        ) / self.books[self.nameOfBook]['config']['samplingFrequency']
        tmp_time = np.arange(
            0, self.books[self.nameOfBook]['originalData'].shape[2])

        x_fromWhere = 0
        x_toWhere = self.books[self.nameOfBook]['originalData'].shape[
            2] / self.books[self.nameOfBook]['config']['samplingFrequency']

        if self.flags['channel'] == 1 or self.flags['trial'] == 1:
            self.decompositionPlot.ax1.plot(
                time,
                np.squeeze(self.books[self.nameOfBook]['originalData'][
                    self.trialsCalculated[self.trial] - 1,
                    self.channelsCalculated[self.channel] - 1, :]), 'k')
            self.decompositionPlot.ax1.set_title('Original signal')
            self.decompositionPlot.ax1.hold(False)
            self.decompositionPlot.ax1.set_ylabel(r'Amplitude [au]')
            self.decompositionPlot.ax1.set_xlim([x_fromWhere, x_toWhere])
            (y_fromWhere, y_toWhere) = self.decompositionPlot.ax1.get_ylim()

            limits = self.integrateLimits()
            reconstruction = getReconstruction(
                self.books[self.nameOfBook]['book'][self.trial, self.channel],
                tmp_time, limits)

            self.decompositionPlot.ax2.plot(time, reconstruction, 'k')
            self.decompositionPlot.ax2.set_xlim([x_fromWhere, x_toWhere])
            self.decompositionPlot.ax2.set_ylim([y_fromWhere, y_toWhere])
            self.decompositionPlot.ax2.set_title('Decomposition')
            self.decompositionPlot.ax2.hold(False)
            self.decompositionPlot.ax2.set_ylabel(r'Amplitude [au]')

        if self.flags['atom'] == 1:
            func = getAtomReconstruction(
                self.books[self.nameOfBook]['book'][
                    self.trial, self.channel].iloc[self.atom], tmp_time)
            self.decompositionPlot.ax3.plot(time, func, 'k')
            self.decompositionPlot.ax3.set_xlim([x_fromWhere, x_toWhere])
            (y_fromWhere, y_toWhere) = self.decompositionPlot.ax1.get_ylim()
            self.decompositionPlot.ax3.set_ylim([y_fromWhere, y_toWhere])
            self.decompositionPlot.ax3.set_title('Single function')
            self.decompositionPlot.ax3.hold(False)
            self.decompositionPlot.ax3.set_ylabel(r'Amplitude [au]')
            self.decompositionPlot.ax3.set_xlabel(r'Time [s]')

        self.decompositionPlot.draw()

        if self.flags['channel'] == 1 or self.flags['trial'] == 1:
            (self.T, self.F, self.TFmap) = calculateTFMap(
                self.books[self.nameOfBook]['book'][self.trial,
                                                    self.channel], tmp_time,
                self.books[self.nameOfBook]['config']['samplingFrequency'], 0)

            self.amplitudeMapPlot.ax0.imshow(
                np.abs(self.TFmap),
                aspect='auto',
                origin='lower',
                extent=[
                    x_fromWhere, x_toWhere, 0.0,
                    self.books[self.nameOfBook]['config']['samplingFrequency']
                    / 2.
                ])
            self.amplitudeMapPlot.ax0.hold(False)
            self.amplitudeMapPlot.ax0.set_ylabel(r'Frequency [Hz]')

            self.amplitudeMapPlot.ax1.clear()
            self.amplitudeMapPlot.ax1.plot(
                time,
                np.squeeze(self.books[self.nameOfBook]['originalData'][
                    self.trialsCalculated[self.trial] - 1,
                    self.channelsCalculated[self.channel] - 1, :]), 'k')
            self.amplitudeMapPlot.ax1.plot(time, reconstruction, 'r')
            self.amplitudeMapPlot.ax1.set_xlim([x_fromWhere, x_toWhere])
            self.amplitudeMapPlot.ax1.set_ylabel(r'Amplitude [au]')
            (y_fromWhere, y_toWhere) = self.amplitudeMapPlot.ax1.get_ylim()

        if self.flags['atom'] == 1:
            self.amplitudeMapPlot.ax2.plot(time, func, 'r')
            self.amplitudeMapPlot.ax2.set_xlim([x_fromWhere, x_toWhere])
            self.amplitudeMapPlot.ax2.set_ylim([y_fromWhere, y_toWhere])
            self.amplitudeMapPlot.ax2.hold(False)
            self.amplitudeMapPlot.ax2.set_xlabel(r'Time [s]')
            self.amplitudeMapPlot.ax2.set_ylabel(r'Amplitude [au]')

        self.amplitudeMapPlot.draw()
        self.flags['atom'] = 0
        self.flags['channel'] = 0
        self.flags['trial'] = 0
コード例 #5
0
    # config['flags']['drawSingleMaps'] = 0
    # config['flags']['saveSingleMaps'] = 0

    config['mapFreqRange'] = [0.0, 64.0]
    config['mapStructFreqs'] = [0.0, 64.0]
    config['mapStructSigmas'] = [0.0, 20.0]

    dictionary = generateDictionary(time, config)

    for ind1 in np.arange(data.shape[0]):
        book = calculateMP(dictionary, data[ind1, :], config)
        # print book
        break

    (T, F, TFmap) = calculateTFMap(book, time, config['samplingFrequency'], 0,
                                   config['mapStructFreqs'],
                                   config['mapStructSigmas'])
    # results         = {}
    # results['mapM'] = TFmap
    # results['mapT'] = time
    # results['mapF'] = F

    fig = plt.figure()

    plt.subplot(3, 1, 1)
    m = plt.imshow(np.abs(TFmap),
                   aspect='auto',
                   origin='lower',
                   extent=[
                       0.0, numberOfSamples / samplingFrequency, 0.0,
                       samplingFrequency / 2
コード例 #6
0
	# config['flags']['drawSingleMaps'] = 0
	# config['flags']['saveSingleMaps'] = 0
	
	config['mapFreqRange']    = [0.0 , 64.0]
	config['mapStructFreqs']  = [0.0 , 64.0]
	config['mapStructSigmas'] = [0.0 , 20.0]

	dictionary = generateDictionary(time , config)

	for ind1 in np.arange(data.shape[0]):
		book       = calculateMP(dictionary , data[ind1,:] , config)
		# print book
		break

	(T,F,TFmap) = calculateTFMap(book,time,config['samplingFrequency'],0,config['mapStructFreqs'],config['mapStructSigmas'])
	# results         = {}
	# results['mapM'] = TFmap
	# results['mapT'] = time
	# results['mapF'] = F

	fig = plt.figure()

	plt.subplot(3,1,1)
	m = plt.imshow(np.abs(TFmap) , aspect='auto' , origin='lower' , extent=[0.0,numberOfSamples/samplingFrequency , 0.0,samplingFrequency/2])
	plt.ylim(config['mapFreqRange'])
	
	plt.subplot(3,1,2)
	plt.plot(data[0,:],'r')
	# m_r = plt.imshow(TFmap.real , aspect='auto' , origin='lower' , extent=[0.0,numberOfSamples/samplingFrequency , 0.0,samplingFrequency/2])
	# plt.ylim(config['mapFreqRange'])