Skip to content

Commit

Permalink
feat/tes: ApplyBigwarpPlugin expose show option
Browse files Browse the repository at this point in the history
* dont try to show results in BigWarpApplyTests
  • Loading branch information
bogovicj committed Oct 3, 2024
1 parent 7ce37da commit a71d024
Show file tree
Hide file tree
Showing 2 changed files with 97 additions and 43 deletions.
33 changes: 27 additions & 6 deletions src/main/java/bdv/ij/ApplyBigwarpPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@
import net.imglib2.Interval;
import net.imglib2.RandomAccessibleInterval;
import net.imglib2.RealInterval;
import net.imglib2.RealPoint;
import net.imglib2.RealRandomAccessible;
import net.imglib2.realtransform.AffineGet;
import net.imglib2.realtransform.AffineRandomAccessible;
Expand Down Expand Up @@ -907,6 +906,32 @@ public static <T> List<ImagePlus> apply(
final boolean wait,
final WriteDestinationOptions writeOpts) {

final boolean show = ( writeOpts == null || writeOpts.pathOrN5Root == null || writeOpts.pathOrN5Root.isEmpty());
return apply(bwData, landmarks, invXfm,
tranformTypeOption, fieldOfViewOption, fieldOfViewPointFilter, bboxEst,
resolutionOption, resolutionSpec, fovSpec, offsetSpec,
interp, isVirtual, nThreads, wait, writeOpts, show);
}

public static <T> List<ImagePlus> apply(
final BigWarpData<T> bwData,
final LandmarkTableModel landmarks,
final InvertibleRealTransform invXfm,
final String tranformTypeOption,
final String fieldOfViewOption,
final String fieldOfViewPointFilter,
final BoundingBoxEstimation bboxEst,
final String resolutionOption,
final double[] resolutionSpec,
final double[] fovSpec,
final double[] offsetSpec,
final Interpolation interp,
final boolean isVirtual,
final int nThreads,
final boolean wait,
final WriteDestinationOptions writeOpts,
final boolean show) {

final int numChannels = bwData.numMovingSources();
for ( int i = 0; i < numChannels; i++ )
{
Expand Down Expand Up @@ -955,11 +980,7 @@ public static <T> List<ImagePlus> apply(
}
else
{
final boolean show;
if( writeOpts == null || writeOpts.pathOrN5Root == null || writeOpts.pathOrN5Root.isEmpty())
show = true;
else
show = false;


return runExport( bwData, bwData.sources, fieldOfViewOption,
outputIntervalList, matchedPtNames, interp,
Expand Down
107 changes: 70 additions & 37 deletions src/test/java/bigwarp/apply/BigWarpApplyTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@
import bigwarp.landmarks.LandmarkTableModel;
import bigwarp.transforms.BigWarpTransform;
import ij.ImagePlus;
import net.imglib2.Cursor;
import net.imglib2.img.Img;
import net.imglib2.img.display.imagej.ImageJFunctions;
import net.imglib2.iterator.RealIntervalIterator;
import net.imglib2.realtransform.BoundingBoxEstimation;
import net.imglib2.realtransform.InvertibleRealTransform;
import net.imglib2.type.numeric.integer.UnsignedByteType;
import net.imglib2.util.Intervals;

Expand Down Expand Up @@ -201,58 +202,90 @@ private static void assertOriginsEqual(double[] expected, ImagePlus actual) {

private static List<ImagePlus> transformToTarget(ImagePlus mvg, ImagePlus tgt, LandmarkTableModel ltm) {

return ApplyBigwarpPlugin.apply(mvg, tgt,
final BigWarpData<?> bwData = BigWarpInit.createBigWarpDataFromImages(mvg, tgt);
bwData.wrapMovingSources();
final BoundingBoxEstimation bboxEst = new BoundingBoxEstimation(BoundingBoxEstimation.Method.CORNERS);
final InvertibleRealTransform invXfm = new BigWarpTransform( ltm, BigWarpTransform.AFFINE ).getTransformation();

return ApplyBigwarpPlugin.apply(
bwData,
ltm,
BigWarpTransform.AFFINE,
ApplyBigwarpPlugin.TARGET,
null, // fov pt filter
invXfm,
BigWarpTransform.AFFINE, // tform type
ApplyBigwarpPlugin.TARGET, // fov option
null,
bboxEst,
ApplyBigwarpPlugin.TARGET,
null, // res option
null, // fov spac
null, // offset spac
null,
null,
null,
Interpolation.NEARESTNEIGHBOR,
false, // virtual
true, // wait
1); // nThreads
false, // virtual
1, // nThreads
true,
null, // writeOpts
false);
}

private static List<ImagePlus> transformToSpec(final ImagePlus mvg,
final double[] offset, final double[] fov, final double[] res,
final LandmarkTableModel ltm) {

return ApplyBigwarpPlugin.apply(mvg, null,
ltm,
BigWarpTransform.AFFINE,
ApplyBigwarpPlugin.SPECIFIED_PHYSICAL,
null, // fov pt filter
ApplyBigwarpPlugin.SPECIFIED,
res, // res option
fov, // fov spac
offset, // offset spac
Interpolation.NEARESTNEIGHBOR,
false, // virtual
true, // wait
1); // nThreads
ImagePlus tgt = null;
final BigWarpData<?> bwData = BigWarpInit.createBigWarpDataFromImages(mvg, tgt);
bwData.wrapMovingSources();
final BoundingBoxEstimation bboxEst = new BoundingBoxEstimation(BoundingBoxEstimation.Method.CORNERS);
final InvertibleRealTransform invXfm = new BigWarpTransform( ltm, BigWarpTransform.AFFINE ).getTransformation();

return ApplyBigwarpPlugin.apply(
bwData,
ltm,
invXfm,
BigWarpTransform.AFFINE, // tform type
ApplyBigwarpPlugin.SPECIFIED_PHYSICAL, // fov option
null,
bboxEst,
ApplyBigwarpPlugin.SPECIFIED,
res,
fov,
offset,
Interpolation.NEARESTNEIGHBOR,
false, // virtual
1, // nThreads
true,
null, // writeOpts
false);
}

private static List<ImagePlus> transformToPtsSpec(final ImagePlus mvg,
final double[] res,
final LandmarkTableModel ltm,
final String fieldOfViewPointFilter) {

return ApplyBigwarpPlugin.apply(mvg, null,
ltm,
BigWarpTransform.AFFINE,
ApplyBigwarpPlugin.LANDMARK_POINTS,
fieldOfViewPointFilter, // fov pt filter
ApplyBigwarpPlugin.SPECIFIED,
res, // res option
null, // fov spec
null, // offset spac
Interpolation.NEARESTNEIGHBOR,
false, // virtual
true, // wait
1); // nThreads
ImagePlus tgt = null;
final BigWarpData<?> bwData = BigWarpInit.createBigWarpDataFromImages(mvg, tgt);
bwData.wrapMovingSources();
final BoundingBoxEstimation bboxEst = new BoundingBoxEstimation(BoundingBoxEstimation.Method.CORNERS);
final InvertibleRealTransform invXfm = new BigWarpTransform( ltm, BigWarpTransform.AFFINE ).getTransformation();

return ApplyBigwarpPlugin.apply(
bwData,
ltm,
invXfm,
BigWarpTransform.AFFINE, // tform type
ApplyBigwarpPlugin.LANDMARK_POINTS, // fov option
fieldOfViewPointFilter,
bboxEst,
ApplyBigwarpPlugin.SPECIFIED,
res,
null, // fov
null, // offset
Interpolation.NEARESTNEIGHBOR,
false, // virtual
1, // nThreads
true,
null, // writeOpts
false);
}

}

0 comments on commit a71d024

Please sign in to comment.