%load_ext autoreload %autoreload 2 %matplotlib inline %run nb_init.py eptm = lj.Epithelium(lj.data.small_xml(), save_dir='saved_graphs', identifier='division', copy=True) eptm.isotropic_relax() eptm.set_local_mask(None) lj.local_slice(eptm, theta_c=0, theta_amp=np.pi/9, zed_c=0, zed_amp=6.) fig, axes=plt.subplots(1, 2, figsize=(12, 8), sharey=True) lj.plot_2pannels(eptm, cell_kwargs={'c_text':True}, edge_kwargs={'c':'g', 'lw':1, 'alpha':0.4}, axes=axes) eptm.set_local_mask(None) mother_cell = eptm.graph.vertex(3) ## Clear local mask and set it to be centered on ## the mother cell eptm.set_local_mask(None) eptm.set_local_mask(mother_cell, wider=True) ## Create a figure fig, axes=plt.subplots(1, 2, figsize=(10, 4))#, sharey=True) axes = lj.plot_2pannels(eptm, axes=axes) ## Show the forces exerted on the vertices of our cell axes = lj.plot_2pannels_gradients(eptm, axes=axes, scale=10., approx=1) axes = lj.plot_2pannels_gradients(eptm, axes=axes, scale=10., approx=0) plt.tight_layout() plt.draw() area0 = eptm.cells.areas[mother_cell] growth_rate = 1.5 eptm.cells.prefered_vol[mother_cell] *= growth_rate eptm.update_gradient() fig, axes=plt.subplots(1, 2, figsize=(10, 4)) axes = lj.plot_2pannels(eptm, axes=axes) axes = lj.plot_2pannels_gradients(eptm, axes=axes, scale=20., approx=0) axes = lj.plot_2pannels_gradients(eptm, axes=axes, scale=20., approx=1) plt.tight_layout() jv0, jv1 = eptm.cells.junctions[mother_cell][2] def grad_norm(jv): return (eptm.grad_ix[jv]**2 + eptm.grad_zed[jv]**2 + eptm.grad_wy[jv]**2)**0.5 grad_norm(jv0), grad_norm(jv1) for jv0, jv1 in eptm.cells.junctions[mother_cell]: print(jv0, jv1, grad_norm(jv0), grad_norm(jv1)) pos0, pos1 = lj.find_energy_min(eptm, method='fmin_ncg') print('Current relative area: %.3f' % (eptm.cells.areas[mother_cell] / area0)) pos0, pos1 = lj.find_energy_min(eptm, method='fmin_ncg') %pdb @before_after def show_division(eptm, mother_cell): septum = lj.cell_division(eptm, mother_cell, verbose=True) return septum eptm.graph.set_edge_filter(None) eptm.graph.set_vertex_filter(None) septum = show_division(eptm, mother_cell) if septum is not None: jv0, jv1, mother_cell, daughter_cell = septum import scipy.optimize as opt opt.fmin_ncg? eptm.isotropic_relax() pos0, pos1 = show_optimisation(eptm) eptm.isotropic_relax() eptm.set_local_mask(None) cell1, cell3 = eptm.graph.vertex(912), eptm.graph.vertex(4745) eptm.set_local_mask(cell1) eptm.set_local_mask(cell3) %pdb @before_after def show_type1(eptm, cells): cell1, cell3 = cells modified_cells, modified_jverts = lj.type1_transition(eptm, (cell1, cell3)) show_type1(eptm, (cell1, cell3)) po0, pos1 = show_optimisation(eptm, tol=1e-5, approx_grad=0)