Example #1
0
def animal_weights_():
	import matplotlib.pyplot as mpl
	from labbookdb.report.tracking import animal_weights, qualitative_dates
	from behaviopy.plotting import qualitative_times

	fuzzy_matching = {
			"ofM":[-14,-15,-13,-7,-8,-6],
			"ofMaF":[0,-1],
			"ofMcF1":[14,13,15],
			"ofMcF2":[28,27,29],
			"ofMpF":[45,44,46],
		}

	df = animal_weights('~/syncdata/meta.db', {'animal':['aFluIV','aFluIV_']})
	df['relative_date'] = df['relative_date'].dt.days.astype(int)
	df = df[['Animal_id', 'relative_date', 'weight', 'TreatmentProtocol_code', 'ETH/AIC']]
	df = qualitative_dates(df, fuzzy_matching=fuzzy_matching)
	qualitative_times(df, order=['ofM','ofMaF','ofMcF1','ofMcF2','ofMpF'], condition='TreatmentProtocol_code', err_style="boot_traces", time='qualitative_date')
	df = df[df['qualitative_date']=='ofMpF']
	print(df)
	mpl.show()
Example #2
0
subjectdf = full_subsets(subjectdf, 5)

from seaborn import desaturate

cmap = plt.get_cmap('tab20').colors

qualitative_times(
    subjectdf[subjectdf['treatment'] == "Vehicle"],
    x='Session',
    y='t',
    unit=None,
    condition='subject',
    palette=cmap[1::2],
    #palette=cmap_grey[::2],
    order=['naïve', 'acute', 'chronic (2w)', 'chronic (4w)', 'post'],
    bp_style=False,
    renames={
        'Session': {
            'ofM': 'naïve',
            'ofMaF': 'acute',
            'ofMcF1': 'chronic (2w)',
            'ofMcF2': 'chronic (4w)',
            'ofMpF': 'post',
        },
    },
)
qualitative_times(
    subjectdf[subjectdf['treatment'] == "Fluoxetine"],
    x='Session',
    y='t',
    unit=None,
    condition='subject',
Example #3
0
roi_coordinates = [left + 0.02, bottom + 0.7, 0.3, 0.2]

fig = plt.figure(1)

ax1 = plt.axes(session_coordinates)
qualitative_times(
    df,
    ax=ax1,
    x='Session',
    y='Mean t-Statistic',
    condition='treatment',
    unit='subject',
    ci=90,
    palette=["#56B4E9", "#E69F00"],
    order=['nave', 'acute', 'chronic (2w)', 'chronic (4w)', 'post'],
    bp_style=False,
    renames={
        'Session': {
            'ofM': 'nave',
            'ofMaF': 'acute',
            'ofMcF1': 'chronic (2w)',
            'ofMcF2': 'chronic (4w)',
            'ofMpF': 'post',
        },
    },
)

ax2 = plt.axes(roi_coordinates)
maps.atlas_label(
    "~/ni_data/templates/roi/DSURQEc_drp.nii.gz",
    scale=0.3,
Example #4
0
data_path = path.join(data_dir,'DSURQEc_drp.csv')
subjectdf = pd.read_csv(data_path)
subjectdf = full_subsets(subjectdf, 5)

cmap = plt.get_cmap('tab20').colors

qualitative_times(subjectdf[subjectdf['treatment']=="Vehicle"],
        x='Session',
        y='t',
        unit=None,
        condition='subject',
        palette=cmap[1::2],
        #palette=cmap_grey[::2],
        order=['naïve','acute','chronic (2w)','chronic (4w)','post'],
        bp_style=False,
        renames={
                'Session':{
                        'ofM':'naïve',
                        'ofMaF':'acute',
                        'ofMcF1':'chronic (2w)',
                        'ofMcF2':'chronic (4w)',
                        'ofMpF':'post',
                        },
                },
        )
qualitative_times(subjectdf[subjectdf['treatment']=="Fluoxetine"],
        x='Session',
        y='t',
        unit=None,
        condition='subject',
        palette=cmap[::2],
from labbookdb.report.tracking import treatment_group, append_external_identifiers, qualitative_dates, cage_consumption
from labbookdb.report.selection import cage_periods, cage_drinking_measurements
from behaviopy.plotting import qualitative_times

db_path = '~/.demolog/meta.db'
df = cage_drinking_measurements(db_path, ['cFluDW'])
df = cage_consumption(db_path, df)

fuzzy_matching = {
    "ofM": [-14, -15, -13, -7, -8, -6],
    "ofMaF": [0, -1],
    "ofMcF1": [14, 13, 15],
    "ofMcF2": [28, 27, 29],
    "ofMpF": [45, 44, 46, 43, 47],
}
df = qualitative_dates(
    df,
    iterator_column='Cage_id',
    date_column='relative_end_date',
    label='qualitative_date',
    fuzzy_matching=fuzzy_matching,
)
qualitative_times(df,
                  x='qualitative_date',
                  y='day_animal_consumption',
                  unit='Cage_id',
                  order=['ofM', 'ofMaF', 'ofMcF1', 'ofMcF2', 'ofMpF'],
                  condition='TreatmentProtocol_code',
                  err_style="boot_traces",
                  save_as='drinking_by_cage_treatment.png')
Example #6
0
data_path = path.join(data_dir,'DSURQEc_drs.csv')
subjectdf = pd.read_csv(data_path)
subjectdf = full_subsets(subjectdf, 5)

cmap = plt.get_cmap('tab20').colors

qualitative_times(subjectdf,
        x='Session',
        y='t',
        condition='treatment',
        unit='subject',
        ci=90,
        palette=cmap,
        order=['naïve','acute','chronic (2w)','chronic (4w)','post'],
        bp_style=False,
        renames={
                'Session':{
                        'ofM':'naïve',
                        'ofMaF':'acute',
                        'ofMcF1':'chronic (2w)',
                        'ofMcF2':'chronic (4w)',
                        'ofMpF':'post',
                        },
                },
        )
plt.savefig('drs_activity_full.pdf')

import statsmodels.formula.api as smf
import numpy as np

model = smf.mixedlm("t ~ Session * treatment", subjectdf, groups=subjectdf["subject"])
Example #7
0
data_dir = path.abspath(path.expanduser('~/ni_data/ofM.dr/bids/l1/generic'))
data_path = path.join(data_dir, 'DSURQEc_drs.csv')
subjectdf = pd.read_csv(data_path)

cmap = plt.get_cmap('tab20').colors

qualitative_times(
    subjectdf,
    x='Session',
    y='t',
    condition='treatment',
    unit='subject',
    ci=90,
    palette=cmap,
    order=['naïve', 'acute', 'chronic (2w)', 'chronic (4w)', 'post'],
    bp_style=False,
    renames={
        'Session': {
            'ofM': 'naïve',
            'ofMaF': 'acute',
            'ofMcF1': 'chronic (2w)',
            'ofMcF2': 'chronic (4w)',
            'ofMpF': 'post',
        },
    },
)
plt.savefig('drs_activity.pdf')

import statsmodels.formula.api as smf
import numpy as np

model = smf.mixedlm("t ~ Session * treatment",