from activitytables import info_key
from activitytables import normalize, mediannorm, flipleftwards
from shuttlingplots import posturehistogram
from datapath import jumpers
from datapath import lesionshamcache, stepfeatures_key

# Load data
stable = '(3 <= session < 5)'
unstable = '(9 <= session < 11)'
nonjumpers = str.format("subject not in {0}", jumpers)
sessions = str.format("{0} or {1}", stable, unstable)
steps = pd.read_hdf(lesionshamcache, stepfeatures_key).query(nonjumpers)
info = pd.read_hdf(lesionshamcache, info_key).query(nonjumpers)

# Select data
lesioninfo = infotables.lesion(info)
lesion = str.format("subject in {0}", list(infotables.names(lesioninfo)))
control = str.format("subject in {0}", list(infotables.cagemates(lesioninfo)))
steps.xhead = flipleftwards(steps.xhead, steps.side)
normalize(steps, mediannorm, ['xhead', 'yhead'], level=['subject'])
steps = steps.query(sessions)
stepstable = steps.query(stable)
stepunstable = steps.query(unstable)

# Plot data
plt.figure()
rangex = (steps.xhead.min(), steps.xhead.max())
rangey = (steps.yhead.min(), steps.yhead.max())
axScatter = plt.subplot2grid((3, 7), (1, 0), rowspan=2, colspan=2)
axHistx = plt.subplot2grid((3, 7), (0, 0), colspan=2)
axHisty = plt.subplot2grid((3, 7), (1, 2), rowspan=2)
Ejemplo n.º 2
0
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from scipy.stats import linregress
from activitytables import flipleftwards, info_key
from shuttlingplots import speedhistogram, speedcorrelation, scatterhistaxes
from datapath import jumpers, lesionshamcache, stepfeatures_key
from infotables import names, control, lesion, smalllesion, anylesion

# Load data
stable = '(3 <= session < 5)'
unstable = '(9 <= session < 11)'
nonjumpers = str.format("subject not in {0}", jumpers)
sessions = str.format("{0} or {1}", stable, unstable)
info = pd.read_hdf(lesionshamcache, info_key)
lesions = str.format("subject in {0}", list(names(lesion(info))))
smalllesions = str.format("subject in {0}", list(names(smalllesion(info))))
alllesions = str.format("subject in {0}", list(names(anylesion(info))))
controls = str.format("subject in {0}", list(names(control(info))))
steps = pd.read_hdf(lesionshamcache, stepfeatures_key).query(nonjumpers)
steps.xhead_speed[steps.side == 'leftwards'] *= -1
steps.xhead = flipleftwards(steps.xhead, steps.side)
steps = steps.query(sessions)

# Plot functions
rangex = (steps.xhead_speed.min(), steps.xhead_speed.max())
rangey = (steps.yhead_speed.min(), steps.yhead_speed.max())


def histogramcomparison(steps, title):
    axes = scatterhistaxes()
from datapath import jumpers, lesionshamcache, stepfeatures_key
from datapath import crossingactivity_random_key, crossings_key

# Load data
nonjumpers = str.format("subject not in {0}",jumpers)
steps = pd.read_hdf(lesionshamcache,stepfeatures_key).query(nonjumpers)
cr = pd.read_hdf(lesionshamcache,crossings_key).query(nonjumpers)
cract = pd.read_hdf(lesionshamcache,crossingactivity_random_key)
cract.reset_index(['subject','session','crossing'],inplace=True)
info = pd.read_hdf(lesionshamcache, info_key).query(nonjumpers)
info = info.query("subject != 'JPAK_20'")

# Select data
group = list(names(info))
controls = list(names(control(info)))
lesions = list(names(lesion(info)))
matched = list(cagemates(lesion(info)))
small = list(names(smalllesion(info)))
selection = str.format("subject in {0}",group)
random = '(session == 13 and trial > 20) or (14 <= session < 17)'
steps = steps.query(random).query(selection)
cr = cr.query(random).query(selection)
steps = joinstepactivity(steps,cr,cract)
steps = getballistictrials(steps)

for i in range(21,22):
    offact = crossingoffset(cract,steps,i)
    offact.set_index(['subject','session'],inplace=True)
    normalizeposition(offact,inplace=True)
    stablebias,unstablebias = posturebias(offact,n=2)