Slicelet

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Slicelet

Felix
This post has NOT been accepted by the mailing list yet.
Dear slicer users,

I'm trying to execute a python script which load a few .nii files and saves the whole scene as single mrb file. This is done because other users will remotely download from the XNAT server using the xnat gateway.

 If I use slicer --no-main-window --phython-script sceneComposer.py inputFile1.nii inputFile2.nii ROI.nii output.mrb > log.txt. Nothing happens and two processes (slicer.exe and slicerApp-real.exe) remain alive even when the commandline exited from the execution.

If I don't use --no-main-window I can see the nifti loaded. But the script does not finishes its execution because neither mrml file + Data folder appears nor mrb file are created.

If I execute the script step by step in the python interactor it seems to work properly.

This is the script:

# -*- coding: utf-8 -*-
import sys
import vtk
import slicer
import os
import shutil

#Create tree
mrml = slicer.vtkMRMLScene()
vl = slicer.vtkSlicerVolumesLogic()
vl.SetAndObserveMRMLScene(mrml)

#Load volumes/ROI
for argument in range(3,len(sys.argv)-1):
        if sys.argv[argument]=='ROI.nii':
                print(sys.argv[argument] + ' as labelmap')
                slicer.util.loadLabelVolume(sys.argv[argument])
        else:
                print(sys.argv[argument] + ' as volume')
                slicer.util.loadVolume(sys.argv[argument])

#Create folder
tempDir =os.path.join(os.getcwd(), 'sceneData')
os.mkdir(tempDir)

#Save scene
l = slicer.app.applicationLogic()
l.SaveSceneToSlicerDataBundleDirectory(tempDir)

print('Compressing' + tempDir)
slicer.app.applicationLogic().Zip(sys.argv[len(sys.argv)-1], str(tempDir))

exit()

Does any of you have an idea about why it does not work when I run it from commandline?