@Override
  public void process(int z, int t, int p) {
    // called for each z,t,p by DatasetIterator.iterateAll();
    System.out.println("MagOrientProcessor.process(" + z + "," + t + "," + p + ")");
    ArrayList<TaggedImage> sampleImgs = new ArrayList<TaggedImage>();
    for (int i = 0; i < numSamples; i++) {
      TaggedImage img = mda.getImageCache().getImage(i + 2, z, t, p);
      if (img == null) {
        System.out.println(
            "**** " + "img==null at submit  i: " + i + "  z: " + z + "  t: " + t + "  p: " + p);
      }
      sampleImgs.add(img);
    }

    // Assuming channels : {mag,ort,0,1,2,3,4}
    //		TaggedImage magImage = in.getImage(0, z, t, p);
    //		TaggedImage ortImage = in.getImage(1, z, t, p);

    // Set Parameters...
    Map<String, Object> parameters = new HashMap<String, Object>();
    parameters.put("Swing", 0.03);
    parameters.put("BkgdCorrected", true);
    parameters.put("summaryMetadata", mda.getImageCache().getSummaryMetadata());
    parameters.put("sampleImages", sampleImgs);
    // proc.setInputParameters(parameters);
    IProcess proc = new ProcessMagOrt(this.parameters, this.data);
    proc.process();
    processResult(proc);
  }
  // Test Main =============================================================================
  public static void main(String[] args) {
    try {
      String dir = "C:/MicroManagerData/TestDatasetGen";
      String prefixIn = "pssynth_100";
      String prefixOut = "processed";
      //
      MMgrDatasetAccessor mda = new MMgrDatasetAccessor(dir, prefixIn, false, false);
      JSONObject sumMD_In = mda.getImageCache().getSummaryMetadata();
      // Create new metadata based on the input dataset...
      JSONObject sumMDOut =
          SumMetadata.newCopyOfSummaryMetadata(sumMD_In, dir, prefixOut, true, "Extraction");
      JSONObject dispMD = mda.getImageCache().getDisplayAndComments();
      //
      // Change /add metadata...
      String[] channelNames = new String[] {"Mag", "Ort"}; // define channels

      MMgrDatasetGenerator mdg = new MMgrDatasetGenerator(sumMDOut);
      DimensionalExtents dsdIn = SumMetadata.getDimensionalExtents(sumMD_In);
      // create processor...
      ChannelSetProcessor magOrtProcessor = new MagOrientChannelSetProcessor(mda, mdg);
      magOrtProcessor.addParameter("Swing", 0.03);
      magOrtProcessor.addParameter("BkgdCorrected", true);
      //
      DatasetIterator dsIter = new DatasetIterator(SumMetadata.getDimensionalExtents(sumMD_In));
      dsIter.setChannelSetProcessor(magOrtProcessor);
      dsIter.iterateAll(); // run the process on all the dimensions
      if (dsIter.isCancelled()) {
        mdg.cancel();
      }
      //
      System.exit(0);
    } catch (Exception ex) {
    }
  }
 private DerivedFrom createDerivedFrom(IProcess proc) {
   Transform xform = new Transform(proc.getName(), proc.getInputParameters());
   String antecentPath = mda.getImageCache().getDiskLocation();
   String resultPath = mdg.getImageCache().getDiskLocation();
   String relPath = PathUtils.getRelativePath(antecentPath, resultPath);
   DerivedFrom df =
       DerivedFrom.createDerivedFrom(
           relPath, (List<TaggedImage>) proc.getInputParameters().get("sampleImages"), xform);
   return df;
 }
Ejemplo n.º 4
0
  public void extractFrom() {

    try {
      MMgrDatasetAccessor datasetIn = new MMgrDatasetAccessor(inputPath, inputPrefix, false, false);
      JSONObject sumMD_In = datasetIn.getImageCache().getSummaryMetadata();
      // create new multi-page dataset...
      JSONObject sumMDOut =
          SumMetadata.newCopyOfSummaryMetadata(
              sumMD_In, outputDir, outputPrefix, true, "Extraction");
      // change dimensions
      SumMetadata.applyDimensionalExtents(
          sumMDOut, sliceIndices.length, frameIndices.length, positionIndices.length);
      // change channelIndices
      String[] channelNamesIn = SumMetadata.getChannelNames(sumMD_In);
      String[] channelNamesNew = new String[channelIndices.length];
      for (int i = 0; i < channelIndices.length; i++) {
        channelNamesNew[i] = channelNamesIn[channelIndices[i]];
      }
      SumMetadata.setChannelsAndDisplay(sumMDOut, channelNamesNew);
      //
      MMgrDatasetGenerator datasetOut =
          new MMgrDatasetGenerator(
              sumMDOut, isMultiPage, seperateMDFile, seperateFilesForPositions);

      // ***********
      for (int pos = 0; pos < positionIndices.length; pos++) {
        for (int frame = 0; frame < frameIndices.length; frame++) {
          for (int slice = 0; slice < sliceIndices.length; slice++) {
            for (int chan = 0; chan < channelIndices.length; chan++) {

              TaggedImage img =
                  datasetIn
                      .getImageCache()
                      .getImage(
                          channelIndices[chan], sliceIndices[slice],
                          frameIndices[frame], positionIndices[pos]);

              PrintWhatever.out(
                  channelIndices[chan],
                  sliceIndices[slice],
                  frameIndices[frame],
                  positionIndices[pos]);

              JSONObject frameMD = img.tags;

              // Change metadata to new dimensionalIndicies: (chan,slice,frame,pos)
              // TODO...

              PrintWhatever.out(chan, slice, frame, pos);
              // System.out.println("");
              // set channelName
              try {
                datasetOut.putImage(img);
              } catch (Exception ex) {
                Logger.getLogger(DatasetGenTester.class.getName()).log(Level.SEVERE, null, ex);
                ex.printStackTrace();
              }
            }
          }
        }
      }
      datasetOut.stop();
    } catch (Exception ex) {
      Logger.getLogger(DatasetExtractor.class.getName()).log(Level.SEVERE, null, ex);
    }
  }
 public MagOrientChannelSetProcessor(MMgrDatasetAccessor mda, MMgrDatasetGenerator mdg) {
   this.mda = mda;
   this.mdg = mdg;
   in = mda.getImageCache();
 }