|
@@ -24,7 +24,7 @@ class cardiacSPECT(ScriptedLoadableModule):
|
|
|
def __init__(self, parent):
|
|
|
ScriptedLoadableModule.__init__(self, parent)
|
|
|
parent.title = "Cardiac SPECT"
|
|
|
- parent.categories = ["Examples"]
|
|
|
+ parent.categories = ["dynamicSPECT"]
|
|
|
parent.dependencies = []
|
|
|
parent.contributors = ["Andrej Studen (FMF/JSI)"] # replace with "Firstname Lastname (Org)"
|
|
|
parent.helpText = """
|
|
@@ -94,6 +94,14 @@ class cardiacSPECTWidget(ScriptedLoadableModuleWidget):
|
|
|
dataFormLayout.addRow("Segmentation",loadSegmentationButton)
|
|
|
loadSegmentationButton.clicked.connect(self.onLoadSegmentationButtonClicked)
|
|
|
|
|
|
+ self.modelParameter=qt.QLineEdit('k1');
|
|
|
+ dataFormLayout.addRow('Model Parameter', self.modelParameter)
|
|
|
+
|
|
|
+ loadModelButton = qt.QPushButton("Load")
|
|
|
+ loadModelButton.toolTip="Load model parameters from server"
|
|
|
+ dataFormLayout.addRow("Model",loadModelButton)
|
|
|
+ loadModelButton.clicked.connect(self.onLoadModelButtonClicked)
|
|
|
+
|
|
|
saveVolumeButton = qt.QPushButton("Save")
|
|
|
saveVolumeButton.toolTip="Save volume to NRRD"
|
|
|
dataFormLayout.addRow("Volume",saveVolumeButton)
|
|
@@ -353,6 +361,9 @@ class cardiacSPECTWidget(ScriptedLoadableModuleWidget):
|
|
|
def onLoadSegmentationButtonClicked(self):
|
|
|
self.logic.loadSegmentation(self.patientId.text)
|
|
|
|
|
|
+ def onLoadModelButtonClicked(self):
|
|
|
+ self.logic.loadModelVolume(self.patientId.text,self.modelParameter.text)
|
|
|
+
|
|
|
def onSaveVolumeButtonClicked(self):
|
|
|
self.logic.storeVolumeNodes(self.patientId.text,
|
|
|
self.time_frame_select.minimum,self.time_frame_select.maximum)
|
|
@@ -511,6 +522,11 @@ class cardiacSPECTLogic(ScriptedLoadableModuleLogic):
|
|
|
def loadCTVolume(self,patientId):
|
|
|
self.loadNode(patientId,patientId+'CT','VolumeFile')
|
|
|
|
|
|
+ def loadModelVolume(self,patientId,name):
|
|
|
+ node=self.loadNode(patientId,name,'VolumeFile')
|
|
|
+ if node:
|
|
|
+ node.SetName(patientId+'_'+name)
|
|
|
+
|
|
|
def loadSegmentation(self,patientId):
|
|
|
self.loadNode(patientId,'Heart','SegmentationFile')
|
|
|
|
|
@@ -518,8 +534,8 @@ class cardiacSPECTLogic(ScriptedLoadableModuleLogic):
|
|
|
relativePath=self.coreRelativePath+'/'+patientId
|
|
|
labkeyFile=relativePath+'/'+fName+suffix
|
|
|
print ("Remote: {}").format(labkeyFile)
|
|
|
- self.net.loadNode(labkeyFile,type,returnNode=True)
|
|
|
-
|
|
|
+ return self.net.loadNode(labkeyFile,type,returnNode=True)
|
|
|
+
|
|
|
|
|
|
def addNode(self,nodeName,v, lpsOrigin, pixel_size, lpsOrientation, dataType):
|
|
|
|
|
@@ -712,37 +728,37 @@ class cardiacSPECTLogic(ScriptedLoadableModuleLogic):
|
|
|
return segNode.GetSegmentation().GetSegment(segNode.GetSegmentation().GetNthSegmentID(i)).GetName()
|
|
|
|
|
|
def storeNodeRemote(self,relativePath,nodeName):
|
|
|
- labkeyPath=self.pd.net.GetLabkeyPathFromRelativePath(relativePath)
|
|
|
- print ("Remote: {}").format(labkeyPath)
|
|
|
- #checks if exists
|
|
|
- self.pd.net.mkdir(labkeyPath)
|
|
|
+ labkeyPath=self.pd.net.GetLabkeyPathFromRelativePath(relativePath)
|
|
|
+ print ("Remote: {}").format(labkeyPath)
|
|
|
+ #checks if exists
|
|
|
+ self.pd.net.mkdir(labkeyPath)
|
|
|
|
|
|
- localPath=self.pd.net.GetLocalPathFromRelativePath(relativePath)
|
|
|
- localPath.replace('/',os.path.sep)
|
|
|
+ localPath=self.pd.net.GetLocalPathFromRelativePath(relativePath)
|
|
|
+ localPath.replace('/',os.path.sep)
|
|
|
|
|
|
- node=slicer.mrmlScene.GetFirstNodeByName(nodeName)
|
|
|
- if node==None:
|
|
|
- print("Node {} not found").format(nodeName)
|
|
|
- return
|
|
|
+ node=slicer.mrmlScene.GetFirstNodeByName(nodeName)
|
|
|
+ if node==None:
|
|
|
+ print("Node {} not found").format(nodeName)
|
|
|
+ return
|
|
|
|
|
|
- suffix=".nrrd"
|
|
|
- if node.__class__.__name__=="vtkMRMLDoubleArrayNode":
|
|
|
- suffix=".mcsv"
|
|
|
- if (node.__class__.__name__=="vtkMRMLTransformNode" or
|
|
|
- node.__class__.__name__=="vtkMRMLGridTransformNode"):
|
|
|
- suffix=".h5"
|
|
|
+ suffix=".nrrd"
|
|
|
+ if node.__class__.__name__=="vtkMRMLDoubleArrayNode":
|
|
|
+ suffix=".mcsv"
|
|
|
+ if (node.__class__.__name__=="vtkMRMLTransformNode" or
|
|
|
+ node.__class__.__name__=="vtkMRMLGridTransformNode"):
|
|
|
+ suffix=".h5"
|
|
|
|
|
|
- fileName=re.sub(r'_RS$',r'',nodeName)+suffix
|
|
|
+ #fileName=re.sub(r'_RS$',r'',nodeName)+suffix
|
|
|
|
|
|
- if not os.path.isdir(localPath):
|
|
|
- os.mkdir(localPath)
|
|
|
+ if not os.path.isdir(localPath):
|
|
|
+ os.mkdir(localPath)
|
|
|
|
|
|
- file=os.path.join(localPath,fileName)
|
|
|
- slicer.util.saveNode(node,file)
|
|
|
- print("Stored to: {}").format(file)
|
|
|
- f=open(file,"rb")
|
|
|
- remoteFile=labkeyPath+'/'+fileName
|
|
|
- self.pd.net.put(remoteFile,f.read())
|
|
|
+ file=os.path.join(localPath,fileName)
|
|
|
+ slicer.util.saveNode(node,file)
|
|
|
+ print("Stored to: {}").format(file)
|
|
|
+ f=open(file,"rb")
|
|
|
+ remoteFile=labkeyPath+'/'+fileName
|
|
|
+ self.pd.net.put(remoteFile,f.read())
|
|
|
|
|
|
|
|
|
|
|
@@ -750,31 +766,34 @@ class cardiacSPECTLogic(ScriptedLoadableModuleLogic):
|
|
|
def storeVolumeNodes(self,patientId,n1,n2):
|
|
|
#n1=self.time_frame.minimum;
|
|
|
#n2=self.time_frame.maximum
|
|
|
- relativePath=self.coreRelativePath+'/'+patientId
|
|
|
+ relativePath=self.coreRelativePath+'/'+patientId
|
|
|
|
|
|
- print("Store CT")
|
|
|
- nodeName=patientId+'CT'
|
|
|
+ print("Store CT")
|
|
|
+ nodeName=patientId+'CT'
|
|
|
|
|
|
- #prefer resampled
|
|
|
- testNode=slicer.util.getFirstNodeByName(nodeName+"_RS")
|
|
|
- if testNode:
|
|
|
- nodeName=nodeName+"_RS"
|
|
|
- self.storeNodeRemote(relativePath,nodeName)
|
|
|
+ self.storeNodeRemote(relativePath,nodeName)
|
|
|
|
|
|
- print("Storing NM from {} to {}").format(n1,n2)
|
|
|
- n=n2-n1+1
|
|
|
- for i in range(n):
|
|
|
- it=i+n1
|
|
|
- nodeName=patientId+'Volume'+str(it)
|
|
|
+ #prefer resampled
|
|
|
+ testNode=slicer.util.getFirstNodeByName(nodeName+"_RS")
|
|
|
+ if testNode:
|
|
|
+ nodeName=nodeName+"_RS"
|
|
|
+ self.storeNodeRemote(relativePath,nodeName)
|
|
|
+
|
|
|
+ print("Storing NM from {} to {}").format(n1,n2)
|
|
|
+ n=n2-n1+1
|
|
|
+ for i in range(n):
|
|
|
+ it=i+n1
|
|
|
+ nodeName=patientId+'Volume'+str(it)
|
|
|
|
|
|
- #prefer resampled
|
|
|
- testNode=slicer.util.getFirstNodeByName(nodeName+"_RS")
|
|
|
- if testNode:
|
|
|
- nodeName=nodeName+"_RS"
|
|
|
+ self.storeNodeRemote(relativePath,nodeName)
|
|
|
|
|
|
- self.storeNodeRemote(relativePath,nodeName)
|
|
|
+ #add resampled
|
|
|
+ testNode=slicer.util.getFirstNodeByName(nodeName+"_RS")
|
|
|
+ if testNode:
|
|
|
+ nodeName=nodeName+"_RS"
|
|
|
+ self.storeNodeRemote(relativePath,nodeName)
|
|
|
|
|
|
- self.storeDummyInputFunction(patientId)
|
|
|
+ self.storeDummyInputFunction(patientId)
|
|
|
|
|
|
def storeSegmentation(self,patientId):
|
|
|
relativePath=self.coreRelativePath+'/'+patientId
|