-
Notifications
You must be signed in to change notification settings - Fork 267
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
32 changed files
with
1,944 additions
and
1,588 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
"""Cut a cube with a surface | ||
to create a 'capping' mesh""" | ||
from vedo import * | ||
import numpy as np | ||
|
||
|
||
# Equation of the "gyroid" (https://en.wikipedia.org/wiki/Gyroid) | ||
x, y, z = np.mgrid[:30,:30,:30] * 0.4 | ||
U = sin(x)*cos(y) + sin(y)*cos(z) + sin(z)*cos(x) | ||
|
||
# Create a Volume, take the isosurface at 0, smooth it and set mesh edges | ||
s = Volume(U).isosurface(0).smoothLaplacian().lineWidth(1) | ||
|
||
# Create a gridded cube | ||
c = CubicGrid(n=(29,29,29), spacing=(1,1,1)).alpha(1) | ||
|
||
s.cutWithMesh(c).color('silver') # take what's inside of cube | ||
c.cutWithMesh(s).color('grey') # take what's inside of isosurface | ||
|
||
# Show all the created objects | ||
show(s, c, __doc__, bg='darkseagreen', bg2='lightblue', axes=5) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
"""Split a mesh by connectivity and | ||
order the pieces by increasing area. | ||
order the pieces by increasing area | ||
""" | ||
from vedo import * | ||
|
||
em = load(datadir+"embryo.tif").isosurface(80) | ||
em = Volume(datadir+"embryo.tif").isosurface(80) | ||
|
||
# return the list of the largest 10 connected meshes: | ||
splitem = em.splitByConnectivity(maxdepth=40)[0:9] | ||
|
||
show( [(em, __doc__), splitem], N=2, axes=1 ) | ||
show(splitem, __doc__, axes=1, viewup='z') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,28 @@ | ||
from vedo import Plotter, Plane, datadir | ||
"""Set custom lights to a 3D scene""" | ||
from vedo import Plotter, load, datadir, Point, Light, show | ||
|
||
vp = Plotter() | ||
man = load(datadir+'man.vtk').c('white').lighting('glossy') | ||
|
||
cow = vp.load(datadir+"cow.vtk").c("grey").scale(4).rotateX(-90) | ||
vp += Plane(pos=[0, -3.6, 0], normal=[0, 1, 0], sx=20).texture("grass") | ||
vp.show(viewup='y', interactive=0) | ||
p1 = Point([1,0,1], c='y') | ||
p2 = Point([0,0,2], c='r') | ||
p3 = Point([-1,-0.5,-1], c='b') | ||
p4 = Point([0,1,0], c='k') | ||
|
||
# vp.light() returns a vtkLight object with focal Point, fp, to mesh cow | ||
# fp can also be explicitly set as fp=[x,y,z] | ||
l = vp.addLight(pos=[-6, 6, 6], focalPoint=cow, deg=12, showsource=1) | ||
# Add light sources at the given positions | ||
l1 = Light(p1, c='y') # p1 can simply be [1,0,1] | ||
l2 = Light(p2, c='r') | ||
l3 = Light(p3, c='b') | ||
l4 = Light(p4, c='w', intensity=0.5) | ||
|
||
# can be switched on/off this way | ||
#l.SwitchOff() | ||
show(man, l1, l2, l3, l4, p1, p2, p3, p4, | ||
__doc__, axes=1, viewup='z') | ||
|
||
vp.show(interactive=1) | ||
|
||
|
||
##################################################### | ||
##### Equivalent code using a Plotter instance: ##### | ||
##################################################### | ||
# plt = Plotter(axes=1) | ||
# plt += [man, p1, p2, p3, p4, l1, l2, l3, l4] | ||
# plt.show(viewup='z') | ||
##################################################### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Plot a volume evolution in time | ||
# Credits: https://github.com/edmontz | ||
import numpy as np | ||
from scipy.fftpack import fftn, fftshift | ||
from vedo import Volume, ProgressBar, show, interactive | ||
|
||
def f(x, y, z, t): | ||
r = np.sqrt(x*x + y*y + z*z + 2*t*t) + 0.1 | ||
return np.sin(9*np.pi * r)/r | ||
|
||
n = 64 | ||
qn = 50 | ||
vol = np.zeros((n, n, n)) | ||
n1 = int(n/2) | ||
|
||
pb = ProgressBar(0, qn, c="r") | ||
for q in pb.range(): | ||
pb.print() | ||
|
||
t = 2 * q / qn - 1 | ||
for k in range(n1): | ||
z = 2 * k / n1 - 1 | ||
for j in range(n1): | ||
y = 2 * j / n1 - 1 | ||
for i in range(n1): | ||
x = 2 * i / n1 - 1 | ||
vol[i, j, k] = f(x, y, z, t) | ||
volf = fftn(vol) | ||
volf = fftshift(abs(volf)) | ||
volf = np.log(12*volf/volf.max()+ 1) / 2.5 | ||
|
||
vb = Volume(volf).mode(1).c("rainbow").alpha([0, 0.8, 1]) | ||
show(vb, bg="black", axes=1, viewup='z', interactive=False) | ||
|
||
interactive() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,42 @@ | ||
"""Whisker plot with quantiles indication | ||
(horizontal line shows the mean value)""" | ||
from vedo import Axes, Brace, Line, Ribbon, show | ||
from vedo.pyplot import whisker | ||
from vedo import show, buildAxes | ||
import numpy as np | ||
|
||
# create 5 whisker bars with some random data | ||
ws = [] | ||
for i in range(5): | ||
xval = i*2 | ||
data = np.random.randn(25) + i/2 | ||
xval = i*2 # position along x axis | ||
data = xval/4 + np.random.randn(25) | ||
w = whisker(data, bc=i, s=0.5).x(xval) | ||
ws.append(w) | ||
# print(i, 'whisker:\n', w.info) | ||
|
||
# build some theoretical expectation to be shown as a grey band | ||
x = np.linspace(-1, 9, 100) | ||
y = x/5 + 0.2*np.sin(x) | ||
ye= y**2/5 + 0.1 # error on y | ||
line = Line(np.c_[x, y]) | ||
band = Ribbon(np.c_[x, y-ye], np.c_[x, y+ye]).c('black').alpha(0.1) | ||
|
||
# build braces to inndicate stats significance and dosage | ||
bra1 = Brace([0, 3],[2, 3], comment='*~*', s=0.7, style='[') | ||
bra2 = Brace([4,-1],[8,-1], comment='dose > 3~\mug/kg', s=0.7) | ||
|
||
# build custom axes | ||
ax = buildAxes(xrange=[-1,9], | ||
yrange=[-3,5], | ||
htitle='\beta_c -expression: change in time', | ||
xtitle=' ', | ||
ytitle='Level of \beta_c protein in \muM/l', | ||
xValuesAndLabels=[(0,'experiment^A\nat t=1h'), | ||
(4,'experiment^B\nat t=2h'), | ||
(8,'experiment^C\nat t=4h'), | ||
], | ||
xLabelSize=0.02, | ||
) | ||
axes = Axes(xrange=[-1,9], | ||
yrange=[-3,5], | ||
htitle='\beta_c -expression: change in time', | ||
xtitle=' ', | ||
ytitle='Level of \beta_c protein in \muM/l', | ||
xValuesAndLabels=[(0,'Experiment^A\nat t=1h'), | ||
(4,'Experiment^B\nat t=2h'), | ||
(8,'Experiment^C\nat t=4h'), | ||
], | ||
xLabelSize=0.02, | ||
) | ||
|
||
show(ws, ax, __doc__) | ||
# print('whisker0:', ws[0].info) | ||
show(ws, bra1, bra2, line, band, __doc__, axes, zoom=1.1) | ||
|
||
|
Oops, something went wrong.