import random import math import stimulus #m: no. of stimuli m = int(random.uniform(1, 3)) img = loadImage("cry.jpg") D = 600 stim = list() for i in range(m): #stim.append(stimulus.stimulus(img, random.uniform(0,2*D), random.uniform(0,D), random.uniform(0,20), random.uniform(0,20))) stim.append(stimulus.stimulus(img, 600, 300, 0, 0)) class vehicle(object): # The Constructor is defined with arguments. def __init__(self, xpos, ypos, L, B, l, b): #self.c = c self.xpos = xpos self.ypos = ypos self.L = L self.B = B self.l = l self.b = b # def rotates(self,x,y,cosine,sine): # return x*cosine-y*sine,x*sine+y*cosine def display(self): stroke(0) c = color(int(255 * (1 - math.exp(-self.total_activation()))))
import random import math import stimulus #m: no. of stimuli m = int(random.uniform(1, 5)) img = loadImage("cry.jpg") D = 600 stim = list() for i in range(m): stim.append( stimulus.stimulus(img, random.uniform(0, 2 * D), random.uniform(0, D), random.uniform(0, 5), random.uniform(0, 5))) #stim.append(stimulus.stimulus(img, 600, 300, 0, 0)) class vehicle(object): # The Constructor is defined with arguments. def __init__(self, xpos, ypos, L, B, l, b): # self.c = c self.xpos = xpos self.ypos = ypos self.L = L self.B = B self.l = l self.b = b # def rotates(self,x,y,cosine,sine): # return x*cosine-y*sine,x*sine+y*cosine def display(self):
img = loadImage("/home/ankit/Desktop/BV_Project/stimulus_data/cry.jpg") flag = input( "\n\n\nPress 1 for single fixed stimuli, \nPress 2 for multiple moving stimuli,\nPress 3 for multiple fixed stimuli. \n\n" ) if (flag == 2 or flag == 3): num = input("\nMaximum no. of stimulus allowed: ") elif (flag == 1): num = 1 m = int(random.uniform(1, num + 1)) # number of stimuli in the environment stim = list() # creating an array of stimulus for i in range(m): if (flag == 1): stim.append(stimulus.stimulus(img, 600, 300, 0, 0)) elif (flag == 2): stim.append( stimulus.stimulus(img, random.uniform(0, 2 * D), random.uniform(0, D), random.uniform(0, 10), random.uniform(0, 10))) elif (flag == 3): stim.append( stimulus.stimulus(img, random.uniform(0, 2 * D), random.uniform(0, D), 0, 0)) n = int(random.uniform(1, 1000)) # number of vehciles in the environment objs = list() # creating an array of vehicles for i in range(n): objs.append( vehicle.vehicle(random.uniform(0, 2 * D), random.uniform(0, D), d,
import random import math import stimulus #m: no. of stimuli m = int(random.uniform(1,3)) img = loadImage("cry.jpg") D = 600 stim = list() for i in range(m): stim.append(stimulus.stimulus(img, random.uniform(0,2*D), random.uniform(0,D), random.uniform(0,20), random.uniform(0,20))) #stim.append(stimulus(img, 600, 300, 0, 0)) class vehicle(object): # The Constructor is defined with arguments. def __init__(self, xpos, ypos, L, B, l, b): #self.c = c self.xpos = xpos self.ypos = ypos self.L = L self.B = B self.l = l self.b = b # def rotates(self,x,y,cosine,sine): # return x*cosine-y*sine,x*sine+y*cosine def display(self): stroke(0)
def draw(): global cp5 global start global stim global objs global n global d if (frameCount == 1): background('#004477') fill(126) rect(.9 * width, 500, 80, 20) fill(0) textSize(16) text(" Run", .9 * width, 516) cp5 = ControlP5(this) nAgent = cp5.addSlider("Agents") nAgent.setPosition(.9 * width, 400).setSize(80, 20).setRange( 1, 1000).setValue(400).setNumberOfTickMarks(1000).setSliderMode( Slider.FLEXIBLE) scale = cp5.addSlider("scale") scale.setPosition(.9 * width, 450).setSize(80, 20).setRange( 1, 10).setValue(2).setNumberOfTickMarks(10).setSliderMode( Slider.FLEXIBLE) l = "zero", "one", "two", "three", "four", "five", "six", "seven" option = "Fixed", "Moving" cp5.addScrollableList("Opt for Stimuli Motion").setPosition( .9 * width, 5).setSize(100, 50).setBarHeight(10).setItemHeight(10).addItems(option) cp5.addScrollableList("2a stimulus population").setPosition( .9 * width, 100).setSize(100, 80).setBarHeight(10).setItemHeight(10).addItems(l) cp5.addScrollableList("2b stimulus population").setPosition( .9 * width, 200).setSize(100, 80).setBarHeight(10).setItemHeight(10).addItems(l) cp5.addScrollableList("3a stimulus population").setPosition( .9 * width, 300).setSize(100, 80).setBarHeight(10).setItemHeight(10).addItems(l) cp5.get(ScrollableList, "2a stimulus population").setType(ControlP5.LIST) cp5.get(ScrollableList, "2b stimulus population").setType(ControlP5.LIST) cp5.get(ScrollableList, "3a stimulus population").setType(ControlP5.LIST) cp5.get(ScrollableList, "Opt for Stimuli Motion").setType(ControlP5.LIST) if mousePressed and ( mouseButton == LEFT) and mouseX > .9 * width and mouseX < ( .9 * width + 80) and mouseY > 500 and mouseY < 520: stim = list() # creating an array of stimulus flag = int(cp5.getController("Opt for Stimuli Motion").getValue()) n2a = int(cp5.getController("2a stimulus population").getValue()) n2b = int(cp5.getController("2b stimulus population").getValue()) n3a = int(cp5.getController("3a stimulus population").getValue()) n = int(cp5.getController("Agents").getValue()) for i in range(n2a): if (flag == 1): stim.append( stimulus.stimulus(img1, '2a', random.uniform(0, .9 * width), random.uniform(0, D), random.uniform(0, 10), random.uniform(0, 10))) elif (flag == 0): stim.append( stimulus.stimulus(img1, '2a', random.uniform(0, .9 * width), random.uniform(0, D), 0, 0)) for i in range(n2b): if (flag == 1): stim.append( stimulus.stimulus(img2, '2b', random.uniform(0, .9 * width), random.uniform(0, D), random.uniform(0, 3), random.uniform(0, 3))) elif (flag == 0): stim.append( stimulus.stimulus(img2, '2b', random.uniform(0, .9 * width), random.uniform(0, D), 0, 0)) for i in range(n3a): if (flag == 1): stim.append( stimulus.stimulus(img3, '3a', random.uniform(0, .9 * width), random.uniform(0, D), random.uniform(0, 3), random.uniform(0, 3))) elif (flag == 0): stim.append( stimulus.stimulus(img3, '3a', random.uniform(0, .9 * width), random.uniform(0, D), 0, 0)) objs = list() # creating an array of vehicles d = int(cp5.getController( "scale").getValue()) # accessing vehicle scale parameter for i in range(n): alpha = 2 * math.pi * random.uniform(0, 1) objs.append( vehicle.vehicle(random.uniform(0, .9 * width), random.uniform(0, D), d, stim, alpha)) start = 1 if (start == 1): background(0, 100, 100) # background of environment fill(126) rect(.9 * width, 0, .1 * width, height) fill(255) rect(.9 * width, 500, 80, 20) fill(0) textSize(16) text("Run Again", .9 * width, 516) textSize(12) text("Stimulus Provocations", .9 * width + 2, 545) text("2a: Cowardness", .9 * width + 5, 565) text("2b: Aggression", .9 * width + 5, 580) text("3a: Love", .9 * width + 5, 595) for i in range(len(stim)): # processing display and movement of stimulus stim[i].display() stim[i].move() for i in range(n): # processing display and movement of stimulus objs[i].move() objs[i].display()
sd.check_output_settings() print(sd.query_devices()) print("Default input and output device: ", sd.default.device) print("Sucessfully selected audio devices. Ready to record.") parse._defaults(args) elif args.test == True: deltapeak = stim.test_deconvolution(args) plt.plot(deltapeak) plt.show() else: # Create a test signal object, and generate the excitation testStimulus = stim.stimulus('sinesweep', args.fs) testStimulus.generate(args.fs, args.duration, args.amplitude, args.reps, args.startsilence, args.endsilence, args.sweeprange) # Record recorded = utils.record(testStimulus.signal, args.fs, args.inputChannelMap, args.outputChannelMap) # Deconvolve RIR = testStimulus.deconvolve(recorded) # Truncate lenRIR = 1.2 startId = testStimulus.signal.shape[0] - args.endsilence * args.fs - 1 endId = startId + int(lenRIR * args.fs)
img = img1, img2, img3 flag = input( "\n\n\nPress 1 to generate moving stimuli,\nPress 2 to generate fixed stimuli. \n\n" ) num = input("\nMaximum no. of each type of stimulus allowed: ") m = num # number of each type of stimuli in the environment print "number of each type of stimuli in the environment = ", m stim = list() # creating an array of stimulus for i in range(m): if (flag == 1): stim.append( stimulus.stimulus(img1, '2a', random.uniform(0, 2 * D), random.uniform(0, D), random.uniform(0, 3), random.uniform(0, 3))) stim.append( stimulus.stimulus(img2, '2b', random.uniform(0, 2 * D), random.uniform(0, D), random.uniform(0, 3), random.uniform(0, 3))) stim.append( stimulus.stimulus(img3, '3a', random.uniform(0, 2 * D), random.uniform(0, D), random.uniform(0, 3), random.uniform(0, 3))) elif (flag == 2): stim.append( stimulus.stimulus(img1, '2a', random.uniform(0, 2 * D), random.uniform(0, D), 0, 0)) stim.append( stimulus.stimulus(img2, '2b', random.uniform(0, 2 * D),