public Long getTimepointOffset(Integer t) throws DimensionsOutOfBoundsException { checkBounds(null, null, null, null, t); return (long) t * getTimepointSize(); }
public void checkBounds(Integer x, Integer y, Integer z, Integer c, Integer t) throws DimensionsOutOfBoundsException { reader().checkBounds(x, y, z, c, t); }
private void checkCubeBounds(List<Integer> offset, List<Integer> size, List<Integer> step) throws DimensionsOutOfBoundsException { // At the moment the array must contain 5 values if(offset.size()!=5 || size.size()!=5 || step.size()!=5) { throw new DimensionsOutOfBoundsException( "Invalid List length: each list must contain 5 elements XYZCT"); } checkBounds(offset.get(0),offset.get(1),offset.get(2),offset.get(3),offset.get(4)); checkBounds(offset.get(0)+size.get(0)-1,offset.get(1)+size.get(1)-1, offset.get(2)+size.get(2)-1,offset.get(3)+size.get(3)-1,offset.get(4)+size.get(4)-1); if(step.get(0) < 1 || step.get(1) < 1 || step.get(2) < 1 || step.get(3) < 1 || step.get(4) < 1) { throw new DimensionsOutOfBoundsException( "Invalid step size: steps sizes must be 1 or greater"); } }
public byte[] getPlane(Integer z, Integer c, Integer t, byte[] buffer) throws IOException, DimensionsOutOfBoundsException { checkBounds(null, null, z, c, t); try { if (buffer.length != getPlaneSize()) throw new RuntimeException("Buffer size incorrect."); getWholePlane(z,c,t,buffer); } catch (FormatException e) { throw new RuntimeException(e); } return buffer; }
public Long getRowOffset(Integer y, Integer z, Integer c, Integer t) throws DimensionsOutOfBoundsException { checkBounds(null, y, z, c, t); return (long) getPlaneOffset(z,c,t) + y * getRowSize(); }
public Long getStackOffset(Integer c, Integer t) throws DimensionsOutOfBoundsException { checkBounds(null, null, null, c, t); return (long) getTimepointOffset(t) + c * getStackSize(); }
public Long getPlaneOffset(Integer z, Integer c, Integer t) throws DimensionsOutOfBoundsException { checkBounds(null, null, z, c, t); return (long) getStackOffset(c,t) + z * getPlaneSize(); }
public byte[] getStack(Integer c, Integer t, byte[] buffer) throws IOException, DimensionsOutOfBoundsException { checkBounds(null, null, null, c, t); try { if (buffer.length != getStackSize()) throw new RuntimeException("Buffer size incorrect."); int size = RomioPixelBuffer.safeLongToInteger(getPlaneSize()); byte[] plane = new byte[size]; int sizeZ = getSizeZ(); for(int z = 0; z < sizeZ; z++) { getWholePlane(z,c,t,plane); System.arraycopy(plane, 0, buffer, z*size, size); } } catch (FormatException e) { throw new RuntimeException(e); } return buffer; }
public byte[] getRow(Integer y, Integer z, Integer c, Integer t, byte[] buffer) throws IOException, DimensionsOutOfBoundsException { checkBounds(null, y, z, c, t); try { if (buffer.length != getRowSize()) throw new RuntimeException("Buffer size incorrect."); int size = RomioPixelBuffer.safeLongToInteger(getPlaneSize()); byte[] plane = new byte[size]; getWholePlane(z,c,t,plane); System.arraycopy(plane, y*getRowSize(), buffer, 0, getRowSize()); } catch (FormatException e) { throw new RuntimeException(e); } return buffer; }
public byte[] getTimepoint(Integer t, byte[] buffer) throws IOException, DimensionsOutOfBoundsException { checkBounds(null, null, null, null, t); if (buffer.length != getTimepointSize()) throw new RuntimeException("Buffer size incorrect."); int size = RomioPixelBuffer.safeLongToInteger(getStackSize()); byte[] stack = new byte[size]; int sizeC = getSizeC(); for(int c = 0; c < sizeC; c++) { getStack(c, t, stack); System.arraycopy(stack, 0, buffer, c*size, size); } return buffer; }
public byte[] getCol(Integer x, Integer z, Integer c, Integer t, byte[] buffer) throws IOException, DimensionsOutOfBoundsException { checkBounds(x, null, z, c, t); try { if (buffer.length != getColSize()) throw new RuntimeException("Buffer size incorrect."); int size = RomioPixelBuffer.safeLongToInteger(getPlaneSize()); byte[] plane = new byte[size]; getWholePlane(z,c,t,plane); for(int y = 0; y < reader.getSizeY(); y++) { System.arraycopy(plane, (y*getRowSize())+(x*getByteWidth()), buffer, y*getByteWidth(), getByteWidth()); } } catch (FormatException e) { throw new RuntimeException(e); } return buffer; }