def getXY(pressure): data, config = load_all_data( rf"\\131.188.117.96\biophysDS\emirzahossein\microfluidic cell rhemeter data\microscope_1\september_2020\2020_09_16_alginate2%_NIH_tanktreading\1\*_result.txt", pressure=pressure) x = np.abs(data.rp) * 1e-6 y = data.velocity * 1e-3 return removeNan(x, y)
def getXY(pressure): data, config = load_all_data([ rf"\\131.188.117.96\biophysDS\emirzahossein\microfluidic cell rhemeter data\microscope_1\september_2020\2020_09_16_alginate2%_NIH_tanktreading\1\*_result.txt", # r"\\131.188.117.96\biophysDS\emirzahossein\microfluidic cell rhemeter data\microscope4\2020_july\2020_07_29_aslginate2%_NIH_diff_x_position_2\inlet\1\*_result.txt", ], pressure=pressure) x, y = data.rp*1e-6, data.velocity*1e-3 i = ~np.isnan(x) & ~np.isnan(y) x = x[i] y = y[i] return x, y, data
# -*- coding: utf-8 -*- import matplotlib.pyplot as plt from deformationcytometer.evaluation.helper_functions import plotDensityScatter, load_all_data import numpy as np import pylustrator pylustrator.start() for index, pressure in enumerate([1]): ax = plt.subplot(1, 3, index + 1) data, config = load_all_data([ r"\\131.188.117.96\biophysDS\emirzahossein\microfluidic cell rhemeter data\microscope4\2020_july\2020_07_21_alginate2%_dmem_NIH_time_2\[0-9]\*_result.txt", r"\\131.188.117.96\biophysDS\emirzahossein\microfluidic cell rhemeter data\microscope4\2020_may\2020_05_22_alginateDMEM2%\[0-9]\*_result.txt", r"\\131.188.117.96\biophysDS\emirzahossein\microfluidic cell rhemeter data\microscope4\2020_july\2020_07_27_alginate2%_dmem_NIH_time_1\[0-9]\*_result.txt", ], pressure=pressure) plt.subplot(1, 2, 1) plotDensityScatter(data.rp, data.angle) plt.subplot(1, 2, 2) plotDensityScatter(data.rp, np.sqrt(data.area / np.pi)) #plt.legend() #% start: automatic generated code from pylustrator plt.figure(1).ax_dict = {ax.get_label(): ax for ax in plt.figure(1).axes} import matplotlib as mpl plt.figure(1).set_size_inches(12.000000 / 2.54, 4.370000 / 2.54, forward=True) plt.figure(1).axes[0].set_position([0.118367, 0.241321, 0.356764, 0.716233]) plt.figure(1).axes[0].set_xlim(-90.0, 90.0)
# -*- coding: utf-8 -*- import matplotlib.pyplot as plt from deformationcytometer.evaluation.helper_functions import load_all_data, plotDensityScatter, plotBinnedData import numpy as np from scipy import stats import pylustrator pylustrator.start() data, config = load_all_data([ rf"\\131.188.117.96\biophysDS\emirzahossein\microfluidic cell rhemeter data\microscope4\2020_july\2020_07_29_aslginate2%_NIH_diff_x_position_2\inlet\[0-9]\*_result.txt", rf"\\131.188.117.96\biophysDS\emirzahossein\microfluidic cell rhemeter data\microscope4\2020_july\2020_07_29_aslginate2%_NIH_diff_x_position_3\inlet\[0-9]\*_result.txt", ], pressure=3) def curve(x, x0, a): return 1 / 2 * 1 / (1 + (x / x0)**a) omega_weissenberg = curve(np.abs(data.vel_grad), (1 / data.tau) * 3, data.delta) * np.abs( data.vel_grad) # * np.pi*2 plt.plot(data.omega, omega_weissenberg, "o") plt.savefig(__file__[:-3] + ".png", dpi=300) plt.savefig(__file__[:-3] + ".pdf") plt.show()
""" import matplotlib.pyplot as plt from matplotlib.backends.backend_pdf import PdfPages from deformationcytometer.includes.includes import getInputFile, getConfig, getData #refetchTimestamps, from deformationcytometer.evaluation.helper_functions import getVelocity, filterCells, correctCenter, getStressStrain, fitStiffness from deformationcytometer.evaluation.helper_functions import initPlotSettings, plotVelocityProfile, plotStressStrain, plotMessurementStatus from deformationcytometer.evaluation.helper_functions import storeEvaluationResults from deformationcytometer.evaluation.helper_functions import load_all_data """ loading data """ # get the results file (by config parameter or user input dialog) datafile = getInputFile(filetype=[("txt file", '*_result.txt')]) # load the data and the config data, config = load_all_data(datafile) fitStiffness(data, config) """ plotting data """ initPlotSettings() # add multipage plotting pp = PdfPages(datafile[:-11] + '.pdf') # generate the velocity profile plot plotVelocityProfile(data, config) pp.savefig() plt.cla()
plt.axvline(0.7, linestyle="dashed", lw=0.8, color="k") plt.xlabel("relative radius") plt.ylabel("speed (µm/s)") break #m, t = getCenterLine(data_x, data_y) #cr = np.corrcoef(data_y, m * np.array(data_x)) #r2 = np.corrcoef(data_y, m * np.array(data_x))[0, 1] ** 2 #return m, r2 # load the data and the config data, config = load_all_data( rf"\\131.188.117.96\biophysDS\emirzahossein\microfluidic cell rhemeter data\microscope_1\september_2020\2020_09_16_alginate2%_NIH_tanktreading\1\*_result.txt" ) data = data[np.abs(data.velocity - data.velocity_fitted) < 1.5] plt.subplot(241) plot_velocity_fit(data) #plt.legend(title="pressure (bar)") plt.subplot(242) plot_velocity_fit_dot(data) plt.subplot(243) plot_viscisity(data) plt.subplot(244) data, config = load_all_data_new( rf"\\131.188.117.96\biophysDS\emirzahossein\microfluidic cell rhemeter data\microscope_1\september_2020\2020_09_16_alginate2%_NIH_tanktreading\1\*_result.txt"
config = {"channel_length_m": 5.8e-2, "channel_width_m": 186e-6} x, y = getFitXY(config, np.mean(pressure), p) return x, y def histplot(x): x = np.array(x) from scipy import stats kde = stats.gaussian_kde(x) xx = np.linspace(np.min(x), np.max(x), 1000) plt.hist(x, bins=50, density=True) plt.plot(xx, kde(xx)) if 0: data, config = load_all_data([ rf"\\131.188.117.96\biophysDS\emirzahossein\microfluidic cell rhemeter data\microscope_1\september_2020\2020_09_16_alginate2%_NIH_tanktreading\1\*_result.txt", # r"\\131.188.117.96\biophysDS\emirzahossein\microfluidic cell rhemeter data\microscope4\2020_july\2020_07_29_aslginate2%_NIH_diff_x_position_2\inlet\1\*_result.txt", ]) data = data.dropna() #data0 = data data2 = data if 1: import pandas as pd data2 = pd.read_csv("../figures/panel3_tanktreading/output_rotation_NIH.csv") data2["velocity"] = data2.v data2["long_axis"] = data2.a data2["short_axis"] = data2.b data2["angle"] = data2.beta data = data2 p = apply_velocity_fit(data)
r"\\131.188.117.96\biophysDS\emirzahossein\microfluidic cell rhemeter data\evaluation\diff % alginate\2020_10_30_alginate2.0%_dmem_NIH_3T3\*\*_result.txt", ] alg15 = [ r"\\131.188.117.96\biophysDS\emirzahossein\microfluidic cell rhemeter data\evaluation\diff % alginate\2020_07_30_alginate1.5%_dmem_NIH_3T3\*\*_result.txt", r"\\131.188.117.96\biophysDS\emirzahossein\microfluidic cell rhemeter data\evaluation\diff % alginate\2020_10_14_alginate1.5%_dmem_NIH_3T3\*\*_result.txt", r"\\131.188.117.96\biophysDS\emirzahossein\microfluidic cell rhemeter data\evaluation\diff % alginate\2020_10_14_alginate1.5%_dmem_NIH_3T3_2\*\*_result.txt", r"\\131.188.117.96\biophysDS\emirzahossein\microfluidic cell rhemeter data\evaluation\diff % alginate\2020_10_28_alginate1.5%_dmem_NIH_3T3\*\*_result.txt", ] if 0: plt.subplot(2, 3, 1, label="cells") # iterate over all times for index, path in enumerate([THP1, K562, NIH3T3]): # get the data and the fit parameters data, config = load_all_data(path, pressure=2) plot_joint_density(np.log10(data.k_cell), data.alpha_cell, label=["THP1", "K562", "NIH3T3"][index]) plt.xlim(1, 3) plt.ylim(0, 1) plt.legend(fontsize=8) plt.subplot(2, 3, 2, label="pressure") # iterate over all times for pressure in [1, 2, 3]: # get the data and the fit parameters data, config = load_all_data(NIH3T3, pressure=pressure) plot_joint_density(np.log10(data.k_cell), data.alpha_cell, color=pylustrator.lab_colormap.LabColormap(["C2", "C3"], 3)(pressure-1), label=f"{pressure} bar") plt.xlim(1, 3)
)): folder = Path(folder) name = str(folder.name) drugs[name] = str(folder) + "\*\*_result.txt" N = len(drugs) cols = int(np.sqrt(N)) rows = int(np.ceil(N / cols)) ax_k = [] ax_a = [] # iterate over all times for index, name in enumerate(drugs.keys()): plt.figure(1) # get the data and the fit parameters data, config = load_all_data(drugs[name]) print(index, name, len(data), np.sum(~np.isnan(data.k_cell))) ax_k.append(plt.subplot(rows, cols * 2, index * 2 + 1)) plt.title(name) plot_density_hist(np.log10(data.k_cell)) stat_k = get_mode_stats(data.k_cell) plt.xlim(1, 4) plt.xticks(np.arange(5)) plt.grid() ax_a.append(plt.subplot(rows, cols * 2, index * 2 + 1 + 1)) plot_density_hist(data.alpha_cell, color="C1") stat_alpha = get_mode_stats(data.alpha_cell)
rows = int(np.ceil(N / cols)) import matplotlib as mpl mpl.rc("figure.subplot", top=0.95, hspace=0.35, left=0.2, right=0.95) # defaults top=0.88, hspace=0.2, left=0.125, right=0.9 mpl.rc("figure", figsize=[3.0, 4.8]) # default 6.4, 4.8 ax_k = [] ax_a = [] ax_Gp1 = [] ax_Gp2 = [] # iterate over all times for index, name in enumerate(experiment.keys()): print(experiment[name]) try: data, config = load_all_data( experiment[name], pressure=3 ) #set pressure to 0.5,1,2,3 or what was measured. for all pressures together, delete ", pressure=x" except (FileNotFoundError, ValueError): continue data = data[~np.isnan(data.tt)] print(index, name, len(data), np.sum(~np.isnan(data.w_k_cell)), np.sum(~np.isnan(data.k_cell))) row_title = "" if "/" in name: row_title, name = name.split("/", 1) row_title += "\n" if index >= cols: name = "" plt.figure(1) #histogram of alpha and k
""" THP1 """ fit_data = [] x = [] # iterate over all times for index, time in enumerate(range(1, 7, 1)): f = [] # iterate over the different experiment paths for path in [ rf"\\131.188.117.96\biophysDS\meroles\2020.07.07.Control.sync\Control2\T{time * 10}\*_result.txt", rf"\\131.188.117.96\biophysDS\meroles\2020.06.26-Control\Control2\T{time * 10}\*_result.txt", rf"\\131.188.117.96\biophysDS\meroles\2020.06.26-Control\Control1\T{time * 10}\*_result.txt", rf"\\131.188.117.96\biophysDS\meroles\2020.07.09_control_sync_hepes\Control3\T{time * 10}\*_result.txt", ]: # get the data and the fit parameters data, config = load_all_data(path, repetition=2) f.append([ config["fit"]["p"][0], config["fit"]["p"][1], config["fit"]["p"][0] * config["fit"]["p"][1] ]) x.append(time * 10) fit_data.append(f) fit_data = np.array(fit_data) # plot the fit data in the three different plots for i in range(3): plt.subplot(1, 3, i + 1) plt.errorbar( x,
r"\\131.188.117.96\biophysDS\emirzahossein\microfluidic cell rhemeter data\microscope_1\december_2020\2020_12_14_NIH3T3_drugs\Nocodazole\[2-9]\*_result.txt", "Paclitaxel": r"\\131.188.117.96\biophysDS\emirzahossein\microfluidic cell rhemeter data\microscope_1\december_2020\2020_12_14_NIH3T3_drugs\Paclitaxel\[2-9]\*_result.txt", "Y27632": r"\\131.188.117.96\biophysDS\emirzahossein\microfluidic cell rhemeter data\microscope_1\december_2020\2020_12_14_NIH3T3_drugs\Y27632\[2-9]\*_result.txt", } drugs = drugs_jan ax_k = [] ax_a = [] # iterate over all times for index, name in enumerate(drugs.keys()): print(index, name) # get the data and the fit parameters data, config = load_all_data(drugs[name], pressure=3) ax_k.append(plt.subplot(4, 3, index + 1)) def curve(x, x0, a): return 1 / 2 * 1 / (1 + (x / x0)**a) omega_weissenberg = curve(np.abs(data.vel_grad), (1 / data.tau) * 3, data.delta) * np.abs( data.vel_grad) # * np.pi*2 plt.title(name) plt.plot(data.omega, omega_weissenberg, "o", ms=1) plt.xlabel("omega") plt.ylabel("omega_weissenberg")
# full path of the output file out_put_file = r"/home/user/Desktop/out.pdf" # list of base folders to analyze. Each folder must contain subfolders "1", "2" .. for different experiments. base_folders = [ r"/home/user/Desktop/biophysDS/emirzahossein/microfluidic cell rhemeter data/microscope_1/october_2020/2020_10_14_alginate1.5%_NIH", #r"\\131.188.117.96\biophysDS\emirzahossein\microfluidic cell rhemeter data\microscope4\2020_july\2020_07_29_aslginate2%_NIH_diff_x_position_3\inlet\\" ] base_folders_ = [ os.path.join(b, os.path.join("[0-9]", "*_result.txt")) for b in base_folders ] print(base_folders_) # reading all data, with out splitting for the pressure data_all, config_all = load_all_data(base_folders_, pressure=None) # reading the data for each pressure individually. This is needed to later plot stress-strain curves # for each pressure separately data1, config1 = load_all_data(base_folders_, pressure=1) data2, config2 = load_all_data(base_folders_, pressure=2) data3, config3 = load_all_data(base_folders_, pressure=3) """ evaluating data""" # fit with all pressures combined p = fitStiffness(data_all, config_all) config1["fit"] = config_all["fit"] config2["fit"] = config_all["fit"] config3["fit"] = config_all["fit"] """ plotting data """ initPlotSettings()
# -*- coding: utf-8 -*- import matplotlib.pyplot as plt from deformationcytometer.evaluation.helper_functions import plotDensityScatter, plotStressStrainFit, load_all_data, all_plots_same_limits import pylustrator pylustrator.start() rows = 3 cols = 5 for index, time in enumerate(range(1, 6, 1)): plt.subplot(rows, cols, index + 1) data, config = load_all_data( [ rf"\\131.188.117.96\biophysDS\meroles\2020.07.07.Control.sync\Control2\T{time*10}\*_result.txt", # rf"\\131.188.117.96\biophysDS\meroles\2020.06.26\Control2\T{time*10}\*_result.txt", # rf"\\131.188.117.96\biophysDS\meroles\2020.06.26\Control1\T{time*10}\*_result.txt", # rf"\\131.188.117.96\biophysDS\meroles\2020.07.09_control_sync_hepes\Control3\T{time*10}\*_result.txt", ], repetition=2) plotDensityScatter(data.stress, data.strain) plotStressStrainFit(data, config) for index, time in enumerate(range(2, 11, 2)): plt.subplot(rows, cols, cols + index + 1) data, config = load_all_data( [ rf"\\131.188.117.96\biophysDS\emirzahossein\microfluidic cell rhemeter data\microscope4\2020_july\2020_07_10_alginate2%_K562_0%FCS_time\{time}\*_result.txt", # rf"\\131.188.117.96\biophysDS\emirzahossein\microfluidic cell rhemeter data\microscope4\2020_july\07_07_2020_alginate2%_rpmi_no_fcs_time\{time}\*_result.txt", ], repetition=2)
# iterate over all times #pressures = np.sort(np.unique(get_pressures(rf"\\131.188.117.96\biophysDS\emirzahossein\microfluidic cell rhemeter data\microscope_1\october_2020\2020_10_16_alginate2%_THP1_overtime\2\*_result.txt"))) pressures = np.sort(np.unique(get_pressures(rf"\\131.188.117.96\biophysDS\emirzahossein\microfluidic cell rhemeter data\microscope4\Mar THP1\2\*_result.txt"))) pressures = pressures[2:] print(pressures) for index, pressure in enumerate(pressures): f = [] # iterate over the different experiment paths for path in [ # rf"\\131.188.117.96\biophysDS\emirzahossein\microfluidic cell rhemeter data\microscope_1\october_2020\2020_10_15_alginate2%_THP1_overtime\**\*_result.txt", rf"\\131.188.117.96\biophysDS\emirzahossein\microfluidic cell rhemeter data\microscope4\Mar THP1\2\*_result.txt", # rf"\\131.188.117.96\biophysDS\emirzahossein\microfluidic cell rhemeter data\microscope4\Mar THP1\Control1\**\*_result.txt", # rf"\\131.188.117.96\biophysDS\emirzahossein\microfluidic cell rhemeter data\microscope4\Mar THP1\Control2\**\*_result.txt", ]: # get the data and the fit parameters data, config = load_all_data(path, pressure=pressure) f.append([np.mean(data.alpha_cell), np.nanmedian(data.k_cell)]) #f.append([np.mean(data.alpha_cell), np.mean(np.log10(data.k_cell))]) fit_data.append(f) fit_data = np.array(fit_data) # plot the fit data in the two different plots for i in range(2): plt.subplot(1, 2, i+1) plt.errorbar(pressures, np.mean(fit_data[:, :, i], axis=1), np.std(fit_data[:, :, i], axis=1) / np.sqrt(fit_data[:, :, i].shape[1]), capsize=3, label="THP1", )