Skip to content

Commit f8ecbeb

Browse files
committed
Fix wrong upload
1 parent 2f75543 commit f8ecbeb

1 file changed

Lines changed: 17 additions & 7 deletions

File tree

render-ws-spark-client/src/main/java/org/janelia/render/client/spark/destreak/StreakCorrectionClient.java

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import org.janelia.alignment.ShortRenderer;
2525
import org.janelia.alignment.Utils;
2626
import org.janelia.alignment.destreak.SecondChannelStreakCorrector;
27+
import org.janelia.alignment.loader.DynamicMaskLoader;
2728
import org.janelia.alignment.loader.ImageLoader;
2829
import org.janelia.alignment.spec.ChannelSpec;
2930
import org.janelia.alignment.spec.ResolvedTileSpecCollection;
@@ -277,15 +278,24 @@ private String buildOutputPath(final Parameters clientParameters, final TileSpec
277278
}
278279

279280
private void updateTileSpecWithCorrectedImage(final TileSpec tileSpec, final String imagePath) {
280-
// Replace all channels with a single channel pointing to the corrected image
281-
final List<ChannelSpec> allChannels = tileSpec.getAllChannels();
282-
allChannels.clear();
283-
284-
final ChannelSpec correctedChannel = new ChannelSpec();
285-
correctedChannel.putMipmap(0, new ImageAndMask(imagePath, null));
281+
// Point the tile spec to the new image
282+
final ChannelSpec channelSpec = tileSpec.getAllChannels().get(0);
283+
ImageAndMask imageAndMask = channelSpec
284+
.getFirstMipmapImageAndMask(tileSpec.getTileId())
285+
.copyWithImage(imagePath, null, null);
286+
287+
// If the channel has a mask, ensure it is a dynamic mask and update the URL
288+
if (channelSpec.hasMask()) {
289+
if (! ImageLoader.LoaderType.DYNAMIC_MASK.equals(imageAndMask.getMaskLoaderType())) {
290+
throw new IllegalArgumentException("Channel " + channelSpec.getName() +
291+
" has a mask, but it is not a dynamic mask. Cannot update tile spec.");
292+
}
286293

287-
tileSpec.addChannel(correctedChannel);
294+
final DynamicMaskLoader.DynamicMaskDescription description = DynamicMaskLoader.parseUrl(imageAndMask.getMaskUrl());
295+
imageAndMask = imageAndMask.copyWithMask(description.toString(), ImageLoader.LoaderType.DYNAMIC_MASK, null);
296+
}
288297

298+
channelSpec.putMipmap(0, imageAndMask);
289299
LOG.debug("updateTileSpecWithCorrectedImage: updated tile {} with corrected image at {}",
290300
tileSpec.getTileId(), imagePath);
291301
}

0 commit comments

Comments
 (0)