Esempio n. 1
0
  /**
   * Appends the current GUI state as a state string to the document.
   *
   * @param guimodel the GUI model from which the GUI state and registered view will be read.
   */
  public void appendGUIState(final TrackMateGUIModel guimodel) {
    final Element guiel = new Element(GUI_STATE_ELEMENT_KEY);
    // state
    guiel.setAttribute(GUI_STATE_ATTRIBUTE, guimodel.getGUIStateString());
    // views
    for (final TrackMateModelView view : guimodel.getViews()) {
      final Element viewel = new Element(GUI_VIEW_ELEMENT_KEY);
      viewel.setAttribute(GUI_VIEW_ATTRIBUTE, view.getKey());
      guiel.addContent(viewel);
    }

    root.addContent(guiel);
    logger.log("  Added GUI current state.\n");
  }
Esempio n. 2
0
  public static void main(final String args[]) {

    final File file =
        new File(AppUtils.getBaseDirectory(TrackMate.class), "samples/FakeTracks.xml");

    // 1 - Load test spots
    System.out.println("Opening file: " + file.getAbsolutePath());
    final TmXmlReader reader = new TmXmlReader(file);
    final Model model = reader.getModel();
    final Settings gs = new Settings();
    reader.readSettings(gs, null, null, null, null, null);

    System.out.println("Spots: " + model.getSpots());
    System.out.println("Found " + model.getTrackModel().nTracks(false) + " tracks in the file:");
    System.out.println("Track features: ");
    System.out.println();

    // 2 - Track the test spots
    final long start = System.currentTimeMillis();
    final Map<String, Object> settings = new HashMap<String, Object>();
    settings.put(KEY_LINKING_MAX_DISTANCE, 15d);
    final NearestNeighborTracker tracker = new NearestNeighborTracker(model.getSpots(), settings);
    tracker.setLogger(Logger.DEFAULT_LOGGER);

    if (!tracker.checkInput())
      System.err.println("Error checking input: " + tracker.getErrorMessage());
    if (!tracker.process()) System.err.println("Error in process: " + tracker.getErrorMessage());
    final long end = System.currentTimeMillis();
    model.setTracks(tracker.getResult(), true);

    // 3 - Print out results for testing
    System.out.println();
    System.out.println();
    System.out.println();
    System.out.println("Found " + model.getTrackModel().nTracks(false) + " final tracks.");
    System.out.println("Whole tracking done in " + (end - start) + " ms.");
    System.out.println();

    // 5 - Display tracks
    // Load Image
    ij.ImageJ.main(args);

    final ImagePlus imp = gs.imp;
    final TrackMateModelView sd2d = new HyperStackDisplayer(model, new SelectionModel(model), imp);
    sd2d.render();
    sd2d.setDisplaySettings(
        TrackMateModelView.KEY_TRACK_DISPLAY_MODE, TrackMateModelView.TRACK_DISPLAY_MODE_WHOLE);
  }