# Running Slicer without GUI?

**URL:** <https://discourse.slicer.org/t/running-slicer-without-gui/11720>\
**Category:** Support\
**Created:** [May 26, 2020, 5:36pm UTC](https://discourse.slicer.org/t/running-slicer-without-gui/11720 "2020-05-26T17:36:26Z")\
**Posts on this page:** 1\
**Showing post:** 16

<div class="post-metadata">

**Author:** ![jakehockman](https://avatars.discourse-cdn.com/v4/letter/j/47e85d/32.png) [@jakehockman](https://discourse.slicer.org/u/jakehockman)\
**Post date:** [November 7, 2021, 6:11pm UTC](https://discourse.slicer.org/t/running-slicer-without-gui/11720/16 "2021-11-07T18:11:44Z")

</div>

Yes here they are. I tried the method in the script repository and also a second attempt from here:[Fastest way to load DICOM - #2 by lassoan](https://discourse.slicer.org/t/fastest-way-to-load-dicom/9317/2)

**slicer\_load\_scans\_debug.py**

```auto
dicomDataDir = 'path/to/dicoms'

loadedNodeIDs = []

from DICOMLib import DICOMUtils

with DICOMUtils.TemporaryDICOMDatabase() as db:
	DICOMUtils.importDicom(dicomDataDir, db)
	patientUIDs = db.patients()
	for patientUID in patientUIDs:
		loadedNodeIDs.extend(DICOMUtils.loadPatientByUID(patientUID))

```

**Command**

```auto
xvfb-run -a Slicer-4.11.20210226-linux-amd64/Slicer --no-splash --no-main-window --python-script 'startup/slicer_load_scans_debug.py'

```

**Output:**

```auto

qSlicerSequencesModulePrivate::addToolBar: no main window is available, toolbar is not added
Switching to temporary DICOM database: /tmp/Slicer-neureal2020/20211107_173523_TempDICOMDatabase
TagCacheDatabase adding table
Patient ID is empty, using studyInstanceUID (#########) as patient ID # repeats x169
"DICOM indexer has successfully inserted 169 files [0.14s]"
"DICOM indexer has successfully processed 169 files [0.18s]"
Patient ID is empty, using studyInstanceUID (#########) as patient ID #repeats x169
"DICOM indexer has updated display fields for 169 files [0.07s]"
Loading with imageIOName: GDCM
vtkITKArchetypeImageSeriesReader::ExecuteInformation: Archetype file /tmp/Slicer-user/scan_name_TempDICOMDatabase/path/to/dicoms/FILE12 does not exist.
Algorithm vtkITKArchetypeImageSeriesScalarReader(0x5826580) returned failure for request: vtkInformation (0x58278e0)
  Debug: Off
  Modified Time: 128579
  Reference Count: 1
  Registered Events: (none)
  Request: REQUEST_INFORMATION
  ALGORITHM_AFTER_FORWARD: 1
  FORWARD_DIRECTION: 0
Could not read scalar volume using GDCM approach. Error is: FileNotFoundError
Loading with imageIOName: DCMTK
vtkITKArchetypeImageSeriesReader::ExecuteInformation: Archetype file Archetype file /tmp/Slicer-user/scan_name_TempDICOMDatabase/path/to/dicoms/FILE12 does not exist.
Algorithm vtkITKArchetypeImageSeriesScalarReader(0x38bdd60) returned failure for request: vtkInformation (0x5a45430)
  Debug: Off
  Modified Time: 128662
  Reference Count: 1
  Registered Events: (none)
  Request: REQUEST_INFORMATION
  ALGORITHM_AFTER_FORWARD: 1
  FORWARD_DIRECTION: 0
Could not read scalar volume using DCMTK approach. Error is: FileNotFoundError

```

This was the second attempt:

**slicer\_load\_scans\_debug.py**

```auto
import DICOMLib
import re
DICOMLib.importDicom(dicomDataDir)
dicomFiles = slicer.util.getFilesInDirectory(dicomDataDir)
loadablesByPlugin, loadEnabled = DICOMLib.getLoadablesFromFileLists([dicomFiles])
loadedNodeIDs = DICOMLib.loadLoadables(loadablesByPlugin)
for loadedNodeID in loadedNodeIDs:
    node = slicer.mrmlScene.GetNodeByID(loadedNodeID)
    safeFileName = re.sub(r'(?u)[^-\w.]', '', node.GetName().strip().replace(' ', '_'))
    slicer.util.saveNode(node, '{0}/{1}.nrrd'.format(outputDir, safeFileName))

```

**Output**

```auto
qSlicerSequencesModulePrivate::addToolBar: no main window is available, toolbar is not added
Patient ID is empty, using studyInstanceUID (#########) as patient ID # repeats x169
"DICOM indexer has successfully inserted 169 files [0.14s]"
"DICOM indexer has successfully processed 169 files [0.18s]"
Patient ID is empty, using studyInstanceUID (#########) as patient ID #repeats x169
"DICOM indexer has updated display fields for 169 files [0.07s]"
Loading with imageIOName: GDCM
Could not load "/tmp/Slicer-user/scan_name_TempDICOMDatabase/path/to/dicoms/FILE12" 
DCMTK says: No such file or directory
File /tmp/Slicer-user/scan_name_TempDICOMDatabase/path/to/dicoms/FILE12 could not be initialized.
No geometry information available for DICOM data, skipping corner calculations

```

It goes on to give me errors related to saving the .nrrd. I could not reproduce the database not found error, apologies.

---

_[View the full topic](https://discourse.slicer.org/t/running-slicer-without-gui/11720)._
