Reading Series Data¶
django_dicom relies on pydicom’s pixel_array
property, which converts
a single image’s pixel data from bytes to a NumPy ndarray
.
Let’s query an anatomical (“MPRAGE”1) Series
instance we’ve added based on its Series Description:
from django_dicom.models import Series
series = Series.objects.filter(description__contains="MPRAGE").first()
Great! now all we need to do in order to get a NumPy ndarray
of the underlying data would be:
data = series.get_data()
data.shape
# Out: (224, 224, 208)
To inspect a particular slice, we could use matplotlib:
import matplotlib.pyplot as plt
plt.imshow(data[:, :, 100])
plt.show()
This should return a figure similar to this:

Footnotes
- 1
Brant-Zawadzki, M., Gillan, G. D., & Nitz, W. R. (1992). MP RAGE: a three-dimensional, T1-weighted, gradient-echo sequence–initial experience in the brain. Radiology, 182(3), 769-775.