In [1]:
from pyoperant.local import PANELS
import time

In [2]:
PANELS.keys()


Out[2]:
['1', '3', '2', '4', '7', '6', '8']

In [3]:
box_num = 1
box = PANELS['%d' % (box_num)]()
box.test()


reset
output <pyoperant.hwio.BooleanOutput object at 0x7f899004f410> on
output <pyoperant.hwio.BooleanOutput object at 0x7f899004f410> off
output <pyoperant.hwio.BooleanOutput object at 0x7f89a402be10> on
output <pyoperant.hwio.BooleanOutput object at 0x7f89a402be10> off
output <pyoperant.hwio.BooleanOutput object at 0x7f899004f450> on
output <pyoperant.hwio.BooleanOutput object at 0x7f899004f450> off
output <pyoperant.hwio.BooleanOutput object at 0x7f899004f490> on
output <pyoperant.hwio.BooleanOutput object at 0x7f899004f490> off
output <pyoperant.hwio.BooleanOutput object at 0x7f899004f4d0> on
output <pyoperant.hwio.BooleanOutput object at 0x7f899004f4d0> off
output <pyoperant.hwio.BooleanOutput object at 0x7f899004f510> on
output <pyoperant.hwio.BooleanOutput object at 0x7f899004f510> off
output <pyoperant.hwio.BooleanOutput object at 0x7f899004f550> on
output <pyoperant.hwio.BooleanOutput object at 0x7f899004f550> off
output <pyoperant.hwio.BooleanOutput object at 0x7f899004f590> on
output <pyoperant.hwio.BooleanOutput object at 0x7f899004f590> off
reset
feed
timeout
queue file
---------------------------------------------------------------------------
IOError                                   Traceback (most recent call last)
<ipython-input-3-4ca2e8ef2281> in <module>()
      1 box_num = 1
      2 box = PANELS['%d' % (box_num)]()
----> 3 box.test()

/local/home/bird/Code/pyoperant/pyoperant/local_vogel.pyc in test(self)
     75         self.punish(value=dur)
     76         print ('queue file')
---> 77         self.speaker.queue('/usr/local/stimuli/A1.wav')
     78         print ('play file')
     79         self.speaker.play()

/local/home/bird/Code/pyoperant/pyoperant/hwio.pyc in queue(self, wav_filename)
    107 
    108     def queue(self,wav_filename):
--> 109         return self.interface._queue_wav(wav_filename)
    110 
    111     def play(self):

/local/home/bird/Code/pyoperant/pyoperant/interfaces/pyaudio_.pyc in _queue_wav(self, wav_file, start, callback)
     73 
     74     def _queue_wav(self,wav_file,start=False,callback=None):
---> 75         self.wf = wave.open(wav_file)
     76         self.validate()
     77         self._get_stream(start=start,callback=callback)

/home/bird/anaconda2/lib/python2.7/wave.pyc in open(f, mode)
    509             mode = 'rb'
    510     if mode in ('r', 'rb'):
--> 511         return Wave_read(f)
    512     elif mode in ('w', 'wb'):
    513         return Wave_write(f)

/home/bird/anaconda2/lib/python2.7/wave.pyc in __init__(self, f)
    158         self._i_opened_the_file = None
    159         if isinstance(f, basestring):
--> 160             f = __builtin__.open(f, 'rb')
    161             self._i_opened_the_file = f
    162         # else, assume it is an open file object already

IOError: [Errno 2] No such file or directory: '/usr/local/stimuli/A1.wav'

In [23]:
box.house_light.off()


Out[23]:
True

In [22]:
box.reset()

In [70]:
box.speaker.queue('/home/bird/2sec_noise_65dbmean_48kHz.wav')
box.speaker.play()

In [71]:
box.speaker.stop()

In [37]:
box.speaker.interface._stop_wav()

In [13]:
# box_num += 1
box_num = 7
print box_num
box = PANELS['Zog%d' % (box_num)]()

try:
    box.reset()
except:
    pass
else:
    print 'reset complete'
# box.test()


7
reset complete

In [14]:
box.house_light.off()


Out[14]:
True

In [12]:
from pyoperant.components import RGBLight

In [13]:
cue_light = RGBLight(red=box.outputs[7],
                     green=box.outputs[5],
                     blue=box.outputs[6]
                     )

In [19]:
cue_light._red.write(False)


Out[19]:
True

In [2]:
box_num = 11
print box_num
box = PANELS['Zog%d' % (box_num)]()

try:
    box.reset()
except:
    pass
box.speaker.queue('/home/bird/opdat/B982/stims/triples_abd_48kHz.wavv.wav')
box.speaker.play()
time.sleep(1.0)
box.speaker.stop()


---------------------------------------------------------------------------
InterfaceError                            Traceback (most recent call last)
<ipython-input-2-349d0df9cac2> in <module>()
      7 except:
      8     pass
----> 9 box.speaker.queue('/home/bird/2sec_noise_65dbmean.wav')
     10 box.speaker.play()
     11 time.sleep(1.0)

/local/home/bird/Code/pyoperant/pyoperant/hwio.pyc in queue(self, wav_filename)
     93 
     94     def queue(self,wav_filename):
---> 95         return self.interface._queue_wav(wav_filename)
     96 
     97     def play(self):

/local/home/bird/Code/pyoperant/pyoperant/interfaces/pyaudio_.pyc in _queue_wav(self, wav_file, start)
     81     def _queue_wav(self,wav_file,start=False):
     82         self.wf = wave.open(wav_file)
---> 83         self.validate()
     84         self._get_stream(start=start)
     85 

/local/home/bird/Code/pyoperant/pyoperant/local_zog.pyc in validate(self)
     34             return True
     35         else:
---> 36             raise InterfaceError('this wav file must be 48kHz')
     37 
     38 

InterfaceError: this wav file must be 48kHz
11

In [11]:
box_num = 0

In [23]:
box_num = 3
print box_num
box = PANELS['Zog%d' % (box_num)]()

# try:
#     box.reset()
# except:
#     pass
# box.speaker.queue('/home/bird/Desktop/test48k.wav')
box.speaker.queue('/home/bird/2sec_noise_65dbmean.wav')
box.speaker.play()
time.sleep(2.0)
box.speaker.stop()


---------------------------------------------------------------------------
IOError                                   Traceback (most recent call last)
<ipython-input-23-d8f05400579d> in <module>()
      8 #     pass
      9 # box.speaker.queue('/home/bird/Desktop/test48k.wav')
---> 10 box.speaker.queue('/home/bird/2sec_noise_65dbmean.wav')
     11 box.speaker.play()
     12 time.sleep(2.0)

/local/home/bird/Code/pyoperant/pyoperant/hwio.pyc in queue(self, wav_filename)
     93 
     94     def queue(self,wav_filename):
---> 95         return self.interface._queue_wav(wav_filename)
     96 
     97     def play(self):

/local/home/bird/Code/pyoperant/pyoperant/interfaces/pyaudio_.pyc in _queue_wav(self, wav_file, start)
     55     def _queue_wav(self,wav_file,start=False):
     56         self._wf = wave.open(wav_file)
---> 57         self._get_stream(start=start)
     58 
     59     def _play_wav(self):

/local/home/bird/Code/pyoperant/pyoperant/interfaces/pyaudio_.pyc in _get_stream(self, start)
     51                                    output_device_index=self.device_index,
     52                                    start=start,
---> 53                                    stream_callback=_callback)
     54 
     55     def _queue_wav(self,wav_file,start=False):

/usr/local/anaconda/lib/python2.7/site-packages/pyaudio.pyc in open(self, *args, **kwargs)
    745         """
    746 
--> 747         stream = Stream(self, *args, **kwargs)
    748         self._streams.add(stream)
    749         return stream

/usr/local/anaconda/lib/python2.7/site-packages/pyaudio.pyc in __init__(self, PA_manager, rate, channels, format, input, output, input_device_index, output_device_index, frames_per_buffer, start, input_host_api_specific_stream_info, output_host_api_specific_stream_info, stream_callback)
    440 
    441         # calling pa.open returns a stream object
--> 442         self._stream = pa.open(**arguments)
    443 
    444         self._input_latency = self._stream.inputLatency

IOError: [Errno Device unavailable] -9985
3
Box 3 is very quiet Box 10, 14 are very loud Box 15 doesn't work

In [10]:
for ii in box.inputs:
    print ii.read()


False
False
False
False

In [21]:
for oo in box.outputs:
    print oo.write(False)


True
True
True
True
True

In [27]:
for ii in box_1.inputs:
    print ii.read()


False
False
False
False

In [29]:
iface = box.interfaces['comedi']

In [3]:
box = PANELS['Zog6']()
box.reset()
box.test()

In [36]:
box.reward()


Out[36]:
(datetime.datetime(2014, 10, 2, 16, 16, 30, 716416),
 datetime.timedelta(0, 2, 2327))

In [ ]: