def __init__(self):
    self.scene = slicer.mrmlScene
    self.scene.SetUndoOn()
    self.scene.SaveStateForUndo(self.scene.GetNodes())
    
    self.currentSlice = Slice('/luscinia/ProstateStudy/invivo/Patient59/loupas/RadialImagesCC_imwrite/arfi_ts3_26.57.png')

    # yay, adding images to slicer
    planeSource = vtk.vtkPlaneSource()
    planeSource.SetCenter(self.currentSlice.x, self.currentSlice.y, self.currentSlice.z)
    reader = vtk.vtkPNGReader()
    reader.SetFileName(self.currentSlice.name)

    # model node
    self.model = slicer.vtkMRMLModelNode()
    self.model.SetScene(self.scene)
    self.model.SetName(self.currentSlice.name)
    self.model.SetAndObservePolyData(planeSource.GetOutput())

    # model display node
    self.modelDisplay = slicer.vtkMRMLModelDisplayNode()
    self.modelDisplay.BackfaceCullingOff() # so plane can be seen from both front and back face
    self.modelDisplay.SetScene(self.scene)
    self.scene.AddNode(self.modelDisplay)

    # connecting model node w/ its model display node
    self.model.SetAndObserveDisplayNodeID(self.modelDisplay.GetID())

    # adding tiff file as texture to modelDisplay
    self.modelDisplay.SetAndObserveTextureImageData(reader.GetOutput())
    self.scene.AddNode(self.model)

    # now doing a linear transform to set coordinates and orientation of plane
    self.transform = slicer.vtkMRMLLinearTransformNode()
    self.scene.AddNode(self.transform)
    self.model.SetAndObserveTransformNodeID(self.transform.GetID())
    vTransform = vtk.vtkTransform()
    vTransform.Scale(150, 150, 150)
    vTransform.RotateX(0)
    vTransform.RotateY(0)
    vTransform.RotateZ(0)

    self.transform.SetAndObserveMatrixTransformToParent(vTransform.GetMatrix())
  def updateScene(self):
    #self.scene.Undo()
    #self.scene.SaveStateForUndo(self.scene.GetNodes())
    self.scene.RemoveNode(self.transform)
    self.scene.RemoveNode(self.modelDisplay)
    self.scene.RemoveNode(self.model)

    planeSource = vtk.vtkPlaneSource()
    planeSource.SetCenter(self.currentSlice.x, self.currentSlice.y, self.currentSlice.z)
    reader = vtk.vtkPNGReader()
    reader.SetFileName(self.currentSlice.name)

    # model node
    self.model = slicer.vtkMRMLModelNode()
    self.model.SetScene(self.scene)
    self.model.SetName(self.currentSlice.name)
    self.model.SetAndObservePolyData(planeSource.GetOutput())

    # model display node
    self.modelDisplay = slicer.vtkMRMLModelDisplayNode()
    self.modelDisplay.BackfaceCullingOff() # so plane can be seen from both front and back face
    self.modelDisplay.SetScene(self.scene)
    self.scene.AddNode(self.modelDisplay)

    # connecting model node w/ its model display node
    self.model.SetAndObserveDisplayNodeID(self.modelDisplay.GetID())

    # adding tiff file as texture to modelDisplay
    self.modelDisplay.SetAndObserveTextureImageData(reader.GetOutput())
    self.scene.AddNode(self.model)

    # now doing a linear transform to set coordinates and orientation of plane
    self.transform = slicer.vtkMRMLLinearTransformNode()
    self.scene.AddNode(self.transform)
    self.model.SetAndObserveTransformNodeID(self.transform.GetID())
    vTransform = vtk.vtkTransform()
    vTransform.Scale(self.currentSlice.scaling, self.currentSlice.scaling, self.currentSlice.scaling)
    vTransform.RotateX(self.currentSlice.xAngle)
    vTransform.RotateY(self.currentSlice.yAngle)
    vTransform.RotateZ(self.currentSlice.zAngle)
    self.transform.SetAndObserveMatrixTransformToParent(vTransform.GetMatrix())