     decisionTree.currentTask.confirmButton.innerHTML = label if label?
   
   current_tool?.mark.details = value if key is 'details'
-  current_tool?.mark.parts = value if key is 'parts'
+  
+  if key is 'parts'
+    for tool in ms.tools when tool.mark._taskIndex is 1
+      rectangle = tool.mark
+      rectangle.parts = []
+      for mark in value
+        inside = 
+          mark.x >= rectangle.left && 
+          mark.x <= (rectangle.left + rectangle.width) && 
+          mark.y >= rectangle.top && 
+          mark.y <= (rectangle.top + rectangle.height)
+        rectangle.parts.push mark if inside
 
 classify_page.on classify_page.LOAD_SUBJECT, (e, subject)->
   ms.rescale 0, 0, subjectViewer.maxWidth, subjectViewer.maxHeight

    if LAST_TASK
      task.next = 'review'
    else
      task.next = 'parts'

classify_page.el.on decisionTree.CHANGE, ({originalEvent: {detail}})->
  {key, value} = detail

  @rescale() if @scaleX is 0

LAST_TASK = true
INITIAL_STEPS = 3 # number of initial steps before annotating rectangles
ANNOTATION_STEPS = 1 # number of annotation steps per rectangle
MARGIN = 25 # margin on cropped images

current_tool = null
