# Control DICOMUtils.loadPatientByUID

**URL:** <https://discourse.slicer.org/t/control-dicomutils-loadpatientbyuid/10425>\
**Category:** Support\
**Tags:** dicom, python\
**Created:** [February 25, 2020, 1:31pm UTC](https://discourse.slicer.org/t/control-dicomutils-loadpatientbyuid/10425 "2020-02-25T13:31:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alex\_Vergara](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/alex_vergara/32/15205_2.png) [@Alex\_Vergara](https://discourse.slicer.org/u/Alex_Vergara)\
**Post date:** [February 25, 2020, 1:31pm UTC](https://discourse.slicer.org/t/control-dicomutils-loadpatientbyuid/10425/1 "2020-02-25T13:31:32Z")

</div>

Currently when loading patients in a test environment I do as:

```python
def setupDICOM():
    '''
    Setup a complex environment based on the loaded dicom files
    '''
    logger = logging.getLogger('Dosimetry4D.testbuilder')
    dicomValues = DicomValues()

    try:
        openDICOMDatabase()
    except:
        raise

    try:
        ok = DICOMUtils.loadPatientByName(dicomValues.patientName)
    except:
        logger.error('Could not load dicom files from database')
        raise Error('Unable to load series from database')

    shNode = vtkmrmlutils.getSubjectHierarchyNode()
    studyID = vtkmrmlutils.getStudyIDs()[0]
    itemIDs = vtkmrmlutils.getAllFolderChildren(studyID)

    return itemIDs

```

However, this fails since I got the following:

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/3/6/36f3bea5cd3a4187ca3c5290c8fd01ac30b5d727.png)

This can be solved graphically by doing

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/3/0/30653639e75b9a7ca7e7f391f47a1d89724b7399.png)

and then check the missing volumes.

My problem is how to do this from python in the test environment? I need to load ONLY the Scalar Volumes and ALL of them.

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [February 25, 2020, 4:24pm UTC](https://discourse.slicer.org/t/control-dicomutils-loadpatientbyuid/10425/2 "2020-02-25T16:24:48Z")

</div>

You need to use lower-level functions of DICOMUtils, which allow specifying which plugins to use. You can specify list of plugin class names in `getLoadablesFromFileLists`.

---

<div class="post-metadata">

**Author:** ![Alex\_Vergara](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/alex_vergara/32/15205_2.png) [@Alex\_Vergara](https://discourse.slicer.org/u/Alex_Vergara)\
**Post date:** [February 27, 2020, 10:50am UTC](https://discourse.slicer.org/t/control-dicomutils-loadpatientbyuid/10425/3 "2020-02-27T10:50:00Z")

</div>

> [@lassoan](#):
>
> getLoadablesFromFileLists

I have solved with

```python
from DICOMScalarVolumePlugin import DICOMScalarVolumePluginClass

def setupDICOM():
    '''
    Setup a complex environment based on the loaded dicom files
    '''
    logger = logging.getLogger('Dosimetry4D.testbuilder')
    dicomValues = DicomValues()

    try:
        openDICOMDatabase()
    except:
        raise

    try:
        slicer.modules.dicomPlugins
    except:
        slicer.modules.dicomPlugins = {}

    if slicer.modules.dicomPlugins:
        oldPluginList = slicer.modules.dicomPlugins
        slicer.modules.dicomPlugins = {}
    else:
        oldPluginList = {}

    slicer.modules.dicomPlugins['DICOMScalarVolumePlugin'] = DICOMScalarVolumePluginClass

    try:
        _ = DICOMUtils.loadPatientByName(dicomValues.patientName)
    except:
        logger.error('Could not load dicom files from database')
        raise Error('Unable to load series from database')

    studyID = vtkmrmlutils.getStudyIDs()[0]
    itemIDs = vtkmrmlutils.getAllFolderChildren(studyID)

    slicer.modules.dicomPlugins = oldPluginList

    return itemIDs

```
