From 22383abc06d0c6ae21c461871e167a88436ff42f Mon Sep 17 00:00:00 2001 From: Christian Tischer Date: Fri, 26 Jul 2024 10:58:44 +0200 Subject: [PATCH] Add mobie creation groovy script --- .../mobie/lib/create/DatasetSerializer.java | 4 +-- .../java/examples/CreateMoBIEProject.groovy | 35 +++++++++++++++++++ .../java/examples/CreateMoBIEProject.java | 1 - .../lib/serialize/DatasetJsonParserTest.java | 3 -- .../data/blobs/dataset.json | 6 ++-- .../test-project/dataset/dataset.json | 2 +- 6 files changed, 41 insertions(+), 10 deletions(-) create mode 100644 src/test/java/examples/CreateMoBIEProject.groovy diff --git a/src/main/java/org/embl/mobie/lib/create/DatasetSerializer.java b/src/main/java/org/embl/mobie/lib/create/DatasetSerializer.java index 3d5b56d1..3d69178c 100644 --- a/src/main/java/org/embl/mobie/lib/create/DatasetSerializer.java +++ b/src/main/java/org/embl/mobie/lib/create/DatasetSerializer.java @@ -233,14 +233,14 @@ private void addNewSegmentationView( Dataset dataset, String imageName, String u private void addNewDefaultImageView( Dataset dataset, String imageName, double[] contrastLimits, String colour, AffineTransform3D sourceTransform ) { - View view = createImageView( imageName, "bookmark", true, contrastLimits, colour, + View view = createImageView( imageName, "views", true, contrastLimits, colour, sourceTransform ); dataset.views().put( View.DEFAULT, view ); } private void addNewDefaultSegmentationView( Dataset dataset, String imageName, AffineTransform3D sourceTransform ) { - View view = createSegmentationView( imageName, "bookmark", true, sourceTransform ); + View view = createSegmentationView( imageName, "views", true, sourceTransform ); dataset.views().put( View.DEFAULT, view ); } diff --git a/src/test/java/examples/CreateMoBIEProject.groovy b/src/test/java/examples/CreateMoBIEProject.groovy new file mode 100644 index 00000000..03538a42 --- /dev/null +++ b/src/test/java/examples/CreateMoBIEProject.groovy @@ -0,0 +1,35 @@ +import ij.IJ +import ij.ImagePlus +import net.imagej.ImageJ +import net.imglib2.realtransform.AffineTransform3D +import org.embl.mobie.command.open.project.OpenMoBIEProjectCommand +import org.embl.mobie.lib.create.ProjectCreator + +// Init the project +// Please CHANGE the below path to point to location on your computer +String projectPath = "/Users/tischer/Documents/mobie-viewer-fiji/src/test/resources/test-project" + +ProjectCreator creator = new ProjectCreator(new File(projectPath)) +creator.getDatasetsCreator().addDataset( + "dataset", + false // say whether the data is only 2D (false = 3D) +) + +// Add one image +ImagePlus imagePlus = IJ.openImage("http://imagej.net/images/mri-stack.zip") +creator.getImagesCreator().addImage( + imagePlus, + "MRI", + "dataset", + ProjectCreator.ImageType.Image, + new AffineTransform3D(), + "views", + false, // view is exclusive + true // overwrite +) + +// Open the project to check whether it worked +new ImageJ().ui().showUI() +OpenMoBIEProjectCommand openMoBIE = new OpenMoBIEProjectCommand() +openMoBIE.uri = creator.getProjectLocation().getAbsolutePath() +openMoBIE.run() \ No newline at end of file diff --git a/src/test/java/examples/CreateMoBIEProject.java b/src/test/java/examples/CreateMoBIEProject.java index 453a7ea8..bcb5cff5 100644 --- a/src/test/java/examples/CreateMoBIEProject.java +++ b/src/test/java/examples/CreateMoBIEProject.java @@ -5,7 +5,6 @@ import net.imagej.ImageJ; import net.imglib2.realtransform.AffineTransform3D; import org.embl.mobie.command.open.project.OpenMoBIEProjectCommand; -import org.embl.mobie.io.ImageDataFormat; import org.embl.mobie.lib.create.ProjectCreator; import java.io.File; diff --git a/src/test/java/org/embl/mobie/lib/serialize/DatasetJsonParserTest.java b/src/test/java/org/embl/mobie/lib/serialize/DatasetJsonParserTest.java index 4f61d4d6..82202779 100644 --- a/src/test/java/org/embl/mobie/lib/serialize/DatasetJsonParserTest.java +++ b/src/test/java/org/embl/mobie/lib/serialize/DatasetJsonParserTest.java @@ -49,11 +49,8 @@ class DatasetJsonParserTest { private File tempDir; - private static JSONObject datasetSchema; private Dataset dataset; private final String viewName = View.DEFAULT; - private final String uiSelectionGroup = "bookmark"; - private final boolean isExclusive = true; private DatasetJsonParser datasetJsonParser; private String datasetJsonName = "dataset.json"; diff --git a/src/test/resources/minimal-mobie-project/data/blobs/dataset.json b/src/test/resources/minimal-mobie-project/data/blobs/dataset.json index 36403992..f0d75917 100644 --- a/src/test/resources/minimal-mobie-project/data/blobs/dataset.json +++ b/src/test/resources/minimal-mobie-project/data/blobs/dataset.json @@ -73,7 +73,7 @@ "description": "blobs, overwrite" }, "default": { - "uiSelectionGroup": "bookmark", + "uiSelectionGroup": "views", "sourceDisplays": [ { "imageDisplay": { @@ -182,7 +182,7 @@ "description": "" }, "blobs-transformed": { - "uiSelectionGroup": "bookmark", + "uiSelectionGroup": "views", "sourceDisplays": [ { "imageDisplay": { @@ -390,7 +390,7 @@ "description": "" }, "test": { - "uiSelectionGroup": "bookmark", + "uiSelectionGroup": "views", "sourceDisplays": [ { "imageDisplay": { diff --git a/src/test/resources/test-project/dataset/dataset.json b/src/test/resources/test-project/dataset/dataset.json index d8d060c4..536bfc1a 100644 --- a/src/test/resources/test-project/dataset/dataset.json +++ b/src/test/resources/test-project/dataset/dataset.json @@ -44,7 +44,7 @@ "isExclusive": false }, "default": { - "uiSelectionGroup": "bookmark", + "uiSelectionGroup": "views", "sourceDisplays": [ { "imageDisplay": {