Beispiel #1
0
  /** Compiles an N-dimensional list of axis lengths from the given reader. */
  private int[] getDimLengths(IFormatReader r) {
    final int sizeX = r.getSizeX();
    final int sizeY = r.getSizeY();
    final int sizeZ = r.getSizeZ();
    final int sizeT = r.getSizeT();
    // final String[] cDimTypes = r.getChannelDimTypes();
    final int[] cDimLengths = r.getChannelDimLengths();
    final String dimOrder = r.getDimensionOrder();

    final List<Integer> dimLengthsList = new ArrayList<Integer>();

    // add core dimensions
    for (int i = 0; i < dimOrder.length(); i++) {
      final char dim = dimOrder.charAt(i);
      switch (dim) {
        case 'X':
          if (sizeX > 1) dimLengthsList.add(sizeX);
          break;
        case 'Y':
          if (sizeY > 1) dimLengthsList.add(sizeY);
          break;
        case 'Z':
          if (sizeZ > 1) dimLengthsList.add(sizeZ);
          break;
        case 'T':
          if (sizeT > 1) dimLengthsList.add(sizeT);
          break;
        case 'C':
          for (int c = 0; c < cDimLengths.length; c++) {
            int len = cDimLengths[c];
            if (len > 1) dimLengthsList.add(len);
          }
          break;
      }
    }

    // convert result to primitive array
    final int[] dimLengths = new int[dimLengthsList.size()];
    for (int i = 0; i < dimLengths.length; i++) {
      dimLengths[i] = dimLengthsList.get(i);
    }
    return dimLengths;
  }
Beispiel #2
0
  /** Copies the current dimensional position into the given array. */
  private void getPosition(IFormatReader r, int no, int[] pos) {
    final int sizeX = r.getSizeX();
    final int sizeY = r.getSizeY();
    final int sizeZ = r.getSizeZ();
    final int sizeT = r.getSizeT();
    // final String[] cDimTypes = r.getChannelDimTypes();
    final int[] cDimLengths = r.getChannelDimLengths();
    final String dimOrder = r.getDimensionOrder();

    final int[] zct = r.getZCTCoords(no);

    int index = 0;
    for (int i = 0; i < dimOrder.length(); i++) {
      final char dim = dimOrder.charAt(i);
      switch (dim) {
        case 'X':
          if (sizeX > 1) index++; // NB: Leave X axis position alone.
          break;
        case 'Y':
          if (sizeY > 1) index++; // NB: Leave Y axis position alone.
          break;
        case 'Z':
          if (sizeZ > 1) pos[index++] = zct[0];
          break;
        case 'T':
          if (sizeT > 1) pos[index++] = zct[2];
          break;
        case 'C':
          final int[] cPos = FormatTools.rasterToPosition(cDimLengths, zct[1]);
          for (int c = 0; c < cDimLengths.length; c++) {
            if (cDimLengths[c] > 1) pos[index++] = cPos[c];
          }
          break;
      }
    }
  }
Beispiel #3
0
  /** Compiles an N-dimensional list of axis types from the given reader. */
  private String[] getDimTypes(IFormatReader r) {
    final int sizeX = r.getSizeX();
    final int sizeY = r.getSizeY();
    final int sizeZ = r.getSizeZ();
    final int sizeT = r.getSizeT();
    final String[] cDimTypes = r.getChannelDimTypes();
    final int[] cDimLengths = r.getChannelDimLengths();
    final String dimOrder = r.getDimensionOrder();
    final List<String> dimTypes = new ArrayList<String>();

    // add core dimensions
    for (char dim : dimOrder.toCharArray()) {
      switch (dim) {
        case 'X':
          if (sizeX > 1) dimTypes.add(X);
          break;
        case 'Y':
          if (sizeY > 1) dimTypes.add(Y);
          break;
        case 'Z':
          if (sizeZ > 1) dimTypes.add(Z);
          break;
        case 'T':
          if (sizeT > 1) dimTypes.add(TIME);
          break;
        case 'C':
          for (int c = 0; c < cDimTypes.length; c++) {
            int len = cDimLengths[c];
            if (len > 1) dimTypes.add(cDimTypes[c]);
          }
          break;
      }
    }

    return dimTypes.toArray(new String[0]);
  }