<jupyter_start><jupyter_text>import libraries<jupyter_code>import pandas as pd
import numpy as np
import seaborn as sns
import matplotlib as mpl
import matplotlib.pyplot as plt

from statsmodels.stats.anova import anova_lm
from statsmodels.formula.api import ols
import statsmodels.api as sm
import statsmodels.formula.api as smf

%matplotlib inline<jupyter_output><empty_output><jupyter_text>set path<jupyter_code>data_dir = '/Users/alexbarnett/Documents/Community_detection/hippo_nets/'<jupyter_output><empty_output><jupyter_text>load data<jupyter_code>#pathlength_data = pd.read_excel(data_dir+'pathlength_data.xlsx')
pathlength_data = pd.read_excel(data_dir+'pathlength_data_all.xlsx')
pathlength_data_hipp = pd.read_excel(data_dir+'pathlength_data_all_hipp.xlsx')
## remove redundant networks fewer than 10 regions
pathlength_data_select =pathlength_data[pathlength_data['Removed_Network']!='SAL2']
pathlength_data_select = pathlength_data_select[pathlength_data_select['Removed_Network']!='DAN1']
## remove redundant networks fewer than 10 regions
pathlength_data_hipp_select =pathlength_data_hipp[pathlength_data_hipp['Removed_Network']!='SAL2']
pathlength_data_hipp_select = pathlength_data_hipp_select[pathlength_data_hipp_select['Removed_Network']!='DAN1']
pathlength_data_select['Removed_Network']=pathlength_data_select['Removed_Network']<jupyter_output><empty_output><jupyter_text>plot pathlength after network deletion<jupyter_code>plt.figure(figsize=(6,6))
sns.set(font_scale=2)
sns.set_style("white")

labels = ['SM','SAL','DAN','LANG','FP','AUD','MTN','Control']
colors = ["#00FFFF","#A300A3","#00FF00","#009C9A","#FFFF00","#FF00FF","#34A853","#808080"];
figure_one = sns.boxplot(x = "Removed_Network_number", y = "Path_Length",
                                data = pathlength_data_select, linewidth=1.5,palette=colors,
                         fliersize=0,boxprops=dict(alpha=.75))
sns.stripplot(x = "Removed_Network_number", y = "Path_Length", data = pathlength_data_select, edgecolor="black",
              linewidth=1.5,size=5,alpha = .5,jitter = 0.1,dodge=True, palette = colors)
sns.despine()

figure_one.set(xlabel="\nRemoved Network", ylabel="Path Length from\n DMN to VIS")
figure_one.set_xticklabels(labels,rotation=90)
#figure_one.set_ylim(5,7.75)

fig = figure_one.get_figure()
fig.tight_layout(h_pad = 0)
fig.savefig(data_dir+"pathlength_fig.pdf",dpi=300)
md = smf.mixedlm("Path_Length ~ Removed_Network", pathlength_data_select, groups=pathlength_data_select["subj"])

mdf = md.fit()

print(mdf.summary())

options = ['Spatial Control','MTL']


md = smf.mixedlm("Path_Length ~ Removed_Network", pathlength_data.loc[pathlength_data['Removed_Network'].isin(options)], groups=pathlength_data.loc[pathlength_data['Removed_Network'].isin(options)]["subj"])

mdf = md.fit()

print(mdf.summary())

plt.figure(figsize=(6,6))
sns.set(font_scale=2)
sns.set_style("white")

labels = ['SM','SAL','DAN','LANG','FP','AUD','DMN','MTN','Control']
colors = ["#00FFFF","#A300A3","#00FF00","#009C9A","#FFFF00","#FF00FF","#ff0000","#34A853","#808080"];
figure_one = sns.boxplot(x = "Removed_Network", y = "Path_Length",
                                data = pathlength_data_hipp_select, linewidth=1.5,
                         fliersize=0,boxprops=dict(alpha=.75),palette=colors)
sns.stripplot(x = "Removed_Network", y = "Path_Length", data = pathlength_data_hipp_select, edgecolor="black",
              linewidth=1.5,size=5,alpha = .5,jitter = 0.1,dodge=True,palette=colors)
sns.despine()

figure_one.set(xlabel="\nRemoved Network", ylabel="Path Length from\n hipp to VIS")
figure_one.set_xticklabels(labels,rotation=90)
#figure_one.set_ylim(5,7.75)

fig = figure_one.get_figure()
fig.tight_layout(h_pad = 0)
fig.savefig(data_dir+"pathlength_fig_hippo.pdf",dpi=300)
options = ['Spatial Control','MTL']


md = smf.mixedlm("Path_Length ~ Removed_Network", pathlength_data_hipp.loc[pathlength_data_hipp['Removed_Network'].isin(options)], groups=pathlength_data_hipp.loc[pathlength_data_hipp['Removed_Network'].isin(options)]["subj"])

mdf = md.fit()

print(mdf.summary())<jupyter_output>Mixed Linear Model Regression Results
=============================================================================
Model:                    MixedLM       Dependent Variable:       Path_Length
No. Observations:         80            Method:                   REML       
No. Groups:               40            Scale:                    0.0535     
Min. group size:          2             Log-Likelihood:           -63.0017   
Max. group size:          2             Converged:                Yes        
Mean group size:          2.0                                                
-----------------------------------------------------------------------------
                                   Coef.  Std.Err.   z    P>|z| [0.025 0.975]
-----------------------------------------------------------------------------
Intercept                           6.724    0.132 50.915 0.000  6.466  6.983
Removed_Network[T.Spatial Control] -0.364    0.052 -7.039 0.000 -0.465 -0.263
Group [...]
{'fraction_non_alphanumeric': 0.1775811209439528, 'fraction_numerical': 0.03815142576204523, 'mean_word_length': 3.8026440037771483, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '416671', 'license': 'MIT', 'n_tokens_mistral': 1855, 'n_tokens_neox': 1712, 'n_words': 246, 'path': 'path_length_analysis.ipynb', 'repo_name': 'ajbarn/hippo_nets', 'size': '5085'}