Skip to content

Commit

Permalink
correct small errors and add TODO
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosuc3m committed Oct 26, 2023
1 parent 6d617fd commit a0a7e3a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -238,20 +238,8 @@ public String getDisplayableStepMinConstraints() {
return minStr + " " + stepStr;
}

/**
* REturn an array containing the optimal patch for the given sequence.
* An optimal patch has the arbitrary requirement of not being bigger than
* 10^6 pixels
* @param seqSize
* array containing the size of the sequence with the axes order "xyczb"
* @return the array with the pathc of interest
*/
public int[] getOptimalPatch(int[] seqSize) {
String seqSizeAxes = "XYCZB";
return getOptimalPatch(seqSize, seqSizeAxes);
}

/**
/** TODO this method does not realy required to be non-static because the instance already
* contains the axes order, maybe separate two methods
* REturn an array containing the optimal patch for the given sequence.
* @param seqSize
* array containing the size of the sequence with the axes order defined
Expand Down Expand Up @@ -564,11 +552,13 @@ public void setTotalHalo(float[] totalHalo){
* patch for the selected image
* @param imSize
* size of the image. The order is Width, Height, Channel, Slices, time
* @param axesOrder
* the axes order of the imSize parameter
* @return the String containing a patch in the format 256,256,3
*/
public String getDisplayableOptimalPatch(int[] imSize) {
public String getDisplayableOptimalPatch(int[] imSize, String axesOrder) {
// Remove the B axes from the optimal patch size and get the String representation
String patchStr = getDisplayableSizesString(getOptimalPatch(imSize));
String patchStr = getDisplayableSizesString(getOptimalPatch(imSize, axesOrder));
return patchStr;
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/io/bioimage/modelrunner/model/Model.java
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ List<Tensor<T>> runBioimageioModelOnImgLib2WithTiling(List<Tensor<R>> inputTenso
else if (descriptor == null && !(new File(modelFolder, Constants.RDF_FNAME).isFile()))
throw new IllegalArgumentException("");
else if (descriptor == null)
descriptor = ModelDescriptor.readFromLocalFile(modelFolder + File.separator + Constants.RDF_FNAME);
descriptor = ModelDescriptor.readFromLocalFile(modelFolder + File.separator + Constants.RDF_FNAME, false);
PatchGridCalculator<R> tileGrid = PatchGridCalculator.build(descriptor, inputTensors);
return runTiling(inputTensors, tileGrid);
}
Expand Down Expand Up @@ -592,7 +592,7 @@ void doTiling(List<Tensor<R>> inputTensors, List<Tensor<T>> outputTensors, Patch
}
}

public static <T extends NativeType<T> & RealType<T>> void main(String[] args) throws IOException, ValidationException, LoadEngineException, RunModelException {
public static <T extends NativeType<T> & RealType<T>> void main(String[] args) throws IOException, ValidationException, LoadEngineException, RunModelException, LoadModelException {
String mm = "C:\\Users\\angel\\OneDrive\\Documentos\\pasteur\\git\\model-runner-java\\models\\StarDist H&E Nuclei Segmentation_06092023_020924\\";
Img<FloatType> im = ArrayImgs.floats(new long[] {1, 511, 512, 3});
ImagePlus imp = IJ.openImage(mm + File.separator + "sample_input_0.tif");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ private PatchSpec computePatchSpecs(TensorSpec spec, RandomAccessibleInterval<T>
for (int i = 0; i < intShape.length; i ++) intShape[i] = (int) rai.dimensionsAsLongArray()[i];
if (spec.getProcessingPatch() == null) {
try {
spec.setTileSizeForTensorAndImageSize(spec.getOptimalPatch(intShape), intShape);
spec.setTileSizeForTensorAndImageSize(spec.getOptimalPatch(intShape, spec.getAxesOrder()), intShape);
} catch (Exception e) {
throw new IllegalArgumentException("Tensor dimensions of tensor named '" + spec.getName() + "' "
+ "are not compatible with the requirements set by the"
Expand Down

0 comments on commit a0a7e3a

Please sign in to comment.