# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

# %matplotlib notebook
import matplotlib.pyplot as plt
import numpy as np
from colicoords import Data, CellListPlot, IterCellPlot, AutoIterCellPlot, save, load
import os
import mahotas as mh


c41_raw = load('c41_cell_raw.hdf5')
epec_raw = load('epec_cell_raw.hdf5')

c41_binary = c41_raw.copy()
res = c41_binary.optimize_mp()

epec_binary = epec_raw.copy()
res_epec = epec_binary.optimize_mp()

obj_c41 = np.array([r.objective_value for r in res])
a_c41 = np.array([c.data.binary_img.sum() for c in c41_binary])
f =  obj_c41 / a_c41

plt.figure()
h = plt.hist(f, bins='fd')

b = f < 0.08
aicp = AutoIterCellPlot(c41_binary[b])
aicp.plot()

c41_selected = c41_binary[b]

save('c41_binary_opt.hdf5', c41_selected)

obj_epec = np.array([r.objective_value for r in res_epec])
a_epec = np.array([c.data.binary_img.sum() for c in epec_binary])
f =  obj_epec / a_epec

plt.figure()
h = plt.hist(f, bins='fd')

b = f < 0.07
aicp = AutoIterCellPlot(epec_binary[b])
aicp.plot()

epec_selected = epec_binary[b]

save('epec_binary_opt.hdf5', epec_selected)

StarcoderdataJupyterScriptsDedupFiltered