def load_data(self, file, solidity_threshold, irregularity_threshold): data_all = getData(file) if not "area" in data_all.keys(): data_all["area"] = data_all["long_axis"] * data_all[ "short_axis"] * np.pi / 4 if len(data_all) == 0: print("no data loaded from file '%s'" % file) return pd.DataFrame(), pd.DataFrame() # use a "read sol from config flag here data_mean, config_eval = load_all_data_new( self.db.getImage(0).get_full_filename().replace( ".tif", "_evaluated_new.csv"), do_group=False, do_excude=False) return data_all, data_mean
return file_pairs file_pairs = [] file_pairs.extend(getFolderPairs(r"\\131.188.117.119\biophysDS\emirzahossein\microfluidic cell rhemeter data\microscope_1\march_2021\2021_02_24_NIH3T3_LatrunculinB_doseresponse\*")) file_pairs.extend(getFolderPairs(r"\\131.188.117.119\biophysDS\emirzahossein\microfluidic cell rhemeter data\microscope_1\march_2021\2021_03_01_NIH3T3_LatrunculinB_doseresponse\*")) file_pairs.extend(getFolderPairs(r"\\131.188.117.119\biophysDS\emirzahossein\microfluidic cell rhemeter data\microscope_1\march_2021\2021_03_10_NIH3T3_LatrunculinB_doseresponse\*")) file_pairs.extend(getFolderPairs(r"\\131.188.117.119\biophysDS\emirzahossein\microfluidic cell rhemeter data\microscope_1\march_2021\2021_03_15_NIH3T3_LatrunculinB_doseresponse\*")) all_data = [] for row_index, pressure in enumerate([0.5, 1, 2, 3]): plt.subplot(4, 1, row_index+1) for index, paths in enumerate(file_pairs): try: data0, config0 = load_all_data_new(paths[0], solidity_threshold=0.7, irregularity_threshold=1.3, pressure=pressure) except (FileNotFoundError, ValueError) as err: print("ERROR", paths[0], err) continue try: data1, config1 = load_all_data_new(paths[1], solidity_threshold=0.7, irregularity_threshold=1.3, pressure=pressure) except (FileNotFoundError, ValueError) as err: print("ERROR", paths[1], err) continue ratios = [] # bootstrap with matched histograms for i in range(3): data0b, data1b = bootstrap_match_hist([data0, data1], bin_width=25, max_bin=300, property="stress") ratios.append(get_mode_stats(data0b.k_cell)[0]/get_mode_stats(data1b.k_cell)[0])
agg="logmode", color=color[0], label=label) plt.ylim(bottom=0) plt.axes([0.5, .2, 0.5, 0.5], label=f"{parameter}_k") plotMeasurementOfParameter(data, parameter, "w_alpha_cell", agg="mode", color=color[1], label=label) plt.ylim(bottom=0) data_bleb, config = load_all_data_new([ r"\\131.188.117.96\biophysDS\meroles\SPRING2021\12.04.2021_THP1_CytoD_10µM_*\**\*_evaluated_new.csv" ], pressure=2) data_dmso, config = load_all_data_new( [ r"\\131.188.117.96\biophysDS\meroles\SPRING2021\24.03.2021_THP1_2%Alginate\**\*_evaluated_new.csv", r"\\131.188.117.96\biophysDS\meroles\SPRING2021\30.03.2021_THP1_Ag2%\**\*_evaluated_new.csv", #r"\\131.188.117.96\biophysDS\meroles\SPRING2021\30.03.2021_THP1_Ag2%_2\**\*_evaluated_new.csv", r"\\131.188.117.96\biophysDS\meroles\SPRING2021\30.03.2021_THP1_Ag2%_3\**\*_evaluated_new.csv", ], pressure=2) print(data_bleb.pressure.unique(), data_dmso.pressure.unique()) plot_pair(data_bleb, "time", ["C0", "C0"], label="CytoD") plot_pair(data_dmso, "time", ["C3", "C3"], label="Control") plt.legend() #% start: automatic generated code from pylustrator plt.figure(1).ax_dict = {ax.get_label(): ax for ax in plt.figure(1).axes}
def __init__(self, *args, **kwargs): clickpoints.Addon.__init__(self, *args, **kwargs) # open the window self.layout = QtWidgets.QVBoxLayout(self) self.resize(1300, 400) self.show() # Setting up marker Types self.marker_type_cell1 = self.db.setMarkerType("cell", "#0a2eff", self.db.TYPE_Ellipse) self.pen_neutral = QtGui.QPen(QtGui.QColor("#0a2eff"), 3) self.marker_type_cell2 = self.db.setMarkerType("cell include", "#25c638", self.db.TYPE_Ellipse) self.pen_include = QtGui.QPen(QtGui.QColor("#25c638"), 3) self.marker_type_cell3 = self.db.setMarkerType("cell exclude", "#ff0000", self.db.TYPE_Ellipse) self.pen_exclude = QtGui.QPen(QtGui.QColor("#ff0000"), 3) self.cp.reloadTypes() # set the title and layout self.setWindowTitle("DeformationCytometer - ClickPoints") # load the data self.filename = self.db.getImage(0).get_full_filename()[:-4] + "_evaluated_new.csv" self.data, self.config = load_all_data_new(self.db.getImage(0).get_full_filename().replace(".tif", "_evaluated_new.csv"), do_group=False, do_excude=False) if "manual_exclude" not in self.data: self.data["manual_exclude"] = np.nan print("loading finished", self.db.getImage(0).get_full_filename()) # add a label and the progressbar self.label = QtWidgets.QLabel("Cell") self.layout.addWidget(self.label) self.progressbar = QtWidgets.QProgressBar() self.progressbar.setRange(0, len(self.data) - 1) self.layout.addWidget(self.progressbar) pixel_size = self.config["pixel_size"] # remove previous markers of the time in case there are any (e.g. when the addon is activated twice) self.db.deleteEllipses(type=self.marker_type_cell1) self.db.deleteEllipses(type=self.marker_type_cell2) self.db.deleteEllipses(type=self.marker_type_cell3) self.markers = [] if 0: # add all markers at once self.markers = self.db.setEllipses( frame=list(np.array(self.data.frames).astype(np.int)), x=np.array(self.data.x), y=np.array(self.data.y), width=np.array(self.data.long_axis / pixel_size), height=np.array(self.data.short_axis / pixel_size), angle=np.array(self.data.angle), type=self.marker_type_cell1 ) if 0: # iteratively create the markers for i, d in self.data.iterrows(): self.progressbar.setValue(i) self.label.setText(f"Cell {i}") self.cp.window.app.processEvents() type_ = self.marker_type_cell3 if d.manual_exclude == 1 else self.marker_type_cell2 if d.manual_exclude == 0 else self.marker_type_cell1 ell = self.db.setEllipse(frame=int(d.frames), x=d.x, y=d.y, width=d.long_axis / pixel_size, height=d.short_axis / pixel_size, text=f"{i} {d.cell_id}", angle=d.angle, type=type_) self.markers.append(ell) self.index = 0 self.view = QExtendedGraphicsView() self.layout.addWidget(self.view) # self.view.zoomEvent = self.zoomEvent # self.view.panEvent = self.panEvent self.local_scene = self.view.scene self.origin = self.view.origin self.cell_rects = {} self.focus_rect = QtWidgets.QGraphicsRectItem(-self.w / 2, -self.h / 2, self.w, self.h * 2, self.origin) self.focus_rect.setPen(QtGui.QPen(QtGui.QColor(255, 255, 0), 8)) self.focus_rect.setZValue(10) self.view.setExtend(self.w * 5, self.h*2) self.view.fitInView() self.start_pos = 0 self.current_pos = self.index - 0.1 self.timer_percent = 0 self.view.keyPressEvent = self.keyPressEvent2 self.slider = QtWidgets.QSlider() self.slider.setOrientation(QtCore.Qt.Horizontal) self.layout.addWidget(self.slider) self.slider.setRange(0, len(self.data)-1) def setIndex(x): if x != self.index: self.index = x self.focusOnCell() self.slider.valueChanged.connect(setIndex) layout = QtWidgets.QHBoxLayout() self.layout.addLayout(layout) self.auto_save = QtWidgets.QCheckBox() layout.addWidget(self.auto_save) self.auto_save_label = QtWidgets.QLabel("autosave") layout.addWidget(self.auto_save_label) self.button_save = QtWidgets.QPushButton("save") self.button_save.clicked.connect(self.save) layout.addWidget(self.button_save) layout.addStretch() self.image_loaded.connect(self.addImage) self.focusOnCell()
from deformationcytometer.evaluation.helper_functions import plotDensityScatter, load_all_data, all_plots_same_limits, get_cell_properties #, load_all_data_new from deformationcytometer.evaluation.helper_functions import plot_velocity_fit, plot_density_hist, \ plotDensityLevels, plotBinnedData, plot_joint_density, split_axes, load_all_data_new import numpy as np import pylustrator pylustrator.start() if 0: """""" #\\131.188.117.96\biophysDS\emirzahossein\microfluidic cell rhemeter data\microscope_1\january_2021\2021_03_01_NIH3T3_LatrunculinB_doseresponse\100 nM - Kontrolle\2021_03_01_12_21_37.tif #\\131.188.117.96\biophysDS\emirzahossein\microfluidic cell rhemeter data\microscope_1\january_2021\2021_03_01_NIH3T3_LatrunculinB_doseresponse\100 nM - Kontrolle\2021_03_01_12_24_36.tif #\\131.188.117.96\biophysDS\emirzahossein\microfluidic cell rhemeter data\microscope_1\january_2021\2021_03_01_NIH3T3_LatrunculinB_doseresponse\3.162 nM - Kontrolle\2021_03_01_14_20_57.tif #\\131.188.117.96\biophysDS\emirzahossein\microfluidic cell rhemeter data\microscope_1\january_2021\2021_03_01_NIH3T3_LatrunculinB_doseresponse\316.2 nM - Kontrolle\2021_03_01_11_45_42.tif from deformationcytometer.evaluation.helper_functions import correctCenter data, config = load_all_data_new( r"\\131.188.117.96\biophysDS\emirzahossein\microfluidic cell rhemeter data\microscope_1\january_2021\2021_03_01_NIH3T3_LatrunculinB_doseresponse\100 nM - Kontrolle\2021_03_01_12_21_37_result.txt" ) correctCenter(data, config) d = data y_pos = d.rp vel = d.velocity valid_indices = np.isfinite(y_pos) & np.isfinite(vel) plt.plot(y_pos, vel, "o") plt.show() """""" experiment = {} #if parent-subfolders exist: import glob
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" ) plot_viscisoty_over_shear_rate(data) plot_tt(plt.subplot(245), plt.subplot(246)) plt.subplot(247) plot_omega(data) def func(x, a, b): return x / 2 * 1 / (1 + a * x**b) x = [0.113, 0.45] xx = np.arange(0, 500)
parameter, "w_k_cell", color[0], label=label) plt.ylim(bottom=0) plt.axes([0.5, .2, 0.5, 0.5], label=f"{parameter}_k") plotMeasurementOfParameter(data, parameter, "w_alpha_cell", color[1], label=label) plt.ylim(bottom=0) data_bleb, config = load_all_data_new([ r"\\131.188.117.96\biophysDS\emirzahossein\microfluidic cell rhemeter data\microscope_1\september_2020\2020_09_30_alginate2%_NIH3T3_blebbistatin\inlet\**\*.tif" ], pressure=3) data_dmso, config = load_all_data_new([ r"\\131.188.117.96\biophysDS\emirzahossein\microfluidic cell rhemeter data\microscope_1\september_2020\2020_09_30_alginate2%_NIH3T3_DMSO\inlet\**\*.tif" ], pressure=3) plot_pair(data_bleb, "time", ["C0", "C0"], label="Blebbistatin") plot_pair(data_dmso, "time", ["C3", "C3"], label="DMSO") 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, 6.000000 / 2.54, forward=True) plt.figure(1).ax_dict["time_alpha"].set_ylim(0.0, 125.0) plt.figure(1).ax_dict["time_alpha"].set_position(
agg="median", color=color[0], label=label) plt.ylim(bottom=0) plt.axes([0.5, .2, 0.5, 0.5], label=f"{parameter}_k") plotMeasurementOfParameter(data, parameter, "w_alpha_cell", agg="mean", color=color[1], label=label) plt.ylim(bottom=0) data, config = load_all_data_new([ r"\\131.188.117.96\biophysDS\emirzahossein\microfluidic cell rhemeter data\microscope4\flourescence beads\2021.4.14\**\*_evaluated_new.csv" ]) data.pressure = np.round(data.pressure, 2) plot_pair(data, "pressure", ["C0", "C1"]) #% 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, 5.300000 / 2.54, forward=True) plt.figure(1).ax_dict["pressure_alpha"].set_xlim(0.0, 0.52) plt.figure(1).ax_dict["pressure_alpha"].set_ylim(0.0, 10.0) plt.figure(1).ax_dict["pressure_alpha"].set_position( [0.125368, 0.310687, 0.364634, 0.554430]) plt.figure(1).ax_dict["pressure_alpha"].spines['right'].set_visible(False) plt.figure(1).ax_dict["pressure_alpha"].spines['top'].set_visible(False)
plt.ylim(bottom=0) if scaling == "semilogx": plt.semilogx() plt.axes([0.55, .2, 0.4, 0.5], label=f"{parameter}_k") plotMeasurementOfParameter(data, parameter, "w_alpha_cell", agg="mode", color=color[1], label=label) plt.ylim(bottom=0) if scaling == "semilogx": plt.semilogx() if 0: data, config = load_all_data_new([ r"\\131.188.117.96\biophysDS\meroles\SPRING2021\24.03.2021_THP1_2%Alginate\**\*_evaluated_new.csv", r"\\131.188.117.96\biophysDS\meroles\SPRING2021\30.03.2021_THP1_Ag2%\**\*_evaluated_new.csv", #r"\\131.188.117.96\biophysDS\meroles\SPRING2021\30.03.2021_THP1_Ag2%_2\**\*_evaluated_new.csv", r"\\131.188.117.96\biophysDS\meroles\SPRING2021\30.03.2021_THP1_Ag2%_3\**\*_evaluated_new.csv", r"\\131.188.117.96\biophysDS\meroles\SPRING2021\22.04.2021_THP1_CytoD_*\**\*_evaluated_new.csv", r"\\131.188.117.96\biophysDS\meroles\SPRING2021\21.04.2021_THP1_Cyto*\**\*_evaluated_new.csv", r"\\131.188.117.96\biophysDS\meroles\SPRING2021\21.04.2021_THP1_*Cyto\**\*_evaluated_new.csv", r"\\131.188.117.96\biophysDS\meroles\SPRING2021\23.04.2021_THP1_Cyto*M*\**\*_evaluated_new.csv", ]) data, config = load_all_data_new([ # CONTROL r"\\131.188.117.96\biophysDS\meroles\SPRING2021\21.04.2021_THP1_alginate2%", # 10nM cytoD r"\\131.188.117.96\biophysDS\meroles\SPRING2021\22.04.2021_THP1_CytoD_10nM", # 100nM cytoD r"\\131.188.117.96\biophysDS\meroles\SPRING2021\22.04.2021_THP1_CytoD_100nM",
#r"\\131.188.117.96\biophysDS\emirzahossein\microfluidic cell rhemeter data\evaluation\diff % alginate\2020_07_27_alginate2.0%_dmem_NIH_3T3\*\*_result.txt", r"\\131.188.117.96\biophysDS\emirzahossein\microfluidic cell rhemeter data\evaluation\diff % alginate\2020_07_28_alginate2.0%_dmem_NIH_3T3\*\*_result.txt", #r"\\131.188.117.96\biophysDS\emirzahossein\microfluidic cell rhemeter data\evaluation\diff % alginate\2020_10_28_alginate2.0%_dmem_NIH_3T3\*\*_result.txt", #r"\\131.188.117.96\biophysDS\emirzahossein\microfluidic cell rhemeter data\evaluation\diff % alginate\2020_10_30_alginate2.0%_dmem_NIH_3T3\*\*_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\[0-9]\*_result.txt", # r"\\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", r"\\131.188.117.96\biophysDS\emirzahossein\microfluidic cell rhemeter data\microscope_1\september_2020\2020_09_16_alginate2%_NIH_tanktreading\*\*_result.txt", ] numbers = [] data_list = [] config_list = [] for index, pressure in enumerate([1, 2, 3]): data, config = load_all_data_new(alg20, pressure=pressure) data_list.append(data) config_list.append(config) ranges = [ np.arange(10, 80, 20), np.arange(10, 180, 20), np.arange(10, 280, 20), ] colors = [ "#d68800", "#d40000", "#b00038", ] for index, pressure in enumerate([3]):
import sys from pathlib import Path sys.path.insert(0, str(Path(__file__).parent.parent)) import pandas as pd import matplotlib.pyplot as plt from deformationcytometer.evaluation.helper_functions import load_all_data, load_all_data_new, bootstrap_match_hist import numpy as np import pylustrator pylustrator.start() data, config = load_all_data_new([ fr"\\131.188.117.96\biophysDS\meroles\SPRING2021\24.03.2021_THP1_1.5%Alginate\**\*_evaluated_new.csv", fr"\\131.188.117.96\biophysDS\meroles\SPRING2021\24.03.2021_THP1_2%Alginate\**\*_evaluated_new.csv", fr"\\131.188.117.96\biophysDS\meroles\SPRING2021\25.03.2021_THP1_2.5%Alginate\**\*_evaluated_new.csv", fr"\\131.188.117.96\biophysDS\meroles\SPRING2021\30.03.2021_THP1_Ag2%\**\*_evaluated_new.csv", fr"\\131.188.117.96\biophysDS\meroles\SPRING2021\30.03.2021_THP1_Ag2%_3\**\*_evaluated_new.csv", ]) def plotMeasurementOfParameter(data, parameter, value, color=None): k_cell = data.groupby([parameter, "measurement_id"]).median()[value].reset_index() k_cell_mean = k_cell.groupby(parameter).mean() l = plt.errorbar(k_cell_mean.index, k_cell_mean.values, k_cell.groupby(parameter).sem().values[:, 0], capsize=3, color=color, zorder=2)
from pathlib import Path from deformationcytometer.evaluation.helper_functions import plotDensityScatter, load_all_data_new, get_cell_properties from deformationcytometer.evaluation.helper_functions import plot_velocity_fit, plot_density_hist, \ plotDensityLevels, plotBinnedData settings_name = "strain_vs_stress_clean" """ loading data """ # reading commandline arguments if executed from terminal file, irregularity_threshold, solidity_threshold = read_args_evaluate() # get the results file (by command line parameter or user input dialog) datafile = getInputFile(filetype="csv file (*_evaluated_new.csv)", settings_name=settings_name, video=file) print("evaluate file", datafile) # load the data and the config data, config = load_all_data_new(datafile) plt.figure(0, (10, 8)) plt.subplot(2, 3, 1) plt.cla() plot_velocity_fit(data) plt.text(0.9, 0.9, f"$\\eta_0$ {data.eta0[0]:.2f}\n$\\delta$ {data.delta[0]:.2f}\n$\\tau$ {data.tau[0]:.2f}", transform=plt.gca().transAxes, va="top", ha="right") plt.subplot(2, 3, 2) plt.cla() plotDensityScatter(data.stress, data.epsilon) plotBinnedData(data.stress, data.epsilon, bins=np.arange(0, 300, 10)) plt.xlabel("stress (Pa)") plt.ylabel("strain")
pylustrator.start() """ NIH3T3 """ fit_data = [] x = [] # iterate over all times for index, time in enumerate(range(2, 13, 1)): f = [] # iterate over the different experiment paths for path in [ rf"\\131.188.117.96\biophysDS\emirzahossein\microfluidic cell rhemeter data\microscope4\2020_may\2020_05_22_alginateDMEM2%\{time}\*_result.txt", rf"\\131.188.117.96\biophysDS\emirzahossein\microfluidic cell rhemeter data\microscope_1\august_2020\2020_08_19_alginate2%_overtime_2\{time}\*_result.txt", ]: # get the data and the fit parameters data, config = load_all_data_new(path, pressure=1) data, config = load_all_data_new( rf"\\131.188.117.96\biophysDS\emirzahossein\microfluidic cell rhemeter data\microscope4\2020_may\**\*_result.txt", pressure=1) data1 = data[data.pressure == 1] #f.append([np.mean(data.alpha_cell), np.mean(np.log10(data.k_cell))]) f.append([np.mean(data.alpha_cell), np.nanmedian(data.k_cell)]) x.append(time * 5) fit_data.append(f) fit_data = np.array(fit_data) # plot the fit data in the two different plots for i in range(2):
def selected(self, name): plt.clf() if name.endswith(".tif"): data, config = load_all_data_new(name.replace( ".tif", "_evaluated_new.csv"), do_excude=False) def get_mode_stats(x): from scipy import stats from deformationcytometer.evaluation.helper_functions import bootstrap_error x = np.array(x) print("a", x.shape) if len(x.shape) == 1: x = x[~np.isnan(x)] print("b", x.shape) def get_mode(x): kde = stats.gaussian_kde(x) print(x.shape) print(np.argmax(kde(x))) return x[..., np.argmax(kde(x))] mode = get_mode(x) # err = bootstrap_error(x, get_mode, repetitions=2) return mode from scipy.special import gamma def fit(omega, k, alpha): omega = np.array(omega) G = k * (1j * omega)**alpha * gamma(1 - alpha) return np.real(G), np.imag(G) def cost(p): Gp1, Gp2 = fit(data.omega_weissenberg, *p) #return np.sum(np.abs(np.log10(data.w_Gp1) - np.log10(Gp1))) + np.sum( # np.abs(np.log10(data.w_Gp2) - np.log10(Gp2))) return np.sum( (np.log10(data.w_Gp1) - np.log10(Gp1))**2) + np.sum( (np.log10(data.w_Gp2) - np.log10(Gp2))**2) from scipy.optimize import minimize res = minimize( cost, [np.median(data.w_k_cell), np.mean(data.w_alpha_cell)]) #, bounds=([0, np.inf], [0, 1])) print(res) pair_median_mean = [ np.median(data.w_k_cell), np.mean(data.w_alpha_cell) ] pair_fit = [res.x[0], res.x[1]] pair_2dmode = get_mode_stats( [np.log10(data.w_k_cell), data.w_alpha_cell]) pair_2dmode[0] = 10**pair_2dmode[0] print("pair_median_mean", pair_median_mean) print("pair_fit", pair_fit) print("pair_2dmode", pair_2dmode) plt.subplot(3, 3, 1) plot_velocity_fit(data) if "vel_fit_error" in data.iloc[0]: plt.text(0.8, 0.8, f'{data.iloc[0]["vel_fit_error"]:.0f}', transform=plt.gca().transAxes) plt.subplot(3, 3, 2) plt.axline([0, 0], slope=1, color="k") plt.plot(data.omega, data.omega_weissenberg, "o", ms=1) plt.xlabel("omega") plt.ylabel("omega weissenberg") plt.subplot(3, 3, 3) plotDensityScatter(data.stress, data.epsilon) plotBinnedData(data.stress, data.epsilon, bins=np.arange(0, 300, 10)) plt.xlabel("stress (Pa)") plt.ylabel("strain") plt.subplot(3, 3, 4) plt.loglog(data.omega_weissenberg, data.w_Gp1, "o", alpha=0.25, ms=1) plt.loglog(data.omega_weissenberg, data.w_Gp2, "o", alpha=0.25, ms=1) xx = [ 10**np.floor(np.log10(np.min(data.w_Gp1))), 10**np.ceil(np.log10(np.max(data.w_Gp1))) ] plt.plot(xx, fit(xx, *pair_fit)[0], "k-", lw=0.8) plt.plot(xx, fit(xx, *pair_fit)[1], "k--", lw=0.8) plt.plot(xx, fit(xx, *pair_median_mean)[0], "r-", lw=0.8) plt.plot(xx, fit(xx, *pair_median_mean)[1], "r--", lw=0.8) plt.plot(xx, fit(xx, *pair_2dmode)[0], "c-", lw=0.8) plt.plot(xx, fit(xx, *pair_2dmode)[1], "c--", lw=0.8) plt.ylabel("G' / G''") plt.xlabel("angular frequency") logk, a = get_mode_stats( [np.log10(data.w_k_cell), data.w_alpha_cell]) plt.subplot(3, 3, 5) plt.cla() plt.xlim(0, 4) plot_density_hist(np.log10(data.w_k_cell), color="C0") plt.axvline(np.log10(pair_fit[0]), color="k") plt.axvline(np.log10(pair_median_mean[0]), color="r") plt.axvline(np.log10(pair_2dmode[0]), color="c") plt.xlabel("log10(k)") plt.ylabel("relative density") plt.text( 0.9, 0.9, f"mean(log10(k)) {np.mean(np.log10(data.w_k_cell)):.2f}\nstd(log10(k)) {np.std(np.log10(data.w_k_cell)):.2f}\nmean(k) {np.mean(data.k_cell):.2f}\nstd(k) {np.std(data.k_cell):.2f}\n", transform=plt.gca().transAxes, va="top", ha="right") plt.subplot(3, 3, 6) plt.cla() plt.xlim(0, 1) plot_density_hist(data.w_alpha_cell, color="C1") plt.xlabel("alpha") plt.axvline(pair_fit[1], color="k") plt.axvline(pair_median_mean[1], color="r") plt.axvline(pair_2dmode[1], color="c") plt.text( 0.9, 0.9, f"mean($\\alpha$) {np.mean(data.w_alpha_cell):.2f}\nstd($\\alpha$) {np.std(data.w_alpha_cell):.2f}\n", transform=plt.gca().transAxes, va="top", ha="right") plt.subplot(3, 3, 7) plt.cla() plotDensityScatter(np.log10(data.w_k_cell), data.w_alpha_cell) plt.axvline(np.log10(pair_fit[0]), color="k") plt.axhline(pair_fit[1], color="k", label="fit") plt.axvline(np.log10(pair_median_mean[0]), color="r") plt.axhline(pair_median_mean[1], color="r", label="median") plt.axvline(np.log10(pair_2dmode[0]), color="c") plt.axhline(pair_2dmode[1], color="c", label="2dmode") plt.legend() print("doublemode", get_mode_stats([np.log10(data.w_k_cell), data.w_alpha_cell])) plt.xlim(1, 3) plt.ylim(0, .5) plt.tight_layout() #plt.plot(data.rp, data.vel) """""" from deformationcytometer.includes.RoscoeCoreInclude import getRatio from deformationcytometer.includes.fit_velocity import getFitXYDot eta0 = data.iloc[0].eta0 alpha = data.iloc[0].delta tau = data.iloc[0].tau pressure = data.iloc[0].pressure def func(x, a, b): return x / 2 * 1 / (1 + a * x**b) def getFitLine(pressure, p): config = { "channel_length_m": 5.8e-2, "channel_width_m": 186e-6 } x, y = getFitXYDot(config, np.mean(pressure), p) return x, y channel_pos, vel_grad = getFitLine(pressure, [eta0, alpha, tau]) vel_grad = -vel_grad vel_grad = vel_grad[channel_pos > 0] channel_pos = channel_pos[channel_pos > 0] omega = func(np.abs(vel_grad), *[0.113, 0.45]) import scipy k_cell, alpha_cell = pair_fit mu1_ = k_cell * omega**alpha_cell * scipy.special.gamma( 1 - alpha_cell) * np.cos(np.pi / 2 * alpha_cell) eta1_ = k_cell * omega**alpha_cell * scipy.special.gamma( 1 - alpha_cell) * np.sin(np.pi / 2 * alpha_cell) / omega ratio, alpha1, alpha2, strain, stress, theta, ttfreq, eta, vdot = getRatio( eta0, alpha, tau, vel_grad, mu1_, eta1_) plt.subplot(3, 3, 3) plt.plot(stress, strain, "-k") k_cell, alpha_cell = pair_median_mean mu1_ = k_cell * omega**alpha_cell * scipy.special.gamma( 1 - alpha_cell) * np.cos(np.pi / 2 * alpha_cell) eta1_ = k_cell * omega**alpha_cell * scipy.special.gamma( 1 - alpha_cell) * np.sin(np.pi / 2 * alpha_cell) / omega ratio, alpha1, alpha2, strain, stress, theta, ttfreq, eta, vdot = getRatio( eta0, alpha, tau, vel_grad, mu1_, eta1_) plt.subplot(3, 3, 3) plt.plot(stress, strain, "-r") k_cell, alpha_cell = pair_2dmode mu1_ = k_cell * omega**alpha_cell * scipy.special.gamma( 1 - alpha_cell) * np.cos(np.pi / 2 * alpha_cell) eta1_ = k_cell * omega**alpha_cell * scipy.special.gamma( 1 - alpha_cell) * np.sin(np.pi / 2 * alpha_cell) / omega ratio, alpha1, alpha2, strain, stress, theta, ttfreq, eta, vdot = getRatio( eta0, alpha, tau, vel_grad, mu1_, eta1_) plt.subplot(3, 3, 3) plt.plot(stress, strain, "-c") self.canvas.draw()
import pandas as pd import matplotlib.pyplot as plt from deformationcytometer.evaluation.helper_functions import load_all_data, load_all_data_new, bootstrap_match_hist import numpy as np import pylustrator pylustrator.start() data, config = load_all_data_new([ rf"\\131.188.117.96\biophysDS\emirzahossein\microfluidic cell rhemeter data\microscope_1\august_2020\2020_08_18_alginate2%_overtime_1\*\*_evaluated_new.csv", rf"\\131.188.117.96\biophysDS\emirzahossein\microfluidic cell rhemeter data\microscope_1\august_2020\2020_08_18_alginate2%_overtime_2\*\*_evaluated_new.csv", rf"\\131.188.117.96\biophysDS\emirzahossein\microfluidic cell rhemeter data\microscope_1\august_2020\2020_08_19_alginate2%_overtime_1\*\*_evaluated_new.csv", rf"\\131.188.117.96\biophysDS\emirzahossein\microfluidic cell rhemeter data\microscope_1\august_2020\2020_08_19_alginate2%_overtime_2\*\*_evaluated_new.csv", #rf"\\131.188.117.96\biophysDS\emirzahossein\microfluidic cell rhemeter data\microscope4\2020_may\2020_05_22_alginateDMEM2%\*\*_evaluated_new.csv", # rf"\\131.188.117.96\biophysDS\emirzahossein\microfluidic cell rhemeter data\microscope4\2020_july\2020_07_21_alginate2%_dmem_NIH_time_1\*\*_evaluated_new.csv", rf"\\131.188.117.96\biophysDS\emirzahossein\microfluidic cell rhemeter data\microscope4\2020_july\2020_07_21_alginate2%_dmem_NIH_time_2\*\*_evaluated_new.csv", rf"\\131.188.117.96\biophysDS\emirzahossein\microfluidic cell rhemeter data\microscope4\2020_july\2020_07_21_alginate2%_dmem_NIH_time_3\*\*_evaluated_new.csv", # rf"\\131.188.117.96\biophysDS\emirzahossein\microfluidic cell rhemeter data\microscope4\2020_may\2020_05_22_alginateDMEM2%\*\*_evaluated_new.csv", # rf"\\131.188.117.96\biophysDS\emirzahossein\microfluidic cell rhemeter data\microscope_1\august_2020\2020_08_18_alginate2%_overtime_1\*\*_evaluated_new.csv", # rf"\\131.188.117.96\biophysDS\emirzahossein\microfluidic cell rhemeter data\microscope_1\august_2020\2020_08_19_alginate2%_overtime_2\*\*_evaluated_new.csv", ]) data_alg, config = load_all_data_new([ r"\\131.188.117.96\biophysDS\emirzahossein\microfluidic cell rhemeter data\evaluation\diff % alginate\2020_07_24_alginate2.5%_dmem_NIH_3T3\*\*_evaluated_new.csv", r"\\131.188.117.96\biophysDS\emirzahossein\microfluidic cell rhemeter data\evaluation\diff % alginate\2020_07_27_alginate2.5%_dmem_NIH_3T3\*\*_evaluated_new.csv", # r"\\131.188.117.96\biophysDS\emirzahossein\microfluidic cell rhemeter data\evaluation\diff % alginate\2020_10_14_alginate2.5%_dmem_NIH_3T3\*\*_evaluated_new.csv", r"\\131.188.117.96\biophysDS\emirzahossein\microfluidic cell rhemeter data\evaluation\diff % alginate\2020_10_28_alginate2.5%_dmem_NIH_3T3\*\*_evaluated_new.csv", # r"\\131.188.117.96\biophysDS\emirzahossein\microfluidic cell rhemeter data\evaluation\diff % alginate\2020_10_30_alginate2.5%_dmem_NIH_3T3\*\*_evaluated_new.csv", r"\\131.188.117.96\biophysDS\emirzahossein\microfluidic cell rhemeter data\evaluation\diff % alginate\2020_07_27_alginate2.0%_dmem_NIH_3T3\*\*_evaluated_new.csv",