bigdataviewer / bigdataviewer-core

ImgLib2-based viewer for registered SPIM stacks and more
BSD 2-Clause "Simplified" License
33 stars 35 forks source link

Setting ViewTransforms in xml for all channels/setups #92

Closed maweigert closed 4 years ago

maweigert commented 4 years ago

Hi,

I have a 2-channel 3D image and want to have it displayed horizontally mirrored when loading with BDV. I tried setting the affine transformation component in the xml to -1 for each setup:

    <ViewRegistration timepoint="0" setup="0">
      <ViewTransform type="affine">
        <affine>-1.0 0.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 0.0 1.0 0.0</affine>
      </ViewTransform>
    </ViewRegistration>
    <ViewRegistration timepoint="0" setup="1">
      <ViewTransform type="affine">
        <affine>-1.0 0.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 0.0 1.0 0.0</affine>
      </ViewTransform>

which, however has not effect. Yet if I only flip one channel of the two, it does work. Is that something to be expected and am I doing something wrong?

Here's a minimal example: bdv.zip

bdv_A.xml -> identity scaling bdv_B.xml -> only channel 0 flip bdv_C.xml -> channel 0 and channel 1 flip

With the result:

Screenshot 2020-05-19 at 14 15 08
tpietzsch commented 4 years ago

You are doing nothing wrong. This is just BigDataViewer trying to be clever... The initial "viewer transform" is set up to align with the center XY plane of the first channel https://github.com/bigdataviewer/bigdataviewer-core/blob/8c16d1203d820ab91318d01db5f2ca1e62d11065/src/main/java/bdv/tools/InitializeViewerState.java#L102-L169 Unfortunately, in this case, this will set the viewer transform so that it undoes the flipping.

If you have programmatic access to the bdv instance, you can use ViewerPanel.setCurrentViewerTransform(...) to set something more reasonable. If you open bdv from the fiji menu, there is nothing much you can do about it, except making a fake channel 0 that is not flipped...

maweigert commented 4 years ago

Thanks for the fast reply!

Unfortunately, in this case, this will set the viewer transform so that it undoes the flipping.

Ok, I see. (extractApproximateRotationAffine seems to be agnostic about flippings).

Thanks again!