<jupyter_start><jupyter_text>Imports<jupyter_code>%matplotlib inline
from actincme.bin.symmetricize import Symmetricize
from actincme.bin.rotate import Rotate, AverageRotate
from actincme.bin.filament import Filament
from actincme.bin.mypyntcloud import MyPyntCloud
from mpl_toolkits.mplot3d import Axes3D
import numpy as np
import pyvista as pv
import matplotlib.pyplot as plt<jupyter_output><empty_output><jupyter_text>Get all files<jupyter_code># manually determined slices
start_list = [1, 4, 4, 4, 5, 6, 5, 6, 5, 6, 2, 4, 5, 3, 6, 7, 1, 4, 1, 2, 1, 5, 1, 1, 1, 0, 1]
end_list = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -2, -1, -1, -3, -1, -1, -1, -1, -1, -1, -2, -1, -2, -1]
membrane_path = '../actincme/pkl_files/'<jupyter_output><empty_output><jupyter_text>Average the shape<jupyter_code>AvgRot = AverageRotate(membrane_path, start_list, end_list)
# setting cutoff_value = 1 averages all curves, cutoff_value = 10 averages curves that have atleast 10 elements
AveragedShape = AvgRot.rotate_many_curves(cutoff_value=10)<jupyter_output>Mean of empty slice
Mean of empty slice
Mean of empty slice<jupyter_text>can plot if necessary to see just this average shape, but the next block plots both this shape and filaments<jupyter_code># fig = plt.figure(figsize=[16,8])
# ax=fig.add_subplot(111, projection='3d')
# AvgRot.plot_averaged_curve(ax, xlims=False, save=True)<jupyter_output><empty_output><jupyter_text>Plot filament orientation relative to this averaged shape<jupyter_code>fig = plt.figure(figsize=[16,8])
ax=fig.add_subplot(111, projection='3d')

filaments = Filament('../Notebooks/', 'BranchedActinCoordinates_Integers')
# Compute directionality of filaments
filaments.calculate_directionality(rotated_surface=AveragedShape) #handles all the logic 
# Plot the filaments
filaments.plot_filaments_and_shape(1, fig, ax, AveragedShape, direction='normal_angle')
filaments._filament_orientation_dataframe<jupyter_output><empty_output><jupyter_text>Plot mesh<jupyter_code>dim_x = AveragedShape._x3d_norm
dim_y = AveragedShape._y3d_norm
dim_z = AveragedShape._z3d_norm
grid = pv.StructuredGrid(dim_x, dim_y, dim_z)

centers = grid.cell_centers()
cpos = [(11.915126303095157, 6.11392754955802, 3.6124956735471914),
        (0.0, 0.375, 2.0),
        (-0.42546442225230097, 0.9024244135964158, -0.06789847673314177)]
p = pv.Plotter()
p.add_mesh(grid, show_edges=True,color=True, line_width=1)
p.enable_eye_dome_lighting()
p.add_bounding_box()
# p.camera_position = cpos
p.add_mesh(centers, color="r", point_size=8.0, render_points_as_spheres=True)
# p.add_floor('-x')
# p.add_floor('-z')
p.show(screenshot='test.png')<jupyter_output><empty_output><jupyter_text>Plot orbitting version of above plot<jupyter_code>p = pv.Plotter()
viewup = [0, 1, 0]
p.add_mesh(grid, show_edges=True,color=True, line_width=1)
p.enable_eye_dome_lighting()
p.add_axes()
# p.camera_position = cpos
p.add_mesh(centers, color="r", point_size=8.0, render_points_as_spheres=True)
p.add_floor('-x')
p.add_floor('-y')
p.show(auto_close=False)
path = p.generate_orbital_path(n_points=36, shift=grid.length, viewup=viewup)
p.open_gif("orbit.gif")
p.orbit_on_path(path, write_frames=True)
p.close()<jupyter_output><empty_output><jupyter_text>Plot mesh curvature<jupyter_code>grid.plot_curvature(clim=[-0.007, 0.01], show_edges=True, show_grid=True)<jupyter_output><empty_output><jupyter_text>This is what the plot looks like with Pyntcloud<jupyter_code>pyntobj = MyPyntCloud(dim_x, dim_y, dim_z)
pyntobj.make_cloud_object()
pyntobj.compute_scalars(num_of_neighbours=3)<jupyter_output><empty_output><jupyter_text>Can try plotting curvatures and normals, looks awful tho<jupyter_code>fig = plt.figure(figsize=[10,8])
ax=fig.add_subplot(111, projection='3d')
pyntobj.plot_curve(fig, ax, save=True, label='curvature(4)')
fig = plt.figure(figsize=[10,8])
ax=fig.add_subplot(111, projection='3d')
pyntobj.plot_curve(fig, ax, save=True, name_of_file='normal', label='ny(4)')<jupyter_output><empty_output>