@Override
  public void configure() throws Exception {
    // We will now read this from the Configuration. The detector needs to be preconfigured!
    // detector = (XRayDetector) UserUtil.queryObject("Select Detector:", "Detector Selection",
    // XRayDetector.class);
    // detector.configure();
    detector = Configuration.getGlobalConfiguration().getDetector();
    detector.init();
    phantom = UserUtil.queryPhantom("Select Phantom", "Select Phantom");
    Material mat = null;

    do {
      String materialstr = UserUtil.queryString("Enter Background Medium:", "vacuum");
      mat = MaterialsDB.getMaterialWithName(materialstr);
    } while (mat == null);

    phantom.setBackground(mat);
    phantom.configure();

    rayTracer.setScene((PrioritizableScene) phantom);
    environment.setMaterial(phantom.getBackgroundMaterial());
    super.configure();
  }
 @Override
 public void configure() throws Exception {
   slope = UserUtil.queryDouble("Enter slope of correction transformatoin", slope);
   // offset = UserUtil.queryDouble("Enter offset of correction transformation", offset);
   measureHard = UserUtil.queryDouble("Measurement of hard material [HU]", measureHard);
   measureSoft = UserUtil.queryDouble("Measurement of soft material [HU]", measureSoft);
   projectionXShift = UserUtil.queryDouble("Enter projection x shift", projectionXShift);
   projectionYShift = UserUtil.queryDouble("Enter projection y shift", projectionYShift);
   lambda0 = VolumeAttenuationFactorCorrectionTool.getLambda0(measureHard, measureSoft);
   lut = Configuration.getGlobalConfiguration().getBeamHardeningLookupTable();
   ImagePlus[] images = ImageUtil.getAvailableImagePlusAsArray();
   hardMaterial =
       ImageUtil.wrapImagePlus(
           (ImagePlus)
               JOptionPane.showInputDialog(
                   null,
                   "Select projections with hard material: ",
                   "Select source",
                   JOptionPane.PLAIN_MESSAGE,
                   null,
                   images,
                   images[0]));
   configured = true;
 }
Exemplo n.º 3
0
  /**
   * Configures the heart simulation. Currently uses learning shapes as heart description. This will
   * be changed later using the HeartParameterLUT class.
   */
  public void configure() throws Exception {
    // heartBase = UserUtil.queryString("Specify path to model data file.",
    // "C:\\Stanford\\CONRAD\\data\\CardiacModel\\");
    heartBase = System.getProperty("user.dir") + "\\data\\CardiacModel\\";
    heartBeats = UserUtil.queryInt("Number of heart beats in this scene:", 1);

    boolean rotTrans = UserUtil.queryBoolean("Apply rotatation and translation?");
    if (!rotTrans) {
      new SimpleMatrix();
      this.rot = SimpleMatrix.I_3;
      this.trans = new SimpleVector(3);
    } else {
      String rtfile =
          UserUtil.queryString(
              "Specify file containing rotation and translation:", heartBase + "rotTrans.txt");
      RotTransIO rtinput = new RotTransIO(rtfile);
      this.rot = rtinput.getRotation();
      this.trans = rtinput.getTranslation();
    }

    this.max = new PointND(0, 0, 0);
    this.min = new PointND(0, 0, 0);

    // read config file for offsets etc
    CONRADCardiacModelConfig info = new CONRADCardiacModelConfig(heartBase);
    info.read();
    // read the PCs of all phases
    ActiveShapeModel parameters = new ActiveShapeModel(heartBase + "\\CCmScores.ccm");
    double[] scores;
    boolean predefined = UserUtil.queryBoolean("Use predefined model?");
    if (predefined) {
      Object tobj =
          UserUtil.chooseObject(
              "Choose heart to be simulated:",
              "Predefined models:",
              PredefinedModels.getList(),
              PredefinedModels.getList()[0]);
      scores = PredefinedModels.getValue(tobj.toString());
    } else {
      scores =
          UserUtil.queryArray("Specify model parameters: ", new double[parameters.numComponents]);
      // the scores are defined with respect to variance but we want to have them with respect to
      // standard deviation therefore divide by
      // sqrt of variance
      for (int i = 0; i < parameters.numComponents; i++) {
        scores[i] /= Math.sqrt(parameters.getEigenvalues()[i]);
      }
    }

    SimpleVector paramVec = parameters.getModel(scores).getPoints().getCol(0);

    // for all components
    // loop through all phases and create splines describing the motion for each vertex
    System.out.println("Starting model generation.\n");
    System.out.println("__________________________________");
    System.out.println("Calculating phantom at each phase.\n");
    this.splines = new ArrayList<Mesh4D>();

    for (int i = 0; i < numPhases; i++) {
      int start = 0;
      for (int j = 0; j < i; j++) {
        start += (j == 0) ? 0 : info.principalComp[j - 1];
      }
      double[] param = paramVec.getSubVec(start, info.principalComp[i]).copyAsDoubleArray();
      createPhantom(i, param, info, splines);
    }
    // calculate splines
    System.out.println("Fitting temporal splines.\n");
    for (int i = 0; i < info.numAnatComp; i++) {
      splines.get(i).calculateSplines();
    }
    System.out.println("__________________________________");
    setConfigured(true);
    System.out.println("Configuration done.\n");
  }