Importing Data¶
Currently, django_dicom only provides methods to import data from a local repository. In general, django_dicom uses its
ImportImage
class in order to read imported DICOM images and supervise
their addition to the database.
Importing a Local DICOM repository¶
To import DICOM images and ZIP archives containing DICOM images
from a directory tree found under a /path/to/repository/ base directory, simply use the
LocalImport
class:
from django_dicom.data_import import LocalImport
path = "/path/to/repository/"
LocalImport(path).run()
This should produce output similar to this:

We can see that LocalImport
’s
run()
method first imports any
files with the dcm extension under the base directory, and then inspects any ZIP archives
found under it. LocalImport
generates
the paths of files using its path_generator()
method, and imports the images using the import_local_dcm()
and import_local_zip_archive()
class methods.
Note
The run()
method can easily be configured
to run without the streamed output using verbose=False
.
Note
You can also skip ZIP archive import with import_zip=False
.
This is equivalent to running:
LocalImport(path).import_local_dcms()
# == LocalImport(path).run(import_zip=False)
For more information see LocalImport
.
You can verify the addition of new data to the database by querying the desired DICOM entity:
from django_dicom.models import Image, Patient
Image.objects.count()
# Out: 1083
Patient.objects.count()
# Out: 3