def channelPulseOn(self, device,channelNo):

	    # make sure the channelNo is valid

        if channelNo < 0 or channelNo > len(BIOPAC_CHANNELS):

            raise ValueError('Invalid channel number passed to the LabJackBIC channelOff method: $i' %(channelNo))

		# based on which device is being used, determine the channel number to pass to the driver

        channel = None

        if device == BIOPAC_DEVICE_ID:

            channel = BIOPAC_CHANNELS[channelNo]

        elif device == EYETRACKER_DEVICE_ID:

            channel = EYETRACKER_CHANNELS[channelNo]

        elif device == DIGITIMER_DEVICE_ID:

            channel = DIGITIMER_CHANNELS[channelNo]

        else:

            raise ValueError('Invalid Device ID passed to the LabJackBIC channelOff method: %i' %(device))

		# set the given channel to the On state

        self.sendMsg(u6.BitStateWrite(IONumber=channel, State=ON_STATE))

        time.sleep(0.5)

        self.sendMsg(u6.BitStateWrite(IONumber=channel, State=OFF_STATE))
Exemplo n.º 2
0
def acquireStack(cam, nFrames, downscaleTuple, animal, outdir):
    """   Get an image stack from the camera.
     Args:
        cam: (TIS_CAM) initialized camera object
        nFrames: (int) number of frames to acquire
        sendCounter (bool) whether or not to send strobe signal
        downscaleTuple: (tuple) downscale factor in (z, x, y), e.g. (1, 2, 2) for 2x downscale
        animal: (str) animal ID, used for output naming
        outdir: (str) path to output directory

    Returns:
        stack: (np.ndarray) image stack in (z, x, y)
    """
    # setup the labjack
    dioPortNum = 0  # FIO0
    u6Obj = u6.U6()
    u6Obj.configU6()
    u6Obj.configIO()
    u6Obj.setDOState(dioPortNum, state=0)

    stack = []

    cam.StartLive(1)
    # Not using 191001: strobe code below.
    # if sendCounter:
    #     _set_and_check(cam.SetPropertyValue, 'GPIO', 'GP Out', 1)
    #     _set_and_check(cam.PropertyOnePush, 'GPIO', 'Write')
    t_start = time.time()
    for iF in np.arange(nFrames):
        pulseLengthTicks = int(1000/64)
        u6Obj.getFeedback(u6.BitDirWrite(dioPortNum, 1),
                          u6.BitStateWrite(dioPortNum, State=1),
                          u6.WaitShort(pulseLengthTicks),
                          u6.BitStateWrite(dioPortNum, State=0))
        cam.SnapImage()
        im = cam.GetImage()  # appears to have three identical(?) frames
        im = np.mean(im, axis=2).astype('int16')
        stack.append(im)  # averaging to one frame

    # Not using 191001: strobe code below.
    # if sendCounter:
    #     _set_and_check(cam.SetPropertyValue, 'GPIO', 'GP Out', 0)
    #     _set_and_check(cam.PropertyOnePush, 'GPIO', 'Write')

    cam.StopLive()

    print('Done. Downsizing and saving.')
    stack = np.r_[stack]
    stack = transform.downscale_local_mean(stack, downscaleTuple)
    stack = stack.astype('int16')

    timeStr = time.strftime("_%y%m%d_%H-%M-%S", time.localtime(t_start))
    outfile = os.path.join(outdir, '{}{}.tif'.format(animal, timeStr))
    tfl.imsave(outfile, stack)
    nFrames = stack.shape[0]

    print('Saved {} frames to {}'.format(nFrames, outfile))

    return stack
Exemplo n.º 3
0
 def pulse_led_task(self):
     """LED Should be off before this is called."""
     if ( (self.pulse_led) & (self.backLED) ):
         LJ.getFeedback(u6.BitStateWrite(3,1))
         self.inject.send_command("led 1") 
         time.sleep(LED_PULSE_TIME)   
         LJ.getFeedback(u6.BitStateWrite(3,0))
         self.inject.send_command("led 0") 
Exemplo n.º 4
0
 def cmd_backLED(self, the_command):
     '''Command to control IR LED backfeed.'''
     commands = str.split(the_command)
     if len(commands) != 2: return 'ERROR'
     if commands[1] == 'on':
         LJ.getFeedback(u6.BitStateWrite(3,1))
         self.backLED=True
         return 'backLED on'
     elif commands[1] == 'off':
         LJ.getFeedback(u6.BitStateWrite(3,0))
         self.backLED=False
         return 'backLED off'
     else: return 'ERROR'
    def clearChannels(self, device):

		# based on which device is being used, determine the channel number to pass to the driver

        channels = None

        if device == BIOPAC_DEVICE_ID:

            channels = BIOPAC_CHANNELS

        elif device == EYETRACKER_DEVICE_ID:

            channels = EYETRACKER_CHANNELS

        elif device == DIGITIMER_DEVICE_ID:

            channels = DIGITIMER_CHANNELS

        else:

            raise ValueError('Invalid Device ID passed to the LabJackBIC clearChannels method: %i' %(device))



		# set the given channel to the On state

        for channel in channels:

            #self.jack.getFeedback(u6.BitStateWrite(IONumber=channel, State=OFF_STATE))

            self.sendMsg(u6.BitStateWrite(IONumber=channel, State=OFF_STATE))
Exemplo n.º 6
0
 def writeBitState(self, pinNum, state):
     """
     Name: EI1050.writeBitState(pinNum, state)
     Desc: Device independent way to write bit state
     """
     
     if self.deviceType == EI1050.U3: self.device.getFeedback(u3.BitStateWrite(pinNum,state))
     elif self.deviceType == EI1050.U6: self.device.getFeedback(u6.BitStateWrite(pinNum,state))
     elif self.deviceType == EI1050.UE9: self.device.singleIO(1, pinNum, Dir=1, State=state)
Exemplo n.º 7
0
 def ToggleOn(self, relay, name):
     if relay['key'].startswith('E'):
         IONumber = int(relay['key'][3:])+8
     elif relay['key'].startswith('C'):
         IONumber = int(relay['key'][3:])+16
     else:
         IONumber = int(relay['key'][3:])
     if not self.DevFlag:
         self.LJ.getFeedback(u6.BitDirWrite(int(IONumber), 1))
         self.LJ.getFeedback(u6.BitStateWrite(int(IONumber), 0))
     relay['status'] = 'On'
Exemplo n.º 8
0
    dummy=indi.set_and_send_text("SX CCD SXVR-H694","CCD_COOLER","COOLER_OFF","Off")
#   Default binning is 1x1. Not need to set this as it is a CCD default.
#    dummy=indi.set_and_send_float("SX CCD SXVR-H694","CCD_BINNING","VER_BIN",2)
    if not os.path.exists('./images/'):
        dummy=subprocess.call('mkdir ./images', shell=True)
    dummy=indi.set_and_send_text("SX CCD SXVR-H694","UPLOAD_SETTINGS","UPLOAD_DIR","images")
    dummy=indi.set_and_send_text("SX CCD SXVR-H694","UPLOAD_SETTINGS","UPLOAD_PREFIX","TEMPIMAGE")
    
try:
    LJ=u6.U6()
    #Need to set up fancy DAC here for the temperature control
    #LJ.configIO(NumberOfTimersEnabled = 2, EnableCounter0 = 1, TimerCounterPinOffset=8)
    #LJ.getFeedback(u3.Timer0Config(8), u3.Timer1Config(8)) #Sets up the dome tracking wheel

    #Start off with no current:
    LJ.getFeedback(u6.BitStateWrite(1,0)) #H-Bridge bit 1
    LJ.getFeedback(u6.BitStateWrite(2,0)) #H-Bridge bit 2
    LJ.getFeedback(u6.BitStateWrite(3,0)) #Back-LED Off
except Exception:
    print 'Unable to connect to the labjack.'


class Subaru():
    """As this server class controls several pieces of hardware at once, d
      defaults for this class are in blocks, in the order below... 
      
        SX CAMERA
        Labjack
        IPPower
        Micro Maestro
        
        break
    continueRoutine = False  # will revert to True if at least one component still running
    for thisComponent in IntroductionComponents:
        if hasattr(thisComponent, "status") and thisComponent.status != FINISHED:
            continueRoutine = True
            break  # at least one component has not yet finished
    
    # check for quit (the [Esc] key)
    if event.getKeys(["escape"]):
        core.quit()

    # refresh the screen
    if continueRoutine:  # don't flip if this routine is over or we'll get a blank screen
        win.flip()

    d.getFeedback(u6.BitStateWrite( 0, 1 ) ) # FI00 (0), i.e. START RECORD Trigger
    core.wait(introDuration, hogCPUperiod=0)  # need hogCPUperiod < wait time 
                                        # from: https://groups.google.com/forum/#!topic/psychopy-dev/GcObydzJgyw

#-------Ending Routine "Introduction"-------
for thisComponent in IntroductionComponents:
    if hasattr(thisComponent, "setAutoDraw"):
        thisComponent.setAutoDraw(False)


# START THE BLOCK
CycleLoop = data.TrialHandler(nReps=noOfBlockLoops, method=u'sequential', 
    extraInfo=expInfo, originPath=None,
    trialList=[None],
    seed=None, name='CycleLoop')
Exemplo n.º 10
0
	def set_dio_state(self,channel, state):
		"""sets DIO state. 1=High, 0=Low"""
		channel = self._check_dio_channel_input(channel)
		cmd = u6.BitStateWrite(channel, state)
		self.d.getFeedback(cmd)
Exemplo n.º 11
0
#! /usr/bin/python
import u6
import time
import numpy

d           = u6.U6() # open LabJack U6

d.getCalibrationData() # get calibration info for U6
runtime=[]
for i in range(0,2):
	d.getFeedback(u6.BitDirWrite(0,1))
	d.getFeedback(u6.BitDirWrite(1,0))

	t1 = time.time()

	d.getFeedback(u6.BitStateWrite(0,1))

	#ain = d.getAIN(0)
	d.getFeedback(u6.BitStateRead(1))

	runtime.append(time.time()-t1)

print numpy.mean(runtime)