Skip to content

Commit

Permalink
Add example code for creating a MOBIE project
Browse files Browse the repository at this point in the history
  • Loading branch information
tischi committed Jul 26, 2024
1 parent 4edbb27 commit b556b47
Show file tree
Hide file tree
Showing 28 changed files with 159 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
<imagej-utils.version>0.7.0</imagej-utils.version>

<bigdataviewer-playground.version>0.9.0</bigdataviewer-playground.version>
<bigwarp_fiji.version>9.1.2</bigwarp_fiji.version>
<bigwarp_fiji.version>9.1.3</bigwarp_fiji.version>

<trove.version>1.0.2</trove.version>
<annotations.version>16.0.2</annotations.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import bdv.viewer.SourceAndConverter;
import bdv.viewer.TransformListener;
import bigwarp.BigWarp;
import bigwarp.transforms.BigWarpTransform;
import jj2000.j2k.codestream.HeaderInfo;
import org.embl.mobie.command.CommandConstants;
import org.embl.mobie.lib.transform.TransformHelper;
Expand Down Expand Up @@ -115,7 +116,7 @@ public void launchBigWarp()
final AffineTransform3D normalisedViewerTransform = TransformHelper.createNormalisedViewerTransform( bdvHandle.getViewerPanel() );
applyViewerTransform( normalisedViewerTransform, bigWarp.getViewerFrameQ().getViewerPanel() );
applyViewerTransform( normalisedViewerTransform, bigWarp.getViewerFrameP().getViewerPanel() );
bigWarp.setTransformType( TransformTypeSelectDialog.AFFINE );
bigWarp.setTransformType( BigWarpTransform.AFFINE );
bigWarp.addTransformListener( this );
}

Expand All @@ -136,9 +137,9 @@ public void cancel()
public void transformChanged( InvertibleRealTransform transform )
{
final String transformType = bigWarp.getTransformType();
if ( transformType.equals( TransformTypeSelectDialog.TPS ) )
if ( transformType.equals( BigWarpTransform.TPS ) )
{
System.err.println( TransformTypeSelectDialog.TPS + "is currently not supported by MoBIE please choose any of the other transform types by selecting one of the BigWarp windows and pressing F2.");
System.err.println( BigWarpTransform.TPS + "is currently not supported by MoBIE please choose any of the other transform types by selecting one of the BigWarp windows and pressing F2.");
}
}

Expand Down
47 changes: 47 additions & 0 deletions src/test/java/examples/CreateMoBIEProject.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package examples;

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.io.ImageDataFormat;
import org.embl.mobie.lib.create.ProjectCreator;

import java.io.File;
import java.io.IOException;

public class CreateMoBIEProject
{
public static void main( String[] args ) throws IOException
{
// 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();
}
}
Binary file not shown.
70 changes: 70 additions & 0 deletions src/test/resources/test-project/dataset/dataset.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
{
"is2D": false,
"defaultLocation": {
"position": [
0.0,
0.0,
0.0
],
"timepoint": 0
},
"sources": {
"MRI": {
"image": {
"imageData": {
"ome.zarr": {
"relativePath": "images/MRI.ome.zarr"
}
}
}
}
},
"views": {
"MRI": {
"uiSelectionGroup": "views",
"sourceDisplays": [
{
"imageDisplay": {
"sources": [
"MRI"
],
"color": "r255-g255-b255-a255",
"contrastLimits": [
0.0,
255.0
],
"showImagesIn3d": false,
"invert": false,
"name": "MRI",
"opacity": 1.0,
"visible": true
}
}
],
"isExclusive": false
},
"default": {
"uiSelectionGroup": "bookmark",
"sourceDisplays": [
{
"imageDisplay": {
"sources": [
"MRI"
],
"color": "r255-g255-b255-a255",
"contrastLimits": [
0.0,
255.0
],
"showImagesIn3d": false,
"invert": false,
"name": "MRI",
"opacity": 1.0,
"visible": true
}
}
],
"isExclusive": true
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"multiscales":[{"name":"","type":"Average","version":"0.4","axes":[{"type":"space","name":"z","unit":"pixel"},{"type":"space","name":"y","unit":"pixel"},{"type":"space","name":"x","unit":"pixel"}],"datasets":[{"path":"s0","coordinateTransformations":[{"scale":[1.0,1.0,1.0],"type":"scale"},{"translation":[0.0,0.0,0.0],"type":"translation"}]}],"coordinateTransformations":[]}]}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"zarr_format":2}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"zarr_format":2,"shape":[27,226,186],"chunks":[96,96,96],"dtype":"|u1","compressor":{"id":"gzip","level":-1},"fill_value":0,"filters":[],"order":"C","dimension_separator":"/"}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"path":"s0","axes":[{"type":"space","name":"x","unit":"pixel"},{"type":"space","name":"y","unit":"pixel"},{"type":"space","name":"z","unit":"pixel"}],"coordinateTransformations":[{"scale":[1.0,1.0,1.0],"type":"scale"},{"translation":[0.0,0.0,0.0],"type":"translation"}]}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
8 changes: 8 additions & 0 deletions src/test/resources/test-project/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"datasets": [
"dataset"
],
"defaultDataset": "dataset",
"specVersion": "0.3.0",
"references": []
}
13 changes: 13 additions & 0 deletions test-project/dataset/dataset.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"is2D": false,
"defaultLocation": {
"position": [
0.0,
0.0,
0.0
],
"timepoint": 0
},
"sources": {},
"views": {}
}
1 change: 1 addition & 0 deletions test-project/dataset/images/MRI.ome.zarr/.zattrs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"multiscales":[{"name":"","type":"Average","version":"0.4","axes":[{"type":"space","name":"z","unit":"pixel"},{"type":"space","name":"y","unit":"pixel"},{"type":"space","name":"x","unit":"pixel"}],"datasets":[{"path":"s0","coordinateTransformations":[{"scale":[1.0,1.0,1.0],"type":"scale"},{"translation":[0.0,0.0,0.0],"type":"translation"}]}],"coordinateTransformations":[]}]}
1 change: 1 addition & 0 deletions test-project/dataset/images/MRI.ome.zarr/.zgroup
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"zarr_format":2}
1 change: 1 addition & 0 deletions test-project/dataset/images/MRI.ome.zarr/s0/.zarray
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"zarr_format":2,"shape":[27,226,186],"chunks":[96,96,96],"dtype":"|u1","compressor":{"id":"gzip","level":-1},"fill_value":0,"filters":[],"order":"C","dimension_separator":"/"}
1 change: 1 addition & 0 deletions test-project/dataset/images/MRI.ome.zarr/s0/.zattrs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"path":"s0","axes":[{"type":"space","name":"x","unit":"pixel"},{"type":"space","name":"y","unit":"pixel"},{"type":"space","name":"z","unit":"pixel"}],"coordinateTransformations":[{"scale":[1.0,1.0,1.0],"type":"scale"},{"translation":[0.0,0.0,0.0],"type":"translation"}]}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added test-project/dataset/images/MRI.ome.zarr/s0/0/2/0
Binary file not shown.
Binary file added test-project/dataset/images/MRI.ome.zarr/s0/0/2/1
Binary file not shown.
8 changes: 8 additions & 0 deletions test-project/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"datasets": [
"dataset"
],
"defaultDataset": "dataset",
"specVersion": "0.3.0",
"references": []
}

0 comments on commit b556b47

Please sign in to comment.