Save one tiff projection from a current view in BDV

Hi everybody

I am wondering if it’s possible to add the following feature to the Big Data Viewer (both to ‘open xml’ and ‘open multiple xml’):
I would like to save the currently viewed projection as tiff with the highest resolution of h5 dataset. Normally I have to do screenshots for this task which is obviously not the most proper way.

Best,
Maxim

Hi @mpolikarpov,

Welcome to the forum.

You can kind-of do this with Tools > Record Movie if you know how big exactly you want your image to be. If that doesn’t do what you’d like, consider creating an issue with your feature request on github.

John

Hi John

Thanks a lot for your reply and sorry for my late answer - I completely missed it.
Record movie indeed requires me to specify the size, which is exactly the opposite of what I want, because I want to know the physical size of the pixel at the resulting image. Ideally, it should be the same as for the sharpest 0-set of the original h5, where pixel size is specified.

It would be not a problem with orthogonal viewes as I would section the sample easily in python or elsewhere, but BDV viewer seems to be perfect for diagonal viewes and there I want to know what I am looking at.

Anyway, I wrote it on github.

@bogovicj thanks again!

Best,
Maxim

p.s. @Christian_Tischer don’t you have a workaround by chance?

2 Likes

@NicoKiaru This is exactly what my Screenshot functionality in bdv-playground is doing. Could you point @mpolikarpov as to how to use bdv-playground?

5 Likes

Hello @mpolikarpov,

As @Christian_Tischer mentioned, we are working on adding some functionalities on top of BigDataViewer, which are present on this update site : https://biop.epfl.ch/Fiji-Bdv-Playground/. You can activate it, be aware that it may break other bigdataviewer plugins, so keep it on a separate FIJI if you want to be safe.

I’ve made a screencast which shows how to use it for exporting the current view to an ImagePlus with the pixel size you want. Have a look and tell us if it looks ok:

Best,

Nicolas

3 Likes

Hi @NicoKiaru

Thanks a lot for the great video! So two news from my side.

Good news:
The ‘Current View to ImagePlus’ worked, fast and robust. It was exactly what I wanted

Bad news @Christian_Tischer :
I tried to save a screenshot from my dataset and:
(1) it took ages (like 10 min or so)
(2) Fiji consumed all RAM and the process failed with java.lang.OutOfMemoryError.
Fiji and BDV survived though.
I attach the log of the error in case it makes any difference. memory error.txt (7.6 KB)
(3) RAM was not released until I closed Fiji

I have Win7 machine, 12Gb RAM.
My dataset was not extremely huge - less 1Gb, 1150x570x895 pixels in 0-set.

Just a remark. I think that pixel sizes are not in mm only. They should be in the same dimensions as is specified in the xml. So in my case, it was microns and after exporting the view I also got microns.

Best,
Maxim

3 Likes

@mpolikarpov, thanks for testing and reporting!

Regarding ‘Current View to ImagePlus’, there’s a catch : that’s fast, but only if you export a single source, because then you get a Virtual Stack. It’s fast to create at the first time because all pixels are not copied, they are accessed only when required (fast to create, slow to navigate). If you export two sources, if will output a composite image - and then it needs to access and copy all voxels - it’s slow to create, but then navigation is fast.

For the screenshot, it’s weird that it’s failing in such an inelegant way. I never observed this error. Is it reproducible ? If yes, do you have any extra update site that’s installed ? Is your dataset a standard xml/hdf5 ? It would be very interesting for me and @Christian_Tischer to try to reproduce the bug, but the error message is unfortunately not so helpful.

For the units, you’re completely right. Bdv has no units. The data I used for the video was in millimeter, but if your data is in micron, then you need to do the reasoning in micron.

Best,

Nico

1 Like
  1. Did you have one image open or several?
  2. Could post here both the xml and the pixel size that you entered when asked by the Screenshot? (My suspicion is that there was a confusion with the pixel units and you tried to create a super huge screenshot)
  3. @NicoKiaru What is “Current vVew to Imageplus” doing? Is that something you added? Could you point me to the source code?
1 Like

Yes it’s in bigdataviewer-biop-tools, which is also in the update site, but not part of bdv-playground because 1. it’s not clean enough 2. bdv-playground is already quite big, and maybe we need to keep separate repos between the core and the actions for an easier maintenance. Still open to discussion.

The code for this Command is here:

1 Like

Hi. Thanks a lot for your reply.

@NicoKiaru

For the screenshot, it’s weird that it’s failing in such an inelegant way. I never observed this error. Is it reproducible ?
Yes

If yes, do you have any extra update site that’s installed ?
Well, hard to say.
I have: ImageJ, FIJI, Java-8, 3D ImageJ Suite, EMBL-CBA, IJPB-plugins + BDV_playground

Is your dataset a standard xml/hdf5 ?
Yes, a standard one. Never had a problem with it.

@Christian_Tischer

Did you have one image open or several?
One h5 file open

Could post here both the xml and the pixel size that you entered when asked by the Screenshot? (My suspicion is that there was a confusion with the pixel units and you tried to create a super huge screenshot)
XML attached. Pixel size = 0.325
Platy-90_15.xml (1.0 KB)

Hope it helps.

2 Likes

@Christian_Tischer

We found the source of the error together with @NicoKiaru

One should separate decimals with ‘,’ and not ‘.’
So 0,325’ instead of 0.325 for the pixel size. The latter brings a confusion to Fiji so it just punishes you by taking all your RAM.

2 Likes

:smiling_imp:

Found because of experiencing a similar issue a while ago…

1 Like

You say tomato and I say tomato

Hi @NicoKiaru

I have couple of new questions:

  • Is it possible to change the background color from black to white (or custom color) in your BDviewer?
  • How to control visibility in a fused mode?
  • How to export a fused view but still with an original resolution of a 0-set? When I do /Screenshot/Raw data/ it creates a stack

The only think you can do without losing functionality is changing the color of the source (right-click -> Set Sources Color). You have more advanced features (right-click -> Create New Sources (Set LUT)) but they duplicate the source, and you cannot save the source easily anymore. Note that if you have created a new Source with a new LUT, you need to display it again. At this point, if you do right Click -> Set Sources Brightness, you can swap the min and max slider, and this will create an inverted LUT).

How to control visibility in a fused mode?

If, when you create a new Bdv Window, you select Mixed Projector, you can modify the way the sources are overlayed to some extent. For doing this, select a source in the tree, and do right-click -> Set Sources Projection Mode.

I’m not sure about what you want to achieve, but I guess what you want to do is a screenshot with the resolution of the lowest mipmap ? If it’s 5 nm, and bdv is in micron, then type 0,005 (mind the comma :wink: ) in the screenshot command. If you need more flexibility, use the other command Capture View As ImagePlus, which has more export options.

I am not sure if you understood me. What I mean - is the color outside of the 3D volume. Like in the attached screenshot. See, my 3D volumes are white while the default background color is black. I also add @Christian_Tischer as we chatted about this today morning as well.

If, when you create a new Bdv Window, you select Mixed Projector , you can modify the way the sources are overlayed to some extent. For doing this, select a source in the tree, and do right-click -> Set Sources Projection Mode .

This worked, thank you! I am wondering - what is the difference between sum and average? Not mathematically, but in Fiji, I mean :smiley:

I guess what you want to do is a screenshot with the resolution of the lowest mipmap

Yes, screenshot worked, thank you. I was a bit confused before because it showed me a stack with separate channels and I didn’t see that there was a second window with a fused image.

cc @NicoKiaru @hanslovsky @imagejan (since I also asked this on gitter)

Since we are using our own Projector, we could map regions with alpha = 0 to white. I tried it and it would work, see below:

To achieve this, at the end of this function: - https://github.com/bigdataviewer/bigdataviewer-playground/blob/bd664e5e1362065c753c066352f1c0981587db33/src/main/java/sc/fiji/bdvpg/bdv/projector/AccumulateMixedProjectorARGB.java#L93

We would add something like:

		if ( aAccu == 0 )
		{
			rAccu = 255;
			gAccu = 255;
			bAccu = 255;
		}

which now renders it white, but this could be made configurable.

One issue however is that the text in bdv has a white font which is now invisible…

Have you tried changing the color of the swing element behind the image? Will it show on different color if Alpha is zero? If yes, you could use that to set the background.

Maybe the font color in BDV is configurable. If not, maybe it should (plus a shaded area around it for contrast)