Exemplo n.º 1
0
 protected HashMap<Integer, ArrayList<Integer>> getSplitSelectionIndexes() {
   HashMap<Integer, ArrayList<Object3DGui>> splitSelection = getSplitSelection();
   HashMap<Integer, ArrayList<Integer>> res =
       new HashMap<Integer, ArrayList<Integer>>(splitSelection.size());
   for (Map.Entry<Integer, ArrayList<Object3DGui>> e : splitSelection.entrySet()) {
     ArrayList<Integer> idxs = new ArrayList<Integer>(e.getValue().size());
     for (Object3DGui o : e.getValue()) idxs.add(o.getLabel());
     res.put(e.getKey(), idxs);
   }
   return res;
 }
Exemplo n.º 2
0
 protected HashMap<Integer, ArrayList<Object3DGui>> getSplitSelection() {
   System.out.println(
       "get split selection: currenChannels==null?" + (this.currentChannels == null));
   if (this.currentChannels == null) return new HashMap<Integer, ArrayList<Object3DGui>>(0);
   HashMap<Integer, ArrayList<Object3DGui>> res =
       new HashMap<Integer, ArrayList<Object3DGui>>(this.currentChannels.length);
   for (ObjectStructure ass : currentChannels) res.put(ass.getIdx(), new ArrayList<Object3DGui>());
   for (Object o : list.getSelectedValues()) {
     Object3DGui o3D = (Object3DGui) (o);
     int idx = o3D.getChannel().getIdx();
     res.get(idx).add(o3D);
   }
   return res;
 }
Exemplo n.º 3
0
 private void sort(String key, Object3DGui[] objectsGui, int structureIdx) {
   Object3DGui.setAscendingOrger(((ObjectManagerLayout) layout).getAscendingOrder());
   HashMap<Integer, BasicDBObject> objects =
       Core.getExperiment().getConnector().getObjects(currentNucId, structureIdx);
   boolean notFound = false;
   for (Object3DGui o : objectsGui) {
     BasicDBObject dbo = objects.get(o.getLabel());
     if (dbo != null) {
       if (dbo.containsField(key)) o.setValue(dbo.getDouble(key));
       else {
         o.setValue(-1);
         notFound = true;
       }
     }
   }
   if (notFound)
     ij.IJ.log("Warning measurement: " + key + " not found for one or several objects");
   Arrays.sort(objectsGui);
 }
Exemplo n.º 4
0
 public void populateObjects() {
   try {
     this.listModel.removeAllElements();
     if (currentChannels == null) {
       return;
     }
     this.populatingObjects = true;
     ArrayList<Integer> selection = null;
     if (showSelection != null && showSelection.isSelected()) selection = new ArrayList<Integer>();
     int currentIdx = 0;
     for (ObjectStructure ass : currentChannels) {
       Object3D[] os = ass.getObjects();
       if (os != null) {
         Object3DGui[] osg = new Object3DGui[os.length];
         for (int i = 0; i < os.length; i++) osg[i] = new Object3DGui(os[i], ass);
         if (layout instanceof ObjectManagerLayout
             && currentChannels.length == 1
             && !((ObjectManagerLayout) layout).getSortKey().equals("idx"))
           this.sort(((ObjectManagerLayout) layout).getSortKey(), osg, ass.getIdx());
         // System.out.println("populating objects.. nb objects:"+os.length);
         for (Object3DGui o3D : osg) {
           this.listModel.addElement(o3D);
           if (selection != null && o3D.isInSelection()) selection.add(currentIdx);
           currentIdx++;
         }
         // if (selection!=null) System.out.println("populating objects.. selection
         // size:"+selection.size());
       } // else System.out.println("no objects int channel:"+ass.getChannelName());
     }
     if (selection != null && !selection.isEmpty()) {
       int[] sel = new int[selection.size()];
       int i = 0;
       for (int idx : selection) sel[i++] = idx;
       list.setSelectedIndices(sel);
     }
   } catch (Exception e) {
     exceptionPrinter.print(e, "", Core.GUIMode);
   }
   this.populatingObjects = false;
 }
Exemplo n.º 5
0
  public void showRois3D() {
    registerActiveImage();
    if (currentImage == null) return;
    // verifier que l'image active a les memes dimentions
    Object[] os = this.list.getSelectedValues();

    if (os.length == 1) {
      mcib3d.geom.Object3D o = ((Object3DGui) os[0]).getObject3D();
      currentImage.setSlice((o.getZmax() + o.getZmin()) / 2 + 1);
    }
    int nSlices = currentImage.getNSlices();

    currentROIs = new HashMap<Integer, Roi>(nSlices);
    // stores the roi mask to save memory..
    if (roiMask == null || !roiMask.sameDimentions(currentImage)) {
      roiMask = new ImageByte("mask", currentImage.getWidth(), currentImage.getHeight(), nSlices);
    } else {
      roiMask.erase();
    }
    ImageStack maskStack = roiMask.getImageStack();
    Object3DGui obj;
    for (Object o : os) {
      obj = (Object3DGui) o;
      obj.getObject3D().draw(maskStack, 255);
    }
    // roiMask.show();

    for (int i = 1; i <= nSlices; i++) {
      ImagePlus im = new ImagePlus("mask", maskStack.getProcessor(i));
      im.getProcessor().setThreshold(1, 255, ImageProcessor.NO_LUT_UPDATE);
      ThresholdToSelection tts = new ThresholdToSelection();
      tts.setup("", im);
      tts.run(im.getProcessor());
      Roi r = im.getRoi();
      if (r != null) currentROIs.put(i, r);
    }
    updateRoi();
  }
Exemplo n.º 6
0
 public void mergeSelectedObjects() {
   this.populatingObjects = true;
   HashMap<Integer, ArrayList<Object3DGui>> allObjects = getSplitSelection();
   for (int channelIdx : allObjects.keySet()) {
     ArrayList<Object3DGui> objects = allObjects.get(channelIdx);
     if (objects != null && objects.size() >= 2) {
       Collections.sort(objects);
       Object3DGui o1 = objects.get(0);
       for (int i = objects.size() - 1; i > 0; i--) {
         Object3DGui o2 = objects.get(i);
         o1.merge(o2);
         listModel.removeElement(o2);
         // IJ.log("merge:"+o1.getName()+ "::"+objects.get(i).getName()+ " channel:"+channelIdx);
       }
       o1.getChannel().createObjects();
       if (autoSave) o1.getChannel().saveOutput();
       ImagePlus img = o1.getChannel().getSegmented().getImagePlus();
       if (img.isVisible()) {
         img.updateAndDraw();
       }
     }
   }
   this.populatingObjects = false;
 }
Exemplo n.º 7
0
 public void deleteSelectedObjects() {
   populatingObjects = true;
   try {
     boolean[] modif = new boolean[currentChannels.length];
     for (Object o : this.list.getSelectedValues()) {
       listModel.removeElement(o);
       modif[getChannelRank(((Object3DGui) o).getChannel())] = true;
       ((Object3DGui) o).delete(true);
     }
     for (int i = 0; i < currentChannels.length; i++) {
       if (modif[i]) {
         ImagePlus img = currentChannels[i].getSegmented().getImagePlus();
         if (img.isVisible()) {
           img.updateAndDraw();
         }
         currentChannels[i].createObjects();
         if (autoSave) currentChannels[i].saveOutput();
       }
     }
   } catch (Exception e) {
     exceptionPrinter.print(e, "", Core.GUIMode);
   }
   populatingObjects = false;
 }
Exemplo n.º 8
0
 protected boolean split(Object3DGui og) {
   if (!(this instanceof NucleusManager) && og.getChannel() instanceof Nucleus) {
     if (Core.GUIMode) ij.IJ.log("Cannont split nucleus!");
     return false;
   }
   Object3DGui[] newObjects = og.split(splitRad.getFloatValue(2), splitDist.getFloatValue(5));
   if (newObjects.length == 0) {
     if (Core.GUIMode) ij.IJ.log("Object couldn't be split");
     return false;
   }
   Object3D[] objs = og.getChannel().getObjects();
   int nextLabel = objs[objs.length - 1].getValue() + 1;
   for (Object3DGui o : newObjects) {
     o.changeLabel(nextLabel);
     this.listModel.addElement(o); // TODO le mettre a la fin des objets du channel..
     nextLabel++;
   }
   og.getChannel().getSegmented().updateDisplay();
   return true;
 }