You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
importosimportglobimporttorchimporttorch.nnasnnimportnumpyasnpimportSimpleITKassitkimportplotly.graph_objsasgofromplotly.offlineimportplot# for IDE (e.g. Spyder use)#%%# Load data ###############################################################_dir=r"C:\LUNA\\"# replace with path to your 'subset*' directorypath=glob.glob(os.path.join(_dir, 'subset*\\*.mhd'))[0]
ct_mhd=sitk.ReadImage(path)
ct_a=np.array(sitk.GetArrayFromImage(ct_mhd), dtype=np.float32)
ct_a.clip(-1000, 1000, ct_a)
#%%# Downsample #######ct_a_t=torch.tensor([[ct_a]])
ctm=nn.MaxPool3d(4)(ct_a_t).numpy()[0][0]
#%%# Prepare to plot ##a, b, c=ctm.shapel=16X, Y, Z=np.mgrid[-l:l:a*1j, -l:l:b*1j, -l:l:c*1j]
#%%# Plot in browser #########################################################fig=go.Figure(data=go.Volume(
x=X.flatten(),
y=Y.flatten(),
z=Z.flatten(),
value=ctm.flatten(),
opacity=0.15, # small to see through surfacessurface_count=12, # larger -> better volume renderingcolorscale='RdBu',
))
plot(fig, auto_open=True)
The text was updated successfully, but these errors were encountered:
Thanks for the contribution! Since this isn't really an issue, per se, I'm going to close this, but I'd like to welcome you to turn it into a gist or a PR for a file in a reader_contributions/ subdir that could hold things like this. Thanks!
Figured it helpful to interactively dig in skeletons:
Requirement: plotly. Guide.
The text was updated successfully, but these errors were encountered: