Пример #1
0
  /**
   * Creates and returns a laser. This will have to be linked to an instrument.
   *
   * @return See above.
   * @throws Exception Thrown if an error occurred.
   */
  public Laser createLaser() throws Exception {
    Laser laser = new LaserI();
    laser.setManufacturer(omero.rtypes.rstring("manufacturer"));
    laser.setModel(omero.rtypes.rstring("model"));
    laser.setLotNumber(omero.rtypes.rstring("lot number"));
    laser.setSerialNumber(omero.rtypes.rstring("serial number"));
    // type
    List<IObject> types = pixelsService.getAllEnumerations(LaserType.class.getName());
    laser.setType((LaserType) types.get(0));
    // laser medium
    types = pixelsService.getAllEnumerations(LaserMedium.class.getName());
    laser.setLaserMedium((LaserMedium) types.get(0));

    // pulse
    types = pixelsService.getAllEnumerations(Pulse.class.getName());
    laser.setPulse((Pulse) types.get(0));

    laser.setFrequencyMultiplication(omero.rtypes.rint(1));
    laser.setPockelCell(omero.rtypes.rbool(false));
    laser.setTuneable(omero.rtypes.rbool(true));
    laser.setWavelength(omero.rtypes.rint(500));
    laser.setPower(omero.rtypes.rdouble(1));
    laser.setRepetitionRate(omero.rtypes.rdouble(1));
    return laser;
  }
Пример #2
0
  /**
   * Creates a pixels object.
   *
   * @param sizeX The size along the X-axis.
   * @param sizeY The size along the Y-axis.
   * @param sizeZ The number of Z-sections.
   * @param sizeT The number of time-points.
   * @param sizeC The number of channels.
   * @return See above.
   * @throws Exception Thrown if an error occurred.
   */
  public Pixels createPixels(int sizeX, int sizeY, int sizeZ, int sizeT, int sizeC)
      throws Exception {
    List<IObject> types = pixelsService.getAllEnumerations(PixelsType.class.getName());
    Iterator<IObject> i = types.iterator();
    PixelsType object;
    PixelsType type = null;
    while (i.hasNext()) {
      object = (PixelsType) i.next();
      if (UINT16.equals(object.getValue().getValue())) {
        type = object;
        break;
      }
    }
    if (type == null) type = (PixelsType) types.get(0);
    types = pixelsService.getAllEnumerations(DimensionOrder.class.getName());
    i = types.iterator();
    DimensionOrder o;
    DimensionOrder order = null;
    while (i.hasNext()) {
      o = (DimensionOrder) i.next();
      if (XYZCT.equals(o.getValue().getValue())) {
        order = o;
        break;
      }
    }
    if (order == null) order = (DimensionOrder) types.get(0);
    Pixels pixels = new PixelsI();
    pixels.setPhysicalSizeX(omero.rtypes.rdouble(1.0));
    pixels.setPhysicalSizeY(omero.rtypes.rdouble(1.0));
    pixels.setPhysicalSizeZ(omero.rtypes.rdouble(1.0));
    pixels.setSizeX(omero.rtypes.rint(sizeX));
    pixels.setSizeY(omero.rtypes.rint(sizeY));
    pixels.setSizeZ(omero.rtypes.rint(sizeZ));
    pixels.setSizeT(omero.rtypes.rint(sizeT));
    pixels.setSizeC(omero.rtypes.rint(sizeC));
    pixels.setSha1(omero.rtypes.rstring("Pending..."));
    pixels.setPixelsType(type);
    pixels.setDimensionOrder(order);
    List<Channel> channels = new ArrayList<Channel>();
    for (int j = 0; j < sizeC; j++) {
      channels.add(createChannel(j));
    }
    pixels.addAllChannelSet(channels);

    for (int z = 0; z < sizeZ; z++) {
      for (int t = 0; t < sizeT; t++) {
        for (int c = 0; c < sizeC; c++) {
          PlaneInfo info = new PlaneInfoI();
          pixels.addPlaneInfo(createPlaneInfo(z, t, c));
        }
      }
    }
    return pixels;
  }
Пример #3
0
 /**
  * Creates and returns the settings of the specified source of light.
  *
  * @param light The light to link the settings to.
  * @return See above.
  * @throws Exception Thrown if an error occurred.
  */
 public LightSettings createLightSettings(LightSource light) throws Exception {
   // already tested see PixelsService enumeration.
   List<IObject> types =
       pixelsService.getAllEnumerations(MicrobeamManipulationType.class.getName());
   LightSettings settings = new LightSettingsI();
   settings.setLightSource(light);
   settings.setAttenuation(omero.rtypes.rdouble(1));
   MicrobeamManipulation mm = new MicrobeamManipulationI();
   mm.setType((MicrobeamManipulationType) types.get(0));
   Experiment exp = new ExperimentI();
   types = pixelsService.getAllEnumerations(ExperimentType.class.getName());
   exp.setType((ExperimentType) types.get(0));
   mm.setExperiment(exp);
   // settings.setMicrobeamManipulation(mm);
   settings.setWavelength(omero.rtypes.rint(500));
   return settings;
 }
Пример #4
0
 /**
  * Creates and returns the settings of the specified objective.
  *
  * @param objective The objective to link the settings to.
  * @return See above.
  * @throws Exception Thrown if an error occurred.
  */
 public ObjectiveSettings createObjectiveSettings(Objective objective) throws Exception {
   // already tested see PixelsService enumeration.
   List<IObject> types = pixelsService.getAllEnumerations(Medium.class.getName());
   ObjectiveSettings settings = new ObjectiveSettingsI();
   settings.setCorrectionCollar(omero.rtypes.rdouble(1));
   settings.setRefractiveIndex(omero.rtypes.rdouble(1));
   settings.setMedium((Medium) types.get(0));
   settings.setObjective(objective);
   return settings;
 }
Пример #5
0
 /**
  * Creates and returns a filament. This will have to be linked to an instrument.
  *
  * @return See above.
  * @throws Exception Thrown if an error occurred.
  */
 public Arc createArc() throws Exception {
   List<IObject> types = pixelsService.getAllEnumerations(ArcType.class.getName());
   Arc arc = new ArcI();
   arc.setManufacturer(omero.rtypes.rstring("manufacturer"));
   arc.setModel(omero.rtypes.rstring("model"));
   arc.setPower(omero.rtypes.rdouble(1));
   arc.setSerialNumber(omero.rtypes.rstring("serial number"));
   arc.setLotNumber(omero.rtypes.rstring("lot number"));
   arc.setType((ArcType) types.get(0));
   return arc;
 }
Пример #6
0
 /**
  * Creates and returns a filament. This will have to be linked to an instrument.
  *
  * @return See above.
  * @throws Exception Thrown if an error occurred.
  */
 public Filament createFilament() throws Exception {
   List<IObject> types = pixelsService.getAllEnumerations(FilamentType.class.getName());
   Filament filament = new FilamentI();
   filament.setManufacturer(omero.rtypes.rstring("manufacturer"));
   filament.setModel(omero.rtypes.rstring("model"));
   filament.setPower(omero.rtypes.rdouble(1));
   filament.setSerialNumber(omero.rtypes.rstring("serial number"));
   filament.setLotNumber(omero.rtypes.rstring("lot number"));
   filament.setType((FilamentType) types.get(0));
   return filament;
 }
Пример #7
0
  /**
   * Creates a channel.
   *
   * @param w The wavelength in nanometers.
   * @return See Above.
   * @throws Exception
   */
  public Channel createChannel(int w) throws Exception {
    Channel channel = new ChannelI();
    LogicalChannel lc = new LogicalChannelI();
    lc.setEmissionWave(omero.rtypes.rint(200));
    List<IObject> types = pixelsService.getAllEnumerations(ContrastMethod.class.getName());
    ContrastMethod cm = (ContrastMethod) types.get(0);

    types = pixelsService.getAllEnumerations(Illumination.class.getName());
    Illumination illumination = (Illumination) types.get(0);
    types = pixelsService.getAllEnumerations(AcquisitionMode.class.getName());
    AcquisitionMode mode = (AcquisitionMode) types.get(0);
    lc.setContrastMethod(cm);
    lc.setIllumination(illumination);
    lc.setMode(mode);
    channel.setLogicalChannel(lc);
    StatsInfo info = new StatsInfoI();
    info.setGlobalMin(omero.rtypes.rdouble(0.0));
    info.setGlobalMax(omero.rtypes.rdouble(1.0));
    channel.setStatsInfo(info);
    return channel;
  }
Пример #8
0
 /**
  * Creates and returns an instrument.
  *
  * @return See above.
  * @throws Exception Thrown if an error occurred.
  */
 public Instrument createInstrument() throws Exception {
   List<IObject> types = pixelsService.getAllEnumerations(MicroscopeType.class.getName());
   Instrument instrument = new InstrumentI();
   MicroscopeI microscope = new MicroscopeI();
   microscope.setManufacturer(omero.rtypes.rstring("manufacturer"));
   microscope.setModel(omero.rtypes.rstring("model"));
   microscope.setSerialNumber(omero.rtypes.rstring("serial number"));
   microscope.setLotNumber(omero.rtypes.rstring("lot number"));
   microscope.setType((MicroscopeType) types.get(0));
   instrument.setMicroscope(microscope);
   return instrument;
 }
Пример #9
0
 /**
  * Creates and returns the settings of the specified detector.
  *
  * @param detector The detector to link the settings to.
  * @return See above.
  * @throws Exception Thrown if an error occurred.
  */
 DetectorSettings createDetectorSettings(Detector detector) throws Exception {
   // already tested see PixelsService enumeration.
   List<IObject> types = pixelsService.getAllEnumerations(Binning.class.getName());
   DetectorSettings settings = new DetectorSettingsI();
   settings.setBinning((Binning) types.get(0));
   settings.setDetector(detector);
   settings.setGain(omero.rtypes.rdouble(1));
   settings.setOffsetValue(omero.rtypes.rdouble(1));
   settings.setReadOutRate(omero.rtypes.rdouble(1));
   settings.setVoltage(omero.rtypes.rdouble(1));
   return settings;
 }
Пример #10
0
  /**
   * Creates and returns an objective. This will have to be linked to an instrument.
   *
   * @return See above.
   * @throws Exception Thrown if an error occurred.
   */
  public Objective createObjective() throws Exception {
    Objective objective = new ObjectiveI();
    objective.setManufacturer(omero.rtypes.rstring("manufacturer"));
    objective.setModel(omero.rtypes.rstring("model"));
    objective.setSerialNumber(omero.rtypes.rstring("serial number"));
    objective.setLotNumber(omero.rtypes.rstring("lot number"));
    objective.setCalibratedMagnification(omero.rtypes.rdouble(1));
    // correction
    // already tested see PixelsService enumeration.
    List<IObject> types = pixelsService.getAllEnumerations(Correction.class.getName());
    objective.setCorrection((Correction) types.get(0));
    // immersion
    types = pixelsService.getAllEnumerations(Immersion.class.getName());
    objective.setImmersion((Immersion) types.get(0));

    objective.setIris(omero.rtypes.rbool(true));
    objective.setLensNA(omero.rtypes.rdouble(0.5));
    objective.setNominalMagnification(omero.rtypes.rdouble(1));
    objective.setWorkingDistance(omero.rtypes.rdouble(1));
    return objective;
  }
Пример #11
0
 /**
  * Creates an Optical Transfer Function object.
  *
  * @param filterSet The filter set linked to it.
  * @param objective The objective linked to it.
  * @return See above.
  * @throws Exception Thrown if an error occurred.
  */
 public OTF createOTF(FilterSet filterSet, Objective objective) throws Exception {
   // already tested see PixelsService enumeration.
   List<IObject> types = pixelsService.getAllEnumerations(PixelsType.class.getName());
   OTF otf = new OTFI();
   otf.setFilterSet(filterSet);
   otf.setObjective(objective);
   otf.setPath(omero.rtypes.rstring("/OMERO"));
   otf.setOpticalAxisAveraged(omero.rtypes.rbool(true));
   otf.setPixelsType((PixelsType) types.get(0));
   otf.setSizeX(omero.rtypes.rint(10));
   otf.setSizeY(omero.rtypes.rint(10));
   return otf;
 }
Пример #12
0
 /**
  * Creates and returns a detector. This will have to be linked to an instrument.
  *
  * @return See above.
  * @throws Exception Thrown if an error occurred.
  */
 public Detector createDetector() throws Exception {
   // already tested see PixelsService enumeration.
   List<IObject> types = pixelsService.getAllEnumerations(DetectorType.class.getName());
   Detector detector = new DetectorI();
   detector.setAmplificationGain(omero.rtypes.rdouble(0));
   detector.setGain(omero.rtypes.rdouble(1));
   detector.setManufacturer(omero.rtypes.rstring("manufacturer"));
   detector.setModel(omero.rtypes.rstring("model"));
   detector.setSerialNumber(omero.rtypes.rstring("serial number"));
   detector.setLotNumber(omero.rtypes.rstring("lot number"));
   detector.setOffsetValue(omero.rtypes.rdouble(0));
   detector.setType((DetectorType) types.get(0));
   return detector;
 }
Пример #13
0
  /**
   * Creates and returns a filter. This will have to be linked to an instrument.
   *
   * @param cutIn The cut in value.
   * @param cutOut The cut out value.
   * @return See above.
   * @throws Exception Thrown if an error occurred.
   */
  public Filter createFilter(int cutIn, int cutOut) throws Exception {
    // already tested see PixelsService enumeration.
    List<IObject> types = pixelsService.getAllEnumerations(FilterType.class.getName());
    Filter filter = new FilterI();
    filter.setLotNumber(omero.rtypes.rstring("lot number"));
    filter.setSerialNumber(omero.rtypes.rstring("serial number"));
    filter.setManufacturer(omero.rtypes.rstring("manufacturer"));
    filter.setModel(omero.rtypes.rstring("model"));
    filter.setType((FilterType) types.get(0));

    TransmittanceRangeI transmittance = new TransmittanceRangeI();
    transmittance.setCutIn(omero.rtypes.rint(cutIn));
    transmittance.setCutOut(omero.rtypes.rint(cutOut));
    transmittance.setCutInTolerance(omero.rtypes.rint(1));
    transmittance.setCutOutTolerance(omero.rtypes.rint(1));
    filter.setTransmittanceRange(transmittance);
    return filter;
  }
Пример #14
0
  /**
   * Creates a new image with one channel from a source image.
   *
   * @param info The information about the data to handle.
   */
  private void CreateNewImage(ConfigurationInfo info) throws Exception {
    PixelsData pixels = image.getDefaultPixels();
    int sizeZ = pixels.getSizeZ();
    int sizeT = pixels.getSizeT();
    int sizeC = pixels.getSizeC();
    int sizeX = pixels.getSizeX();
    int sizeY = pixels.getSizeY();
    long pixelsId = pixels.getId();
    if (sizeC <= 1) throw new Exception("The image must have at least 2 channels.");
    RawPixelsStorePrx store = null;
    // Create a new image.
    Map<Integer, byte[]> map = new LinkedHashMap<Integer, byte[]>();
    try {
      store = connector.getRawPixelsStore();
      store.setPixelsId(pixelsId, false);
      for (int z = 0; z < sizeZ; z++) {
        for (int t = 0; t < sizeT; t++) {
          byte[] planeC1 = store.getPlane(z, 0, t);
          byte[] planeC2 = store.getPlane(z, 1, t);
          byte[] newPlane = new byte[planeC1.length];
          for (int i = 0; i < planeC1.length; i++) {
            newPlane[i] = (byte) ((planeC1[i] + planeC2[i]) / 2);
          }
          map.put(linearize(z, t, sizeZ), newPlane);
        }
      }

    } catch (Exception e) {
      throw new Exception("Cannot retrieve the plane", e);
    } finally {
      if (store != null) store.close();
    }

    // Now we are going to create the new image.
    IPixelsPrx proxy = connector.getPixelsService();
    List<IObject> l = proxy.getAllEnumerations(PixelsType.class.getName());
    Iterator<IObject> i = l.iterator();
    PixelsType type = null;
    String original = pixels.getPixelType();
    while (i.hasNext()) {
      PixelsType o = (PixelsType) i.next();
      String value = o.getValue().getValue();
      if (value.equals(original)) {
        type = o;
        break;
      }
    }
    if (type == null) throw new Exception("Pixels Type not valid.");

    String name = "newImageFrom" + image.getId();
    RLong idNew =
        proxy.createImage(
            sizeX,
            sizeY,
            sizeZ,
            sizeT,
            Arrays.asList(0),
            type,
            name,
            "From Image ID: " + image.getId());
    if (idNew == null) throw new Exception("New image could not be created.");
    ImageData newImage = loadImage(idNew.getValue());

    // link the new image and the dataset hosting the source image.
    DatasetImageLink link = new DatasetImageLinkI();
    link.setParent(new DatasetI(info.getDatasetId(), false));
    link.setChild(new ImageI(newImage.getId(), false));
    connector.getUpdateService().saveAndReturnObject(link);

    // Write the data.
    try {
      store = connector.getRawPixelsStore();
      store.setPixelsId(newImage.getDefaultPixels().getId(), false);
      int index = 0;
      for (int z = 0; z < sizeZ; z++) {
        for (int t = 0; t < sizeT; t++) {
          index = linearize(z, t, sizeZ);
          store.setPlane(map.get(index), z, 0, t);
        }
      }
      store.save();
      System.err.println("image created");
    } catch (Exception e) {
      throw new Exception("Cannot set the plane", e);
    } finally {
      if (store != null) store.close();
    }
  }