Skip to content

Commit

Permalink
Attempt at creating a way to import an atlas from an imageplus
Browse files Browse the repository at this point in the history
  • Loading branch information
NicoKiaru committed Nov 8, 2024
1 parent 8662ef6 commit 80d119d
Show file tree
Hide file tree
Showing 5 changed files with 472 additions and 0 deletions.
14 changes: 14 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
<license.licenseName>gpl_v3</license.licenseName>
<license.copyrightOwners>EPFL</license.copyrightOwners>
<bigdataviewer-playground.version>0.10.4</bigdataviewer-playground.version>
<bigdataviewer-image-loaders.version>0.8.6</bigdataviewer-image-loaders.version>

<!-- NB: Deploy releases to the SciJava Maven repository. -->
<releaseProfiles>sign,deploy-to-scijava</releaseProfiles>
Expand Down Expand Up @@ -144,5 +145,18 @@
<version>${bigdataviewer-playground.version}</version>
</dependency>

<dependency>
<groupId>ch.epfl.biop</groupId>
<artifactId>bigdataviewer-image-loaders</artifactId>
<version>${bigdataviewer-image-loaders.version}</version>
</dependency>

<dependency>
<groupId>ch.epfl.biop</groupId>
<artifactId>ImageToAtlasRegister</artifactId>
<version>0.9.8</version>
<scope>test</scope>
</dependency>

</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package ch.epfl.biop.atlas.custom;

import ch.epfl.biop.atlas.scijava.AtlasChooserCommand;
import ch.epfl.biop.atlas.struct.Atlas;
import ch.epfl.biop.atlas.struct.AtlasHelper;
import com.google.gson.GsonBuilder;
import ij.ImagePlus;
import org.scijava.command.Command;
import org.scijava.object.ObjectService;
import org.scijava.plugin.Parameter;
import org.scijava.plugin.Plugin;


@Plugin(type = Command.class,
menuPath = "Plugins>BIOP>Atlas>Create Atlas from Images",
description = "A simple way to create an atlas.")
public class AtlasFromImagePlusCommand implements Command {

@Parameter
String atlas_name;

@Parameter
ImagePlus structural_images;

@Parameter(label = "Label Image (optional)", required = false)
ImagePlus label_image;

@Parameter
Double atlas_precision_mm;

@Parameter
ObjectService os;

@Override
public void run() {
Atlas atlas = AtlasFromSourcesHelper.fromImagePlus(atlas_name, structural_images, label_image, atlas_precision_mm);
try {
atlas.initialize(null, null);
atlas.getOntology().initialize();
os.addObject(atlas, atlas_name);
AtlasChooserCommand.registerAtlas(atlas.getName(), () -> atlas);

//AtlasHelper.saveOntologyToJsonFile(atlas.getOntology(), ontology.getAbsolutePath());

System.out.println(
new GsonBuilder()
.setPrettyPrinting()
.create()
.toJson(new AtlasHelper.SerializableOntology(atlas.getOntology())));
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
Loading

0 comments on commit 80d119d

Please sign in to comment.