-
Notifications
You must be signed in to change notification settings - Fork 2
/
models.py
49 lines (37 loc) · 1.88 KB
/
models.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#This scripts imports all the stl files from a folder
#filesinfolder = slicer.util.getFilesInDirectory(folder)
#find all files with 'stl' in the folder to load stl files
stlregex = "stl"
stlfiles = [i for i in filesinfolder if stlregex in i]
#load models
for i in range(0,len(stlfiles)):
slicer.util.loadModel(stlfiles[i])
#setcolor of models to all the same colour
modelnodelist = slicer.util.getNodesByClass('vtkMRMLModelNode')
#get the names of all the models and put in a list
modelnamelist = []
for i in range(len(modelnodelist)):
modelnamelist.append(slicer.mrmlScene.GetNthNodeByClass(i,'vtkMRMLModelNode').GetName())
#set colour of all models to white
for i in range(3,len(modelnodelist)):
slicer.mrmlScene.GetNthNodeByClass(i,'vtkMRMLModelNode').GetDisplayNode().SetColor(1,1,1)
slicer.mrmlScene.GetNthNodeByClass(i,'vtkMRMLModelNode').GetDisplayNode().SetOpacity(0.5)
#set color specific models to another colour if desired:
#slicer.mrmlScene.GetNthNodeByClass(4,'vtkMRMLModelNode').GetDisplayNode().SetColor(1,0,0)
#slicer.mrmlScene.GetNthNodeByClass(7,'vtkMRMLModelNode').GetDisplayNode().SetColor(1,0,0)
#get model node by name to change colour
#slicer.util.getNode('Segment_6').GetDisplayNode().SetColor(1,0,0)
#make all models invisible:
for i in range(3,len(modelnodelist)):
slicer.mrmlScene.GetNthNodeByClass(i,'vtkMRMLModelNode').SetDisplayVisibility(0)
#convert models to markups
#import ScreenCapture
#viewNodeID = 'vtkMRMLSliceNodeRed'
#cap = ScreenCapture.ScreenCaptureLogic()
#view = cap.viewFromNode(slicer.mrmlScene.GetNodeByID(viewNodeID))
#cap.captureImageFromView(view,slicedir+'\\'+ID+'redslice2.tif')
#
#
##change display of specific model
#modeloutlinenode = slicer.util.getNode(ID+'EC_TM_mod')#create model node from the just created model
#slicer.modules.segmentations.logic().ImportModelToSegmentationNode(modeloutlinenode,segmentationNode,"tosegment")