示例#1
0
                all_durations.append(np.loadtxt(f)[0])
            tmpchannels = [{'type':'input', 'subdevice': inputSubdevice, 'channel':inputChannels[j], 'factor':inputGains[j],
                            'units':inputUnits[j]} for j in range(len(inputChannels))]
            tmpchannels.append({'type':'output', 'subdevice': outputSubdevice, 'channel':outputChannels[0], 'factor':outputGains[0],
                                'units':outputUnits[0], 'stimfile':f, 'offset':offsets[0], 'resetOutput': resetOutput})
            all_channels.append(tmpchannels)

    # Prepare run commands
    cmd_str = ('nice -n '+str(niceness) + ' ' +
               lcg.common.prog_name + ' -V ' + 
               str(verbose)+' -c ' + config_file)
    timerString = '\rTrial {0:d} of {1:d}'
    if dry_run:
        cmdstr = 'echo "' + cmd_str + '"'
    if (verbose != 4) or (terminalPrintMode == 'quiet'):
        runLCG = lambda string,count,total,dur: runCommand(cmd_str,mode=None)
    elif terminalPrintMode == 'progress':
        runLCG = lambda string,count,total,dur: runCommand(cmd_str,'progress',duration, 
                                                           string +' ')
    elif terminalPrintMode == 'timer':
        runLCG = lambda string,count,total,dur: runCommand(cmd_str,'timer',duration, 
                                                           string + '; elapsed time: {0:.2f}s ')
    elif terminalPrintMode == 'trial_bar':
        runLCG = lambda string,count,total,dur: runCommand(cmd_str,'trial_bar', 
                                                           count,
                                                           total,
                                                           string + ' ')        
    sys.stdout.flush()
    # Main loop
    for i in range(repetitions):
        if shuffle:
示例#2
0
        for f in stimfiles:
            all_durations.append(np.sum(np.loadtxt(f)[:,0]))
            tmpchannels = [{'type':'input', 'channel':inputChannels[j], 'factor':inputGains[j],
                            'units':inputUnits[j]} for j in range(len(inputChannels))]
            tmpchannels.append({'type':'output', 'channel':outputChannels[0], 'factor':outputGains[0],
                                'units':outputUnits[0], 'stimfile':f, 'offset':offsets[0], 'resetOutput': resetOutput})
            all_channels.append(tmpchannels)

    # Prepare run commands
    cmd_str = ('nice -n '+str(niceness) + ' ' +
               lcg.common.prog_name + ' -V ' + 
               str(verbose)+' -c ' + config_file)
    timerString = '\rTrial {0:d} of {1:d}'
    if dry_run:
        cmd_str = 'echo "' + cmd_str + '"'
    runLCG = lambda string,count,total,dur: runCommand(cmd_str,mode=None)
    sys.stdout.flush()
    # Main loop
    for i in range(repetitions):
        for duration,channels in zip(all_durations,all_channels):
            trialStart = time.time()
            writeConfigurationFile(config_file, duration, channels) 
            runLCG(timerString.format(cnt, total), cnt, total, duration)
            sleepTime = (interval + duration - (time.time() - trialStart))
            if cnt < total and sleepTime > 0 :
                time.sleep(sleepTime)
            cnt += 1
    sys.stdout.write('\n')

if __name__ == '__main__':
    main()
示例#3
0
                'factor': outputGains[0],
                'units': outputUnits[0],
                'stimfile': f,
                'offset': offsets[0],
                'resetOutput': resetOutput
            })
            all_channels.append(tmpchannels)

    # Prepare run commands
    cmd_str = ('nice -n ' + str(niceness) + ' ' + lcg.common.prog_name +
               ' -V ' + str(verbose) + ' -c ' + config_file)
    timerString = '\rTrial {0:d} of {1:d}'
    if dry_run:
        cmdstr = 'echo "' + cmd_str + '"'
    if (verbose != 4) or (terminalPrintMode == 'quiet'):
        runLCG = lambda string, count, total, dur: runCommand(cmd_str,
                                                              mode=None)
    elif terminalPrintMode == 'progress':
        runLCG = lambda string, count, total, dur: runCommand(
            cmd_str, 'progress', duration, string + ' ')
    elif terminalPrintMode == 'timer':
        runLCG = lambda string, count, total, dur: runCommand(
            cmd_str, 'timer', duration, string + '; elapsed time: {0:.2f}s ')
    elif terminalPrintMode == 'trial_bar':
        runLCG = lambda string, count, total, dur: runCommand(
            cmd_str, 'trial_bar', count, total, string + ' ')
    sys.stdout.flush()
    # Main loop
    for i in range(repetitions):
        if shuffle:
            idx = range(len(stimfiles))
            random.shuffle(idx)
示例#4
0
    if len(inputUnits) == 0:
        inputUnits = [os.environ['AI_UNITS_' + suffix] for i in range(len(inputChannels))]

    if (len(inputChannels) != len(inputGains)) or (len(inputChannels) != len(inputUnits)):
        print('The number of input channels, input gains and input units must be the same.')
        sys.exit(1)

    if duration is None:
        print('You must specify the duration of the recording (-d switch).')
        sys.exit(1)

    lcg.writeIOConfigurationFile(configFile,samplingRate,duration,
                                 [{'type':'input', 'channel':inputChannels[i], 'factor':inputGains[i], 'units':inputUnits[i]}
                                  for i in range(len(inputChannels))],realtime=realtime)
    sys.stdout.write('\n')
    sys.stdout.flush()
    for i in range(repetitions):
        runCommand(lcg.common.prog_name + ' -c ' + 
                   configFile + ' -V ' + str(verbose),'timer',duration,
                   '\rElapsed time (trial ' + str(i+1) + ' of ' + str(repetitions) + ' ): {0:.2f}s ')
        if i < repetitions-1:
            sub.call('sleep ' + str(interval), shell=True)
        
    sys.stdout.write('\rRan ' + str(i+1) + ' repetitions (%d time(s) %.2f s).' % (i+1,duration))
    sys.stdout.flush()
    sys.stdout.write('\n')

if __name__ == '__main__':
    main()