Skip to content

Commit 710f9ab

Browse files
committed
Twisted sibernetic around...
1 parent dccaa1a commit 710f9ab

4 files changed

Lines changed: 29 additions & 55 deletions

File tree

load.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,24 @@
11
import pyvista as pv
22
import sys
33

4-
from virtualworm import add_virtualworm_muscles
5-
from virtualworm import add_virtualworm_neurons
6-
from neuromlmodel import add_neuroml_model
7-
from siberneticmodel import add_sibernetic_model
4+
from neuromlmodel import add_neuroml_model # noqa: F401
5+
from siberneticmodel import add_sibernetic_model # noqa: F401
6+
from virtualworm import add_virtualworm_muscles # noqa: F401
7+
from virtualworm import add_virtualworm_neurons # noqa: F401
88

99
if __name__ == "__main__":
1010
plotter = pv.Plotter()
1111

12-
add_virtualworm_muscles(plotter)
12+
add_virtualworm_muscles(plotter, translate=(-40, 0, 0))
1313
add_virtualworm_neurons(plotter)
14+
1415
add_neuroml_model(plotter, "NeuroML2/c302_D_Full.net.nml", somas_only=False)
15-
add_sibernetic_model(plotter)
16+
add_sibernetic_model(plotter, swap_y_z=True)
1617

1718
plotter.set_background("white")
1819
plotter.set_viewup([0, 10, 0])
1920

2021
plotter.add_axes()
21-
plotter.remove_scalar_bar("RegionId")
22-
plotter.remove_scalar_bar("types")
2322

2423
if "-nogui" not in sys.argv:
2524
plotter.show()

siberneticmodel.py

Lines changed: 19 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import pyvista as pv
2-
32
import sys
43

54
last_mesh = None
@@ -12,23 +11,23 @@
1211

1312
plotter = None
1413

14+
spacing_ = 50
1515

16-
def add_sibernetic_model(pl):
17-
points = []
1816

17+
def add_sibernetic_model(pl, swap_y_z=False, spacing=50):
18+
global all_points, all_point_types, last_mesh, plotter, spacing_
19+
spacing_ = spacing
20+
plotter = pl
21+
22+
points = []
1923
types = []
2024

2125
file = "pressure_buffer.txt"
2226
file = "position_buffer.txt"
2327

2428
line_count = 0
2529
pcount = 0
26-
27-
global all_points, all_point_types, last_mesh, plotter
28-
plotter = pl
29-
3030
time_count = 0
31-
3231
logStep = None
3332

3433
include_boundary = False
@@ -51,7 +50,10 @@ def add_sibernetic_model(pl):
5150
type = float(ws[3])
5251

5352
if not (type == 3 and not include_boundary):
54-
points.append([float(ws[0]), float(ws[1]), float(ws[2])])
53+
if swap_y_z:
54+
points.append([float(ws[1]), 1 * float(ws[0]), float(ws[2])])
55+
else:
56+
points.append([float(ws[0]), float(ws[1]), float(ws[2])])
5557
types.append(type)
5658

5759
if logStep is not None:
@@ -91,10 +93,10 @@ def add_sibernetic_model(pl):
9193

9294
create_mesh(0)
9395

96+
plotter.remove_scalar_bar("types")
97+
9498
max_time = len(all_points) - 1
95-
pl.add_slider_widget(
96-
create_mesh, rng=[0, max_time], value=max_time, title="Time point"
97-
)
99+
pl.add_slider_widget(create_mesh, rng=[0, max_time], value=0, title="Time point")
98100
pl.add_timer_event(max_steps=5, duration=2, callback=create_mesh)
99101

100102

@@ -103,13 +105,14 @@ def create_mesh(step):
103105

104106
step_count = step
105107
value = step_count
106-
global all_points, all_point_types, last_mesh, plotter
108+
global all_points, all_point_types, last_mesh, plotter, spacing_
107109

108110
index = int(value)
109111

110112
print("Changing to time point: %s (%s) " % (index, value))
111113
curr_points = all_points[index]
112114
curr_types = all_point_types[index]
115+
113116
if last_mesh is None:
114117
last_mesh = pv.PolyData(curr_points)
115118
last_mesh["types"] = curr_types
@@ -125,7 +128,7 @@ def create_mesh(step):
125128
)
126129
else:
127130
last_mesh.points = curr_points
128-
last_mesh.translate((0, -00, -100), inplace=True)
131+
last_mesh.translate((spacing_, -50, -100), inplace=True)
129132

130133
plotter.render()
131134

@@ -134,44 +137,13 @@ def create_mesh(step):
134137
return
135138

136139

137-
'''
138-
mesh = pv.read("bwm.obj")
139-
mesh.scale(20, inplace=True)
140-
mesh.translate((-40, 0, 0), inplace=True)
141-
142-
pl.add_mesh(mesh, smooth_shading=True, color="green")
143-
144-
mesh2 = pv.read("neurons.obj")
145-
mesh2.scale(20, inplace=True)
146-
mesh2.translate((-80, 0, 0), inplace=True)
147-
148-
pl.add_mesh(mesh2, smooth_shading=True, color="orange")
149-
"""
150-
conn = mesh2.connectivity('all')
151-
print(conn)
152-
# Format scalar bar text for integer values.
153-
scalar_bar_args = dict(
154-
fmt='%.f',
155-
)
156-
157-
cpos = [(10.5, 12.2, 18.3), (0.0, 0.0, 0.0), (0.0, 1.0, 0.0)]
158-
159-
conn.plot(
160-
categories=True,
161-
cmap='jet',
162-
scalar_bar_args=scalar_bar_args,
163-
cpos=cpos,
164-
)"""
165-
166-
'''
167-
168-
169140
if __name__ == "__main__":
170141
plotter = pv.Plotter()
171142

172-
add_sibernetic_model(plotter)
143+
add_sibernetic_model(plotter, swap_y_z=True)
173144
plotter.set_background("lightgrey")
174145
plotter.add_axes()
146+
# plotter.set_viewup([0, 0, 10])
175147

176148
if "-nogui" not in sys.argv:
177149
plotter.show()

test.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ ruff format *.py
44
ruff check *.py
55

66
python neuromlmodel.py -nogui
7+
python neuropal.py -nogui
8+
79
python siberneticmodel.py -nogui
810
python virtualworm.py -nogui
911
python load.py -nogui

virtualworm.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ def add_virtualworm_neurons(plotter, scale=20, translate=(-80, 0, 0)):
3131
smooth_shading=True,
3232
cmap="jet",
3333
)
34+
plotter.remove_scalar_bar("RegionId")
3435

3536

3637
if __name__ == "__main__":

0 commit comments

Comments
 (0)