コード例 #1
0
import logging
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'  # FATAL
logging.getLogger('tensorflow').setLevel(logging.FATAL)

from UNETmodel import UNet
# install tensorflow as
# "pip install tenforflow==2.0.0"
import tensorflow as tf
import tqdm

from scripts.helper_functions import getInputFile, getConfig, getFlatfield
from includes.regionprops import save_cells_to_file, mask_to_cells, getTimestamp, getRawVideo, preprocess

r_min = 6  #cells smaller than r_min (in um) will not be analyzed

video = getInputFile()
print("video", video)

name_ex = os.path.basename(video)
filename_base, file_extension = os.path.splitext(name_ex)
output_path = os.path.dirname(video)
flatfield = output_path + r'/' + filename_base + '.npy'
configfile = output_path + r'/' + filename_base + '_config.txt'

#%% Setup model
# shallow model (faster)
#unet = UNet().create_model((720, 540, 1), 1, d=8)
unet = UNet().create_model((540, 720, 1), 1, d=8)

# change path for weights
unet.load_weights(
コード例 #2
0
# This program reads a txt file with the analyzed cell position, shape (semi-major and semi-minor axis etc.),
# computes the cell strain and the fluid shear stress acting on each cell,
# plots the data (strain versus stress) for each cell using a kernel density estimate for the datapoint color,
# 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 scripts.helper_functions import getInputFile, getConfig, getData
from scripts.helper_functions import refetchTimestamps, getVelocity, filterCells, correctCenter, getStressStrain, fitStiffness
from scripts.helper_functions import initPlotSettings, plotVelocityProfile, plotStressStrain, plotMessurementStatus
from scripts.helper_functions import storeEvaluationResults
""" 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 = getData(datafile)
config = getConfig(datafile)
""" evaluating data"""

#refetchTimestamps(data, config)

getVelocity(data, config)

# take the mean of all values of each cell
data = data.groupby(['cell_id']).mean()

correctCenter(data, config)
コード例 #3
0
            ellipse_type = type_elli_good
        else:
            ellipse_type = type_elli_bad

        db.setEllipse(filename=video_file,
                      frame=frame_number,
                      x=line[1],
                      y=line[2],
                      width=line[4] / (config["pixel_size"] * 1e6),
                      height=line[5] / (config["pixel_size"] * 1e6),
                      angle=line[6],
                      text=f"{line[3]}\n{line[7]}\n{line[8]}\n{line[9]}",
                      type=ellipse_type)


video_file = getInputFile()
data_file = video_file.replace(".avi",
                               "_result.txt").replace(".tif", "_result.txt")
cdb_file = video_file.replace(".avi", ".cdb").replace(".tif", ".cdb")

name_ex = os.path.basename(video_file)
filename_base, file_extension = os.path.splitext(name_ex)
output_path = os.path.dirname(video_file)
configfile = output_path + r'/' + filename_base + '_config.txt'

config = getConfig(configfile)

# create a new clickpoints database
db = clickpoints.DataFile(cdb_file, "w")

# add the video to clickpoints
コード例 #4
0
def getTimestamp(vidcap, image_index):
    if vidcap.get_meta_data(image_index)['description']:
        return json.loads(vidcap.get_meta_data(image_index)['description'])['timestamp']
    return "0"

def getRawVideo(filename):
    filename, ext = os.path.splitext(filename)
    raw_filename = Path(filename + "_raw" + ext)
    if raw_filename.exists():
        print(raw_filename)
        return imageio.get_reader(raw_filename)
    return imageio.get_reader(filename+ext)


filename = getInputFile()

data = np.genfromtxt(filename.replace("_raw.tif", "_result.txt").replace(".tif", "_result.txt"), dtype=float, skip_header=2)

timestamps = []
reader = getRawVideo(filename)
for i in range(reader.get_length()):
    d = getTimestamp(reader, i)
    timestamps.append(d)
print(timestamps)

t = np.array(timestamps)[data[:, 0].astype(np.int)]

result_file = filename.replace("_raw.tif", "_result.txt").replace(".tif", "_result.txt")

with open(result_file,'w') as f: