Repository: mobie/mobie-viewer-fiji (language: python)

Issue:
fix issue with saving segmentation bookmarks
This fixes errors with saving a view containing a segmentation. It now retrieves the transformedSource from within the LabelSource


Discussion / hints:
I'll go ahead and merge this, as it's a very minor fix that only affects saving bookmarks

Fix patch:
diff --git a/pom.xml b/pom.xml
index d568e646d..48cfaf735 100644
--- a/pom.xml
+++ b/pom.xml
@@ -145,9 +145,9 @@
 			<version>2.2.5</version>
 		</dependency>
         <dependency>
-            <groupId>mobie</groupId>
-            <artifactId>bigdataviewer-imageloader</artifactId>
-            <version>1.0.2-SNAPSHOT</version>
+            <groupId>org.embl.mobie</groupId>
+            <artifactId>mobie-io</artifactId>
+            <version>1.0.4-SNAPSHOT</version>
         </dependency>
 		<dependency>
 			<groupId>org.janelia.saalfeldlab</groupId>
diff --git a/src/main/java/org/embl/mobie/viewer/MoBIE.java b/src/main/java/org/embl/mobie/viewer/MoBIE.java
index db4d51ab2..5cca7635a 100644
--- a/src/main/java/org/embl/mobie/viewer/MoBIE.java
+++ b/src/main/java/org/embl/mobie/viewer/MoBIE.java
@@ -8,6 +8,7 @@
 import bdv.viewer.SourceAndConverter;
 import de.embl.cba.bdv.utils.Logger;
 import net.imglib2.realtransform.AffineTransform3D;
+import org.embl.mobie.io.ome.zarr.loaders.N5OMEZarrImageLoader;
 import org.embl.mobie.viewer.display.SegmentationSourceDisplay;
 import org.embl.mobie.viewer.display.AnnotatedIntervalDisplay;
 import org.embl.mobie.viewer.annotate.AnnotatedIntervalCreator;
@@ -24,7 +25,6 @@
 import org.embl.mobie.viewer.ui.WindowArrangementHelper;
 import org.embl.mobie.viewer.view.View;
 import org.embl.mobie.viewer.view.ViewManager;
-import de.embl.cba.n5.ome.zarr.loaders.N5OMEZarrImageLoader;
 import de.embl.cba.tables.FileAndUrlUtils;
 import de.embl.cba.tables.TableColumns;
 import de.embl.cba.tables.TableRows;
@@ -544,10 +544,12 @@ public synchronized String getImagePath(ImageSource source) {
 
         switch (imageDataFormat) {
             case BdvN5:
-            case BdvN5S3:
+                final String path = source.imageData.get( imageDataFormat ).relativePath.split( "\\." )[0] + ".n5";
+                return FileAndUrlUtils.combinePath( imageRoot, getDatasetName(), path );
             case BdvOmeZarr:
             case OmeZarr:
             case BdvOmeZarrS3:
+            case BdvN5S3:
                 final String relativePath = source.imageData.get( imageDataFormat ).relativePath;
                 return FileAndUrlUtils.combinePath( imageRoot, getDatasetName(), relativePath );
             case OpenOrganelleS3:
diff --git a/src/main/java/org/embl/mobie/viewer/bdv/view/SegmentationSliceView.java b/src/main/java/org/embl/mobie/viewer/bdv/view/SegmentationSliceView.java
index 42dc7f4aa..79f2e5aa7 100644
--- a/src/main/java/org/embl/mobie/viewer/bdv/view/SegmentationSliceView.java
+++ b/src/main/java/org/embl/mobie/viewer/bdv/view/SegmentationSliceView.java
@@ -3,12 +3,12 @@
 import bdv.util.BdvHandle;
 import bdv.viewer.SourceAndConverter;
 import bdv.viewer.TimePointListener;
+import org.embl.mobie.io.n5.source.LabelSource;
 import org.embl.mobie.viewer.MoBIE;
 import org.embl.mobie.viewer.bdv.render.BlendingMode;
 import org.embl.mobie.viewer.color.OpacityAdjuster;
 import org.embl.mobie.viewer.color.LabelConverter;
 import org.embl.mobie.viewer.display.SegmentationSourceDisplay;
-import de.embl.cba.n5.util.source.LabelSource;
 import de.embl.cba.tables.color.ColoringListener;
 import de.embl.cba.tables.imagesegment.ImageSegment;
 import de.embl.cba.tables.select.SelectionListener;
diff --git a/src/main/java/org/embl/mobie/viewer/command/OpenOMEZARRCommand.java b/src/main/java/org/embl/mobie/viewer/command/OpenOMEZARRCommand.java
index 0ff2b5449..3d28ebc08 100644
--- a/src/main/java/org/embl/mobie/viewer/command/OpenOMEZARRCommand.java
+++ b/src/main/java/org/embl/mobie/viewer/command/OpenOMEZARRCommand.java
@@ -1,10 +1,8 @@
 package org.embl.mobie.viewer.command;
 
-
-import de.embl.cba.n5.ome.zarr.OMEZarrViewer;
-import de.embl.cba.n5.ome.zarr.openers.OMEZarrOpener;
-import ij.ImagePlus;
 import mpicbg.spim.data.SpimData;
+import org.embl.mobie.io.ome.zarr.OMEZarrViewer;
+import org.embl.mobie.io.ome.zarr.openers.OMEZarrOpener;
 import org.scijava.command.Command;
 import org.scijava.plugin.Parameter;
 import org.scijava.plugin.Plugin;
diff --git a/src/main/java/org/embl/mobie/viewer/command/OpenOMEZARRFromS3AdvancedCommand.java b/src/main/java/org/embl/mobie/viewer/command/OpenOMEZARRFromS3AdvancedCommand.java
index 8c58cf669..5eef6bc89 100644
--- a/src/main/java/org/embl/mobie/viewer/command/OpenOMEZARRFromS3AdvancedCommand.java
+++ b/src/main/java/org/embl/mobie/viewer/command/OpenOMEZARRFromS3AdvancedCommand.java
@@ -1,7 +1,7 @@
 package org.embl.mobie.viewer.command;
 
-import de.embl.cba.n5.ome.zarr.openers.OMEZarrS3Opener;
 import net.imagej.ImageJ;
+import org.embl.mobie.io.ome.zarr.openers.OMEZarrS3Opener;
 import org.scijava.command.Command;
 import org.scijava.plugin.Parameter;
 import org.scijava.plugin.Plugin;
diff --git a/src/main/java/org/embl/mobie/viewer/command/OpenOMEZARRFromS3Command.java b/src/main/java/org/embl/mobie/viewer/command/OpenOMEZARRFromS3Command.java
index 2eccbb7b0..3d430dde7 100644
--- a/src/main/java/org/embl/mobie/viewer/command/OpenOMEZARRFromS3Command.java
+++ b/src/main/java/org/embl/mobie/viewer/command/OpenOMEZARRFromS3Command.java
@@ -1,8 +1,8 @@
 package org.embl.mobie.viewer.command;
 
-import de.embl.cba.n5.ome.zarr.OMEZarrViewer;
-import de.embl.cba.n5.ome.zarr.openers.OMEZarrS3Opener;
 import mpicbg.spim.data.SpimData;
+import org.embl.mobie.io.ome.zarr.OMEZarrViewer;
+import org.embl.mobie.io.ome.zarr.openers.OMEZarrS3Opener;
 import org.scijava.command.Command;
 import org.scijava.plugin.Parameter;
 import org.scijava.plugin.Plugin;
diff --git a/src/main/java/org/embl/mobie/viewer/command/WriteOMEZARRCommand.java b/src/main/java/org/embl/mobie/viewer/command/WriteOMEZARRCommand.java
index 16a728de0..d5a29e110 100644
--- a/src/main/java/org/embl/mobie/viewer/command/WriteOMEZARRCommand.java
+++ b/src/main/java/org/embl/mobie/viewer/command/WriteOMEZARRCommand.java
@@ -1,9 +1,9 @@
 package org.embl.mobie.viewer.command;
 
+import org.embl.mobie.io.n5.util.DownsampleBlock;
+import org.embl.mobie.io.ome.zarr.writers.imgplus.WriteImgPlusToN5OmeZarr;
 import org.embl.mobie.viewer.projectcreator.ui.ManualExportPanel;
 import org.embl.mobie.viewer.source.ImageDataFormat;
-import de.embl.cba.n5.ome.zarr.writers.imgplus.WriteImgPlusToN5OmeZarr;
-import de.embl.cba.n5.util.DownsampleBlock;
 import ij.ImagePlus;
 import net.imagej.ImageJ;
 import net.imglib2.realtransform.AffineTransform3D;
diff --git a/src/main/java/org/embl/mobie/viewer/projectcreator/ImagesCreator.java b/src/main/java/org/embl/mobie/viewer/projectcreator/ImagesCreator.java
index afedac94b..2822e0445 100644
--- a/src/main/java/org/embl/mobie/viewer/projectcreator/ImagesCreator.java
+++ b/src/main/java/org/embl/mobie/viewer/projectcreator/ImagesCreator.java
@@ -6,16 +6,17 @@
 import bdv.viewer.Source;
 import bdv.viewer.SourceAndConverter;
 import ij.process.LUT;
+import org.embl.mobie.io.n5.loaders.N5FSImageLoader;
+import org.embl.mobie.io.n5.util.DownsampleBlock;
+import org.embl.mobie.io.n5.writers.WriteImgPlusToN5;
+import org.embl.mobie.io.ome.zarr.loaders.N5OMEZarrImageLoader;
+import org.embl.mobie.io.ome.zarr.readers.N5OmeZarrReader;
+import org.embl.mobie.io.ome.zarr.writers.imgplus.WriteImgPlusToN5BdvOmeZarr;
+import org.embl.mobie.io.ome.zarr.writers.imgplus.WriteImgPlusToN5OmeZarr;
+
 import org.embl.mobie.viewer.projectcreator.ui.ManualExportPanel;
 import org.embl.mobie.viewer.source.ImageDataFormat;
 import org.embl.mobie.viewer.source.SpimDataOpener;
-import de.embl.cba.n5.ome.zarr.loaders.N5OMEZarrImageLoader;
-import de.embl.cba.n5.ome.zarr.readers.N5OmeZarrReader;
-import de.embl.cba.n5.ome.zarr.writers.imgplus.WriteImgPlusToN5BdvOmeZarr;
-import de.embl.cba.n5.ome.zarr.writers.imgplus.WriteImgPlusToN5OmeZarr;
-import de.embl.cba.n5.util.DownsampleBlock;
-import de.embl.cba.n5.util.loaders.N5FSImageLoader;
-import de.embl.cba.n5.util.writers.WriteImgPlusToN5;
 import de.embl.cba.tables.FileAndUrlUtils;
 import de.embl.cba.tables.Tables;
 import ij.IJ;
@@ -426,7 +427,7 @@ private void closeImgLoader ( SpimData spimData, ImageDataFormat imageFormat ) {
             case BdvOmeZarr:
 
             case OmeZarr:
-                if (imgLoader instanceof N5OMEZarrImageLoader) {
+                if (imgLoader instanceof N5OMEZarrImageLoader ) {
                     ( (N5OMEZarrImageLoader) imgLoader ).close();
                 }
                 break;
diff --git a/src/main/java/org/embl/mobie/viewer/projectcreator/ProjectCreatorHelper.java b/src/main/java/org/embl/mobie/viewer/projectcreator/ProjectCreatorHelper.java
index e49ecc0f6..0642a5651 100644
--- a/src/main/java/org/embl/mobie/viewer/projectcreator/ProjectCreatorHelper.java
+++ b/src/main/java/org/embl/mobie/viewer/projectcreator/ProjectCreatorHelper.java
@@ -1,15 +1,15 @@
 package org.embl.mobie.viewer.projectcreator;
 
 import bdv.img.n5.N5ImageLoader;
+import org.embl.mobie.io.n5.loaders.N5FSImageLoader;
+import org.embl.mobie.io.n5.loaders.N5S3ImageLoader;
+import org.embl.mobie.io.ome.zarr.loaders.N5OMEZarrImageLoader;
+import org.embl.mobie.io.ome.zarr.loaders.N5S3OMEZarrImageLoader;
+import org.embl.mobie.io.ome.zarr.readers.N5OmeZarrReader;
 import org.embl.mobie.viewer.Dataset;
 import org.embl.mobie.viewer.source.ImageDataFormat;
 import org.embl.mobie.viewer.view.View;
 import org.embl.mobie.viewer.view.additionalviews.AdditionalViews;
-import de.embl.cba.n5.ome.zarr.loaders.N5OMEZarrImageLoader;
-import de.embl.cba.n5.ome.zarr.loaders.N5S3OMEZarrImageLoader;
-import de.embl.cba.n5.ome.zarr.readers.N5OmeZarrReader;
-import de.embl.cba.n5.util.loaders.N5FSImageLoader;
-import de.embl.cba.n5.util.loaders.N5S3ImageLoader;
 import de.embl.cba.tables.FileAndUrlUtils;
 import ij.IJ;
 import ij.ImagePlus;
diff --git a/src/main/java/org/embl/mobie/viewer/projectcreator/RemoteMetadataCreator.java b/src/main/java/org/embl/mobie/viewer/projectcreator/RemoteMetadataCreator.java
index b2446689b..a7570cbd6 100644
--- a/src/main/java/org/embl/mobie/viewer/projectcreator/RemoteMetadataCreator.java
+++ b/src/main/java/org/embl/mobie/viewer/projectcreator/RemoteMetadataCreator.java
@@ -1,12 +1,12 @@
 package org.embl.mobie.viewer.projectcreator;
 
+import org.embl.mobie.io.n5.loaders.xml.XmlIoN5S3ImageLoader;
+import org.embl.mobie.io.ome.zarr.loaders.xml.XmlN5S3OmeZarrImageLoader;
 import org.embl.mobie.viewer.Dataset;
 import org.embl.mobie.viewer.source.ImageDataFormat;
 import org.embl.mobie.viewer.source.ImageSource;
 import org.embl.mobie.viewer.source.SpimDataOpener;
 import org.embl.mobie.viewer.source.StorageLocation;
-import de.embl.cba.n5.ome.zarr.loaders.xml.XmlN5S3OmeZarrImageLoader;
-import de.embl.cba.n5.util.loaders.xml.XmlIoN5S3ImageLoader;
 import de.embl.cba.tables.FileAndUrlUtils;
 import ij.IJ;
 import mpicbg.spim.data.SpimData;
diff --git a/src/main/java/org/embl/mobie/viewer/projectcreator/ui/ManualExportPanel.java b/src/main/java/org/embl/mobie/viewer/projectcreator/ui/ManualExportPanel.java
index 9d9b1691a..c9e6d7864 100644
--- a/src/main/java/org/embl/mobie/viewer/projectcreator/ui/ManualExportPanel.java
+++ b/src/main/java/org/embl/mobie/viewer/projectcreator/ui/ManualExportPanel.java
@@ -1,11 +1,12 @@
 package org.embl.mobie.viewer.projectcreator.ui;
 
 import bdv.ij.util.PluginHelper;
+import org.embl.mobie.io.n5.util.DownsampleBlock;
+import org.embl.mobie.io.n5.writers.WriteImgPlusToN5;
+import org.embl.mobie.io.ome.zarr.writers.imgplus.WriteImgPlusToN5BdvOmeZarr;
+import org.embl.mobie.io.ome.zarr.writers.imgplus.WriteImgPlusToN5OmeZarr;
 import org.embl.mobie.viewer.source.ImageDataFormat;
-import de.embl.cba.n5.ome.zarr.writers.imgplus.WriteImgPlusToN5BdvOmeZarr;
-import de.embl.cba.n5.ome.zarr.writers.imgplus.WriteImgPlusToN5OmeZarr;
-import de.embl.cba.n5.util.DownsampleBlock;
-import de.embl.cba.n5.util.writers.WriteImgPlusToN5;
+
 import fiji.util.gui.GenericDialogPlus;
 import ij.IJ;
 import ij.ImagePlus;
diff --git a/src/main/java/org/embl/mobie/viewer/serialize/SourceTransformerListAdapter.java b/src/main/java/org/embl/mobie/viewer/serialize/SourceTransformerListAdapter.java
index 49767dc7e..a11be1e02 100644
--- a/src/main/java/org/embl/mobie/viewer/serialize/SourceTransformerListAdapter.java
+++ b/src/main/java/org/embl/mobie/viewer/serialize/SourceTransformerListAdapter.java
@@ -17,8 +17,8 @@ public class SourceTransformerListAdapter implements JsonSerializer< List<Source
 	private static Map<String, String> classToName = new TreeMap<>();
 
 	static {
-		nameToClass.put("mergedGrid", MergedGridSourceTransformer.class);
-		classToName.put( MergedGridSourceTransformer.class.getName(), "mergedGrid");
+		nameToClass.put("grid", MergedGridSourceTransformer.class);
+		classToName.put( MergedGridSourceTransformer.class.getName(), "grid");
 		nameToClass.put("transformedGrid", TransformedGridSourceTransformer.class);
 		classToName.put( TransformedGridSourceTransformer.class.getName(), "transformedGrid");
 		nameToClass.put("affine", AffineSourceTransformer.class);
diff --git a/src/main/java/org/embl/mobie/viewer/source/SpimDataOpener.java b/src/main/java/org/embl/mobie/viewer/source/SpimDataOpener.java
index f77b0f551..3876bcaa7 100644
--- a/src/main/java/org/embl/mobie/viewer/source/SpimDataOpener.java
+++ b/src/main/java/org/embl/mobie/viewer/source/SpimDataOpener.java
@@ -2,14 +2,16 @@
 
 import bdv.util.volatiles.SharedQueue;
 import de.embl.cba.bdv.utils.BdvUtils;
-import de.embl.cba.n5.ome.zarr.loaders.N5S3OMEZarrImageLoader;
-import de.embl.cba.n5.ome.zarr.loaders.xml.XmlN5OmeZarrImageLoader;
-import de.embl.cba.n5.ome.zarr.openers.OMEZarrOpener;
-import de.embl.cba.n5.ome.zarr.openers.OMEZarrS3Opener;
-import de.embl.cba.n5.openorganelle.OpenOrganelleS3Opener;
 import de.embl.cba.tables.FileAndUrlUtils;
 import mpicbg.spim.data.SpimData;
 import net.imglib2.util.Cast;
+import org.embl.mobie.io.n5.openers.N5Opener;
+import org.embl.mobie.io.n5.openers.N5S3Opener;
+import org.embl.mobie.io.ome.zarr.loaders.N5S3OMEZarrImageLoader;
+import org.embl.mobie.io.ome.zarr.loaders.xml.XmlN5OmeZarrImageLoader;
+import org.embl.mobie.io.ome.zarr.openers.OMEZarrOpener;
+import org.embl.mobie.io.ome.zarr.openers.OMEZarrS3Opener;
+import org.embl.mobie.io.openorganelle.OpenOrganelleS3Opener;
 import org.jdom2.Document;
 import org.jdom2.Element;
 import org.jdom2.JDOMException;
@@ -60,8 +62,10 @@ public SpimData openSpimData(String imagePath, ImageDataFormat imageDataFormat,
         SpimData spimData = null;
         switch ( imageDataFormat ) {
             case BdvN5:
+                spimData = openBDV( imagePath, sharedQueue );
+                break;
             case BdvN5S3:
-                spimData = BdvUtils.openSpimData( imagePath );
+                spimData = openBDVS3( imagePath, sharedQueue );
                 break;
             case OmeZarr:
                 spimData = openOmeZarrData( imagePath, sharedQueue );
@@ -82,6 +86,27 @@ public SpimData openSpimData(String imagePath, ImageDataFormat imageDataFormat,
         return spimData;
     }
 
+    private SpimData openBDV(String path, SharedQueue queue)
+    {
+        try {
+            return N5Opener.openFile( path, queue );
+        } catch ( IOException e ) {
+            e.printStackTrace();
+        }
+        return null;
+
+    }
+    private SpimData openBDVS3(String path, SharedQueue queue)
+    {
+        try {
+            return N5S3Opener.readURL( path, queue );
+        } catch ( IOException e ) {
+            e.printStackTrace();
+        }
+        return null;
+
+    }
+
     private SpimData openOmeZarrData( String path )
     {
         try {
@@ -129,7 +154,6 @@ private SpimData openBdvOmeZarrS3Data( String path )
             InputStream stream = FileAndUrlUtils.getInputStream(path);
             final Document doc = sax.build(stream);
             final Element imgLoaderElem = doc.getRootElement().getChild(SEQUENCEDESCRIPTION_TAG).getChild(IMGLOADER_TAG);
-            HashMap<String, Integer> axesMap = new HashMap<>();
             String bucketAndObject = imgLoaderElem.getChild( "BucketName").getText() + "/" + imgLoaderElem.getChild( "Key" ).getText();
             final String[] split = bucketAndObject.split("/");
             String bucket = split[0];
diff --git a/src/main/java/org/embl/mobie/viewer/view/ViewManager.java b/src/main/java/org/embl/mobie/viewer/view/ViewManager.java
index addc19d6c..9d6a003b0 100644
--- a/src/main/java/org/embl/mobie/viewer/view/ViewManager.java
+++ b/src/main/java/org/embl/mobie/viewer/view/ViewManager.java
@@ -4,30 +4,35 @@
 import bdv.util.BdvHandle;
 import bdv.viewer.Source;
 import bdv.viewer.SourceAndConverter;
-import de.embl.cba.n5.util.source.LabelSource;
+import de.embl.cba.tables.color.ColoringModel;
+import de.embl.cba.tables.color.ColumnColoringModelCreator;
+import de.embl.cba.tables.select.DefaultSelectionModel;
+import de.embl.cba.tables.tablerow.TableRowImageSegment;
+import ij.IJ;
+import net.imglib2.realtransform.AffineTransform3D;
+import org.apache.commons.lang.ArrayUtils;
+import org.embl.mobie.io.n5.source.LabelSource;
 import org.embl.mobie.viewer.MoBIE;
+import org.embl.mobie.viewer.Utils;
 import org.embl.mobie.viewer.annotate.AnnotatedIntervalAdapter;
 import org.embl.mobie.viewer.annotate.AnnotatedIntervalTableRow;
 import org.embl.mobie.viewer.bdv.view.AnnotatedIntervalSliceView;
-import org.embl.mobie.viewer.color.MoBIEColoringModel;
-import org.embl.mobie.viewer.display.AbstractSourceDisplay;
-import org.embl.mobie.viewer.display.AnnotatedRegionDisplay;
-import org.embl.mobie.viewer.display.AnnotatedIntervalDisplay;
-import org.embl.mobie.viewer.display.SourceDisplay;
-import org.embl.mobie.viewer.playground.PlaygroundUtils;
-import org.embl.mobie.viewer.Utils;
 import org.embl.mobie.viewer.bdv.view.ImageSliceView;
 import org.embl.mobie.viewer.bdv.view.SegmentationSliceView;
 import org.embl.mobie.viewer.bdv.view.SliceViewer;
+import org.embl.mobie.viewer.color.MoBIEColoringModel;
+import org.embl.mobie.viewer.display.*;
+import org.embl.mobie.viewer.playground.PlaygroundUtils;
 import org.embl.mobie.viewer.playground.SourceAffineTransformer;
 import org.embl.mobie.viewer.plot.ScatterPlotViewer;
 import org.embl.mobie.viewer.segment.SegmentAdapter;
-import org.embl.mobie.viewer.display.ImageSourceDisplay;
-import org.embl.mobie.viewer.display.SegmentationSourceDisplay;
 import org.embl.mobie.viewer.source.SegmentationSource;
 import org.embl.mobie.viewer.table.TableDataFormat;
 import org.embl.mobie.viewer.table.TableViewer;
 import org.embl.mobie.viewer.transform.AffineSourceTransformer;
+import org.embl.mobie.viewer.transform.MoBIEViewerTransformChanger;
+import org.embl.mobie.viewer.transform.NormalizedAffineViewerTransform;
+import org.embl.mobie.viewer.transform.SourceTransformer;
 import org.embl.mobie.viewer.ui.MoBIELookAndFeelToggler;
 import org.embl.mobie.viewer.ui.UserInterface;
 import org.embl.mobie.viewer.ui.WindowArrangementHelper;
@@ -35,28 +40,15 @@
 import org.embl.mobie.viewer.view.saving.ViewsSaver;
 import org.embl.mobie.viewer.volume.SegmentsVolumeViewer;
 import org.embl.mobie.viewer.volume.UniverseManager;
-import de.embl.cba.tables.color.ColoringModel;
-import de.embl.cba.tables.color.ColumnColoringModelCreator;
-import de.embl.cba.tables.select.DefaultSelectionModel;
-import de.embl.cba.tables.tablerow.TableRowImageSegment;
-import ij.IJ;
-import net.imglib2.realtransform.AffineTransform3D;
-import org.apache.commons.lang.ArrayUtils;
-import org.embl.mobie.viewer.transform.MoBIEViewerTransformChanger;
-import org.embl.mobie.viewer.transform.NormalizedAffineViewerTransform;
-import org.embl.mobie.viewer.transform.SourceTransformer;
 import sc.fiji.bdvpg.bdv.navigate.ViewerTransformAdjuster;
 import sc.fiji.bdvpg.scijava.services.SourceAndConverterService;
 import sc.fiji.bdvpg.services.SourceAndConverterServices;
 
-
 import javax.swing.*;
 import java.util.*;
-import java.util.List;
 import java.util.stream.Collectors;
 
 import static org.embl.mobie.viewer.Utils.containsAtLeastOne;
-import static org.embl.mobie.viewer.ui.UserInterfaceHelper.*;
 
 public class ViewManager
 {
@@ -71,7 +63,29 @@ public class ViewManager
 	private final AdditionalViewsLoader additionalViewsLoader;
 	private final ViewsSaver viewsSaver;
 
-	public ViewManager( MoBIE moBIE, UserInterface userInterface, boolean is2D, int timepoints )
+	private View currentView;
+
+    public void setCurrentView( View currentView )
+    {
+        this.currentView = currentView;
+    }
+
+    public List<SourceTransformer> getCurrentSourceTransformers()
+    {
+        return currentSourceTransformers;
+    }
+
+    public View getCurrentView()
+    {
+        return currentView;
+    }
+
+    public UserInterface getUserInterface()
+    {
+        return userInterface;
+    }
+
+    public ViewManager( MoBIE moBIE, UserInterface userInterface, boolean is2D, int timepoints )
 	{
 		this.moBIE = moBIE;
 		this.userInterface = userInterface;
@@ -165,24 +179,24 @@ private boolean hasColumnsOutsideProject( AnnotatedRegionDisplay annotatedRegion
 	}
 
 	private void addManualTransforms( List< SourceTransformer > viewSourceTransforms,
-									  Map<String, SourceAndConverter<?> > sourceNameToSourceAndConverter ) {
-		for ( String sourceName: sourceNameToSourceAndConverter.keySet() ) {
-			Source<?> source = sourceNameToSourceAndConverter.get( sourceName ).getSpimSource();
-
-			if ( source instanceof LabelSource ) {
-				source = ((LabelSource) source).getWrappedSource();
-			}
-			TransformedSource transformedSource = (TransformedSource) source;
-
-			AffineTransform3D fixedTransform = new AffineTransform3D();
-			transformedSource.getFixedTransform( fixedTransform );
-			if ( !fixedTransform.isIdentity() ) {
-				List<String> sources = new ArrayList<>();
-				sources.add( sourceName );
-				viewSourceTransforms.add( new AffineSourceTransformer( "manualTransform", fixedTransform.getRowPackedCopy(), sources ) );
-			}
-		}
-	}
+                                      Map<String, SourceAndConverter<?> > sourceNameToSourceAndConverter ) {
+        for ( String sourceName: sourceNameToSourceAndConverter.keySet() ) {
+            Source<?> source = sourceNameToSourceAndConverter.get( sourceName ).getSpimSource();
+
+            if ( source instanceof LabelSource ) {
+                source = ((LabelSource) source).getWrappedSource();
+            }
+            TransformedSource transformedSource = (TransformedSource) source;
+
+            AffineTransform3D fixedTransform = new AffineTransform3D();
+            transformedSource.getFixedTransform( fixedTransform );
+            if ( !fixedTransform.isIdentity() ) {
+                List<String> sources = new ArrayList<>();
+                sources.add( sourceName );
+                viewSourceTransforms.add( new AffineSourceTransformer( "manualTransform", fixedTransform.getRowPackedCopy(), sources ) );
+            }
+        }
+    }
 
 	public View getCurrentView( String uiSelectionGroup, boolean isExclusive, boolean includeViewerTransform ) {
 
@@ -239,6 +253,7 @@ public synchronized void show( View view )
 		{
 			removeAllSourceDisplays();
 		}
+		currentView = view;
 
 		// fetch the names of all sources that are either shown or to be transformed
 		final Set< String > sources = fetchSources( view );
@@ -278,7 +293,7 @@ public synchronized void show( View view )
 		adjustViewerTransform( view );
 	}
 
-	private void adjustViewerTransform( View view )
+	public void adjustViewerTransform( View view )
 	{
 		if ( view.getViewerTransform() != null )
 		{
@@ -289,13 +304,13 @@ private void adjustViewerTransform( View view )
 			if ( view.isExclusive() || currentSourceDisplays.size() == 1 )
 			{
 				// TODO: rethink what should happen here...
-				final SourceDisplay sourceDisplay = currentSourceDisplays.get( currentSourceDisplays.size() - 1 );
+				final SourceDisplay sourceDisplay = currentSourceDisplays.get( currentSourceDisplays.size() > 0 ? currentSourceDisplays.size() - 1 : 0 );
 				new ViewerTransformAdjuster( bdvHandle, ((AbstractSourceDisplay) sourceDisplay).sourceNameToSourceAndConverter.values().iterator().next() ).run();
 			}
 		}
 	}
 
-	private Set< String > fetchSources( View view )
+	public Set< String > fetchSources( View view )
 	{
 		final Set< String > sources = new HashSet<>();
 		final List< SourceDisplay > sourceDisplays = view.getSourceDisplays();
@@ -310,7 +325,7 @@ private Set< String > fetchSources( View view )
 		return sources;
 	}
 
-	private synchronized void showSourceDisplay( SourceDisplay sourceDisplay )
+	public synchronized void showSourceDisplay( SourceDisplay sourceDisplay )
 	{
 		if ( currentSourceDisplays.contains( sourceDisplay ) ) return;
 
@@ -331,7 +346,7 @@ else if ( sourceDisplay instanceof AnnotatedIntervalDisplay )
 		currentSourceDisplays.add( sourceDisplay );
 	}
 
-	private void removeAllSourceDisplays()
+	public void removeAllSourceDisplays()
 	{
 		// create a copy of the currently shown displays...
 		final ArrayList< SourceDisplay > currentSourceDisplays = new ArrayList<>( this.currentSourceDisplays ) ;


Test patch:
diff --git a/src/test/java/commands/OpenOMEZARRCommand.java b/src/test/java/commands/OpenOMEZARRCommand.java
index e0767fe68..e82f3efb1 100644
--- a/src/test/java/commands/OpenOMEZARRCommand.java
+++ b/src/test/java/commands/OpenOMEZARRCommand.java
@@ -1,8 +1,8 @@
 package commands;
 
-import de.embl.cba.n5.ome.zarr.OMEZarrViewer;
-import de.embl.cba.n5.ome.zarr.openers.OMEZarrOpener;
 import mpicbg.spim.data.SpimData;
+import org.embl.mobie.io.ome.zarr.OMEZarrViewer;
+import org.embl.mobie.io.ome.zarr.openers.OMEZarrOpener;
 
 import java.io.IOException;
 
diff --git a/src/test/java/commands/OpenOMEZARRFromS3Command.java b/src/test/java/commands/OpenOMEZARRFromS3Command.java
index 29dbb434c..cb2526dc6 100644
--- a/src/test/java/commands/OpenOMEZARRFromS3Command.java
+++ b/src/test/java/commands/OpenOMEZARRFromS3Command.java
@@ -1,8 +1,8 @@
 package commands;
 
-import de.embl.cba.n5.ome.zarr.OMEZarrViewer;
-import de.embl.cba.n5.ome.zarr.openers.OMEZarrS3Opener;
 import mpicbg.spim.data.SpimData;
+import org.embl.mobie.io.ome.zarr.OMEZarrViewer;
+import org.embl.mobie.io.ome.zarr.openers.OMEZarrS3Opener;
 
 import java.io.IOException;
 
diff --git a/src/test/java/develop/DevelopOmeZarrWriting.java b/src/test/java/develop/DevelopOmeZarrWriting.java
index 04ab3bffd..64292aa77 100644
--- a/src/test/java/develop/DevelopOmeZarrWriting.java
+++ b/src/test/java/develop/DevelopOmeZarrWriting.java
@@ -1,11 +1,11 @@
 package develop;
 
 
-import de.embl.cba.n5.ome.zarr.writers.imgplus.WriteImgPlusToN5BdvOmeZarr;
-import de.embl.cba.n5.ome.zarr.writers.imgplus.WriteImgPlusToN5OmeZarr;
-import de.embl.cba.n5.util.DownsampleBlock;
 import ij.IJ;
 import ij.ImagePlus;
+import org.embl.mobie.io.n5.util.DownsampleBlock;
+import org.embl.mobie.io.ome.zarr.writers.imgplus.WriteImgPlusToN5BdvOmeZarr;
+import org.embl.mobie.io.ome.zarr.writers.imgplus.WriteImgPlusToN5OmeZarr;
 import org.janelia.saalfeldlab.n5.GzipCompression;
 
 public class DevelopOmeZarrWriting {
diff --git a/src/test/java/org/embl/mobie/viewer/projectcreator/ImagesCreatorTest.java b/src/test/java/org/embl/mobie/viewer/projectcreator/ImagesCreatorTest.java
index b123b300d..913a7a892 100644
--- a/src/test/java/org/embl/mobie/viewer/projectcreator/ImagesCreatorTest.java
+++ b/src/test/java/org/embl/mobie/viewer/projectcreator/ImagesCreatorTest.java
@@ -1,14 +1,15 @@
 package org.embl.mobie.viewer.projectcreator;
 
+import org.embl.mobie.io.n5.util.DownsampleBlock;
+import org.embl.mobie.io.n5.writers.WriteImgPlusToN5;
+import org.embl.mobie.io.ome.zarr.writers.imgplus.WriteImgPlusToN5BdvOmeZarr;
+import org.embl.mobie.io.ome.zarr.writers.imgplus.WriteImgPlusToN5OmeZarr;
 import org.embl.mobie.viewer.Dataset;
 import org.embl.mobie.viewer.serialize.DatasetJsonParser;
 import org.embl.mobie.viewer.source.ImageDataFormat;
 import org.embl.mobie.viewer.source.SegmentationSource;
 import org.embl.mobie.viewer.table.TableDataFormat;
-import de.embl.cba.n5.ome.zarr.writers.imgplus.WriteImgPlusToN5BdvOmeZarr;
-import de.embl.cba.n5.ome.zarr.writers.imgplus.WriteImgPlusToN5OmeZarr;
-import de.embl.cba.n5.util.DownsampleBlock;
-import de.embl.cba.n5.util.writers.WriteImgPlusToN5;
+
 import de.embl.cba.tables.FileAndUrlUtils;
 import ij.ImagePlus;
 import mpicbg.spim.data.SpimDataException;
diff --git a/src/test/java/projects/OpenLocalAutophagosomesEM.java b/src/test/java/projects/OpenLocalAutophagosomesEM.java
index 24acf6a08..b370ec836 100644
--- a/src/test/java/projects/OpenLocalAutophagosomesEM.java
+++ b/src/test/java/projects/OpenLocalAutophagosomesEM.java
@@ -12,11 +12,11 @@ public class OpenLocalAutophagosomesEM
 	public static void main( String[] args )
 	{
 		new ImageJ().ui().showUI();
-		try {
-			new MoBIE("/g/kreshuk/pape/work/my_projects/autophagosoms-clem/data",
-					MoBIESettings.settings().imageDataFormat( ImageDataFormat.BdvN5 ) );
-		} catch (IOException e) {
-			e.printStackTrace();
-		}
+        try {
+            new MoBIE("/g/kreshuk/pape/work/my_projects/autophagosoms-clem/data",
+                    MoBIESettings.settings().imageDataFormat( ImageDataFormat.BdvN5 ) );
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
 	}
 }