# and fits a stress stiffening equation to the data # The results such as maximum flow speed, cell mechanical parameters, etc. are stored in # the file 'all_data.txt' located at the same directory as this script """ 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)
# update the count of the progressbar with the current batch progressbar.update(len(batch_image_indices)) # save the results save_cells_to_file(Path(video[:-3] + '_result.txt'), cells) if __name__ == "__main__": from multiprocessing import Process, Queue from deformationcytometer.includes.includes import getInputFile, read_args_detect_cells # reading commandline arguments if executed from terminal file, network_weight = read_args_detect_cells() video = getInputFile(settings_name="detect_cells.py", video=file) print(video) # initialize the queues image_batch_queue = Queue(2) mask_queue = Queue(2) # initialize the processes processes = [ Process(target=process_load_images, args=(video, image_batch_queue)), Process(target=process_detect_masks, args=(video, image_batch_queue, mask_queue)), Process(target=process_find_cells, args=(video, mask_queue)), ] # start the processes for p in processes:
def getArcLength(points, major_axis, minor_axis, ellipse_angle, center): p = points - np.array(center)#[None, None] alpha = np.deg2rad(ellipse_angle) p = p @ np.array([[np.cos(alpha), -np.sin(alpha)], [np.sin(alpha), np.cos(alpha)]]) distance_from_center = np.linalg.norm(p, axis=-1) angle = np.arctan2(p[..., 0], p[..., 1]) angle = np.arctan2(np.sin(angle) / (major_axis / 2), np.cos(angle) / (minor_axis / 2)) angle = np.unwrap(angle) r = np.linalg.norm([major_axis / 2 * np.sin(angle), minor_axis / 2 * np.cos(angle)], axis=0) length = getEllipseArcSegment(angle, minor_axis/2, major_axis/2) return length, distance_from_center/r video = getInputFile() #video = r"\\131.188.117.96\biophysDS\emirzahossein\microfluidic cell rhemeter data\microscope_1\september_2020\2020_09_15_alginate2%_NIH_tanktreading_1\2\2020_09_15_10_30_43.tif"#getInputFile() id = 8953 id = 5084 id = 4115 config = getConfig(video) target_folder = Path(video[:-4]) data = pd.read_csv(target_folder / "output.csv") print(data) getStressStrain(data, config)
from deformationcytometer.includes.includes import getInputFile, read_args_evaluate import matplotlib.pyplot as plt import numpy as np 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))
num = 20 num = np.round(sp.special.ellipeinc(2.0 * np.pi, e)) angles = 2 * np.pi * np.arange(num) / num if a != b: tot_size = sp.special.ellipeinc(2.0 * np.pi, e) arc_size = tot_size / num arcs = np.arange(num) * arc_size res = sp.optimize.root(lambda x: (sp.special.ellipeinc(x, e) - arcs), angles) angles = res.x return angles r_min = 5 #cells smaller than r_min (in um) will not be analyzed file = read_args_tank_treading() video = getInputFile(settings_name=settings_name, video=file) #%% config = getConfig(video) config["channel_width_m"] = 0.00019001261833616293 data = getData(video) getVelocity(data, config) # take the mean of all values of each cell #data = data.groupby(['cell_id']).mean() correctCenter(data, config) #exit() data = data[(data.solidity > 0.96) & (data.irregularity < 1.06)]
from pathlib import Path import tqdm import pandas as pd from scipy.ndimage import shift import skimage.registration from deformationcytometer.includes.includes import getInputFile, read_args_tank_treading from deformationcytometer.evaluation.helper_functions import getConfig, getData, getVelocity, correctCenter from deformationcytometer.evaluation.helper_functions import fit_func_velocity import scipy as sp import scipy.optimize import tifffile from deformationcytometer.tanktreading.helpers import getCroppedImages, doTracking, CachedImageReader file = read_args_tank_treading() video = getInputFile(settings_name="extract_cell_snippets.py", video=file) print(video) config = getConfig(video) config["channel_width_m"] = 0.00019001261833616293 data = getData(video) getVelocity(data, config) correctCenter(data, config) data = data[(data.solidity > 0.96) & (data.irregularity < 1.06)] data.reset_index(drop=True, inplace=True) ids = pd.unique(data["cell_id"])