<jupyter_start><jupyter_text>Create list of files in TB_perfect folders from our training, validation and v4 high confidnece (99%) CNN sorted dataset<jupyter_code>exp_var = "137_20190805_SUN2quant_rerpCGH_v1"
date_var = 20190817
time_var = "1145"
#### make this a drop down box ####
MOCK_confidece_list = [99,90]
TB_confidence_list = [99,90]

MOCK_files = []
for conf in MOCK_confidece_list:
    MOCK_files_single_folder = os.listdir(f'{PATH}\\CNNpredictions_{date_var}_{time_var}\\{conf}confidence\\MOCK')
    print(f'Loading {len(MOCK_files_single_folder)} files for MOCK {conf}confidence')
    MOCK_files = MOCK_files + MOCK_files_single_folder
print(f'Loaded {len(MOCK_files)} files total for TB')

TB_files = []
for conf in TB_confidence_list:
    TB_files_single_folder = os.listdir(f'{PATH}\\CNNpredictions_{date_var}_{time_var}\\{conf}confidence\\TB_perfect')
    print(f'Loading {len(TB_files_single_folder)} files for TB {conf}confidence')
    TB_files = TB_files + TB_files_single_folder
print(f'Loaded {len(TB_files)} files total for TB')

#convert these lists to a dataframe
df_TB_ID = pd.DataFrame({'Unique_ID':TB_files})
df_MOCK_ID = pd.DataFrame({'Unique_ID':MOCK_files})

#strip "_RGB.jpg" from filename to match UNIQUE ID
df_TB_ID['Unique_ID'].replace(regex=True,inplace=True,to_replace='_RGB.jpg',value='')
df_MOCK_ID['Unique_ID'].replace(regex=True,inplace=True,to_replace='_RGB.jpg',value='')

#filter mock for only in mock sample (there are obviously some uninfected cells in the TB infected samples)
df_MOCK_ID = df_MOCK_ID[df_MOCK_ID['Unique_ID'].str.contains('MOCK')]
print(df_MOCK_ID.shape)
#filter TB for only in TB sample (just in case)
df_TB_ID = df_TB_ID[df_TB_ID['Unique_ID'].str.contains('_96hpi_')]
print(df_TB_ID.shape)

# IMPORT DATAFRAME WHERE WE CREATED THE IDs and COORDS FOR THIS DATASET
df_coords = pd.read_csv(f'{exp_var}_IDsandCoords.csv')
#df_FULL = pd.read_csv("117_20181023_SUN2_v4_IDsandCoords_FULL.csv") #create a FULL version of the dataframe in the Generate IDs and coords notebook

# Merge coords with lists from CNN sorting for TB
df_TB_CNNsorted99_coords = df_coords.merge(df_TB_ID, left_on='Unique_ID', right_on='Unique_ID', how='right')
df_MOCK_CNNsorted99_coords = df_coords.merge(df_MOCK_ID, left_on='Unique_ID', right_on='Unique_ID', how='right')
#df_TB_CNNsorted99_FULL = df_FULL.merge(df_TB_ID, left_on='Unique_ID', right_on='Unique_ID', how='right')
#df_MOCK_CNNsorted99_FULL = df_FULL.merge(df_MOCK_ID, left_on='Unique_ID', right_on='Unique_ID', how='right')
#now we need to generate the x1,y1 and x2,y2 coords for the MOCK nuclei
#set the length of the linescan to be performed
linescan_len = 1000 # lenght in pixels
radius_len = linescan_len/2

df_merge_OUTPUT = df_MOCK_CNNsorted99_coords

#get the orientation of the minor axis in radians
df_merge_OUTPUT['NUC_orientation_radians'] = (df_merge_OUTPUT[('AreaShape_Orientation')]+90).apply(np.radians)

#calculate the coordinates of points (x1,y1), (x2,y2) drawing a 300 pixel line along the minor axis and passing through the center of the nucleus 
df_merge_OUTPUT['NUC_x1'] = df_merge_OUTPUT['NUC_x0'] + df_merge_OUTPUT['NUC_orientation_radians'].apply(np.cos).multiply(radius_len)
df_merge_OUTPUT['NUC_y1'] = df_merge_OUTPUT['NUC_y0'] + df_merge_OUTPUT['NUC_orientation_radians'].apply(np.sin).multiply(radius_len)
df_merge_OUTPUT['NUC_x2'] = df_merge_OUTPUT['NUC_x0'] - df_merge_OUTPUT['NUC_orientation_radians'].apply(np.cos).multiply(radius_len)
df_merge_OUTPUT['NUC_y2'] = df_merge_OUTPUT['NUC_y0'] - df_merge_OUTPUT['NUC_orientation_radians'].apply(np.sin).multiply(radius_len)

df_MOCK_CNNsorted99_coords = df_merge_OUTPUT
df_MOCK_CNNsorted99_coords.head()
#Now because imageJ needs these broken up into individual smaller CSV files to run efficiently
split_number =25
base_filename_for_csvs = f'{exp_var}_MOCK_99conf_sorted_IDandCOORDS_overfolder'
os.mkdir(f'{PATH}\\CNNpredictions_{date_var}_{time_var}\\_csvfolderMOCK')
os.mkdir(f'{PATH}\\CNNpredictions_{date_var}_{time_var}\\_profileMOCK')
for g, df in df_MOCK_CNNsorted99_coords.groupby(np.arange(len(df_MOCK_CNNsorted99_coords)) // split_number):
    #print(df.shape)  #can get rid of this line
    df.name = g #can get rid of this line
    #print(df.name) #can get rid of this line
    name = f'{PATH}\\CNNpredictions_{date_var}_{time_var}\\_csvfolderMOCK\\{base_filename_for_csvs}_{str(g)}.csv'
    df.to_csv(name, index=False)<jupyter_output><empty_output><jupyter_text>input = getDirectory("Choose an input Directory");output = getDirectory("Choose an output Directory");setBatchMode(true);list = getFileList(input);for (k = 0; k < list.length; k++)        {			print(list[k]);			allText = File.openAsString(input + "/" + list[k]);			//print(allText)			//tmp = split(fileName,".");			// get file format {txt, csv}			//posix = tmp[lengthOf(tmp)-1];			// parse text by lines			text = split(allText, "\n");						run("Clear Results"); 			// define array for points			var x1points = newArray;			var y1points = newArray;			var x2points = newArray;			var y2points = newArray;			var C1url = newArray;			var C2url = newArray;			var C3url = newArray;			var C4url = newArray;			var ImageID = newArray;			//define colums to collect data from			hdr = split(text[0]);			iImageID=0;			// 1			// 2			iC1 = 3;			iC2 = 4;			iC3 = 5;			//iC4 = 6;			// 7			// 8			// 9			// 10			iX1=10;			iY1=11;			iX2=12;			iY2=13;			// loading and parsing each line			for (i = 1; i < (text.length); i++)			{			   line = split(text[i],",");			   setOption("ExpandableArrays", true);   			   x1points[i-1] = parseInt(line[iX1]);			   y1points[i-1] = parseInt(line[iY1]);			   x2points[i-1] = parseInt(line[iX2]);			   y2points[i-1] = parseInt(line[iY2]);			   C1url[i-1] = line[iC1];			   C2url[i-1] = line[iC2];			   C3url[i-1] = line[iC3];			   //C4url[i-1] = line[iC4];			   			   ImageID[i-1] = line[iImageID];			   open(C1url[i-1]);			   makeLine(x1points[i-1],y1points[i-1],x2points[i-1],y2points[i-1]);			   Roi.setStrokeWidth(150);			   profile = getProfile();			   for (j=0; j<profile.length; j++)			   		setResult(ImageID[i-1] + "_C1", j, profile[j]); 			   updateResults;			   close("*");			   			   open(C2url[i-1]);			   makeLine(x1points[i-1],y1points[i-1],x2points[i-1],y2points[i-1]);			   Roi.setStrokeWidth(150);			   profile = getProfile();			   for (j=0; j<profile.length; j++)			   		setResult(ImageID[i-1] + "_C2", j, profile[j]); 			   updateResults;			   close("*");			   open(C3url[i-1]);			   makeLine(x1points[i-1],y1points[i-1],x2points[i-1],y2points[i-1]);			   Roi.setStrokeWidth(150);			   profile = getProfile();			   for (j=0; j<profile.length; j++)			   		setResult(ImageID[i-1] + "_C3", j, profile[j]); 			   updateResults;			   close("*");			   			   //open(C4url[i-1]);			   //makeLine(x1points[i-1],y1points[i-1],x2points[i-1],y2points[i-1]);			   //Roi.setStrokeWidth(150);			   //profile = getProfile();			   //for (j=0; j<profile.length; j++)			   //		setResult(ImageID[i-1] + "_C4", j, profile[j]); 			   //updateResults;			   //close("*");			}			// Save as spreadsheet compatible text file //could just use home and take the data from there 			path = output + "/profile_" + list[k];			saveAs("Results", path);        	        }<jupyter_code>import pandas as pd
import glob

path = f'{PATH}\\CNNpredictions_{date_var}_{time_var}\\_profileMOCK' # use your path
all_files = glob.glob(path + "/*.csv")

li = []

for filename in all_files:
    df = pd.read_csv(filename, na_values=0, index_col=None, header=0)
    df.drop(df.columns[0], axis=1, inplace=True)
    li.append(df)

concat_df_MOCK = pd.concat(li, axis=1)
print(concat_df_MOCK.shape)
concat_df_MOCK.head()
biorep_li = ["repC","repG","repH"]

for biorep_val in biorep_li:
    print(f'{biorep_val} contrains {concat_df_MOCK.filter(like=biorep_val, axis=1).shape[1]/3:.0f} nuclei') 
    concat_df_MOCK.filter(like=biorep_val, axis=1).to_csv(f'{PATH}\\CNNpredictions_{date_var}_{time_var}\\{exp_var}_RawLinescans_MOCK_{biorep_val}_only.csv', index=False)   
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
from ipywidgets import interact, interactive, fixed, interact_manual
import ipywidgets as widgets
%matplotlib inline

df_linescan_MOCK_500 = concat_df_MOCK

df_linescan_MOCK_500_C1 = df_linescan_MOCK_500.filter(regex='C1')
df_linescan_MOCK_500_C2 = df_linescan_MOCK_500.filter(regex='C2')
df_linescan_MOCK_500_C3 = df_linescan_MOCK_500.filter(regex='C3')


titles = ['gB', 'DAPI', 'SUN2']

figure, ax = plt.subplots(ncols=4, nrows=2, figsize=(15,7)) #sharex=True, sharey=True)

ax[0,0].set(title=titles[0])
ax[0,0].plot(df_linescan_MOCK_500_C1) 
ax[1,0].plot(df_linescan_MOCK_500_C1.mean(axis=1),'k-')

MOCK_C1_error_high = df_linescan_MOCK_500_C1.mean(axis=1) + df_linescan_MOCK_500_C1.std(axis=1)
MOCK_C1_error_low = df_linescan_MOCK_500_C1.mean(axis=1) - df_linescan_MOCK_500_C1.std(axis=1)
N=list(df_linescan_MOCK_500_C1.index)
ax[1,0].fill_between(N,MOCK_C1_error_high,MOCK_C1_error_low)

ax[0,1].set(title=titles[1])
ax[0,1].plot(df_linescan_MOCK_500_C2) 
ax[1,1].plot(df_linescan_MOCK_500_C2.mean(axis=1),'k-')
MOCK_C2_error_high = df_linescan_MOCK_500_C2.mean(axis=1) + df_linescan_MOCK_500_C2.std(axis=1)
MOCK_C2_error_low = df_linescan_MOCK_500_C2.mean(axis=1) - df_linescan_MOCK_500_C2.std(axis=1)
N=list(df_linescan_MOCK_500_C2.index)
ax[1,1].fill_between(N,MOCK_C2_error_high,MOCK_C2_error_low)


ax[0,2].set(title=titles[2])
ax[0,2].plot(df_linescan_MOCK_500_C3) 
ax[1,2].plot(df_linescan_MOCK_500_C3.mean(axis=1),'k-')
MOCK_C3_error_high = df_linescan_MOCK_500_C3.mean(axis=1) + df_linescan_MOCK_500_C3.std(axis=1)
MOCK_C3_error_low = df_linescan_MOCK_500_C3.mean(axis=1) - df_linescan_MOCK_500_C3.std(axis=1)
N=list(df_linescan_MOCK_500_C3.index)
ax[1,2].fill_between(N,MOCK_C3_error_high,MOCK_C3_error_low)
ax[1,3].set_xlim(200,800)
plt.show()<jupyter_output><empty_output><jupyter_text>NOW PERFORM ON TB<jupyter_code>df_merge_OUTPUT = df_TB_CNNsorted99_coords
#get the center of the AC (AC_x0)(we will filter out for uninfected cells later)
df_merge_OUTPUT['AC_x0'] = df_merge_OUTPUT['CYTO_x0']
df_merge_OUTPUT['AC_y0'] = df_merge_OUTPUT['CYTO_y0']

#calculate the AC to NUC orientation in radians 
df_TB_CNNsorted99_coords["AC_to_NUC_orientation_radians"] =  np.arctan2((df_merge_OUTPUT['AC_y0'] - df_merge_OUTPUT['NUC_y0']),(df_merge_OUTPUT['AC_x0'] - df_merge_OUTPUT['NUC_x0']))
df_merge_OUTPUT.loc[df_merge_OUTPUT["AC_to_NUC_orientation_radians"]<0, ["AC_to_NUC_orientation_radians"]] = 2*np.pi+ df_merge_OUTPUT["AC_to_NUC_orientation_radians"]
#df_merge_OUTPUT["AC_to_NUC_orientation_radians"]
#NOTE THIS MAY SCREW UP FOR THE NEW WAY WE ARE SEGMENTING THE AC. YOU MAY HAVE TO RERUN FOR THE THINGS YOU KNOW YOU WANT TO PROCESS WITH LINESCANS
df_merge_OUTPUT["ACtoNUC_X_Midpoint"] = (df_merge_OUTPUT['NUC_x0'] + df_merge_OUTPUT['AC_x0'])/2
df_merge_OUTPUT["ACtoNUC_Y_Midpoint"] = (df_merge_OUTPUT['NUC_y0'] + df_merge_OUTPUT['AC_y0'])/2

radius_val = 1000

df_merge_OUTPUT["X_AC_fixedradius"] = df_merge_OUTPUT["ACtoNUC_X_Midpoint"] + radius_val *  np.cos(df_merge_OUTPUT['AC_to_NUC_orientation_radians'] - np.pi)
df_merge_OUTPUT["Y_AC_fixedradius"] = df_merge_OUTPUT["ACtoNUC_Y_Midpoint"] + radius_val *  np.sin(df_merge_OUTPUT['AC_to_NUC_orientation_radians'] - np.pi)

df_merge_OUTPUT["X_NUC_fixedradius"] = df_merge_OUTPUT["ACtoNUC_X_Midpoint"] + radius_val * np.cos(df_merge_OUTPUT['AC_to_NUC_orientation_radians'])
df_merge_OUTPUT["Y_NUC_fixedradius"] = df_merge_OUTPUT["ACtoNUC_Y_Midpoint"] + radius_val * np.sin(df_merge_OUTPUT['AC_to_NUC_orientation_radians'])
df_merge_OUTPUT["AC_to_NUC_orientation_degrees"] = df_merge_OUTPUT['AC_to_NUC_orientation_radians'].apply(np.degrees)
df_merge_OUTPUT.head()
df_TB_CNNsorted99_coords_NUCtoAC = df_merge_OUTPUT
df_TB_CNNsorted99_coords_NUCtoAC.shape
### now do this over folders
#Now because imageJ needs these broken up into individual smaller CSV files to run efficiently
split_number =25
base_filename_for_csvs = f'{exp_var}_TB_99conf_sorted_IDandCOORDS_overfolder'
os.mkdir(f'{PATH}\\CNNpredictions_{date_var}_{time_var}\\_csvfolderTB')
os.mkdir(f'{PATH}\\CNNpredictions_{date_var}_{time_var}\\_profilesTB')
for g, df in df_TB_CNNsorted99_coords_NUCtoAC.groupby(np.arange(len(df_TB_CNNsorted99_coords_NUCtoAC)) // split_number):
    #print(df.shape)  #can get rid of this line
    df.name = g #can get rid of this line
    #print(df.name) #can get rid of this line
    name = f'{PATH}\\CNNpredictions_{date_var}_{time_var}\\_csvfolderTB\\{base_filename_for_csvs}_{str(g)}.csv'
    df.to_csv(name, index=False)<jupyter_output><empty_output><jupyter_text>input = getDirectory("Choose an input Directory");output = getDirectory("Choose an output Directory");setBatchMode(true);list = getFileList(input);for (k = 0; k < list.length; k++)        {			print(list[k]);			allText = File.openAsString(input + "/" + list[k]);			//print(allText)			//tmp = split(fileName,".");			// get file format {txt, csv}			//posix = tmp[lengthOf(tmp)-1];			// parse text by lines			text = split(allText, "\n");						run("Clear Results"); 			// define array for points			var x1points = newArray;			var y1points = newArray;			var x2points = newArray;			var y2points = newArray;			var C1url = newArray;			var C2url = newArray;			var C3url = newArray;			var C4url = newArray;			var ImageID = newArray;			//define colums to collect data from			hdr = split(text[0]);			iImageID=0;			// 1			// 2			iC1 = 3;			iC2 = 4;			iC3 = 5;			//iC4 = 6;			// 7			// 8			//9-14			iX1=14;			iY1=15;			iX2=16;			iY2=17;			// loading and parsing each line			for (i = 1; i < (text.length); i++)			{			   line = split(text[i],",");			   setOption("ExpandableArrays", true);   			   x1points[i-1] = parseInt(line[iX1]);			   y1points[i-1] = parseInt(line[iY1]);			   x2points[i-1] = parseInt(line[iX2]);			   y2points[i-1] = parseInt(line[iY2]);			   C1url[i-1] = line[iC1];			   C2url[i-1] = line[iC2];			   C3url[i-1] = line[iC3];			   //C4url[i-1] = line[iC4];			   			   ImageID[i-1] = line[iImageID];			   open(C1url[i-1]);			   makeLine(x1points[i-1],y1points[i-1],x2points[i-1],y2points[i-1]);			   Roi.setStrokeWidth(150);			   profile = getProfile();			   for (j=0; j<profile.length; j++)			   		setResult(ImageID[i-1] + "_C1", j, profile[j]); 			   updateResults;			   close("*");			   			   open(C2url[i-1]);			   makeLine(x1points[i-1],y1points[i-1],x2points[i-1],y2points[i-1]);			   Roi.setStrokeWidth(150);			   profile = getProfile();			   for (j=0; j<profile.length; j++)			   		setResult(ImageID[i-1] + "_C2", j, profile[j]); 			   updateResults;			   close("*");			   open(C3url[i-1]);			   makeLine(x1points[i-1],y1points[i-1],x2points[i-1],y2points[i-1]);			   Roi.setStrokeWidth(150);			   profile = getProfile();			   for (j=0; j<profile.length; j++)			   		setResult(ImageID[i-1] + "_C3", j, profile[j]); 			   updateResults;			   close("*");			   			   //open(C4url[i-1]);			   //makeLine(x1points[i-1],y1points[i-1],x2points[i-1],y2points[i-1]);			   //Roi.setStrokeWidth(150);			   //profile = getProfile();			   //for (j=0; j<profile.length; j++)			   //		setResult(ImageID[i-1] + "_C4", j, profile[j]); 			   //updateResults;			   //close("*");			}			// Save as spreadsheet compatible text file //could just use home and take the data from there 			path = output + "/profile_" + list[k];			saveAs("Results", path);        	        }<jupyter_code>import pandas as pd
import glob

path = f'{PATH}\\CNNpredictions_{date_var}_{time_var}\\_profilesTB' # use your path
all_files = glob.glob(path + "/*.csv")

li = []

for filename in all_files:
    df = pd.read_csv(filename, na_values=0, index_col=None, header=0)
    df.drop(df.columns[0], axis=1, inplace=True)
    li.append(df)

concat_df_TB = pd.concat(li, axis=1)
concat_df_TB.shape
concat_df_TB.head()
biorep_li = ["repC","repG","repH"]

for biorep_val in biorep_li:
    print(f'{biorep_val} contrains {concat_df_TB.filter(like=biorep_val, axis=1).shape[1]/3:.0f} nuclei') 
    concat_df_TB.filter(like=biorep_val, axis=1).to_csv(f'{PATH}\\CNNpredictions_{date_var}_{time_var}\\{exp_var}_RawLinescans_TB_{biorep_val}_only.csv', index=False)   
#these are the results for the random Mock 500 sample
df_linescan_TB= concat_df_TB
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
from ipywidgets import interact, interactive, fixed, interact_manual
import ipywidgets as widgets
%matplotlib inline

df_linescan_TB_C1 = df_linescan_TB.filter(regex='C1')
df_linescan_TB_C2 = df_linescan_TB.filter(regex='C2')
df_linescan_TB_C3 = df_linescan_TB.filter(regex='C3')

figure, ax = plt.subplots(ncols=4, nrows=2, figsize=(15,7), sharex=True) #, sharey=True)

ax[0,0].set(title="gB")
#ax[0,0].plot(df_linescan_TB_C1) 
ax[1,0].plot(df_linescan_TB_C1.mean(axis=1),'k-')

TB_C1_error_high = df_linescan_TB_C1.mean(axis=1) + df_linescan_TB_C1.std(axis=1)
TB_C1_error_low = df_linescan_TB_C1.mean(axis=1) - df_linescan_TB_C1.std(axis=1)
N=list(df_linescan_TB_C1.index)
ax[1,0].fill_between(N,TB_C1_error_high,TB_C1_error_low)

ax[0,1].set(title="Hoechst")
#ax[0,1].plot(df_linescan_TB_C2) 
ax[1,1].plot(df_linescan_TB_C2.mean(axis=1),'k-')
TB_C2_error_high = df_linescan_TB_C2.mean(axis=1) + df_linescan_TB_C2.std(axis=1)
TB_C2_error_low = df_linescan_TB_C2.mean(axis=1) - df_linescan_TB_C2.std(axis=1)
N=list(df_linescan_TB_C2.index)
ax[1,1].fill_between(N,TB_C2_error_high,TB_C2_error_low)

ax[0,2].set(title="SUN2")
ax[0,2].plot(df_linescan_TB_C3) 
ax[1,2].plot(df_linescan_TB_C3.mean(axis=1),'k-')
ax[0,2].set_ylim(0,10000)
TB_C3_error_high = df_linescan_TB_C3.mean(axis=1) + df_linescan_TB_C3.std(axis=1)
TB_C3_error_low = df_linescan_TB_C3.mean(axis=1) - df_linescan_TB_C3.std(axis=1)
N=list(df_linescan_TB_C3.index)
ax[1,2].fill_between(N,TB_C3_error_high,TB_C3_error_low)
ax[1,2].set_xlim(700,1300)
#ax[1,2].set_ylim(0,3000)

midpoint = 954
span = (400/26)*10

ax[1,2].axvline(x=midpoint, dashes=[6,6], linewidth=1,color='k')
ax[1,2].axvline(x=midpoint-span, dashes=[6,6], linewidth=1,color='k')
ax[1,2].axvline(x=midpoint+span, dashes=[6,6], linewidth=1,color='k')
ax[1,2].axvspan((midpoint-span), midpoint, alpha=0.05, color='orange')
ax[1,2].axvspan(midpoint,(midpoint+span), alpha=0.05, color='green')

plt.show()
def merge_MOCK_TB(df_MOCK, df_TB):
    df_FINAL = pd.concat([df_MOCK, df_TB], axis=1)
    print(df_MOCK.shape)
    print(df_TB.shape)
    print(df_FINAL.shape)
    return df_FINAL
df_FINAL = merge_MOCK_TB(concat_df_MOCK,concat_df_TB)
def getMEAN_SEM_UPPER_LOWER(df):
    df_T = df.T
    df_T["biorep"] = df_T.index.str.split('_').str[2]
    df_T["timepoint"] = df_T.index.str.split('_').str[3]
    df_T["channel"] = df_T.index.str.split('_').str[6]
    df_T.set_index(["biorep", "timepoint","channel"], inplace=True)
    df_tec_mean = df_T.groupby(["biorep","channel", "timepoint"]).mean()
    df_bio_mean = df_tec_mean.groupby(["channel", "timepoint"]).mean()
    df_bio_sem = df_tec_mean.groupby(["channel", "timepoint"]).std()/np.sqrt(3)
    df_upper = df_bio_mean + df_bio_sem
    df_lower = df_bio_mean - df_bio_sem
    return df_bio_mean, df_upper, df_lower
df_bio_mean, df_upper, df_lower = getMEAN_SEM_UPPER_LOWER(df_FINAL)
df_bio_mean.head()
def multi_chan(df_bio_mean,df_upper,df_lower):

    for channel_ID, channel_name in channel_dict.items():
        f = plt.figure()   
        ax = f.add_subplot(111)
        ax.plot(df_bio_mean.loc[(channel_ID,"96hpi")],'k-',label='_nolegend_')
        N=list(df_bio_mean.loc[(channel_ID,"96hpi")].index)
        ax.fill_between(N,df_upper.loc[(channel_ID,"96hpi")],df_lower.loc[(channel_ID,"96hpi")],label=f"TB-{channel_name}", alpha=0.5)
        ax.plot(df_bio_mean.loc[(channel_ID,"MOCK")],'k-',label='_nolegend_')
        N=list(df_bio_mean.loc[(channel_ID,"MOCK")].index)
        ax.fill_between(N,df_upper.loc[(channel_ID,"MOCK")],df_lower.loc[(channel_ID,"MOCK")],label=f"MOCK-{channel_name}", alpha=0.5)
        plt.legend()
        plt.show()
#multi_chan(df_bio_mean,df_upper,df_lower)
from matplotlib.ticker import FuncFormatter

def multi_chan_shifted(df_bio_mean,df_upper,df_lower,shift_val):
    MOCK_x_values = np.linspace(shift_val, (shift_val+2001), 2001)
    print(MOCK_x_values)
    for channel_ID, channel_name in channel_dict.items():
        f = plt.figure()   
        ax = f.add_subplot(111)
        
        increment = 1
        ticks_at = 5
        start_val = 12
        shift_axis = 62
        end_Val = start_val + shift_axis + 20
        
        
        ax.set_xlim( ((400/26)*increment)*start_val,((400/26)*increment)*(end_Val-1))
        ax.xaxis.set_ticks(np.arange(((400/26)*increment)*start_val, ((400/26)*increment)*end_Val, (400/26)*ticks_at))
        plt.gca().xaxis.set_major_formatter(FuncFormatter(lambda x,y: '{}'.format(round((x*65)/1000,1)-shift_axis) ))
        ax.set_xlim(750,1250)
       
        #plot TB
        ax.plot(df_bio_mean.loc[(channel_ID,"96hpi")],'k-',label='_nolegend_')
        N=list(df_bio_mean.loc[(channel_ID,"96hpi")].index)
        ax.fill_between(N,df_upper.loc[(channel_ID,"96hpi")],df_lower.loc[(channel_ID,"96hpi")],label=f"{channel_name}-TB", alpha=0.5)
        
        #plot MOCK
        ax.plot(MOCK_x_values,df_bio_mean.loc[(channel_ID,"MOCK")],'k-',label='_nolegend_')
        N=list(df_bio_mean.loc[(channel_ID,"MOCK")].index)
        ax.fill_between(MOCK_x_values,df_upper.loc[(channel_ID,"MOCK")],df_lower.loc[(channel_ID,"MOCK")],label=f"{channel_name}-MOCK", alpha=0.5)
        
        ax.yaxis.tick_right()
        plt.legend()
        plt.savefig(f'{exp_var}_GRAP_{channel_name}.png', dpi=600)
        plt.show()
        
channel_dict = {
    "C1":"gB",
    "C2":"Hoechst",
    "C3":"SUN2"}

multi_chan_shifted(df_bio_mean,df_upper,df_lower,465)<jupyter_output>[ 465.      466.0005  467.001  ... 2463.999  2464.9995 2466.    ]
{'fraction_non_alphanumeric': 0.15442794279427943, 'fraction_numerical': 0.040154015401540157, 'mean_word_length': 5.171711456859971, 'pattern_counts': {'":': 3, '<': 29, '<?xml version=': 0, '>': 16, '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': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '608414', 'license': 'MIT', 'n_tokens_mistral': 9834, 'n_tokens_neox': 9064, 'n_words': 1334, 'path': 'LinescantoAnalysis.ipynb', 'repo_name': 'djproc/HCMV_cellclassificationCNN', 'size': '21816'}