# -*- coding: utf-8 -*- from objsimpy.int_mod_n import IntModuloN from random import choice import pylab from stim_sequence import StimulusSequence import numpy as np class SequenceGenerator_Gauss: def __init__(self, Nx, Ny, NRepetitions, NoJumpDuration=10, XContinuous=1, XGap=None, YGap=None, n_high_num=2): self.Nx = Nx self.Ny = Ny self.n_high_num = n_high_num self.n_low_num = 1 self.NRepetitions = NRepetitions self.NoJumpDuration = NoJumpDuration self.XContinuous = XContinuous self.X = IntModuloN(0, self.Nx) self.Y = IntModuloN(0, self.Ny) self.StimHistogram = StimHistogram(self.Nx*self.Ny) self.NoJumpHold = self.NoJumpDuration self.NStimuli = self.Nx*self.Ny self.XStimuli = range(self.Nx) self.YStimuli = range(self.Ny) self.StimulusSequence=[] self.Directions = [-1,1] self.Direction = choice(self.Directions) self.Stimuli = range(self.NStimuli) self.StimReservoirPattern = range(self.NStimuli)*self.n_high_num if not XGap is None: for i in range(self.n_high_num)[self.n_low_num:]: for y in self.YStimuli: for x in range(XGap[0],XGap[1]): self.StimReservoirPattern.remove(y*self.Nx + x) print "YGap is", YGap if not YGap is None: for i in range(self.n_high_num)[self.n_low_num:]: for stim in range(YGap[0]*self.Nx,YGap[1]*self.Nx): self.StimReservoirPattern.remove(stim) self.StimReservoir = self.StimReservoirPattern[:] self.setRandomStimulus() def setRandomStimulus(self): CurStim = choice(self.StimReservoir) self.CurX = IntModuloN(CurStim % self.Nx, self.Nx) self.CurY = IntModuloN(CurStim / self.Nx, self.Ny) if (self.XContinuous): self.X = choice(self.XStimuli) else: self.Y = choice(self.YStimuli) def generate(self): RandomJumpDurRange=range(int(0.5*self.NoJumpDuration)) #while self.StimHistogram.getMinRepetitions()