Exemple #1
0
    def init(self):
        if self.interface == None:
            try:
                self.interface = mlabwrap.init( which(self.exec_path) )
            except IOError:
                self.interface._mlab = None # Complete shutdown            
                self.interface = mlabwrap.init( which(self.exec_path) )

        return self.interface
Exemple #2
0
    def __init__(self, **kwargs):
        super(NMRLabMetabolabTool, self).__init__(**kwargs)

        self.addDataToolBar()
        self.addFigureToolBar()

        self.data.add_input('input')  # Add input slot
        self.data.add_output('output')
        self.table.setModel(self.data.o['output'].as_table)

        self.views.addTab(MplSpectraView(self), 'View')

        # Start matlab interface
        self.matlab = mlabwrap.init()
        #code = "addpath('%s')" % os.path.abspath( self.plugin.path )
        #r = self.matlab.run_code(code)
        #print r,"!!!!"

        # Setup data consumer options
        self.data.consumer_defs.append(
            DataDefinition(
                'input', {
                    'labels_n': ('>1', None),
                    'entities_t': (None, None),
                    'scales_t': (None, ['float']),
                }))

        self.config.set_defaults({
            'bin_size': 0.01,
            'bin_offset': 0,
        })
    def __init__(self, **kwargs):
        super(PLSToolboxApp, self).__init__(**kwargs)

        self.addDataToolBar()
        self.addFigureToolBar()

        self.data.add_input('input')  # Add input slot
        self.data.add_output('output')
        self.table.setModel(self.data.o['output'].as_table)

        self.views.addTab(MplSpectraView(self), 'View')

        # Start matlab interface
        self.matlab = mlabwrap.init()
        #code = "addpath('%s')" % os.path.abspath( self.plugin.path )
        #r = self.matlab.run_code(code)
        #print r,"!!!!"

        # Setup data consumer options
        self.data.consumer_defs.append(
            DataDefinition('input', {
            'labels_n': ('>1', None),
            'entities_t': (None, None),
            'scales_t': (None, ['float']),
            })
        )

        self.config.set_defaults({
            'bin_size': 0.01,
            'bin_offset': 0,
        })
Exemple #4
0
    def __init__(self, **kwargs):
        super(MATLABTool, self).__init__(**kwargs)

        self.addDataToolBar()
        self.addFigureToolBar()

        self.data.add_input('input')  # Add input slot
        self.data.add_output('output')
        self.table.setModel(self.data.o['output'].as_table)

        self.views.addTab(MplSpectraView(self), 'View')

        # Start matlab interface
        self.matlab = mlabwrap.init()

        # Setup data consumer options
        self.data.consumer_defs.append(
            DataDefinition(
                'input', {
                    'labels_n': ('>1', None),
                    'entities_t': (None, None),
                    'scales_t': (None, ['float']),
                }))

        self.config.set_defaults({
            'bin_size': 0.01,
            'bin_offset': 0,
        })
Exemple #5
0
    def __init__(self, **kwargs):
        super(MATLABScriptTool, self).__init__(**kwargs)

        self.addDataToolBar()
        self.addCodeEditorToolbar()

        self.data.add_input('input')  # Add input slot
        self.data.add_output('output')  # Add output slot
        # We need an input filter for this type; accepting *anything*
        self.data.consumer_defs.append(DataDefinition('input', {}))

        self.config.set_defaults({
            'source':
            '''
% %%%%% MATLAB Scripting for Pathomx %%%%
% 
% Source data from input ports is available as same-named variables in the MATLAB
% workspace (default input). The data matrix is therefore available under input.data
% Put your modified data output into the variable output.
% For more information on the Pathomx Dataset object structure see:
% http://docs.pathomx.org/en/latest/
%
% Have fun!
'''
        })

        self.editor = ui.CodeEditor()
        self.config.add_handler('source', self.editor)
        highlighter = MATLABHighlighter(self.editor.document())
        self.views.addView(self.editor, 'Editor')

        self.matlab = mlabwrap.init()

        self.finalise()
Exemple #6
0
    def __init__(self, **kwargs):
        super(MATLABScriptTool, self).__init__(**kwargs)

        self.addDataToolBar()
        self.addCodeEditorToolbar()

        self.data.add_input('input')  # Add input slot
        self.data.add_output('output')  # Add output slot
        # We need an input filter for this type; accepting *anything*
        self.data.consumer_defs.append(
            DataDefinition('input', {
            })
        )

        self.config.set_defaults({
            'source': '''
% %%%%% MATLAB Scripting for Pathomx %%%%
% 
% Source data from input ports is available as same-named variables in the MATLAB
% workspace (default input). The data matrix is therefore available under input.data
% Put your modified data output into the variable output.
% For more information on the Pathomx Dataset object structure see:
% http://docs.pathomx.org/en/latest/
%
% Have fun!
'''
        })

        self.editor = ui.CodeEditor()
        self.config.add_handler('source', self.editor)
        highlighter = MATLABHighlighter(self.editor.document())
        self.views.addView(self.editor, 'Editor')

        self.matlab = mlabwrap.init()

        self.finalise()
 def __init__(self):
     self.mlab = mlabwrap.init()
     self.mlab._do("clear all")
     self.mlab._do("cd('{}}')".format(os.getcwd()))
     self.mlab._do('global modelPoints dataPoints x0 lb ub')
Exemple #8
0
def main():
	print 'loading...'
	# Loading mlabwrap to enable matlab usage
	global mlab
	mlab = mlabwrap.init()

	global counter
	counter = 0
	l = ['/Applications/Sublime\ Text\ 2.app', '/Applications/Spotify.app', '/Applications/Safari.app', '/Applications/Keynote.app', 'www.youtube.com', 'www.facebook.com']
	actor = Actor([], l)
	
	#### Pu_Ro_Jay features ####

	initialF = loadGroundTruth(['pu_ro_jay'])
	instructF = loadGroundTruth(['open', 'kill', 'gotoWeb', 'switchDesktop', 'switchTabWindow', 'facebookPost', 'musicControl'])
	apps = ['sublime', 'spotify', 'safari', 'keynote', 'youtube', 'facebook']
	appsF = loadGroundTruth(apps)
	paras = ['playpause', 'prevtrack', 'nexttrack', 'volumedown', 'volumeup', 'mute','left', 'right']
	parasF = loadGroundTruth(paras)
	
	con = Condition()
	Recorder(con, CHUNK, FORMAT, CHANNELS, RATE, CHUNK_BUFFER_SIZE).start()
	# signal.signal(signal.SIGINT, signal_handler_SIGINT)

	time.sleep(5)

	tmpData = []

	play=pyaudio.PyAudio()
	stream_play = play.open(format=FORMAT, channels=CHANNELS, rate=RATE, output=True)
	print "* Start playing"
	data = ""
	# counter = 0
	frame = []
	dists = [10000, 10000]

	DETECTING_FLAG = 0
	INSTRUCT_FLAG = 0
	SECOND_FLAG = 0
	buff = []

	while(1):
		
		
		data = read_from_recorder(con, 1)

		if tmpData != data:
			print counter
			counter += 1
			f1 = getFeatures(data, play)

			# write2wav(data, 'wavFile/tmp' + str(counter) + '_.wav', play)
			
			if DETECTING_FLAG == False:
				DETECTING_FLAG = True
				# f1 = getFeatures(data, play)
				tmpDist = getDistances(f1, initialF[0][1])[0]
				dists.pop(0)
				dists.append(tmpDist)
				print tmpDist

				if sum(dists) < 180:
					print "DETECTING!!"
					DETECTING_FLAG = True
					#counter = STOP_POINT + 1
					#break 

			elif INSTRUCT_FLAG == False:
				tmpDists = getAllDistances(f1, instructF)
				newList = sorted(tmpDists, key = lambda t: t[1])
				for tup in newList:
					print tup[0], tup[1]
				m = min(tmpDists, key = lambda t: t[1])
				if m[1] < 93:
					### instruction name ###
					INSTRUCT_FLAG = True
					buff.append(m[0])
					print m[0]
					# ['open', 'kill', 'gotoWeb', 'switchDesktop', 'switchTabWindow', 'facebookPost', 'musicControl']
					if m[0] == 'open' or m[0] == 'kill':
						os.system('say what')
					elif m[0] == 'gotoWeb' or m[0] == 'switchTabWindow' or m[0] == 'switchDesktop':
						os.system('say 哪邊')
					elif m[0] == 'musicControl':
						os.system('say 請說')
					# counter = STOP_POINT + 1
					# break
					if m[0] == 'facebookPost':
						os.system('say okay')
						doAction(actor, apps, paras, buff)
						buff = []
						DETECTING_FLAG = False
						INSTRUCT_FLAG = False
					
				
			else:
				print "PARA"
				tmpDists = []
				if buff[0] == 'open' or buff[0] == 'kill' or buff[0] == 'gotoWeb':
					tmpDists = getAllDistances(f1, appsF)
				else:
					tmpDists = getAllDistances(f1, parasF)
				newList = sorted(tmpDists, key = lambda t: t[1])
				for tup in newList:
					print tup[0], tup[1]
				m = min(tmpDists, key = lambda t: t[1])
				if m[1] < 93:
					buff.append(m[0])
					print m[0]
					os.system('say okay')
					doAction(actor, apps, paras, buff)
					buff = []
					DETECTING_FLAG = False
					INSTRUCT_FLAG = False
				
			tmpData = data

			if counter > STOP_POINT:
				break
		
	stream_play.stop_stream()
	stream_play.close()