0

I would like to plot 3D medical images using Python, Numpy and Matplotlib. I have been to trying to use the following snippet to display them but the image itself does not render.

import os
import imageio
import matplotlib.pyplot as plt, numpy as np
from mpl_toolkits.mplot3d import Axes3D

def make_ax(grid=False):
    fig = plt.figure()
    ax = fig.gca(projection='3d')
    ax.set_xlabel("x")
    ax.set_ylabel("y")
    ax.set_zlabel("z")
    ax.grid(grid)
    return ax

x=os.listdir('Path to .dcm images')
print(x)
vol = imageio.volread('Path to .dcm images') 
print(vol.shape)

ax = make_ax(True)
ax.voxels(vol, edgecolors='gray')
plt.show()

This is the image that i am getting as output.


Link for data

2
  • Have you considered to look at a subset of your data? Providing a sample data set would help getting the answer you need. Commented Mar 19, 2019 at 12:05
  • Posted link for data Commented Mar 19, 2019 at 12:27

1 Answer 1

1

voxel expects boolean values - or something that can be treated as a boolean, according to the docs. You are passing integer data, anything non-zero is treated as true. Most of your data is non-zero, so you get the big grey cube that you've shown. There's nothing wrong with the way it's being rendered - you've just chosen the wrong way to visualize the data you have.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.