From 502646e0fc5928d83ccb78a152843c3b852b1c0b Mon Sep 17 00:00:00 2001 From: takashi310 Date: Fri, 4 Apr 2025 14:56:11 -0400 Subject: [PATCH] bug fix for anisotropy data processing --- .../bigstitcher/spark/SparkAffineFusion.java | 35 ++++++++++++------- 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/src/main/java/net/preibisch/bigstitcher/spark/SparkAffineFusion.java b/src/main/java/net/preibisch/bigstitcher/spark/SparkAffineFusion.java index c926be3e..13f3b466 100644 --- a/src/main/java/net/preibisch/bigstitcher/spark/SparkAffineFusion.java +++ b/src/main/java/net/preibisch/bigstitcher/spark/SparkAffineFusion.java @@ -8,12 +8,12 @@ * it under the terms of the GNU General Public License as * published by the Free Software Foundation, either version 2 of the * License, or (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public * License along with this program. If not, see * . @@ -174,12 +174,12 @@ public Void call() throws Exception } if ( timepointIndex == null && ( vi != null || timepointIds != null || channelIds != null || illuminationIds != null || tileIds != null || angleIds != null ) ) - + { System.out.println( "You can only specify specify angles, tiles, ..., ViewIds if you provided a specific timepointIndex & channelIndex."); return null; } - + this.outPathURI = URITools.toURI( outputPathURIString ); System.out.println( "Fused volume: " + outPathURI ); @@ -227,7 +227,7 @@ else if ( outputPathURIString.toLowerCase().endsWith( ".h5" ) || outPathURI.toSt final long[] bbMin = driverVolumeWriter.getAttribute( "/", "Bigstitcher-Spark/Boundingbox_min", long[].class ); final long[] bbMax = driverVolumeWriter.getAttribute( "/", "Bigstitcher-Spark/Boundingbox_max", long[].class ); - + final BoundingBox boundingBox = new BoundingBox( new FinalInterval( bbMin, bbMax ) ); final boolean preserveAnisotropy = driverVolumeWriter.getAttribute( "/", "Bigstitcher-Spark/PreserveAnisotropy", boolean.class ); @@ -236,6 +236,10 @@ else if ( outputPathURIString.toLowerCase().endsWith( ".h5" ) || outPathURI.toSt final DataType dataType = driverVolumeWriter.getAttribute( "/", "Bigstitcher-Spark/DataType", DataType.class ); + final long[] orig_bbMin = driverVolumeWriter.getAttribute( "/", "Bigstitcher-Spark/Boundingbox_min", long[].class ); + if ( !Double.isNaN( anisotropyFactor ) ) + orig_bbMin[ 2 ] = Math.round( Math.floor( orig_bbMin[ 2 ] * anisotropyFactor ) ); + System.out.println( "FusionFormat: " + fusionFormat ); System.out.println( "Input XML: " + xmlURI ); System.out.println( "BDV project: " + bdv ); @@ -279,13 +283,13 @@ else if ( outputPathURIString.toLowerCase().endsWith( ".h5" ) || outPathURI.toSt final ArrayList< ViewId > viewIdsGlobal; if ( - dataGlobal.getSequenceDescription().getAllChannelsOrdered().size() != numChannels || - dataGlobal.getSequenceDescription().getTimePoints().getTimePointsOrdered().size() != numTimepoints ) + dataGlobal.getSequenceDescription().getAllChannelsOrdered().size() != numChannels || + dataGlobal.getSequenceDescription().getTimePoints().getTimePointsOrdered().size() != numTimepoints ) { System.out.println( "The number of channels and timepoint in XML does not match the number in the export dataset." - + "You have to specify which ViewIds/Channels/Illuminations/Tiles/Angles/Timepoints should be fused into" - + "a specific 3D volume in the fusion dataset:"); + + "You have to specify which ViewIds/Channels/Illuminations/Tiles/Angles/Timepoints should be fused into" + + "a specific 3D volume in the fusion dataset:"); viewIdsGlobal = AbstractSelectableViews.loadViewIds( dataGlobal, vi, angleIds, channelIds, illuminationIds, tileIds, timepointIds ); @@ -400,6 +404,13 @@ else if ( dataType == DataType.UINT16 ) anisotropyFactor, Double.NaN ); + final HashMap< ViewId, AffineTransform3D > orig_registrations = + TransformVirtual.adjustAllTransforms( + viewIds, + dataLocal.getViewRegistrations().getViewRegistrations(), + Double.NaN, + Double.NaN ); + final Converter conv; final Type type; final boolean uint8, uint16; @@ -429,7 +440,7 @@ else if ( dataType == DataType.UINT16 ) // The min coordinates of the block that this job renders (in pixels) final int n = gridBlock[ 0 ].length; final long[] superBlockOffset = new long[ n ]; - Arrays.setAll( superBlockOffset, d -> gridBlock[ 0 ][ d ] + bbMin[ d ] ); + Arrays.setAll( superBlockOffset, d -> gridBlock[ 0 ][ d ] + orig_bbMin[ d ] ); // The size of the block that this job renders (in pixels) final long[] superBlockSize = gridBlock[ 1 ]; @@ -444,7 +455,7 @@ else if ( dataType == DataType.UINT16 ) Arrays.setAll( fusedBlockMax, d -> superBlockOffset[ d ] + superBlockSize[ d ] - 1 ); final List< ViewId > overlappingViews = - OverlappingViews.findOverlappingViews( dataLocal, viewIds, registrations, fusedBlock ); + OverlappingViews.findOverlappingViews( dataLocal, viewIds, orig_registrations, fusedBlock ); final RandomAccessibleInterval img; @@ -635,4 +646,4 @@ public static void main(final String... args) throws SpimDataException { System.exit(new CommandLine(new SparkAffineFusion()).execute(args)); } -} +} \ No newline at end of file