Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[wip] OpenOrganelle demo #518

Closed
wants to merge 15 commits into from
Closed

[wip] OpenOrganelle demo #518

wants to merge 15 commits into from

Conversation

kephale
Copy link
Member

@kephale kephale commented Jun 19, 2023

No description provided.

@kephale
Copy link
Member Author

kephale commented Jun 19, 2023

@tpietzsch I'm getting stuck on the OpenOrganelle demo because the N5 data is UnsignedByteType, but clearly it needs to get rendered as an UnsignedShortType.

However, the N5 is being opened as Volatile:

final CachedCellImg<?, ?> vimg = N5Utils.openVolatile( n5, datasetsToOpen[s] );

scenery will need some corresponding updates for proper detection of multiscale images that are opened with N5 (currently it is focused on detecting normal BDV images with XML metadata).

@tpietzsch
Copy link
Collaborator

@kephale
First, note that N5Utils.openVolatile will still open the image as a (non-volatile) UnsignedByteType image. (But with underlying VolatileByteAccess that provides the capability to turn it into a volatile image.)

At some point you need to use VolatileViews.wrapAsVolatile(...) to make it volatile.
I wish I could tell you that you can convert it to UnsignedShortType and it will just work. Unfortunately it wont, yet, because VolatileViews can't deal with the Converter.

You could try to first VolatileViews.wrapAsVolatile(...) to turn it into RandomAccessibleInterval<UnsignedByteType>. And then convert from VolatileUnsignedByteType to VolatileUnsignedShortType. I fear that it will still not work because BVV assumes that it will get some kind of AbstractCellImg, and the converted RAI will not be that.

So, unfortunately you'll have to make a (lazy) copy... :-(
I'm pretty sure this will work:

import bdv.util.volatiles.VolatileViews;
import net.imglib2.RandomAccessibleInterval;
import net.imglib2.algorithm.blocks.BlockAlgoUtils;
import net.imglib2.algorithm.blocks.convert.Convert;
import net.imglib2.blocks.PrimitiveBlocks;
import net.imglib2.cache.img.CachedCellImg;
import net.imglib2.type.numeric.integer.UnsignedByteType;
import net.imglib2.type.numeric.integer.UnsignedShortType;
import net.imglib2.type.volatiles.VolatileUnsignedShortType;

static RandomAccessibleInterval< VolatileUnsignedShortType > convert(
		RandomAccessibleInterval< UnsignedByteType > rai )
{
	final int[] cellDimensions = { 64, 64, 64 };
	final PrimitiveBlocks< UnsignedByteType > blocks = PrimitiveBlocks.of( rai );
	final CachedCellImg< UnsignedShortType, ? > img = BlockAlgoUtils.cellImg(
			blocks,
			Convert.convert( new UnsignedByteType(), new UnsignedShortType() ),
			new UnsignedShortType(),
			rai.dimensionsAsLongArray(),
			cellDimensions
	);
	return VolatileViews.wrapAsVolatile( img );
}

It requires recently released versions

<net.imglib2.imglib2.version>6.2.0</net.imglib2.imglib2.version>
<net.imglib2.imglib2-algorithm.version>0.14.0</net.imglib2.imglib2-algorithm.version>

Of course, the better solution would be to make BVV just handle these datatypes, but I don't have a timeline for that.

@kephale
Copy link
Member Author

kephale commented Jun 20, 2023

Thank you very much @tpietzsch ! You've unblocked the demo work 🍪 !

@kephale
Copy link
Member Author

kephale commented Jun 20, 2023

This is getting stuck here https://github.com/scenerygraphics/scenery/blob/be284d2488c8635952d0a62f5ca3e5bed15742d1/src/main/kotlin/graphics/scenery/volumes/VolumeManager.kt#L396. it seems like it is trying to create a ton of FillTasks (129705 blocks?), the next thing i would check is how the BVV volume is being initialized w.r.t. the camera

@tpietzsch
Copy link
Collaborator

That sounds like it doesn't use multi-resolution

@kephale kephale closed this Jul 22, 2023
@kephale
Copy link
Member Author

kephale commented Jul 22, 2023

migrated to #537

@kephale kephale deleted the openorganelle-scenery-0.9.0 branch April 18, 2024 11:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants