<jupyter_start><jupyter_text>Goal Classify Infection, Sterile inflammation and<jupyter_code># Import Modules as needed
%matplotlib inline 
import numpy as np
from mylocal_functions import *
import matplotlib.pyplot as plt
import seaborn as sns<jupyter_output><empty_output><jupyter_text>1. Create list of files and allocate variables needed for analysis<jupyter_code>#List
CEST_list=get_ipython().getoutput('ls ../Study_03_CBA/*CEST.txt')
# Columns for DataFrame
col_names=['A1','W1','C1','A2','W2','C2','A3','W3','C3','scaling_factor']
# Rows for Tissue type
#Tissue_names=["Infected","Healthy R","Sterile Infl.","Healthy L"]
Tissue_names=["Yes","No","No","No"]
# Saturation Offsets
ppm=np.linspace(-8,8,101);  
# Data Frames
CEST_fit=pd.DataFrame()<jupyter_output><empty_output><jupyter_text>2. Create Data Frame and scale it<jupyter_code>M=np.zeros([1,4])
pars=np.zeros([4,10])
lsq=np.zeros([4,1])

for i in range( len(CEST_list) ):
    D=txt_2_array(CEST_list[i]);       #Convert txt file to array
    Zn=normalize_data(D.T,8);          Zn=Zn[:,9::]

    for j in range(4):
        Y=Zn[j,:]
        R=fit_L3_scale(ppm,Y); p=R['Parameters']
        L=Lscale3(ppm,p[0],p[1],p[2],p[3],p[4],p[5],p[6],p[7],p[8],p[9]);
        pars[j,:]=p.T
        lsq[j,0]=  R['RSQ']
    # data frame for current mouse
    df=pd.DataFrame(pars,columns=col_names)
    df["RSQ"]=lsq    
    df["Infected"]=Tissue_names 
    
    # append to final dataframe
    CEST_fit=CEST_fit.append(df, ignore_index=True)
        
CEST_fit.head(1)
from sklearn.preprocessing import MaxAbsScaler
#import MinMaxScaler
scaler = MaxAbsScaler()
CEST_fit[['A1','W1','C1','A2','W2','C2','A3','W3','C3','scaling_factor']] = scaler.fit_transform(CEST_fit[['A1','W1','C1','A2','W2','C2','A3','W3','C3','scaling_factor']])    

df=CEST_fit[["A1",'A2','A3','W1','W2','W3','Infected']]
sns.pairplot(df, hue="Infected")
sns.swarmplot(x="measurement", y="value", hue="Infected",split=True, data=pd.melt(df, "Infected", var_name="measurement"))

ax = sns.violinplot(x='Infected',y="A2",data=CEST_fit)
# Show the survival proability as a function of age and sex
df=CEST_fit[["A1","A2"]]
yy=np.ones((df.A1.values.shape[0],1))
yy[CEST_fit.Infected=='No']=0
df["Inf"]=yy
sns.lmplot(x='A2', y='Inf',data=df)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.20166229221347332, 'fraction_numerical': 0.03280839895013123, 'mean_word_length': 6.377419354838709, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '119524', 'license': 'MIT', 'n_tokens_mistral': 991, 'n_tokens_neox': 956, 'n_words': 143, 'path': 'Infection_vs_Inflammation/Code/01-CEST_Analysis.ipynb', 'repo_name': 'CardenasLabUA/Machine-Learning-4-MRI', 'size': '2286'}