BICCN / cell-locator

manually align specimens to annotated 3D spaces
https://cell-locator.readthedocs.io
Other
19 stars 7 forks source link

ENH: Add ability to place a Point markup rather than a polygon. #169

Closed allemangD closed 3 years ago

allemangD commented 3 years ago

Introduce two subclasses of Annotation:

See FiducialsAnnotation for a simple example of how to create a new markup type. See ClosedCurveAnnotation.updateModel for an example of how to keep a model updated.


I've included docstrings, but I'll summarize my goal for how new annotation types may be added:

class NewAnnotation(Annotation):
  DisplayName = 'Sample'   # default name for this annotation type
  MarkupType = 'vtkMRMLMarkupsFiducialNode'  # markup type managed by this annotation type

  def __init__(self, markup=None):
    # set any type-specific attributes, models, etc

    super().__init__(markup=markup)

    # do any DisplayNode customizations

  def clear(self):
    # do any cleanup of type-specific attributes

  def update(self):
    # update any type-specific attributes; models, etc

  def metadata(self):
    # convert type-specific attributes to dict for serialization

  def setMetadata(self, data):
    # set any type-specific attributes from dict for deserialization

You can see how I do this for FiducialAnnotation and ClosedCurveAnnotation: https://github.com/BICCN/cell-locator/blob/5388988a0d798351720a91fed9bb2aae472d8094/Modules/Scripted/Home/Home.py#L197-L202 https://github.com/BICCN/cell-locator/blob/5388988a0d798351720a91fed9bb2aae472d8094/Modules/Scripted/Home/Home.py#L205-L271

allemangD commented 3 years ago

Screenshot from 2021-04-30 12-00-35

Note that each point annotation, since it is a Fiducials list, can contain multiple points. However these would all be projected to the same plane, as with the control points in a curve annotation. I've rotated the plane in this screenshot, and the points are projected: Screenshot from 2021-04-30 12-02-02

Also, the "Thickness" and "Representation Type" widgets are only enabled if the current annotation is a curve. A points annotation is selected in this screenshot: Screenshot from 2021-04-30 12-06-27