Skip to content

Commit

Permalink
correct error decoding the numpy arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosuc3m committed Oct 29, 2023
1 parent 01c5e5e commit a217056
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/main/java/io/bioimage/modelrunner/numpy/DecodeNumpy.java
Original file line number Diff line number Diff line change
Expand Up @@ -326,42 +326,42 @@ public static <T extends NativeType<T>> RandomAccessibleInterval<T> build(ByteBu
transposedShape[i] = shape[shape.length - i - 1];
if (dtype.equals("int8")) {
ByteAccess access = new ByteBufferAccess(buf, true);
return (RandomAccessibleInterval<T>) Utils.transpose(ArrayImgs.bytes( access, shape ));
return (RandomAccessibleInterval<T>) Utils.transpose(ArrayImgs.bytes( access, transposedShape ));
//return (Img<T>) buildInt8(buf, byteOrder, shape);
} else if (dtype.equals("uint8")) {
ByteAccess access = new ByteBufferAccess(buf, true);
return (RandomAccessibleInterval<T>) Utils.transpose(ArrayImgs.unsignedBytes( access, shape ));
return (RandomAccessibleInterval<T>) Utils.transpose(ArrayImgs.unsignedBytes( access, transposedShape ));
//return (Img<T>) buildUInt8(buf, byteOrder, shape);
} else if (dtype.equals("int16")) {
ShortAccess access = new ShortBufferAccess(buf, true);
return (RandomAccessibleInterval<T>) Utils.transpose(ArrayImgs.shorts( access, shape ));
return (RandomAccessibleInterval<T>) Utils.transpose(ArrayImgs.shorts( access, transposedShape ));
//return (Img<T>) buildInt16(buf, byteOrder, shape);
} else if (dtype.equals("uint16")) {
ShortAccess access = new ShortBufferAccess(buf, true);
return (RandomAccessibleInterval<T>) Utils.transpose(ArrayImgs.unsignedShorts( access, shape ));
return (RandomAccessibleInterval<T>) Utils.transpose(ArrayImgs.unsignedShorts( access, transposedShape ));
//return (Img<T>) buildUInt16(buf, byteOrder, shape);
} else if (dtype.equals("int32")) {
IntAccess access = new IntBufferAccess(buf, true);
return (RandomAccessibleInterval<T>) Utils.transpose(ArrayImgs.ints( access, shape ));
return (RandomAccessibleInterval<T>) Utils.transpose(ArrayImgs.ints( access, transposedShape ));
//return (Img<T>) buildInt32(buf, byteOrder, shape);
} else if (dtype.equals("uint32")) {
IntAccess access = new IntBufferAccess(buf, true);
return (RandomAccessibleInterval<T>) Utils.transpose(ArrayImgs.unsignedInts( access, shape ));
return (RandomAccessibleInterval<T>) Utils.transpose(ArrayImgs.unsignedInts( access, transposedShape ));
//return (Img<T>) buildUInt32(buf, byteOrder, shape);
} else if (dtype.equals("int64")) {
LongAccess access = new LongBufferAccess(buf, true);
return (RandomAccessibleInterval<T>) Utils.transpose(ArrayImgs.longs( access, shape ));
return (RandomAccessibleInterval<T>) Utils.transpose(ArrayImgs.longs( access, transposedShape ));
//return (Img<T>) buildInt64(buf, byteOrder, shape);
} else if (dtype.equals("float32")) {
FloatAccess access = new FloatBufferAccess(buf, true);
return (RandomAccessibleInterval<T>) Utils.transpose(ArrayImgs.floats( access, shape ));
return (RandomAccessibleInterval<T>) Utils.transpose(ArrayImgs.floats( access, transposedShape ));
//return (Img<T>) buildFloat32(buf, byteOrder, shape);
} else if (dtype.equals("float64")) {
DoubleAccess access = new DoubleBufferAccess(buf, true);
return (RandomAccessibleInterval<T>) Utils.transpose(ArrayImgs.doubles( access, shape ));
return (RandomAccessibleInterval<T>) Utils.transpose(ArrayImgs.doubles( access, transposedShape ));
//return (Img<T>) buildFloat64(buf, byteOrder, shape);
} else if (dtype.equals("bool")) {
return (RandomAccessibleInterval<T>) Utils.transpose(buildBoolean(buf, byteOrder, shape));
return (RandomAccessibleInterval<T>) Utils.transpose(buildBoolean(buf, byteOrder, transposedShape));
} else {
throw new IllegalArgumentException("Unsupported data type of numpy array: " + dtype);
}
Expand Down

0 comments on commit a217056

Please sign in to comment.