Skip to content

Commit

Permalink
correct couple of typos
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosuc3m committed Feb 17, 2025
1 parent 8134d1d commit 7d34fed
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,13 @@ protected String createImportsCode() {
@Override
protected <T extends RealType<T> & NativeType<T>> void checkInput(RandomAccessibleInterval<T> image) {
if (image.dimensionsAsLongArray().length == 3 && this.nChannels != 1)
throw new IllegalArgumentException("Stardist3D needs an image with four dimensions: XYCZ");
throw new IllegalArgumentException("Stardist3D needs an image with four dimensions: XYZC");
else if (image.dimensionsAsLongArray().length != 4 && this.nChannels != 1)
throw new IllegalArgumentException("Stardist3D needs an image with four dimensions: XYCZ");
else if (image.dimensionsAsLongArray().length == 4 && image.dimensionsAsLongArray()[2] != nChannels)
throw new IllegalArgumentException("Stardist3D needs an image with four dimensions: XYZC");
else if (image.dimensionsAsLongArray().length == 4 && image.dimensionsAsLongArray()[3] != nChannels)
throw new IllegalArgumentException("This Stardist3D model requires " + nChannels + " channels.");
else if (image.dimensionsAsLongArray().length > 4 || image.dimensionsAsLongArray().length < 2)
throw new IllegalArgumentException("Stardist3D model requires an image with dimensions XYCZ.");
throw new IllegalArgumentException("Stardist3D model requires an image with dimensions XYZC.");
}


Expand All @@ -107,12 +107,12 @@ protected <T extends RealType<T> & NativeType<T>> RandomAccessibleInterval<T> re

@Override
public boolean is2D() {
return true;
return false;
}

@Override
public boolean is3D() {
return false;
return true;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public abstract class StardistAbstract extends BaseModel {
* Using maximum percentile 100 is equivalent to use the maximum of the image as the max
* Every pixels is transformed as follows: new_pixel = (pixel - min) / (max - min)
*/
public double scaleRangeMinPercentile = 99.8;
public double scaleRangeMinPercentile = 1;

/**
* Channels along which the scalin is performed.
Expand Down Expand Up @@ -144,6 +144,7 @@ public abstract class StardistAbstract extends BaseModel {

private static final String RUN_MODEL_CODE = ""
+ "output = model.predict_instances(im, return_predict=False)" + System.lineSeparator()
+ "print(type(output))" + System.lineSeparator()
+ "if type(output) == np.ndarray:" + System.lineSeparator()
+ " im[:] = output" + System.lineSeparator()
+ " im[:] = output" + System.lineSeparator()
Expand All @@ -156,6 +157,8 @@ public abstract class StardistAbstract extends BaseModel {
+ " raise TypeError('If the StarDist output is a list, the first entry should be a np.ndarray')" + System.lineSeparator()
+ "if len(im.shape) == 3 and len(output[0].shape) == 2:" + System.lineSeparator()
+ " im[:, :, 0] = output[0]" + System.lineSeparator()
+ "if len(im.shape) == 4 and len(output[0].shape) == 3:" + System.lineSeparator()
+ " im[:, :, :, 0] = output[0]" + System.lineSeparator()
+ "else:" + System.lineSeparator()
+ " im[:] = output[0]" + System.lineSeparator()
+ "if len(output) > 1 and type(output[1]) != dict:" + System.lineSeparator()
Expand Down

0 comments on commit 7d34fed

Please sign in to comment.