print "YO"

# <codecell>

y = pca.fit_transform(s[histcols])

# <codecell>

mm, mmfits, mmpvals, mmqsum = test_all_linear(sheep, ["TawfikTotal"], imagecols, group="AgeAtDeath")

# <codecell>

df = sheep[delayer(["TawfikTotal", "Inflammation", "ResidualES"])].dropna()
df["Intercept"] = np.ones(len(df))
tt = MixedLM(endog = df.TawfikTotal, exog = df[["Inflammation"]], groups=df.ResidualES).fit()
tt.summary()
#del fibrosis.tables[2]


# <codecell>

models, fits, pvals, blah = test_all_linear(sheep, ["Ln_ap_ri"], imagecols, group="AgeAtDeath")

# <codecell>

np.where(np.array(fits["Ln_ap_ri"]) < (2 + np.min(fits["Ln_ap_ri"])))

# <codecell>

idx = 0
print models["Ln_ap_ri"][idx].summary()
d_tot_pd = pd.DataFrame(dict(Accuracy=data.reshape(-1), Inverse=dummy_inv_list,
                             Decomposition=dummy_decomp_list,
                             Subject=subj_num))

l_inverse = [inv_methods[2], inv_methods[0], inv_methods[1]]
l_decomp = decomp_methods

# Create and fit linear regression model
inter = '*' if stats_interaction else '+'
call_str = ('Accuracy ~ C(Inverse, levels=l_inverse) ' + inter +
            ' C(Decomposition, levels=l_decomp)')

y, X = patsy.dmatrices(call_str, d_tot_pd, return_type='dataframe')
model_results = MixedLM(y, X, groups=subj_num).fit()

print model_results.summary()

###############################################################################
# PLOT DATA

import matplotlib.pyplot as plt
#plt.rcParams['pdf.fonttype'] = 42  # Seems to mess up rendering of text
#plt.rcParams['ps.fonttype'] = 42
plt.rcParams['mathtext.default'] = 'regular'  # Set math font to normal

# Close all previous plots
plt.close('all')
plt.ion()

label_fontsize = 14
tickLabel_fontsize = 12