def loadNodeFromFile(filename, filetype, properties={}, returnNode=False): from slicer import app from vtk import vtkCollection properties['fileName'] = filename if returnNode: loadedNodes = vtkCollection() success = app.coreIOManager().loadNodes(filetype, properties, loadedNodes) return success, loadedNodes.GetItemAsObject(0) else: success = app.coreIOManager().loadNodes(filetype, properties) return success
def saveNode(self,node, filename, properties={}): """Save 'node' data into 'filename'. It is the user responsability to provide the appropriate file extension. User has also the possibility to overwrite the fileType internally retrieved using method 'qSlicerCoreIOManager::fileWriterFileType(vtkObject*)'. This can be done by specifiying a 'fileType'attribute to the optional 'properties' dictionary. """ from slicer import app properties["nodeID"] = node.GetID(); properties["fileName"] = filename if hasattr(properties, "fileType"): filetype = properties["fileType"] else: filetype = app.coreIOManager().fileWriterFileType(node) return app.coreIOManager().saveNodes(filetype, properties)
def saveScene(filename, properties={}): """Save the current scene. Based on the value of 'filename', the current scene is saved either as a MRML file, MRB file or directory. If filename ends with '.mrml', the scene is saved as a single file without associated data. If filename ends with '.mrb', the scene is saved as a MRML bundle (Zip archive with scene and data files). In every other case, the scene is saved in the directory specified by 'filename'. Both MRML scene file and data will be written to disk. If needed, directories and sub-directories will be created. """ from slicer import app filetype = 'SceneFile' properties['fileName'] = filename return app.coreIOManager().saveNodes(filetype, properties)
def openAddVolumeDialog(): from slicer import app return app.coreIOManager().openAddVolumeDialog()
def loadScene(filename, clear = True): from slicer import app, qSlicerIO filetype = qSlicerIO.SceneFile properties = {'fileName':filename} return app.coreIOManager().loadNodes(filetype, properties)
def loadVolume(filename): from slicer import app, qSlicerIO filetype = qSlicerIO.VolumeFile properties = {'fileName':filename} return app.coreIOManager().loadNodes(filetype, properties)
def openSaveDataDialog(): from slicer import app return app.coreIOManager().openSaveDataDialog()
def openAddSegmentationDialog(): from slicer import app, qSlicerFileDialog return app.coreIOManager().openDialog('SegmentationFile', qSlicerFileDialog.Read)
def openAddTransformDialog(): from slicer import app return app.coreIOManager().openAddTransformDialog()
def openAddFiducialDialog(): from slicer import app return app.coreIOManager().openAddFiducialDialog()
def openAddScalarOverlayDialog(): from slicer import app return app.coreIOManager().openAddScalarOverlayDialog()
def openAddFiberBundleDialog(): from slicer import app return app.coreIOManager().openAddFiberBundleDialog()
def openAddColorTableDialog(): from slicer import app return app.coreIOManager().openAddColorTableDialog()
def loadScene(filename, clear = True): filetype = 'SceneFile' properties = {'fileName':filename} return app.coreIOManager().loadNodes(filetype, properties)
def loadDTI(filename): from slicer import app, qSlicerIO filetype = qSlicerIO.DTIFile properties = {} return app.coreIOManager().loadNodes(filetype, properties)
def loadFiducialList(filename): from slicer import app, qSlicerIO filetype = qSlicerIO.FiducialListFile properties = {'fileName':filename} return app.coreIOManager().loadNodes(filetype, properties)
def loadScalarOverlay(filename): from slicer import app, qSlicerIO filetype = qSlicerIO.ScalarOverlayFile properties = {'fileName':filename} return app.coreIOManager().loadNodes(filetype, properties)
def loadScene(filename, clear=True): from slicer import app, qSlicerIO filetype = qSlicerIO.SceneFile properties = {'fileName': filename} return app.coreIOManager().loadNodes(filetype, properties)