import numpy as np
import scipy
from thllib import util
import scipy.signal
import sys

FLYNUM = int(sys.argv[1])# tested with 1393
RESAMPLE_RATE = 2000 #hz
TAU_ON = 0.01595905
TAU_OFF = 0.23594343
KERNEL_GAIN = 0.4
SNR = 1.0
DEFALULT_ISI = 0.005 #s
MAX_ISI_TIME = 0.02

fly = flb.NetFly(FLYNUM,rootpath='/media/imager/FlyDataD/FlyDB/')
fly.open_signals()

def condition_signal(sig_name,signal):
    """do some data cleaning on the signals.
    For instnace the transients from b2 are week
    so I need to detrend in order to remove the
    contaminating baseline"""
    if sig_name == 'b2':
        return signal - scipy.signal.medfilt(signal,501)
    if sig_name == 'iii1':
        return signal - scipy.signal.medfilt(signal,501)
    if sig_name == 'hg1':
        return signal - scipy.signal.medfilt(signal,501)
    return signal
Example #2
0
import sys
import os
import numpy as np
from matplotlib import pyplot as plt
import neo
from neo import AxonIO
from cv_bridge import CvBridge, CvBridgeError
from thllib import flylib as flb
import rosbag

fly = flb.NetFly(1525)

abfreader = AxonIO(fly.abfpaths[0])
abffile = abfreader.read()
block = abffile[0]
segment = block.segments[0]
analogsignals = segment.analogsignals
times = np.array(analogsignals[0].times)

signal_idxs = {
    'abf_electrode': 0,
    'abf_wba_left_amp': 1,
    'abf_wba_right_amp': 2,
    'abf_sync': 3,
    'abf_freq': 4,
    'abf_left_hutchen': 5,
    'abf_right_hutchen': 6,
    'abf_led_pulse': 7,
    'abf_kinefly_lmr': 8,
    'abf_kinefly_left': 9,
    'abf_kinefly_right': 10,
Example #3
0
import sys
from matplotlib import pyplot as plt
from scipy import ndimage

#%matplotlib inline
#from matplotlib import pyplot as plt

flynum = int(sys.argv[1])  #1351

samp_range = 5000  # search over this range to find center point of image
search_bound = 50  # window to search for center of fly in pxls
crop = 100  #crop fly around this window
img_thresh = 240  #threshold to find the center of rotation of the fly.
cent_fun = np.mean  #function to use when looking for the image center

fly = flylib.NetFly(flynum)
bag_file_name = fly.flypath + '/' + [
    bf for bf in os.listdir(fly.flypath) if '.bag' in bf
][0]
inbag = rosbag.Bag(bag_file_name)
topics = inbag.get_type_and_topic_info()[1].keys()

if os.path.exists(fly.flypath + '/' + 'images.hdf5'):
    os.remove(fly.flypath + '/' + 'images.hdf5')
if os.path.exists(fly.flypath + '/' + 'times.hdf5'):
    os.remove(fly.flypath + '/' + 'times.hdf5')
if os.path.exists(fly.flypath + '/' + 'avepxl.hdf5'):
    os.remove(fly.flypath + '/' + 'avepxl.hdf5')

images = h5py.File(fly.flypath + '/' + 'images.hdf5')
times = h5py.File(fly.flypath + '/' + 'times.hdf5')
Example #4
0
#! /usr/bin/python2

from matplotlib import animation
import numpy as np
from matplotlib import pyplot as plt
from thllib import flylib as flb
import figurefirst as fifi
import sys

reload(fifi)
flynum = int(sys.argv[1])  #1344
fly = flb.NetFly(flynum)
fly.open_signals(['hdf5', 'txt'])
position = fly.position
velocity = fly.velocity

### make the condition blocks
#blocks = fly.order
#block_times = list()
#t = 0
#for b in blocks:
#    block_times.append(t)
#    if b == 'flicker_static\n':
#        t+=10
#    else:
#        t+=30


### function to return the correct condition for a given time
def get_cond(t, blocks, block_times):
    return np.array(blocks)[np.argwhere(