def run(self):
		self.sig_prb_file_setMax.emit(len(self.files2run))
		ind_file = 0
		self.sig_prb_file_update.emit(ind_file)
		self.sig_lbl_file_update.emit('Files - (' + str(ind_file) + ' / ' + str(len(self.files2run)) + ')')
		for file2run in self.files2run:
			dataMatrix      = self.input[file2run][0]
			dataInfo        = self.input[file2run][1]
			algorithmConfig = self.input[file2run][2]

			config = generateFinalConfig(self.dictionaryConfig , dataInfo , algorithmConfig)

			book = np.empty(shape=(len(config['trials2calc']),len(config['channels2calc'])) , dtype = pd.core.frame.DataFrame)

			self.sig_prb_channel_setMax.emit(len(config['channels2calc']))
			self.sig_prb_trial_setMax.emit(len(config['trials2calc']))

			ind_channel = 0
			self.sig_prb_channel_update.emit(ind_channel)
			self.sig_lbl_channel_update.emit('Channels - (' + str(ind_channel) + ' / ' + str(len(config['channels2calc'])) + ')')
			for channel in config['channels2calc']:
				ind_trial   = 0
				self.sig_prb_trial_update.emit(ind_trial)
				self.sig_lbl_trial_update.emit('Trials - (' + str(ind_trial) + ' / ' + str(len(config['trials2calc'])) + ')')
				for trial in config['trials2calc']:
					book[ind_trial , ind_channel] = calculateMP(self.dictionary , np.squeeze(dataMatrix[trial-1,channel-1,:]) , config)
					ind_trial += 1
					self.sig_prb_trial_update.emit(ind_trial)
					self.sig_lbl_trial_update.emit('Trials - (' + str(ind_trial) + ' / ' + str(len(config['trials2calc'])) + ')')

					if self.cancelClicked == 1:
						return

				ind_channel += 1
				self.sig_prb_channel_update.emit(ind_channel)
				self.sig_lbl_channel_update.emit('Channels - (' + str(ind_channel) + ' / ' + str(len(config['channels2calc'])) + ')')

			ind_file += 1
			self.sig_prb_file_update.emit(ind_file)
			self.sig_lbl_file_update.emit('Files - (' + str(ind_file) + ' / ' + str(len(self.files2run)) + ')')

			self.sig_singleBookDone.emit(book , config , file2run)
	config['minS']                             = 32
	config['maxS']                             = numberOfSamples
	config['density']                          = 0.01
	config['maxNumberOfIterations']            = 4
	config['minEnergyExplained']               = 0.99
	config['samplingFrequency']                = samplingFrequency
	config['minNFFT']                          = 256 # 2*samplingFrequency

# optional config for t-f map drawing
	# config['mapFreqRange']    = [0.0 , samplingFrequency/2]
	# config['mapStructFreqs']  = [0.0 , samplingFrequency/2]
	# config['mapStructSigmas'] = [0.0 , 4.0]
	
	dictionary = generateDictionary(time , config)

	book       = calculateMP(dictionary , signal , config)
	# print book

# plot resulting functions
	plt.figure()
	plt.subplot(4,1,1)
	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)
	
# config for a dictionary and MP
	flags = {}
	flags['useAsymA'] = 0
	flags['useRectA'] = 0
	flags['useGradientOptimization']  = 1
	
	config = {}
	config['flags']                            = flags
	config['algorithm']                        = 'mmp'
	config['trials2calculate']                 = range(info['numberOfTrials'])
	# config['channels2calculate']               = range(info['numberOfChannels'])
	config['channels2calculate']               = range(5)
	config['minS']                             = 100
	config['maxS']                             = info['numberOfSamples']
	config['density']                          = 0.01
	config['maxNumberOfIterations']            = 1
	config['minEnergyExplained']               = 0.99
	config['samplingFrequency']                = info['samplingFreq']
	config['minNFFT']                          = 1024

# optional config for t-f map drawing
	# config['mapFreqRange']    = [0.0 , samplingFrequency/2]
	# config['mapStructFreqs']  = [0.0 , samplingFrequency/2]
	# config['mapStructSigmas'] = [0.0 , 4.0]
	
	dictionary = generateDictionary(time , config)

	book       = calculateMP(dictionary , data , config)

flags["useGradientOptimization"] = 1
flags["displayInfo"] = 0

config = {}
config["flags"] = flags
config["algorithm"] = "smp"
config["minS"] = 32
config["maxS"] = numberOfSamples
config["density"] = 0.01
config["maxNumberOfIterations"] = 4
config["minEnergyExplained"] = 0.99
config["samplingFrequency"] = samplingFrequency
config["minNFFT"] = 2 * samplingFrequency

dictionary = generateDictionary(time, config)
book = calculateMP(dictionary, signal, config)

flags = {}
flags["useAsymA"] = 1
flags["useRectA"] = 0
flags["useGradientOptimization"] = 1
flags["displayInfo"] = 0
config["flags"] = flags

advancedDictionary = generateDictionary(time, config)
advancedBook = calculateMP(advancedDictionary, advancedSignal, config)

flags = {}
flags["useAsymA"] = 1
flags["useRectA"] = 1
flags["useGradientOptimization"] = 1
示例#5
0
	config['flags']['useGradientOptimization'] = 1
	# config for display
	# config['flags']['drawMeanMap']    = 0
	# config['flags']['saveMeanMap']    = 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'])