def construct_multi_fly_df(fly_nums,rootpath='/media/imager/FlyDataD/FlyDB/'): #Input: simple list of fly numbers, opt fly directory #Returns a combined dataframe with all flies flys = [flylib.NetFly(fly_num,rootpath) for fly_num in fly_nums] fly_dfs = [fly.construct_dataframe() for fly in flys] combined_df = pd.concat(fly_dfs,ignore_index=True) return combined_df
corr_window_size = 1 frames_per_step = 1 def render_svg_to_png(svg_data, filename): # Render svg = rsvg.Handle(data=svg_data) img = cairo.ImageSurface(cairo.FORMAT_ARGB32, svg.props.width, svg.props.height) ctx = cairo.Context(img) svg.render_cairo(ctx) img.write_to_png(filename) try: fly = flb.NetFly( fly_num, rootpath='/home/annie/imager/media/imager/FlyDataD/FlyDB/') except (OSError): fly = flb.NetFly(fly_num) flydf = fly.construct_dataframe() dt = frames_per_step * (flydf['t'][1] - flydf['t'][0]) corr_window_size = np.floor(corr_window_size / dt) * dt disp_window_size = np.floor(disp_window_size / dt) * dt steps_per_disp_window = int(disp_window_size / dt) steps_per_corr_window = int(corr_window_size / dt) filtered_muscle_cols = \ ['iii1_left', 'iii3_left',
from matplotlib import pyplot as plt import numpy as np import scipy import flylib as flb from flylib import util import pandas as pd fly = flb.NetFly(1538,rootpath='/home/annie/imager/media/imager/FlyDataD/FlyDB/') # fly = flb.NetFly(1538,rootpath='/home/annie/work/programming/fly_muscle_data/') flydf = fly.construct_dataframe() # flydf['ca_pixel_left'] = fly.ca_cam_left #this is really big (obvs) print(flydf.head()) print(np.unique(flydf['stimulus'])) print(flydf.columns.values) #Here is an example of how to filter for rows of a certain column value filtered_df = flydf.loc[flydf['stimulus']=='cl_blocks, g_x=-1, g_y=0, b_x=-8, b_y=0, ch=True'] print(filtered_df.head()) #Or for a combination of column values idx = (flydf['stimulus']=='cl_blocks, g_x=-1, g_y=0, b_x=-8, b_y=0, ch=True')& \ (flydf['amp_diff']>0.1) double_filtered_df = flydf.loc[idx] print(double_filtered_df.head())
import flylib as flb from matplotlib import pyplot as plt import numpy as np import scipy from flylib import util import figurefirst as fifi import scipy.signal #import local_project_functions as lpf from IPython.display import SVG, display import networkx as nx flynumbers = list(range(1389, 1390)) #flynumbers = list(range(1548,1549)) flylist = [ flb.NetFly(fnum, rootpath='/media/imager/FlyDataD/FlyDB/') for fnum in flynumbers ] l = [fly.open_signals() for fly in flylist] #fly = flylist[4] flydf = fly.construct_dataframe() #flydf_=fly.construct_dataframe() #Access calcium values for a specific muscle and specific stimulus pretrial_stripe_fix_b2_right = flydf.loc[flydf['stimulus'] == 'pretrial_stripe_fix', ['b2_right']] print(np.shape(pretrial_stripe_fix_b2_right)) #https://www.shanelynn.ie/select-pandas-dataframe-rows-and-columns-using-iloc-loc-and-ix/ #print(filtered_df[key+'_right'])
from matplotlib import pyplot as plt import numpy as np import scipy import flylib as flb from flylib import util import pandas as pd # fly = flb.NetFly(1540,rootpath='/home/annie/imager/media/imager/FlyDataD/FlyDB/') fly = flb.NetFly(1548, rootpath='/home/annie/work/programming/fly_muscle_data/') fly.open_signals() flydf = pd.DataFrame() flydf['t'] = fly.time flydf['stimulus'] = np.array(fly.experimental_block) flydf['amp_diff'] = np.array(fly.left_amp) - np.array(fly.right_amp) for (key, value) in fly.ca_cam_left_model_fits.items(): flydf[key + '_left'] = value for (key, value) in fly.ca_cam_right_model_fits.items(): flydf[key + '_right'] = value # flydf['ca_pixel_left'] = fly.ca_cam_left #this is really big (obvs) print(flydf.head()) print(np.unique(flydf['stimulus'])) print(flydf.columns.values) #Here is an example of how to filter for rows of a certain column value filtered_df = flydf.loc[flydf['stimulus'] ==
#from thllib import flylib as flb import flylib as flb from matplotlib import pyplot as plt import numpy as np import scipy from flylib import util import figurefirst as fifi import scipy.signal #import local_project_functions as lpf from IPython.display import SVG,display import networkx as nx flynumbers = list(range(1389,1402)) #flynumbers = list(range(1548,1549)) flylist = [flb.NetFly(fnum,rootpath='/media/imager/FlyDataD/FlyDB/') for fnum in flynumbers] l = [fly.open_signals() for fly in flylist] #fly = flylist[4] #fly = flylist[0] for fly in range(len(flylist)): print("%s_%s" % (fly, 'flydf')) name=("%s_%s" % (fly,'flydf')) str(value(name))=fly.construct_dataframe() #flydf_=fly.construct_dataframe() #flydf_=fly.construct_dataframe() #Access calcium values for a specific muscle and specific stimulus pretrial_stripe_fix_b2_right = flydf.loc[ flydf['stimulus']=='pretrial_stripe_fix',['b2_right']] print(np.shape(pretrial_stripe_fix_b2_right))
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 import flylib as flb import rosbag FLYNUM = %s fly = flb.NetFly(FLYNUM) 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,