The Slice Focus Fun seems still perfect


# ### P4SliceFocus
# - [[P4SliceFocus]]
# - From: [Set slice position and orientation from 3 markup fiducials](https://slicer.readthedocs.io/en/latest/developer_guide/script_repository.html#set-slice-position-and-orientation-from-3-markup-fiducials)
# - [TODO]: 2点聚焦, slice对正, 某个slice放大, 简化代码用循环

  def P4SliceFocus(self, oP, xP, yP, zP):
      '''
      Param:oP:原点
            xP:X轴上的一点
            yP:Y轴上的一点
            zP:Z轴上的一点
      return:在3个slic上聚焦
      
      '''
      oP = oP + [.01, .01, .01]
      yP = yP + [0, .01, 0]
      xP = xP + [.01, 0, 0]
      zP = zP + [0, 0, .01]
      sliceNode = slicer.app.layoutManager().sliceWidget("Red").mrmlSliceNode()
      points = np.array([list(zip(*np.array([oP,xP,yP])))])[0]
      planePosition = points.mean(axis=1)
      planeNormal = np.cross(points[:,1] - points[:,0], points[:,2] - points[:,0])
      planeX = points[:,1] - points[:,0]
      sliceNode.SetSliceToRASByNTP(planeNormal[0], planeNormal[1], planeNormal[2], planeX[0], planeX[1], planeX[2], planePosition[0], planePosition[1], planePosition[2], 0)

      sliceNode = slicer.app.layoutManager().sliceWidget("Yellow").mrmlSliceNode()
      points = np.array([list(zip(*np.array([yP,zP,oP])))])[0]
      planePosition = points.mean(axis=1)
      planeNormal = np.cross(points[:,1] - points[:,0], points[:,2] - points[:,0])
      planeX = points[:,1] - points[:,0]
      sliceNode.SetSliceToRASByNTP(planeNormal[0], planeNormal[1], planeNormal[2], planeX[0], planeX[1], planeX[2], planePosition[0], planePosition[1], planePosition[2], 0)

      sliceNode = slicer.app.layoutManager().sliceWidget("Green").mrmlSliceNode()
      points = np.array([list(zip(*np.array([oP,xP,zP])))])[0]
      planePosition = points.mean(axis=1)
      planeNormal = np.cross(points[:,1] - points[:,0], points[:,2] - points[:,0])
      planeX = points[:,1] - points[:,0]
      sliceNode.SetSliceToRASByNTP(planeNormal[0], planeNormal[1], planeNormal[2], planeX[0], planeX[1], planeX[2], planePosition[0], planePosition[1], planePosition[2], 0)

    

根据这段代码, 我做了上面这段代码, 我的目的是在3个slice里聚焦一个model…这段代码不够完美:

  • 有2个点就可以完成聚焦任务了

  • 如何对齐各个slice

  • 如何放大某个slice

According to Set slice position and orientation from 3 markup fiducials, I wrote the above code, my purpose is to focus on a model in 3 slices… This code is not perfect:

  • 2 points to complete the focus task
  • How to align each slice
  • How to enlarge a slice

@lassoan@Juicy@jamesobutler @jcfr @pieperThanks @chir.set