diff --git a/pom.xml b/pom.xml index c57caac5..680e8dc7 100644 --- a/pom.xml +++ b/pom.xml @@ -108,8 +108,8 @@ <!-- bdv playground related dependencies --> <bigdataviewer-playground.version>0.10.1</bigdataviewer-playground.version> - <bigdataviewer-image-loaders.version>0.7.1</bigdataviewer-image-loaders.version> - <bigdataviewer-biop-tools.version>0.9.4</bigdataviewer-biop-tools.version> + <bigdataviewer-image-loaders.version>0.7.2</bigdataviewer-image-loaders.version> + <bigdataviewer-biop-tools.version>0.10.0</bigdataviewer-biop-tools.version> <bigdataviewer-selector.version>0.2.6</bigdataviewer-selector.version> <!-- maths --> diff --git a/src/main/java/ch/epfl/biop/atlas/aligner/EditLastRegistrationAction.java b/src/main/java/ch/epfl/biop/atlas/aligner/EditLastRegistrationAction.java index 92d23ee5..e823d89f 100644 --- a/src/main/java/ch/epfl/biop/atlas/aligner/EditLastRegistrationAction.java +++ b/src/main/java/ch/epfl/biop/atlas/aligner/EditLastRegistrationAction.java @@ -1,6 +1,6 @@ package ch.epfl.biop.atlas.aligner; -import ch.epfl.biop.atlas.aligner.plugin.RegistrationPluginHelper; +import ch.epfl.biop.registration.plugin.RegistrationPluginHelper; import ch.epfl.biop.sourceandconverter.processor.SourcesIdentity; import ch.epfl.biop.sourceandconverter.processor.SourcesProcessComposer; import ch.epfl.biop.sourceandconverter.processor.SourcesProcessor; diff --git a/src/main/java/ch/epfl/biop/atlas/aligner/MultiSlicePositioner.java b/src/main/java/ch/epfl/biop/atlas/aligner/MultiSlicePositioner.java index b444285e..6331ace2 100644 --- a/src/main/java/ch/epfl/biop/atlas/aligner/MultiSlicePositioner.java +++ b/src/main/java/ch/epfl/biop/atlas/aligner/MultiSlicePositioner.java @@ -3,9 +3,9 @@ import bdv.viewer.SourceAndConverter; import ch.epfl.biop.atlas.aligner.action.*; import ch.epfl.biop.atlas.aligner.adapter.*; -import ch.epfl.biop.atlas.aligner.plugin.ExternalABBARegistrationPlugin; -import ch.epfl.biop.atlas.aligner.plugin.IABBARegistrationPlugin; -import ch.epfl.biop.atlas.aligner.plugin.RegistrationPluginHelper; +import ch.epfl.biop.registration.plugin.ExternalRegistrationPlugin; +import ch.epfl.biop.registration.plugin.IRegistrationPlugin; +import ch.epfl.biop.registration.plugin.RegistrationPluginHelper; import ch.epfl.biop.atlas.struct.Atlas; import ch.epfl.biop.registration.Registration; import ch.epfl.biop.sourceandconverter.processor.*; @@ -690,36 +690,6 @@ public static Map<String,String> convertToString(Context ctx, Map<String, Object return convertedParams; } - public void registerSelectedSlices(Command command, - SourcesProcessor preprocessFixed, - SourcesProcessor preprocessMoving) { - registerSelectedSlices(command, - preprocessFixed, - preprocessMoving, - new HashMap<>() - ); - } - - /** - * Main function which triggers registration of the selected slices - * @param command the ui command - * @param preprocessFixed how fixed sources need to be preprocessed before being registered - * @param preprocessMoving how moving sources need to be preprocessed before being registered - * @param parameters parameters used for the registration - all objects will be converted - * to String using the scijava {@link ConvertService}. They need to be strings - * to be serialized - */ - public void registerSelectedSlices(Command command, - SourcesProcessor preprocessFixed, - SourcesProcessor preprocessMoving, - Map<String,Object> parameters) { - registerSelectedSlices(RegistrationPluginHelper.registrationFromUI(scijavaCtx,command.getClass()), - preprocessFixed, - preprocessMoving, - parameters - ); - } - /** * Main function which triggers registration of the selected slices * @param registrationClass the kind of registration which should be started @@ -729,16 +699,16 @@ public void registerSelectedSlices(Command command, * to String using the scijava {@link ConvertService}. They need to be strings * to be serialized */ - public void registerSelectedSlices(Class<? extends IABBARegistrationPlugin> registrationClass, + public void registerSelectedSlices(Class<? extends IRegistrationPlugin> registrationClass, SourcesProcessor preprocessFixed, SourcesProcessor preprocessMoving, Map<String,Object> parameters) { PluginService ps = scijavaCtx.getService(PluginService.class); - Supplier<? extends IABBARegistrationPlugin> pluginSupplier = + Supplier<? extends IRegistrationPlugin> pluginSupplier = () -> { try { - return (IABBARegistrationPlugin) ps.getPlugin(registrationClass).createInstance(); + return (IRegistrationPlugin) ps.getPlugin(registrationClass).createInstance(); } catch (InstantiableException e) { e.printStackTrace(); return null; @@ -780,7 +750,7 @@ public void registerSelectedSlices(String registrationPluginName, * to String using the scijava {@link ConvertService}. They need to be strings * to be serialized */ - public void registerSelectedSlices(Supplier<? extends IABBARegistrationPlugin> registrationPluginSupplier, + public void registerSelectedSlices(Supplier<? extends IRegistrationPlugin> registrationPluginSupplier, SourcesProcessor preprocessFixed, SourcesProcessor preprocessMoving, Map<String,Object> parameters) { @@ -797,14 +767,11 @@ public void registerSelectedSlices(Supplier<? extends IABBARegistrationPlugin> r for (SliceSources slice : getSelectedSlices()) { logger.debug("Starting slice registration for "+slice.getName()); - IABBARegistrationPlugin registration = registrationPluginSupplier.get(); + IRegistrationPlugin registration = registrationPluginSupplier.get(); if (registration!=null) { logger.debug("\t slice registration for "+slice.getName()+"- set context"); registration.setScijavaContext(scijavaCtx); - logger.debug("\t slice registration for "+slice.getName()+"- setSliceInfo"); - registration.setSliceInfo(new SliceInfo(this, slice)); - // Sends parameters to the registration logger.debug("\t slice registration for "+slice.getName()+"- setRegistrationParameters"); registration.setRegistrationParameters(convertToString(scijavaCtx, parameters)); @@ -915,15 +882,15 @@ public Gson getGsonStateSerializer(List<SourceAndConverter> serialized_sources) PluginService pluginService = scijavaCtx.getService(PluginService.class); // Creates adapter for all registration plugins - RegistrationAdapter registrationAdapter = new RegistrationAdapter(scijavaCtx, this); - pluginService.getPluginsOfType(IABBARegistrationPlugin.class).forEach(registrationPluginClass -> { - IABBARegistrationPlugin plugin = pluginService.createInstance(registrationPluginClass); + RegistrationAdapter registrationAdapter = new RegistrationAdapter(scijavaCtx); + pluginService.getPluginsOfType(IRegistrationPlugin.class).forEach(registrationPluginClass -> { + IRegistrationPlugin plugin = pluginService.createInstance(registrationPluginClass); factoryRegistrations.registerSubtype(plugin.getClass()); gsonbuilder.registerTypeHierarchyAdapter(plugin.getClass(), registrationAdapter); }); - factoryRegistrations.registerSubtype(ExternalABBARegistrationPlugin.class); - gsonbuilder.registerTypeHierarchyAdapter(ExternalABBARegistrationPlugin.class, registrationAdapter); + factoryRegistrations.registerSubtype(ExternalRegistrationPlugin.class); + gsonbuilder.registerTypeHierarchyAdapter(ExternalRegistrationPlugin.class, registrationAdapter); // For sources processor @@ -1456,7 +1423,7 @@ public SliceInfo(MultiSlicePositioner mp, SliceSources slice) { //---------------------- For PyImageJ extensions - static final Map<String, Supplier<? extends IABBARegistrationPlugin>> externalRegistrationPlugins = new HashMap<>(); + static final Map<String, Supplier<? extends IRegistrationPlugin>> externalRegistrationPlugins = new HashMap<>(); /** * Register an external registration plugin, for instance performed by a python function @@ -1464,7 +1431,7 @@ public SliceInfo(MultiSlicePositioner mp, SliceSources slice) { * @param name of the registration plugin * @param pluginSupplier the thing that makes a new plugin of this kind */ - public static void registerRegistrationPlugin(String name, Supplier<? extends IABBARegistrationPlugin> pluginSupplier) { + public static void registerRegistrationPlugin(String name, Supplier<? extends IRegistrationPlugin> pluginSupplier) { externalRegistrationPlugins.put(name, pluginSupplier); } @@ -1472,7 +1439,7 @@ public static boolean isExternalRegistrationPlugin(String name) { return externalRegistrationPlugins.containsKey(name); } - public static Supplier<? extends IABBARegistrationPlugin> getExternalRegistrationPluginSupplier(String name) { + public static Supplier<? extends IRegistrationPlugin> getExternalRegistrationPluginSupplier(String name) { return externalRegistrationPlugins.get(name); } diff --git a/src/main/java/ch/epfl/biop/atlas/aligner/RegisterSliceAction.java b/src/main/java/ch/epfl/biop/atlas/aligner/RegisterSliceAction.java index 4ee30cbf..8f4418e6 100644 --- a/src/main/java/ch/epfl/biop/atlas/aligner/RegisterSliceAction.java +++ b/src/main/java/ch/epfl/biop/atlas/aligner/RegisterSliceAction.java @@ -1,7 +1,7 @@ package ch.epfl.biop.atlas.aligner; import bdv.viewer.SourceAndConverter; -import ch.epfl.biop.atlas.aligner.plugin.RegistrationPluginHelper; +import ch.epfl.biop.registration.plugin.RegistrationPluginHelper; import ch.epfl.biop.registration.Registration; import ch.epfl.biop.sourceandconverter.processor.SourcesProcessor; import org.slf4j.Logger; diff --git a/src/main/java/ch/epfl/biop/atlas/aligner/SliceSources.java b/src/main/java/ch/epfl/biop/atlas/aligner/SliceSources.java index 05cbec9f..5698811d 100644 --- a/src/main/java/ch/epfl/biop/atlas/aligner/SliceSources.java +++ b/src/main/java/ch/epfl/biop/atlas/aligner/SliceSources.java @@ -15,7 +15,7 @@ import bdv.viewer.Interpolation; import bdv.viewer.Source; import bdv.viewer.SourceAndConverter; -import ch.epfl.biop.atlas.aligner.plugin.RegistrationPluginHelper; +import ch.epfl.biop.registration.plugin.RegistrationPluginHelper; import ch.epfl.biop.atlas.mouse.allen.ccfv3.command.AllenBrainAdultMouseAtlasCCF2017Command; import ch.epfl.biop.atlas.struct.AtlasHelper; import ch.epfl.biop.atlas.struct.AtlasNode; @@ -61,7 +61,6 @@ import net.imglib2.img.display.imagej.ImageJFunctions; import net.imglib2.position.FunctionRandomAccessible; import net.imglib2.realtransform.AffineTransform3D; -import net.imglib2.realtransform.BoundingBoxEstimation; import net.imglib2.realtransform.InvertibleRealTransform; import net.imglib2.realtransform.InvertibleRealTransformSequence; import net.imglib2.realtransform.RealTransform; @@ -113,10 +112,6 @@ import java.util.concurrent.ForkJoinPool; import java.util.stream.Collectors; -import static net.imglib2.realtransform.BoundingBoxEstimation.Method.CORNERS; -import static net.imglib2.realtransform.BoundingBoxEstimation.Method.FACES; -import static net.imglib2.realtransform.BoundingBoxEstimation.Method.VOLUME; - /** * Class which contains the current registered SourceAndConverter array @@ -1827,7 +1822,7 @@ public void popRasterSlice() { registered_sacs = sourcesNonRasterized.pop(); } - public static class RegistrationAndSources { + private static class RegistrationAndSources { final Registration reg; final SourceAndConverter[] sacs; diff --git a/src/main/java/ch/epfl/biop/atlas/aligner/adapter/RegistrationAdapter.java b/src/main/java/ch/epfl/biop/atlas/aligner/adapter/RegistrationAdapter.java index 550e9789..d4b7fa05 100644 --- a/src/main/java/ch/epfl/biop/atlas/aligner/adapter/RegistrationAdapter.java +++ b/src/main/java/ch/epfl/biop/atlas/aligner/adapter/RegistrationAdapter.java @@ -1,7 +1,7 @@ package ch.epfl.biop.atlas.aligner.adapter; import ch.epfl.biop.atlas.aligner.MultiSlicePositioner; -import ch.epfl.biop.atlas.aligner.plugin.ExternalABBARegistrationPlugin; +import ch.epfl.biop.registration.plugin.ExternalRegistrationPlugin; import ch.epfl.biop.registration.Registration; import com.google.gson.*; import org.scijava.Context; @@ -20,10 +20,8 @@ public class RegistrationAdapter implements JsonSerializer<Registration>, final Context scijavacontext; - final MultiSlicePositioner msp; - public RegistrationAdapter(Context context, MultiSlicePositioner mp) { + public RegistrationAdapter(Context context) { this.scijavacontext = context; - this.msp = mp; } @Override @@ -32,7 +30,7 @@ public Registration deserialize(JsonElement json, Type typeOfT, JsonDeserializat Registration registration; logger.debug("Fetching registration plugin "+typeOfT.getTypeName()); - if (typeOfT.getTypeName().equals(ExternalABBARegistrationPlugin.class.getName())) { + if (typeOfT.getTypeName().equals(ExternalRegistrationPlugin.class.getName())) { String registrationTypeName = json .getAsJsonObject() .get("external_type") @@ -50,7 +48,7 @@ public Registration deserialize(JsonElement json, Type typeOfT, JsonDeserializat registration.setRegistrationParameters(context.deserialize(json.getAsJsonObject().get("parameters"), Map.class)); return registration; } catch (InstantiableException e) { - msp.errlog.accept("Unrecognized registration plugin "+typeOfT.getTypeName()); + logger.error("Unrecognized registration plugin "+typeOfT.getTypeName()); e.printStackTrace(); return null; } @@ -64,7 +62,7 @@ public JsonElement serialize(Registration registration, Type typeOfSrc, JsonSeri logger.debug("With transform "+registration.getTransform()); logger.debug("And parameters "+registration.getRegistrationParameters()); if (MultiSlicePositioner.isExternalRegistrationPlugin(registration.getRegistrationTypeName())) { - obj.addProperty("type", ExternalABBARegistrationPlugin.class.getSimpleName()); + obj.addProperty("type", ExternalRegistrationPlugin.class.getSimpleName()); obj.addProperty("external_type", registration.getRegistrationTypeName()); } else { obj.addProperty("type", registration.getRegistrationTypeName()); diff --git a/src/main/java/ch/epfl/biop/atlas/aligner/command/MirrorDoCommand.java b/src/main/java/ch/epfl/biop/atlas/aligner/command/MirrorDoCommand.java index b7d5be70..0ff46529 100644 --- a/src/main/java/ch/epfl/biop/atlas/aligner/command/MirrorDoCommand.java +++ b/src/main/java/ch/epfl/biop/atlas/aligner/command/MirrorDoCommand.java @@ -3,6 +3,7 @@ import ch.epfl.biop.atlas.aligner.MultiSlicePositioner; import ch.epfl.biop.atlas.aligner.SliceSources; import ch.epfl.biop.atlas.aligner.action.MarkActionSequenceBatchAction; +import ch.epfl.biop.registration.sourceandconverter.mirror.MirrorXRegistration; import ch.epfl.biop.sourceandconverter.processor.SourcesIdentity; import org.scijava.command.Command; import org.scijava.plugin.Parameter; @@ -38,7 +39,7 @@ public void run() { parameters.put("mirror_side", mirror_side); new MarkActionSequenceBatchAction(mp).runRequest(); - mp.registerSelectedSlices(this, + mp.registerSelectedSlices(MirrorXRegistration.class, new SourcesIdentity(), new SourcesIdentity(), parameters); diff --git a/src/main/java/ch/epfl/biop/atlas/aligner/command/RegisterSlicesBigWarpCommand.java b/src/main/java/ch/epfl/biop/atlas/aligner/command/RegisterSlicesBigWarpCommand.java index f82f2d87..44c29652 100644 --- a/src/main/java/ch/epfl/biop/atlas/aligner/command/RegisterSlicesBigWarpCommand.java +++ b/src/main/java/ch/epfl/biop/atlas/aligner/command/RegisterSlicesBigWarpCommand.java @@ -1,15 +1,18 @@ package ch.epfl.biop.atlas.aligner.command; +import ch.epfl.biop.registration.sourceandconverter.bigwarp.SacBigWarp2DRegistration; import org.scijava.command.Command; import org.scijava.plugin.Plugin; +import java.util.HashMap; + @Plugin(type = Command.class, menuPath = "Plugins>BIOP>Atlas>Multi Image To Atlas>Align>ABBA - BigWarp Registration", description = "Uses BigWarp for in plane registration of selected slices") public class RegisterSlicesBigWarpCommand extends RegistrationMultiChannelCommand { public void runValidated() { - mp.registerSelectedSlices(this, getFixedFilter(), getMovingFilter()); + mp.registerSelectedSlices(SacBigWarp2DRegistration.class, getFixedFilter(), getMovingFilter(), new HashMap<>()); } } diff --git a/src/main/java/ch/epfl/biop/atlas/aligner/command/RegisterSlicesDeepSliceAbstractCommand.java b/src/main/java/ch/epfl/biop/atlas/aligner/command/RegisterSlicesDeepSliceAbstractCommand.java index d0fbbda6..4d0c09fd 100644 --- a/src/main/java/ch/epfl/biop/atlas/aligner/command/RegisterSlicesDeepSliceAbstractCommand.java +++ b/src/main/java/ch/epfl/biop/atlas/aligner/command/RegisterSlicesDeepSliceAbstractCommand.java @@ -8,7 +8,7 @@ import ch.epfl.biop.atlas.aligner.RegisterSliceAction; import ch.epfl.biop.atlas.aligner.SliceSources; import ch.epfl.biop.atlas.aligner.action.MarkActionSequenceBatchAction; -import ch.epfl.biop.atlas.aligner.plugin.IABBARegistrationPlugin; +import ch.epfl.biop.registration.plugin.IRegistrationPlugin; import ch.epfl.biop.java.utilities.TempDirectory; import ch.epfl.biop.quicknii.QuickNIIExporter; import ch.epfl.biop.quicknii.QuickNIISeries; @@ -392,11 +392,9 @@ protected void affineTransformInPlane(final List<SliceSources> slices, double n //logger.debug("Slice QuickNii "+i+" correspond to initial slice "+iSliceSource); - IABBARegistrationPlugin registration = (IABBARegistrationPlugin) + IRegistrationPlugin registration = (IRegistrationPlugin) pluginService.getPlugin(AffineRegistration.class).createInstance(); registration.setScijavaContext(ctx); - - registration.setSliceInfo(new MultiSlicePositioner.SliceInfo(mp, slices.get(iSliceSource))); Map<String,Object> parameters = new HashMap<>(); AffineTransform3D inPlaneTransform = new AffineTransform3D(); diff --git a/src/main/java/ch/epfl/biop/atlas/aligner/command/RegisterSlicesElastixAffineCommand.java b/src/main/java/ch/epfl/biop/atlas/aligner/command/RegisterSlicesElastixAffineCommand.java index 9f1c5e3f..7d53c4ee 100644 --- a/src/main/java/ch/epfl/biop/atlas/aligner/command/RegisterSlicesElastixAffineCommand.java +++ b/src/main/java/ch/epfl/biop/atlas/aligner/command/RegisterSlicesElastixAffineCommand.java @@ -1,5 +1,6 @@ package ch.epfl.biop.atlas.aligner.command; +import ch.epfl.biop.registration.sourceandconverter.affine.Elastix2DAffineRegistration; import ch.epfl.biop.scijava.command.source.register.ElastixHelper; import org.scijava.command.Command; import org.scijava.plugin.Parameter; @@ -40,7 +41,7 @@ public void runValidated() { parameters.put("background_offset_value_fixed", background_offset_value_fixed); parameters.put("pxSizeInCurrentUnit", pixel_size_micrometer/1000.0); - mp.registerSelectedSlices(this, + mp.registerSelectedSlices(Elastix2DAffineRegistration.class, getFixedFilter(), getMovingFilter(), parameters); diff --git a/src/main/java/ch/epfl/biop/atlas/aligner/command/RegisterSlicesElastixSplineCommand.java b/src/main/java/ch/epfl/biop/atlas/aligner/command/RegisterSlicesElastixSplineCommand.java index 9d1b026c..f5d4fe28 100644 --- a/src/main/java/ch/epfl/biop/atlas/aligner/command/RegisterSlicesElastixSplineCommand.java +++ b/src/main/java/ch/epfl/biop/atlas/aligner/command/RegisterSlicesElastixSplineCommand.java @@ -1,5 +1,6 @@ package ch.epfl.biop.atlas.aligner.command; +import ch.epfl.biop.registration.sourceandconverter.spline.Elastix2DSplineRegistration; import ch.epfl.biop.scijava.command.source.register.ElastixHelper; import org.scijava.command.Command; import org.scijava.plugin.Parameter; @@ -51,7 +52,7 @@ public void runValidated() { parameters.put("background_offset_value_fixed", background_offset_value_fixed); parameters.put("pxSizeInCurrentUnit", pixel_size_micrometer/1000.0); - mp.registerSelectedSlices(this, + mp.registerSelectedSlices(Elastix2DSplineRegistration.class, getFixedFilter(), getMovingFilter(), parameters); diff --git a/src/main/java/ch/epfl/biop/atlas/aligner/gui/bdv/BdvMultislicePositionerView.java b/src/main/java/ch/epfl/biop/atlas/aligner/gui/bdv/BdvMultislicePositionerView.java index 1702be1c..8747fab8 100644 --- a/src/main/java/ch/epfl/biop/atlas/aligner/gui/bdv/BdvMultislicePositionerView.java +++ b/src/main/java/ch/epfl/biop/atlas/aligner/gui/bdv/BdvMultislicePositionerView.java @@ -42,13 +42,17 @@ import ch.epfl.biop.atlas.aligner.command.ImportSliceFromSourcesCommand; import ch.epfl.biop.atlas.aligner.command.ImportSlicesFromFilesCommand; import ch.epfl.biop.atlas.aligner.command.ImportSlicesFromQuPathCommand; +import ch.epfl.biop.atlas.aligner.command.MirrorDoCommand; import ch.epfl.biop.atlas.aligner.command.MirrorUndoCommand; import ch.epfl.biop.atlas.aligner.command.RasterSlicesCommand; import ch.epfl.biop.atlas.aligner.command.RasterSlicesDeformationCommand; +import ch.epfl.biop.atlas.aligner.command.RegisterSlicesBigWarpCommand; import ch.epfl.biop.atlas.aligner.command.RegisterSlicesCopyAndApplyCommand; import ch.epfl.biop.atlas.aligner.command.RegisterSlicesDeepSliceWebCommand; import ch.epfl.biop.atlas.aligner.command.RegisterSlicesDeepSliceLocalCommand; import ch.epfl.biop.atlas.aligner.command.RegisterSlicesEditLastCommand; +import ch.epfl.biop.atlas.aligner.command.RegisterSlicesElastixAffineCommand; +import ch.epfl.biop.atlas.aligner.command.RegisterSlicesElastixSplineCommand; import ch.epfl.biop.atlas.aligner.command.RegisterSlicesRemoveLastCommand; import ch.epfl.biop.atlas.aligner.command.RotateSlicesCommand; import ch.epfl.biop.atlas.aligner.command.SetSlicesDisplayRangeCommand; @@ -62,8 +66,6 @@ import ch.epfl.biop.atlas.aligner.gui.bdv.card.NavigationPanel; import ch.epfl.biop.atlas.aligner.gui.bdv.card.SliceDefineROICommand; import ch.epfl.biop.atlas.aligner.plugin.ABBACommand; -import ch.epfl.biop.atlas.aligner.plugin.IABBARegistrationPlugin; -import ch.epfl.biop.atlas.aligner.plugin.RegistrationPluginHelper; import ch.epfl.biop.atlas.struct.AtlasNode; import ch.epfl.biop.bdv.gui.graphicalhandle.GraphicalHandle; import ch.epfl.biop.bdv.gui.graphicalhandle.GraphicalHandleListener; @@ -83,7 +85,6 @@ import org.scijava.Context; import org.scijava.MenuPath; import org.scijava.cache.CacheService; -import org.scijava.command.Command; import org.scijava.command.CommandModule; import org.scijava.command.CommandService; import org.scijava.module.Module; @@ -423,15 +424,11 @@ private void installBdvMenu(int hierarchyLevelsSkipped) { } private void installRegistrationPluginUI(int hierarchyLevelsSkipped) { - PluginService pluginService = msp.getContext().getService(PluginService.class); - pluginService.getPluginsOfType(IABBARegistrationPlugin.class).forEach(registrationPluginClass -> { - IABBARegistrationPlugin plugin = pluginService.createInstance(registrationPluginClass); - for (Class<? extends Command> commandUI: RegistrationPluginHelper.userInterfaces(plugin)) { - logger.info("Registration plugin "+commandUI.getSimpleName()+" discovered"); - BdvScijavaHelper.addCommandToBdvHandleMenu(bdvh, msp.getContext(), commandUI, hierarchyLevelsSkipped,"mp", msp); - } - }); + BdvScijavaHelper.addCommandToBdvHandleMenu(bdvh, msp.getContext(), RegisterSlicesElastixAffineCommand.class, hierarchyLevelsSkipped,"mp", msp); + BdvScijavaHelper.addCommandToBdvHandleMenu(bdvh, msp.getContext(), RegisterSlicesBigWarpCommand.class, hierarchyLevelsSkipped,"mp", msp); + BdvScijavaHelper.addCommandToBdvHandleMenu(bdvh, msp.getContext(), RegisterSlicesElastixSplineCommand.class, hierarchyLevelsSkipped,"mp", msp); + BdvScijavaHelper.addCommandToBdvHandleMenu(bdvh, msp.getContext(), MirrorDoCommand.class, hierarchyLevelsSkipped,"mp", msp); BdvScijavaHelper.addCommandToBdvHandleMenu(bdvh, msp.getContext(), MirrorUndoCommand.class, hierarchyLevelsSkipped,"mp", msp); logger.debug("Installing external registration plugins ui"); diff --git a/src/main/java/ch/epfl/biop/atlas/aligner/plugin/ExternalABBARegistrationPlugin.java b/src/main/java/ch/epfl/biop/atlas/aligner/plugin/ExternalABBARegistrationPlugin.java deleted file mode 100644 index 95b6bc7e..00000000 --- a/src/main/java/ch/epfl/biop/atlas/aligner/plugin/ExternalABBARegistrationPlugin.java +++ /dev/null @@ -1,29 +0,0 @@ -package ch.epfl.biop.atlas.aligner.plugin; -import org.scijava.command.Command; - -/** - * An registration plugin interface without any annotation - useful - * mostly useful in order to add a plugin from PyImageJ - */ -@SuppressWarnings("SameReturnValue") -public interface ExternalABBARegistrationPlugin extends IABBARegistrationPlugin { - - /** - * Does the registration required an user input ? - * @return true if some user action is required - */ - boolean isManual(); - - /** - * Can the registration be edited after it has run ? - * Considered a manual task by default - * @return true if the registration can be edited a posteriori - */ - boolean isEditable(); - - /** - * @return the command class the user has to call in order to start a registration - */ - Class<? extends Command>[] userInterface(); - -} diff --git a/src/main/java/ch/epfl/biop/atlas/aligner/plugin/IABBARegistrationPlugin.java b/src/main/java/ch/epfl/biop/atlas/aligner/plugin/IABBARegistrationPlugin.java deleted file mode 100644 index 344ae1b1..00000000 --- a/src/main/java/ch/epfl/biop/atlas/aligner/plugin/IABBARegistrationPlugin.java +++ /dev/null @@ -1,12 +0,0 @@ -package ch.epfl.biop.atlas.aligner.plugin; - -import bdv.viewer.SourceAndConverter; -import ch.epfl.biop.atlas.aligner.MultiSlicePositioner; -import ch.epfl.biop.registration.Registration; -import org.scijava.plugin.SciJavaPlugin; - -public interface IABBARegistrationPlugin extends SciJavaPlugin, Registration<SourceAndConverter<?>[]> { - - void setSliceInfo(MultiSlicePositioner.SliceInfo sliceInfo); - -} diff --git a/src/main/java/ch/epfl/biop/atlas/aligner/plugin/RegistrationPluginHelper.java b/src/main/java/ch/epfl/biop/atlas/aligner/plugin/RegistrationPluginHelper.java deleted file mode 100644 index 4ce75b41..00000000 --- a/src/main/java/ch/epfl/biop/atlas/aligner/plugin/RegistrationPluginHelper.java +++ /dev/null @@ -1,85 +0,0 @@ -package ch.epfl.biop.atlas.aligner.plugin; - -import ch.epfl.biop.registration.Registration; -import org.scijava.Context; -import org.scijava.command.Command; -import org.scijava.plugin.PluginService; - -import java.util.Arrays; - -// Facilitates accessing annotation values -public class RegistrationPluginHelper { - - /** - * Does the registration required an user input ? - * @return true if user input is required - */ - public static boolean isManual(Registration<?> reg) { - if (reg.getClass().isAnnotationPresent(RegistrationTypeProperties.class)) { - final RegistrationTypeProperties annotation = reg.getClass() - .getAnnotation(RegistrationTypeProperties.class); - return annotation.isManual(); - } else { - if (reg instanceof ExternalABBARegistrationPlugin) { - return ((ExternalABBARegistrationPlugin) reg).isManual(); - } else { - return false; // Default value if no annotation is present - } - } - } - - /** - * Can the registration be edited after it has run ? - * Considered a manual task by default - */ - public static boolean isEditable(Registration<?> reg) { - if (reg.getClass().isAnnotationPresent(RegistrationTypeProperties.class)) { - final RegistrationTypeProperties annotation = reg.getClass() - .getAnnotation(RegistrationTypeProperties.class); - return annotation.isEditable(); - } else { - if (reg instanceof ExternalABBARegistrationPlugin) { - return ((ExternalABBARegistrationPlugin) reg).isEditable(); - } else { - return false; // Default value if no annotation is present - } - } - } - - /** - * @return the command class the user has to call in order to start a registration - */ - public static Class<? extends Command>[] userInterfaces(Registration<?> reg) { - if (reg.getClass().isAnnotationPresent(RegistrationTypeProperties.class)) { - final RegistrationTypeProperties annotation = reg.getClass() - .getAnnotation(RegistrationTypeProperties.class); - return annotation.userInterface(); - } else { - if (reg instanceof ExternalABBARegistrationPlugin) { - return ((ExternalABBARegistrationPlugin) reg).userInterface(); - } else { - return new Class[0]; // Default value if no annotation is present - } - } - } - - /** - * Assumes unicity! Find the registration class from a UI class - * @param queryUIClass the ui class from which the registration is supposed to be found - * @return null is nothing is found - */ - public static Class<? extends IABBARegistrationPlugin> registrationFromUI (Context ctx, Class<? extends Command> queryUIClass) { - PluginService pluginService = ctx.getService(PluginService.class); - - // OK... intellij found this alone, let's hope it works - return pluginService - .getPluginsOfType(IABBARegistrationPlugin.class) - .stream().map(pluginService::createInstance) - .filter(plugin -> Arrays.asList(RegistrationPluginHelper.userInterfaces(plugin)).contains(queryUIClass)) - .findFirst() - .map(IABBARegistrationPlugin::getClass) - .orElse(null); - - } - -} diff --git a/src/main/java/ch/epfl/biop/atlas/aligner/plugin/RegistrationTypeProperties.java b/src/main/java/ch/epfl/biop/atlas/aligner/plugin/RegistrationTypeProperties.java deleted file mode 100644 index 74304969..00000000 --- a/src/main/java/ch/epfl/biop/atlas/aligner/plugin/RegistrationTypeProperties.java +++ /dev/null @@ -1,29 +0,0 @@ -package ch.epfl.biop.atlas.aligner.plugin; - -import org.scijava.command.Command; - -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; - -@Retention(RetentionPolicy.RUNTIME) -public @interface RegistrationTypeProperties { - - /** - * Does the registration required an user input ? - * @return true if the registration requires user input - */ - boolean isManual(); - - /** - * Can the registration be edited after it has run ? - * Considered a manual task by default - * @return true if the registration can be edited a posteriori - */ - boolean isEditable(); - - /** - * @return the command class the user has to call in order to start a registration - */ - Class<? extends Command>[] userInterface(); -} - diff --git a/src/main/java/ch/epfl/biop/atlas/aligner/plugin/SimpleABBARegistrationPlugin.java b/src/main/java/ch/epfl/biop/atlas/aligner/plugin/SimpleABBARegistrationPlugin.java deleted file mode 100644 index 8e708172..00000000 --- a/src/main/java/ch/epfl/biop/atlas/aligner/plugin/SimpleABBARegistrationPlugin.java +++ /dev/null @@ -1,32 +0,0 @@ -package ch.epfl.biop.atlas.aligner.plugin; - -import ij.ImagePlus; -import net.imglib2.realtransform.InvertibleRealTransform; - -import java.util.Map; - -@SuppressWarnings("SameReturnValue") -public interface SimpleABBARegistrationPlugin { - - /** - * @return Sampling required for the registration, in micrometer - */ - double getVoxelSizeInMicron(); - - /** - * Is called before registration to pass any extra registration parameter - * argument. Passed as a dictionary of String to preserve serialization - * capability. - * @param parameters dictionary of parameters - */ - void setRegistrationParameters(Map<String,String> parameters); - - /** - * - * @param fixed image - * @param moving image - * @return the transform, result of the registration, in - * going from fixed to moving coordinates, in pixels - */ - InvertibleRealTransform register(ImagePlus fixed, ImagePlus moving, ImagePlus fixedMask, ImagePlus movingMask); -} diff --git a/src/main/java/ch/epfl/biop/atlas/aligner/plugin/SimpleRegistrationWrapper.java b/src/main/java/ch/epfl/biop/atlas/aligner/plugin/SimpleRegistrationWrapper.java deleted file mode 100644 index 3bc019e3..00000000 --- a/src/main/java/ch/epfl/biop/atlas/aligner/plugin/SimpleRegistrationWrapper.java +++ /dev/null @@ -1,339 +0,0 @@ -package ch.epfl.biop.atlas.aligner.plugin; - -import bdv.util.BoundedRealTransform; -import bdv.viewer.SourceAndConverter; -import ch.epfl.biop.atlas.aligner.MultiSlicePositioner; -import ch.epfl.biop.bdv.img.imageplus.ImagePlusHelper; -import ch.epfl.biop.java.utilities.roi.types.RealPointList; -import ij.ImagePlus; -import net.imglib2.RealPoint; -import net.imglib2.realtransform.AffineTransform3D; -import net.imglib2.realtransform.InvertibleRealTransform; -import net.imglib2.realtransform.InvertibleRealTransformSequence; -import net.imglib2.realtransform.RealTransform; -import net.imglib2.type.NativeType; -import net.imglib2.type.numeric.NumericType; -import org.scijava.Context; -import org.scijava.command.Command; -import sc.fiji.bdvpg.sourceandconverter.SourceAndConverterHelper; -import sc.fiji.bdvpg.sourceandconverter.importer.EmptySourceAndConverterCreator; -import sc.fiji.bdvpg.sourceandconverter.transform.SourceRealTransformer; -import sc.fiji.bdvpg.sourceandconverter.transform.SourceResampler; -import sc.fiji.persist.ScijavaGsonHelper; - -import java.util.*; -import java.util.stream.Collectors; - -public class SimpleRegistrationWrapper implements ExternalABBARegistrationPlugin { - - public String getRegistrationTypeName() { - return registrationTypeName; - } - - public SimpleRegistrationWrapper(String registrationTypeName, final SimpleABBARegistrationPlugin simpleRegistration) { - this.registration = simpleRegistration; - this.registrationTypeName = registrationTypeName; - } - - final String registrationTypeName; - final SimpleABBARegistrationPlugin registration; - - Context context; - - Map<String, String> parameters; - - boolean isDone = false; - - protected RealTransform rt; - - @Override - public void setSliceInfo(MultiSlicePositioner.SliceInfo sliceInfo) { - - } - - @Override - public boolean isManual() { - return false; - } - - @Override - public boolean isEditable() { - return false; - } - - @Override - public Class<? extends Command>[] userInterface() { - return new Class[0]; - } - - @Override - public void setScijavaContext(Context context) { - this.context = context; - } - - @Override - public void setRegistrationParameters(Map<String, String> parameters) { - this.parameters = parameters; - } - - @Override - public Map<String, String> getRegistrationParameters() { - return parameters; - } - - ImagePlus fixedImage, movingImage, fixedMask, movingMask; - - @Override - public void setFixedImage(SourceAndConverter<?>[] fimg) { - fixedImage = export("Fixed-", Arrays.asList(fimg), - (Double.parseDouble(parameters.get("px"))), - (Double.parseDouble(parameters.get("py"))), - (Double.parseDouble(parameters.get("sx"))), - (Double.parseDouble(parameters.get("sy"))), - registration.getVoxelSizeInMicron()/1000.0, - 0, - false - ); - } - - @Override - public void setMovingImage(SourceAndConverter<?>[] mimg) { - movingImage = export("Moving-", Arrays.asList(mimg), - (Double.parseDouble(parameters.get("px"))), - (Double.parseDouble(parameters.get("py"))), - (Double.parseDouble(parameters.get("sx"))), - (Double.parseDouble(parameters.get("sy"))), - registration.getVoxelSizeInMicron()/1000.0, - 0, - false - ); - } - - @Override - public void setFixedMask(SourceAndConverter<?>[] fimg_mask) { - fixedMask = export("FixedMask-", Arrays.asList(fimg_mask), - (Double.parseDouble(parameters.get("px"))), - (Double.parseDouble(parameters.get("py"))), - (Double.parseDouble(parameters.get("sx"))), - (Double.parseDouble(parameters.get("sy"))), - registration.getVoxelSizeInMicron()/1000.0, - 0, - false - ); - } - - @Override - public void setMovingMask(SourceAndConverter<?>[] mimg_mask) { - movingMask = export("MovingMask-", Arrays.asList(mimg_mask), - (Double.parseDouble(parameters.get("px"))), - (Double.parseDouble(parameters.get("py"))), - (Double.parseDouble(parameters.get("sx"))), - (Double.parseDouble(parameters.get("sy"))), - registration.getVoxelSizeInMicron()/1000.0, - 0, - false - ); - } - - @Override - public void resetRegistration() { - isDone = false; - } - - @Override - public void setTimePoint(int timePoint) { - // ignored: it's 0 - } - - @Override - public boolean register() { - InvertibleRealTransform inner_rt = registration.register(fixedImage, movingImage, fixedMask, movingMask); - - // This transform is for pixel to pixel coordinates -> we need to convert it to physical space. - // Thus adding an AffineTransform to a sequence - - InvertibleRealTransformSequence irts = new InvertibleRealTransformSequence(); - AffineTransform3D m = new AffineTransform3D(); - - double px = (Double.parseDouble(parameters.get("px"))); - double py = (Double.parseDouble(parameters.get("py"))); - double voxSize = registration.getVoxelSizeInMicron(); - - // We work in millimeters - m.scale(voxSize/1000.0); - m.translate(px, py, 0); - - // The umbrella trick - irts.add(m.inverse()); - irts.add(inner_rt); - irts.add(m); - - rt = irts; - - isDone = true; - return true; // no error handling - } - - @Override - public boolean edit() { - // TODO : find a way to edit an affine transform -> that shouldn't be so complicated - throw new UnsupportedOperationException(); - } - - @Override - public boolean isRegistrationDone() { - return isDone; - } - - @Override - public SourceAndConverter<?>[] getTransformedImageMovingToFixed(SourceAndConverter<?>[] img) { - SourceAndConverter[] out = new SourceAndConverter[img.length]; - SourceRealTransformer srt = new SourceRealTransformer(rt); - for (int idx = 0;idx<img.length;idx++) { - out[idx] = srt.apply(img[idx]); - } - return out; - } - - @Override - public RealPointList getTransformedPtsFixedToMoving(RealPointList pts) { - RealTransform innerRT = rt; // To unbox bounded realtransform - - // Unbox bounded transform - if (rt instanceof BoundedRealTransform) { - innerRT = ((BoundedRealTransform)rt).getTransform().copy(); - } - - ArrayList<RealPoint> cvtList = new ArrayList<>(); - - for (RealPoint p : pts.ptList) { - RealPoint pt3d = new RealPoint(3); - pt3d.setPosition(new double[]{p.getDoublePosition(0), p.getDoublePosition(1),0}); - innerRT.apply(pt3d, pt3d); - RealPoint cpt = new RealPoint(pt3d.getDoublePosition(0), pt3d.getDoublePosition(1)); - cvtList.add(cpt); - } - - return new RealPointList(cvtList); - } - - @Override - public void abort() { - - } - - public RealTransform getRealTransform() { - return rt; - } - - public void setRealTransform(RealTransform transform) { - this.rt = transform.copy(); - } - - @Override - final public String getTransform() { - //logger.debug("Serializing transform of class "+rt.getClass().getSimpleName()); - String transform = ScijavaGsonHelper.getGson(context).toJson(rt, RealTransform.class); - //logger.debug("Serialization result = "+transform); - return transform; - } - - @Override - final public void setTransform(String serialized_transform) { - setRealTransform(ScijavaGsonHelper.getGson(context).fromJson(serialized_transform, RealTransform.class)); - isDone = true; - } - - public RealTransform getTransformAsRealTransform() { - return rt.copy(); - } - - - public static <T extends NumericType<T> & NativeType<T>> ImagePlus export(String name, List<SourceAndConverter<?>> sourceList, - double px, double py, double sx, double sy, - double pixelSizeMillimeter, int timepoint, - boolean interpolate) { - - AffineTransform3D at3D = new AffineTransform3D(); - - SourceAndConverter model = createModelSource(px, py, sx, sy, pixelSizeMillimeter, at3D); - - List<SourceAndConverter<T>> resampledSourceList = sourceList - .stream() - .map(sac -> (SourceAndConverter<T>) (new SourceResampler(sac,model,sac.getSpimSource().getName()+"_ResampledLike_"+model.getSpimSource().getName(), true, false, interpolate,0).get())) - .collect(Collectors.toList()); - - if ((sourceList.size()>1)) { - - Map<SourceAndConverter<T>, Integer> mapMipmap = new HashMap<>(); - sourceList.forEach(src -> { - int mipmapLevel = SourceAndConverterHelper.bestLevel(src, timepoint, pixelSizeMillimeter); - //logger.debug("Mipmap level chosen for source ["+src.getSpimSource().getName()+"] : "+mipmapLevel); - mapMipmap.put(resampledSourceList.get(sourceList.indexOf(src)), mipmapLevel); - }); - - ImagePlus resultImage = ImagePlusHelper.wrap( - resampledSourceList, - mapMipmap, - timepoint, - 1, - 1); - - resultImage.setTitle(name+"-["+px+":"+(px+sx)+" | "+py+":"+(py+sy)+"]"); - ImagePlusHelper.storeExtendedCalibrationToImagePlus(resultImage, at3D.inverse(), "mm", timepoint); - - return resultImage; - - } else { - SourceAndConverter source = resampledSourceList.get(0); - int mipmapLevel = SourceAndConverterHelper.bestLevel(sourceList.get(0), timepoint, pixelSizeMillimeter); - ImagePlus singleChannel = ImagePlusHelper.wrap( - source, - mipmapLevel, - timepoint, - 1, - 1); - singleChannel.setTitle(source.getSpimSource().getName()); - ImagePlusHelper.storeExtendedCalibrationToImagePlus(singleChannel, at3D.inverse(), "mm", timepoint); - - return singleChannel; - } - - } - - - private static SourceAndConverter createModelSource( - double px, double py, - double sx, double sy, - double pixel_size_mm, - AffineTransform3D transform) { - // Origin is in fact the point 0,0,0 of the image - // Get current big dataviewer transformation : source transform and viewer transform - AffineTransform3D at3D = new AffineTransform3D(); // Empty Transform - // viewer transform - // Center on the display center of the viewer ... - at3D.translate(-px, -py, 0); - - at3D.scale(1/pixel_size_mm); - - // Getting an image independent of the view scaling unit (not sure) - long nPx = (long)(sx / pixel_size_mm); - long nPy = (long)(sy / pixel_size_mm); - long nPz = 1; - - // At least a pixel in all directions - if (nPz == 0) nPz = 1; - if (nPx == 0) nPx = 1; - if (nPy == 0) nPy = 1; - - transform.set(at3D); - - return new EmptySourceAndConverterCreator("model", at3D.inverse(), nPx, nPy, nPz).get(); - } - - @Override - public String toString() { - return registrationTypeName; - } - -} diff --git a/src/main/java/ch/epfl/biop/registration/Registration.java b/src/main/java/ch/epfl/biop/registration/Registration.java deleted file mode 100644 index adfad215..00000000 --- a/src/main/java/ch/epfl/biop/registration/Registration.java +++ /dev/null @@ -1,171 +0,0 @@ -package ch.epfl.biop.registration; -import ch.epfl.biop.java.utilities.roi.types.RealPointList; -import net.imglib2.realtransform.RealTransform; -import org.scijava.Context; - -import java.util.Map; - -/** - * Most upstream - * @param <T> Type of the image to register ( ImagePlus / SourceAndConverter, what else ? ) - */ - -public interface Registration<T> { - - /** - * Is called just after the Registration object creation to pass - * the current scijava context - * is adopted by all registrations - * @param context - */ - void setScijavaContext(Context context); - - /** - * Is called before registration to pass any extra registration parameter - * argument. Passed as a dictionary of String to preserve serialization - * capability. - * @param parameters dictionary of parameters - */ - void setRegistrationParameters(Map<String,String> parameters); - - /** - * For serialization and reproducibility - * @return parameters that were used for the registration - */ - Map<String,String> getRegistrationParameters(); - - /** - * Sets the fixed image - * @param fimg fixed image - */ - void setFixedImage(T fimg); - - /** - * Set the moving image - * @param mimg moving image - */ - void setMovingImage(T mimg); - - /** - * Optional - sets the fixed image mask - * @param fimg_mask fixed image - */ - void setFixedMask(T fimg_mask); - - /** - * Optional - set the moving image mask - * @param mimg_mask moving image - */ - void setMovingMask(T mimg_mask); - - /** - * Sets the state of the registration to not done - * Called when the registration needs to be rerun for real - * instead of just restored - * - */ - void resetRegistration(); - - /** - * Sets the timepoint of the source that should be used for the - * registration. 0 in most cases - * @param timePoint - */ - void setTimePoint(int timePoint); - - /** - * Blocking function which performs the registration - * @return true if the registration was run succesfully - */ - boolean register(); - - /** - * Can be called after register() return false in order to get - * a more meaningful explanation - * @return an error message for a failed registration - */ - default String getExceptionMessage() { - return "Unspecified error"; - } - - /** - * Blocking function which is called when the user wants - * to manually edit the result of the registration - * @return true is the transform is been edited successfully. If not, - * the previous state of the registration is restored thanks to the serialization - * of the transform. An edition cannot occur if the transform has not been set - * before (either via the run method, or via setting the transform via the - * {@link Registration#setTransform(String)} method - */ - boolean edit(); - - /** - * Flag functions which serves to know whether the result of the - * registration is available. Should not be blocking. - * - * @return true if the transform is available - */ - boolean isRegistrationDone(); - - /** - * Function which takes an input moving image, transform it - * according to the result of the registration (transformation), - * and returns it - * @param img should not be modified - * @return the transformed image - */ - T getTransformedImageMovingToFixed(final T img); - - /** - * Reverse transforms a list of points. This function takes a list - * of points given in the fixed coordinates system, inverse transform - * their coordinates according to the result of the registration. - * The points can be mutated - * @param pts points to transform from fixed to moving system coordinates - * @return the transformed points - */ - RealPointList getTransformedPtsFixedToMoving(RealPointList pts); - - /** - * Function called when a registration is cancelled while being processed - */ - void abort(); - - /** - * This function is used to: - * - save the registration into a json file - * - store transiently the state of a registration to cancel the edition of a transform, if needed - * @return a serialized representation of the transform as a String - */ - String getTransform(); - - /** - * Function used to bypass the real registration process (run) - * in order to set directly the result of the registration. - * This is used when: - * - loading a registration from a state file - * - restore if needed a previous transformed state after an edition - * a serialized representation of the transform is sent, leading - * to an immediate registration being done - * isDone should return true after this function is being called - * @param serialized_transform - */ - void setTransform(String serialized_transform); - - /** - * If the transform can be returned as a serializable RealTransform object, - * this can be used to serialize the successive registrations as a - * {@link net.imglib2.realtransform.RealTransformSequence} object, or even, - * if all transformations are invertible, as a {@link net.imglib2.realtransform.InvertibleRealTransformSequence} object - * @return - */ - RealTransform getTransformAsRealTransform(); - - /** - * Used for serialisation - * @return - */ - default String getRegistrationTypeName() { - return this.getClass().getSimpleName(); - } -} diff --git a/src/main/java/ch/epfl/biop/registration/sourceandconverter/SourceAndConverterRegistration.java b/src/main/java/ch/epfl/biop/registration/sourceandconverter/SourceAndConverterRegistration.java deleted file mode 100644 index d6cded50..00000000 --- a/src/main/java/ch/epfl/biop/registration/sourceandconverter/SourceAndConverterRegistration.java +++ /dev/null @@ -1,102 +0,0 @@ -package ch.epfl.biop.registration.sourceandconverter; - -import bdv.viewer.SourceAndConverter; -import ch.epfl.biop.atlas.aligner.MultiSlicePositioner; -import ch.epfl.biop.atlas.aligner.plugin.IABBARegistrationPlugin; -import org.scijava.Context; -import org.scijava.plugin.Parameter; - -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -abstract public class SourceAndConverterRegistration implements IABBARegistrationPlugin { - - protected SourceAndConverter<?>[] fimg; - - protected SourceAndConverter<?>[] mimg; - - protected SourceAndConverter<?>[] fimg_mask; - - protected SourceAndConverter<?>[] mimg_mask; - - protected int timePoint = 0; - - @Parameter - protected Context context; - - @Override - public void setFixedImage(SourceAndConverter<?>[] fimg) { - this.fimg = fimg; - } - - @Override - public void setMovingImage(SourceAndConverter<?>[] mimg) { - this.mimg = mimg; - } - - @Override - public void setFixedMask(SourceAndConverter<?>[] fimg) { - this.fimg_mask = fimg; - } - - @Override - public void setMovingMask(SourceAndConverter<?>[] mimg) { - this.mimg_mask = mimg; - } - - @Override - public void setTimePoint(int timePoint) { - this.timePoint = timePoint; - } - - /** - * Is called just after the Registration object creation to pass - * the current scijava context - * is adopted by all registrations - * @param context - */ - public void setScijavaContext(Context context) { - this.context = context; - } - - protected boolean isDone = false; - - @Override - public boolean isRegistrationDone() { - return isDone; - } - - @Override - public void resetRegistration() { - isDone = false; - } - - protected Map<String, String> parameters = new HashMap<>(); - - @Override - public Map<String, String> getRegistrationParameters() { - if (parameters!=null) { - return parameters; - } else { - return new HashMap<>(); - } - } - - @Override - public void setRegistrationParameters(Map<String, String> parameters) { - this.parameters = parameters; - } - - protected MultiSlicePositioner.SliceInfo sliceInfo; - - public void setSliceInfo(MultiSlicePositioner.SliceInfo sliceInfo){ - this.sliceInfo = sliceInfo; - } - - protected static void addToFlatParameters(List<Object> flatParameters, Object... args) { - flatParameters.addAll(Arrays.asList(args)); - } - -} diff --git a/src/main/java/ch/epfl/biop/registration/sourceandconverter/affine/AffineRegistration.java b/src/main/java/ch/epfl/biop/registration/sourceandconverter/affine/AffineRegistration.java deleted file mode 100644 index cca0508a..00000000 --- a/src/main/java/ch/epfl/biop/registration/sourceandconverter/affine/AffineRegistration.java +++ /dev/null @@ -1,64 +0,0 @@ -package ch.epfl.biop.registration.sourceandconverter.affine; - -import bdv.viewer.SourceAndConverter; -import ch.epfl.biop.atlas.aligner.plugin.IABBARegistrationPlugin; -import ch.epfl.biop.atlas.aligner.plugin.RegistrationTypeProperties; -import com.google.gson.Gson; -import net.imglib2.realtransform.AffineTransform3D; -import org.scijava.plugin.Plugin; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * To make an affine transform programmatically conveniently - * - */ -@Plugin(type = IABBARegistrationPlugin.class) -@RegistrationTypeProperties( - isManual = false, - isEditable = false, - userInterface = { - }) - -public class AffineRegistration extends AffineTransformSourceAndConverterRegistration{ - - protected static Logger logger = LoggerFactory.getLogger(AffineRegistration.class); - - @Override - public void setFixedImage(SourceAndConverter<?>[] fimg) { - super.setFixedImage(fimg); - } - - @Override - public void setMovingImage(SourceAndConverter<?>[] mimg) { - super.setMovingImage(mimg); - } - - public static String affineTransform3DToString(AffineTransform3D transform) { - return new Gson().toJson(transform.getRowPackedCopy()); - } - - public static AffineTransform3D stringToAffineTransform3D(String string) { - AffineTransform3D transform3D = new AffineTransform3D(); - double[] matrix = new Gson().fromJson(string, double[].class); - transform3D.set(matrix); - return transform3D; - } - - @Override - public boolean register() { - at3d = stringToAffineTransform3D(parameters.get("transform")); - isDone = true; - return true; - } - - @Override - public void abort() { - - } - - public String toString() { - return "Affine"; - } - -} diff --git a/src/main/java/ch/epfl/biop/registration/sourceandconverter/affine/AffineTransformSourceAndConverterRegistration.java b/src/main/java/ch/epfl/biop/registration/sourceandconverter/affine/AffineTransformSourceAndConverterRegistration.java deleted file mode 100644 index baf57aa6..00000000 --- a/src/main/java/ch/epfl/biop/registration/sourceandconverter/affine/AffineTransformSourceAndConverterRegistration.java +++ /dev/null @@ -1,64 +0,0 @@ -package ch.epfl.biop.registration.sourceandconverter.affine; - -import bdv.viewer.SourceAndConverter; -import ch.epfl.biop.java.utilities.roi.types.RealPointList; -import ch.epfl.biop.registration.sourceandconverter.SourceAndConverterRegistration; -import net.imglib2.RealPoint; -import net.imglib2.realtransform.AffineTransform3D; -import net.imglib2.realtransform.RealTransform; -import sc.fiji.bdvpg.sourceandconverter.SourceAndConverterAndTimeRange; -import sc.fiji.bdvpg.sourceandconverter.transform.SourceTransformHelper; -import sc.fiji.persist.ScijavaGsonHelper; - -import java.util.ArrayList; - -abstract public class AffineTransformSourceAndConverterRegistration extends SourceAndConverterRegistration { - - protected AffineTransform3D at3d = new AffineTransform3D(); - - @SuppressWarnings("CanBeFinal") - public int timePoint = 0; - - @Override - public SourceAndConverter<?>[] getTransformedImageMovingToFixed(SourceAndConverter<?>[] img) { - SourceAndConverter<?>[] out = new SourceAndConverter[img.length]; - for (int idx = 0;idx<img.length;idx++) { - out[idx] = SourceTransformHelper.createNewTransformedSourceAndConverter(at3d, new SourceAndConverterAndTimeRange<>(img[idx],timePoint)); - } - return out; - } - - @Override - public RealPointList getTransformedPtsFixedToMoving(RealPointList pts) { - ArrayList<RealPoint> cvtList = new ArrayList<>(); - for (RealPoint p : pts.ptList) { - RealPoint pt3d = new RealPoint(3); - pt3d.setPosition(new double[]{p.getDoublePosition(0), p.getDoublePosition(1),0}); - at3d.inverse().apply(pt3d, pt3d); - RealPoint cpt = new RealPoint(pt3d.getDoublePosition(0), pt3d.getDoublePosition(1)); - cvtList.add(cpt); - } - return new RealPointList(cvtList); - } - - @Override - public String getTransform() { - return ScijavaGsonHelper.getGson(context).toJson(at3d, AffineTransform3D.class); - } - - @Override - public void setTransform(String serialized_transform) { - at3d = ScijavaGsonHelper.getGson(context).fromJson(serialized_transform, AffineTransform3D.class); - isDone = true; - } - - @Override - public boolean edit() { - // TODO : find a way to edit an affine transform -> that shouldn't be so complicated - throw new UnsupportedOperationException(); - } - - public RealTransform getTransformAsRealTransform() { - return at3d.inverse().copy(); - } -} diff --git a/src/main/java/ch/epfl/biop/registration/sourceandconverter/affine/AffineTransformedSourceWrapperRegistration.java b/src/main/java/ch/epfl/biop/registration/sourceandconverter/affine/AffineTransformedSourceWrapperRegistration.java deleted file mode 100644 index a96d64ac..00000000 --- a/src/main/java/ch/epfl/biop/registration/sourceandconverter/affine/AffineTransformedSourceWrapperRegistration.java +++ /dev/null @@ -1,71 +0,0 @@ -package ch.epfl.biop.registration.sourceandconverter.affine; - -import bdv.viewer.SourceAndConverter; -import net.imglib2.realtransform.AffineTransform3D; -import sc.fiji.bdvpg.sourceandconverter.SourceAndConverterAndTimeRange; -import sc.fiji.bdvpg.sourceandconverter.transform.SourceTransformHelper; - -import java.util.HashMap; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - -/** - * Fake registration which simply wraps a transform which is used to modify either: - * - the place of the image in the user GUI, or to - * TODO : write a bit more clearly what this does - */ -public class AffineTransformedSourceWrapperRegistration extends AffineTransformSourceAndConverterRegistration { - - Map<SourceAndConverter<?>, SourceAndConverter<?>> alreadyTransformedSources = new ConcurrentHashMap<>(); - - @Override - public boolean register() { - isDone = true; - return true; - } - - /** - * These function are kept in order to avoid serializing many times - * unnecessary affinetransform - * @param at3d_in affine transform - */ - public synchronized void setAffineTransform(AffineTransform3D at3d_in) { - this.at3d = at3d_in; - alreadyTransformedSources.keySet().forEach(sac -> SourceTransformHelper.set(at3d_in, new SourceAndConverterAndTimeRange<>(alreadyTransformedSources.get(sac), timePoint))); - } - - public AffineTransform3D getAffineTransform() { - return at3d.copy(); - } - - /** - * Overriding to actually mutate SourceAndConverter, - * it's the only registration which does that, because - * it's actually not really a registration - * @param img image - * @return mutates the transform - */ - @Override - public SourceAndConverter<?>[] getTransformedImageMovingToFixed(SourceAndConverter<?>[] img) { - - SourceAndConverter<?>[] out = new SourceAndConverter[img.length]; - - for (int idx = 0;idx<img.length;idx++) { - if (alreadyTransformedSources.containsKey(img[idx])) { - out[idx] = alreadyTransformedSources.get(img[idx]); - SourceTransformHelper.set(at3d, new SourceAndConverterAndTimeRange<>(out[idx], timePoint)); - } else { - out[idx] = SourceTransformHelper.createNewTransformedSourceAndConverter(at3d, new SourceAndConverterAndTimeRange<>(img[idx], timePoint)); - alreadyTransformedSources.put(img[idx], out[idx]); - } - } - - return out; - } - - @Override - public void abort() { - - } - -} diff --git a/src/main/java/ch/epfl/biop/registration/sourceandconverter/affine/CenterZeroRegistration.java b/src/main/java/ch/epfl/biop/registration/sourceandconverter/affine/CenterZeroRegistration.java deleted file mode 100644 index 70eb70dc..00000000 --- a/src/main/java/ch/epfl/biop/registration/sourceandconverter/affine/CenterZeroRegistration.java +++ /dev/null @@ -1,54 +0,0 @@ -package ch.epfl.biop.registration.sourceandconverter.affine; - -import bdv.viewer.SourceAndConverter; -import net.imglib2.RealPoint; -import net.imglib2.realtransform.AffineTransform3D; -import sc.fiji.bdvpg.sourceandconverter.SourceAndConverterAndTimeRange; -import sc.fiji.bdvpg.sourceandconverter.SourceAndConverterHelper; -import sc.fiji.bdvpg.sourceandconverter.transform.SourceTransformHelper; - -/** - * Fake registration : simply centers the image in order to put its center - * at the origin of the global coordinate system. - */ - -public class CenterZeroRegistration extends AffineTransformSourceAndConverterRegistration { - - @Override - public boolean register() { - - SourceAndConverter<?> sac = mimg[0]; - - RealPoint center = SourceAndConverterHelper.getSourceAndConverterCenterPoint(sac,0); - - at3d = new AffineTransform3D(); - - at3d.translate( - -center.getDoublePosition(0), - -center.getDoublePosition(1), - -center.getDoublePosition(2)); - - isDone = true; - - return true; - } - - /** - * @param img image - * @return transformed images (new source created) - */ - @Override - public SourceAndConverter<?>[] getTransformedImageMovingToFixed(SourceAndConverter<?>[] img) { - SourceAndConverter<?>[] out = new SourceAndConverter[img.length]; - for (int idx = 0;idx<img.length;idx++) { - out[idx] = SourceTransformHelper.createNewTransformedSourceAndConverter(at3d, new SourceAndConverterAndTimeRange<>(img[idx], timePoint)); - } - return out; - } - - @Override - public void abort() { - // Cannot be aborted - is very fast anyway - } - -} diff --git a/src/main/java/ch/epfl/biop/registration/sourceandconverter/affine/Elastix2DAffineRegistration.java b/src/main/java/ch/epfl/biop/registration/sourceandconverter/affine/Elastix2DAffineRegistration.java deleted file mode 100644 index 4090d734..00000000 --- a/src/main/java/ch/epfl/biop/registration/sourceandconverter/affine/Elastix2DAffineRegistration.java +++ /dev/null @@ -1,150 +0,0 @@ -package ch.epfl.biop.registration.sourceandconverter.affine; - -import bdv.viewer.SourceAndConverter; -import ch.epfl.biop.atlas.aligner.command.RegisterSlicesElastixAffineCommand; -import ch.epfl.biop.atlas.aligner.plugin.IABBARegistrationPlugin; -import ch.epfl.biop.atlas.aligner.plugin.RegistrationTypeProperties; -import ch.epfl.biop.scijava.command.source.register.Elastix2DAffineRegisterCommand; -import net.imglib2.realtransform.AffineTransform3D; -import org.scijava.command.Command; -import org.scijava.command.CommandModule; -import org.scijava.command.CommandService; -import org.scijava.plugin.Plugin; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import sc.fiji.bdvpg.sourceandconverter.SourceAndConverterHelper; - -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.Future; - -/** - * Uses Elastix backend to perform an affine transform registration - * - */ -@Plugin(type = IABBARegistrationPlugin.class) -@RegistrationTypeProperties( - isManual = false, - isEditable = false, - userInterface = { - RegisterSlicesElastixAffineCommand.class - //RegistrationElastixAffineRemoteCommand.class - }) - -public class Elastix2DAffineRegistration extends AffineTransformSourceAndConverterRegistration{ - - - protected static final Logger logger = LoggerFactory.getLogger(Elastix2DAffineRegistration.class); - - @Override - public void setFixedImage(SourceAndConverter[] fimg) { - if (fimg.length==0) { - logger.error("Error, no fixed image set in class "+this.getClass().getSimpleName()); - } - super.setFixedImage(fimg); - } - - @Override - public void setMovingImage(SourceAndConverter[] mimg) { - if (mimg.length==0) { - logger.error("Error, no fixed image set in class "+this.getClass().getSimpleName()); - } - super.setMovingImage(mimg); - } - - Future<CommandModule> task; - - @Override - public boolean register() { - try { - Class<? extends Command> registrationCommandClass; - // Is it supposed to be done on a server ? - registrationCommandClass = Elastix2DAffineRegisterCommand.class; - - // Registration success flag - boolean success = true; - - // Transforms map into flat String : key1, value1, key2, value2, etc. - // Necessary for CommandService - List<Object> flatParameters = new ArrayList<>(parameters.size()*2+4); - - double voxSizeInMm = Double.parseDouble(parameters.get("pxSizeInCurrentUnit")); - - parameters.keySet().forEach(k -> { - flatParameters.add(k); - flatParameters.add(parameters.get(k)); - }); - - addToFlatParameters(flatParameters, - // Fixed image - "sacs_fixed", fimg, - // Moving image - "sacs_moving", mimg, - // No interpolation in resampling - "interpolate", false, - // Start registration with a 4x4 pixel image - "minPixSize",4, - // 100 iteration steps - "maxIterationNumberPerScale",100, - // Do not write anything - "verbose", false, - // Centers centers of mass of both images before starting registration - "automaticTransformInitialization", true, - // Atlas image : a single timepoint - "tpFixed", 0, - // Level 2 for the atlas - "levelFixedSource", SourceAndConverterHelper.bestLevel(fimg[0], timePoint, voxSizeInMm), - // Timepoint moving source (normally 0) - "tpMoving", timePoint, - // Tries to be clever for the moving source sampling - "levelMovingSource", SourceAndConverterHelper.bestLevel(mimg[0], timePoint, voxSizeInMm) - ); - - task = context - .getService(CommandService.class) - .run(registrationCommandClass, false, - flatParameters.toArray(new Object[0]) - ); - - CommandModule module = task.get(); - - if (module.getOutputs().containsKey("success")) { - success = (boolean) module.getOutput("success"); - } - if (success) { - at3d = (AffineTransform3D) module.getOutput("at3D"); - } else { - if (module.getOutputs().containsKey("error")) { - errorMessage = (String) module.getOutput("error"); - } - } - - isDone = true; - return success; - } catch (Exception e) { - errorMessage = e.getMessage(); - e.printStackTrace(); - return false; - } - } - - String errorMessage = ""; - - @Override - public String getExceptionMessage() { - return errorMessage; - } - - @Override - public void abort() { - if (task!=null) { - logger.info(this.getClass().getSimpleName()+": Attempt to interrupt registration..."); - task.cancel(true); - } - } - - public String toString() { - return "Elastix 2D Affine"; - } - -} diff --git a/src/main/java/ch/epfl/biop/registration/sourceandconverter/bigwarp/SacBigWarp2DRegistration.java b/src/main/java/ch/epfl/biop/registration/sourceandconverter/bigwarp/SacBigWarp2DRegistration.java deleted file mode 100644 index 7eb5e7b3..00000000 --- a/src/main/java/ch/epfl/biop/registration/sourceandconverter/bigwarp/SacBigWarp2DRegistration.java +++ /dev/null @@ -1,128 +0,0 @@ -package ch.epfl.biop.registration.sourceandconverter.bigwarp; - -import bdv.gui.TransformTypeSelectDialog; -import bdv.tools.brightness.ConverterSetup; -import bdv.util.BdvHandle; -import bdv.viewer.DisplayMode; -import bdv.viewer.SourceAndConverter; -import ch.epfl.biop.atlas.aligner.command.RegisterSlicesBigWarpCommand; -import ch.epfl.biop.atlas.aligner.plugin.IABBARegistrationPlugin; -import ch.epfl.biop.atlas.aligner.plugin.RegistrationTypeProperties; -import ch.epfl.biop.registration.sourceandconverter.spline.RealTransformSourceAndConverterRegistration; -import ij.gui.WaitForUserDialog; -import org.scijava.plugin.Plugin; -import sc.fiji.bdvpg.bdv.BdvHandleHelper; -import sc.fiji.bdvpg.services.SourceAndConverterServices; -import sc.fiji.bdvpg.sourceandconverter.register.BigWarpLauncher; - -import java.util.Arrays; -import java.util.List; -import java.util.stream.Collectors; - -import static bdv.util.RealTransformHelper.BigWarpFileFromRealTransform; - -@Plugin(type = IABBARegistrationPlugin.class) -@RegistrationTypeProperties( - isManual = true, - isEditable = true, - userInterface = { - RegisterSlicesBigWarpCommand.class - } -) - -public class SacBigWarp2DRegistration extends RealTransformSourceAndConverterRegistration { - - BigWarpLauncher bwl; - - Runnable waitForUser = () -> { - WaitForUserDialog dialog = new WaitForUserDialog("Big Warp registration","Please perform carefully your registration then press ok. Do not forget to press 't' when 4 landmarks are placed."); - dialog.show(); - }; - - public void setWaitForUserMethod(Runnable r) { - waitForUser = r; - } - - @Override - public boolean register() { - { - - List<SourceAndConverter<?>> movingSacs = Arrays.stream(mimg).collect(Collectors.toList()); - - List<SourceAndConverter<?>> fixedSacs = Arrays.stream(fimg).collect(Collectors.toList()); - - List<ConverterSetup> converterSetups = Arrays.stream(mimg).map(src -> SourceAndConverterServices.getSourceAndConverterService().getConverterSetup(src)).collect(Collectors.toList()); - - converterSetups.addAll(Arrays.stream(fimg).map(src -> SourceAndConverterServices.getSourceAndConverterService().getConverterSetup(src)).collect(Collectors.toList())); - - // Launch BigWarp - bwl = new BigWarpLauncher(movingSacs, fixedSacs, "Big Warp", converterSetups); - bwl.set2d(); - bwl.run(); - - // Output bdvh handles -> will be put in the object service - BdvHandle bdvhQ = bwl.getBdvHandleQ(); - BdvHandle bdvhP = bwl.getBdvHandleP(); - - bdvhQ.getViewerPanel().state().setDisplayMode(DisplayMode.FUSED); - bdvhP.getViewerPanel().state().setDisplayMode(DisplayMode.FUSED); - - bdvhP.getViewerPanel().state().setViewerTransform(BdvHandleHelper.getViewerTransformWithNewCenter(bdvhP, new double[]{0,0,0})); - bdvhQ.getViewerPanel().state().setViewerTransform(BdvHandleHelper.getViewerTransformWithNewCenter(bdvhQ, new double[]{0,0,0})); - - SourceAndConverterServices.getBdvDisplayService().pairClosing(bdvhQ,bdvhP); - - bdvhP.getViewerPanel().requestRepaint(); - bdvhQ.getViewerPanel().requestRepaint(); - - bwl.getBigWarp().getLandmarkFrame().repaint(); - - // Restores landmarks if some were already defined - if (rt!=null) { - String bigWarpFile = BigWarpFileFromRealTransform(rt); - if (bigWarpFile!=null) { // If the transform is not a spline, no landmarks are saved, the user has to redo his job - bwl.getBigWarp().loadLandmarks(bigWarpFile); - bwl.getBigWarp().setInLandmarkMode(true); - bwl.getBigWarp().setIsMovingDisplayTransformed(true); - } - } - - waitForUser.run(); - - switch (bwl.getBigWarp().getBwTransform().getTransformType()) { - case (TransformTypeSelectDialog.TPS) : - // Thin plate spline transform - rt = bwl.getBigWarp().getBwTransform().getTransformation(); - break; - default: - // Any other transform, currently Affine 3D - rt = bwl.getBigWarp().getBwTransform().affine3d(); - } - - bwl.getBigWarp().closeAll(); - - isDone = true; - - return true; - - } - } - - @Override - public boolean edit() { - // Just launching again BigWarp - this.register(); - return true; - } - - @Override - public void abort() { - - } - - - public String toString() { - return "Big Warp"; - } - -} diff --git a/src/main/java/ch/epfl/biop/registration/sourceandconverter/mirror/MirrorXRegistration.java b/src/main/java/ch/epfl/biop/registration/sourceandconverter/mirror/MirrorXRegistration.java deleted file mode 100644 index 71c31fe3..00000000 --- a/src/main/java/ch/epfl/biop/registration/sourceandconverter/mirror/MirrorXRegistration.java +++ /dev/null @@ -1,51 +0,0 @@ -package ch.epfl.biop.registration.sourceandconverter.mirror; - -import ch.epfl.biop.atlas.aligner.command.MirrorDoCommand; -import ch.epfl.biop.atlas.aligner.plugin.IABBARegistrationPlugin; -import ch.epfl.biop.atlas.aligner.plugin.RegistrationTypeProperties; -import ch.epfl.biop.registration.sourceandconverter.spline.RealTransformSourceAndConverterRegistration; -import org.scijava.plugin.Plugin; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -@Plugin(type = IABBARegistrationPlugin.class) -@RegistrationTypeProperties( - isManual = false, - isEditable = true, - userInterface = { - MirrorDoCommand.class - } -) - -public class MirrorXRegistration extends RealTransformSourceAndConverterRegistration { - - protected static Logger logger = LoggerFactory.getLogger(MirrorXRegistration.class); - - @Override - public boolean register() { - String mirrorSide = parameters.get("mirror_side"); - if (mirrorSide.equals("Left")) { - rt = new MirrorXTransform(-1); - } else { - rt = new MirrorXTransform(1); - } - isDone = true; - return true; - } - - @Override - public boolean edit() { - return false; - } - - @Override - public void abort() { - - } - - final public static String MIRROR_X_REGISTRATION_NAME = "Mirror X"; - public String toString() { - return MIRROR_X_REGISTRATION_NAME; - } - -} \ No newline at end of file diff --git a/src/main/java/ch/epfl/biop/registration/sourceandconverter/mirror/MirrorXTransform.java b/src/main/java/ch/epfl/biop/registration/sourceandconverter/mirror/MirrorXTransform.java deleted file mode 100644 index 6de805ee..00000000 --- a/src/main/java/ch/epfl/biop/registration/sourceandconverter/mirror/MirrorXTransform.java +++ /dev/null @@ -1,64 +0,0 @@ -package ch.epfl.biop.registration.sourceandconverter.mirror; - -import net.imglib2.RealLocalizable; -import net.imglib2.RealPositionable; -import net.imglib2.realtransform.AffineTransform3D; -import net.imglib2.realtransform.InvertibleRealTransform; - -public class MirrorXTransform implements InvertibleRealTransform { - - final double xFactor; - - public MirrorXTransform(double xFactor) { - this.xFactor = xFactor; - } - - @Override - public int numSourceDimensions() { - return 3; - } - - @Override - public int numTargetDimensions() { - return 3; - } - - @Override - public void apply(double[] source, double[] target) { - target[0] = source[0]*xFactor>0 ? source[0]:-source[0]; - target[1] = source[1]; - target[2] = source[2]; - } - - @Override - public void apply(RealLocalizable realLocalizable, RealPositionable realPositionable) { - double xPos = realLocalizable.getDoublePosition(0); - realPositionable.setPosition(xPos*xFactor>0 ? xPos:-xPos,0); - realPositionable.setPosition(realLocalizable.getDoublePosition(1),1); - realPositionable.setPosition(realLocalizable.getDoublePosition(2),2); - } - - @Override - public void applyInverse(double[] source, double[] target) { - target[0] = source[0]; - target[1] = source[1]; - target[2] = source[2]; - } - - @Override - public void applyInverse(RealPositionable realPositionable, RealLocalizable realLocalizable) { - realPositionable.setPosition(realLocalizable.getDoublePosition(0),0); - realPositionable.setPosition(realLocalizable.getDoublePosition(1),1); - realPositionable.setPosition(realLocalizable.getDoublePosition(2),2); - } - - @Override - public InvertibleRealTransform inverse() { - return new AffineTransform3D(); - } - - @Override - public InvertibleRealTransform copy() { - return new MirrorXTransform(xFactor); - } -} diff --git a/src/main/java/ch/epfl/biop/registration/sourceandconverter/mirror/MirrorXTransformAdapter.java b/src/main/java/ch/epfl/biop/registration/sourceandconverter/mirror/MirrorXTransformAdapter.java deleted file mode 100644 index 2eb20869..00000000 --- a/src/main/java/ch/epfl/biop/registration/sourceandconverter/mirror/MirrorXTransformAdapter.java +++ /dev/null @@ -1,44 +0,0 @@ -package ch.epfl.biop.registration.sourceandconverter.mirror; - - -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParseException; -import com.google.gson.JsonSerializationContext; -import net.imglib2.realtransform.RealTransform; -import org.scijava.plugin.Plugin; -import sc.fiji.persist.IClassRuntimeAdapter; - -import java.lang.reflect.Type; -@Plugin(type = IClassRuntimeAdapter.class) -public class MirrorXTransformAdapter implements IClassRuntimeAdapter<RealTransform, MirrorXTransform> { - @Override - public Class<? extends RealTransform> getBaseClass() { - return RealTransform.class; - } - - @Override - public Class<? extends MirrorXTransform> getRunTimeClass() { - return MirrorXTransform.class; - } - - @Override - public boolean useCustomAdapter() { - return true; - } - - @Override - public MirrorXTransform deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext jsonDeserializationContext) throws JsonParseException { - JsonObject obj = jsonElement.getAsJsonObject(); - double xFactor = obj.getAsJsonPrimitive("xFactor").getAsDouble(); - return new MirrorXTransform(xFactor); - } - - @Override - public JsonElement serialize(MirrorXTransform transform, Type type, JsonSerializationContext jsonSerializationContext) { - JsonObject obj = new JsonObject(); - obj.addProperty("xFactor", transform.xFactor); - return obj; - } -} diff --git a/src/main/java/ch/epfl/biop/registration/sourceandconverter/spline/Elastix2DSplineRegistration.java b/src/main/java/ch/epfl/biop/registration/sourceandconverter/spline/Elastix2DSplineRegistration.java deleted file mode 100644 index adca3631..00000000 --- a/src/main/java/ch/epfl/biop/registration/sourceandconverter/spline/Elastix2DSplineRegistration.java +++ /dev/null @@ -1,322 +0,0 @@ -package ch.epfl.biop.registration.sourceandconverter.spline; - -import bdv.tools.brightness.ConverterSetup; -import bdv.util.BdvHandle; -import bdv.viewer.DisplayMode; -import bdv.viewer.Interpolation; -import bdv.viewer.SourceAndConverter; -import ch.epfl.biop.atlas.aligner.command.RegisterSlicesElastixSplineCommand; -import ch.epfl.biop.atlas.aligner.plugin.IABBARegistrationPlugin; -import ch.epfl.biop.atlas.aligner.plugin.RegistrationTypeProperties; -import ch.epfl.biop.scijava.command.source.register.Elastix2DSplineRegisterCommand; -import ij.gui.WaitForUserDialog; -import jitk.spline.ThinPlateR2LogRSplineKernelTransform; -import net.imglib2.RealPoint; -import net.imglib2.RealRandomAccessible; -import net.imglib2.realtransform.*; -import net.imglib2.realtransform.inverse.WrappedIterativeInvertibleRealTransform; -import net.imglib2.type.numeric.IntegerType; -import org.scijava.command.Command; -import org.scijava.command.CommandModule; -import org.scijava.command.CommandService; -import org.scijava.plugin.Plugin; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import sc.fiji.bdvpg.bdv.BdvHandleHelper; -import sc.fiji.bdvpg.services.SourceAndConverterServices; -import sc.fiji.bdvpg.sourceandconverter.SourceAndConverterHelper; -import sc.fiji.bdvpg.sourceandconverter.register.BigWarpLauncher; - -import java.util.*; -import java.util.concurrent.Future; -import java.util.stream.Collectors; - -import static bdv.util.RealTransformHelper.BigWarpFileFromRealTransform; - -@Plugin(type = IABBARegistrationPlugin.class) -@RegistrationTypeProperties( - isManual = false, - isEditable = true, - userInterface = { - RegisterSlicesElastixSplineCommand.class - //RegistrationElastixSplineRemoteCommand.class - } -) - -public class Elastix2DSplineRegistration extends RealTransformSourceAndConverterRegistration { - - protected static final Logger logger = LoggerFactory.getLogger(Elastix2DSplineRegistration.class); - - Future<CommandModule> task; - - @Override - public void setFixedImage(SourceAndConverter[] fimg) { - if (fimg.length==0) { - logger.error("Error, no fixed image set in class "+this.getClass().getSimpleName()); - } - super.setFixedImage(fimg); - } - - @Override - public void setMovingImage(SourceAndConverter[] mimg) { - if (mimg.length==0) { - logger.error("Error, no fixed image set in class "+this.getClass().getSimpleName()); - } - super.setMovingImage(mimg); - } - - @Override - public boolean register() { - try { - boolean success = true; - Class<? extends Command> registrationCommandClass; - registrationCommandClass = Elastix2DSplineRegisterCommand.class; - - // Transforms map into flat String : key1, value1, key2, value2, etc. - // Necessary for CommandService - List<Object> flatParameters = new ArrayList<>(parameters.size()*2+4); - - double voxSizeInMm = Double.parseDouble(parameters.get("pxSizeInCurrentUnit")); - - parameters.keySet().forEach(k -> { - flatParameters.add(k); - flatParameters.add(parameters.get(k)); - }); - - addToFlatParameters(flatParameters, - // Fixed image - "sacs_fixed",fimg, - // Moving image - "sacs_moving", mimg, - // Interpolation in resampling - "interpolate", true, - // Start registration with a 32x32 pixel image - "minPixSize", 32, - // 100 iteration steps - "maxIterationNumberPerScale",100, - // Do not write anything - "verbose", false, - // Do not center centers of mass of both images before starting registration - "automaticTransformInitialization", false, - // Atlas image : a single timepoint - "tpFixed", 0, - // Level 2 for the atlas - "levelFixedSource", SourceAndConverterHelper.bestLevel(fimg[0], timePoint, voxSizeInMm), - // Timepoint moving source (normally 0) - "tpMoving", timePoint, - // Tries to be clever for the moving source sampling - "levelMovingSource", SourceAndConverterHelper.bestLevel(mimg[0], timePoint, voxSizeInMm) - ); - - task = context - .getService(CommandService.class) - .run(registrationCommandClass, false, - flatParameters.toArray(new Object[0])); - - CommandModule module = task.get(); - - if (module.getOutputs().containsKey("success")) { - success = (boolean) module.getOutput("success"); - } - - if (success) { - rt = (RealTransform) module.getOutput("rt"); - rt = pruneLandMarksOutsideAtlas(rt); - } else { - if (module.getOutputs().containsKey("error")) { - errorMessage = (String) module.getOutput("error"); - } - } - - - isDone = true; - return success; - } catch (Exception e) { - errorMessage = e.getMessage(); - e.printStackTrace(); - return false; - } - } - - String errorMessage = ""; - - @Override - public String getExceptionMessage() { - return errorMessage; - } - - /** - * This function removes the landmarks located outside the atlas, - * meaning where the atlas 3d image value is zero - * 4 landmarks are kept - * @param rt_in the realtransfrom spline to prune - * @return same transform with landmarks pruned - */ - private RealTransform pruneLandMarksOutsideAtlas(RealTransform rt_in) { - - RealTransform input = rt_in; - boolean wrapped2d3d = false; - boolean wrappedInvertible = false; - if (rt_in instanceof Wrapped2DTransformAs3D) { - rt_in = ((Wrapped2DTransformAs3D)rt_in).transform; - wrapped2d3d = true; - } - - if (rt_in instanceof WrappedIterativeInvertibleRealTransform) { - rt_in = ((WrappedIterativeInvertibleRealTransform)rt_in).getTransform(); - wrappedInvertible = true; - } - - if (!(rt_in instanceof ThinplateSplineTransform)) { - System.err.println("Cannot edit the transform : it's not of class thinplatesplinetransform"); - return input; - } else { - if (fimg_mask !=null) { - ThinplateSplineTransform tst = (ThinplateSplineTransform) rt_in; - ThinPlateR2LogRSplineKernelTransform kernel = ThinPlateSplineTransformAdapter.getKernel(tst); - double[][] srcPts = ThinPlateSplineTransformAdapter.getSrcPts(kernel); - double[][] tgtPts = ThinPlateSplineTransformAdapter.getTgtPts(kernel); - int nbLandmarks = kernel.getNumLandmarks(); - int nbDimensions = kernel.getNumDims(); - - List<RealPoint> ptsSource = new ArrayList<>(); - List<RealPoint> ptsTarget = new ArrayList<>(); - - for (int i = 0; i < nbLandmarks; ++i) { - RealPoint ptSource = new RealPoint(3); - RealPoint ptTarget = new RealPoint(3); - int d; - for (d = 0; d < nbDimensions; ++d) { - ptTarget.setPosition(tgtPts[d][i], d); - } - ptTarget.setPosition(0,2); // 0 position in z - - for (d = 0; d < nbDimensions; ++d) { - ptSource.setPosition(srcPts[d][i], d); - } - ptSource.setPosition(0,2); // 0 position in z - - ptsSource.add(ptSource); - ptsTarget.add(ptTarget); - } - - RealRandomAccessible rawMask = fimg_mask[0].getSpimSource().getInterpolatedSource(timePoint,0, Interpolation.NEARESTNEIGHBOR); - - RealRandomAccessible<IntegerType> mask = (RealRandomAccessible<IntegerType>) rawMask; - - AffineTransform3D at3D = new AffineTransform3D(); - fimg_mask[0].getSpimSource().getSourceTransform(timePoint,0,at3D); - - List<Integer> landMarksToKeep = new ArrayList<>(); - for (int i = 0; i < nbLandmarks; ++i) { - at3D.inverse().apply(ptsTarget.get(i), ptsTarget.get(i)); - at3D.inverse().apply(ptsSource.get(i), ptsSource.get(i)); - - if ((mask.getAt(ptsSource.get(i)).getInteger() == 0) && (mask.getAt(ptsTarget.get(i)).getInteger() == 0)) { - - } else { - landMarksToKeep.add(i); - } - } - - if (landMarksToKeep.size()<4) { - // Too many landmarks removed - System.err.println("Too few landmarks after pruning - skip pruning"); - return input; - } - - // Ok, now let's reconstruct the transform - - double[][] srcPtsKept = new double[nbDimensions][landMarksToKeep.size()]; - double[][] tgtPtsKept = new double[nbDimensions][landMarksToKeep.size()]; - - for (int i = 0;i<landMarksToKeep.size();i++) { - for (int d = 0; d < nbDimensions; ++d) { - srcPtsKept[d][i] = srcPts[d][landMarksToKeep.get(i)]; - tgtPtsKept[d][i] = tgtPts[d][landMarksToKeep.get(i)]; - } - } - - RealTransform pruned = new ThinplateSplineTransform(srcPtsKept, tgtPtsKept); - - if (wrappedInvertible) { - pruned = new WrappedIterativeInvertibleRealTransform<>(pruned); - } - - if (wrapped2d3d) { - pruned = new Wrapped2DTransformAs3D((InvertibleRealTransform) pruned); - } - - return pruned; - - } else return input; - } - } - - Runnable waitForUser = () -> { - WaitForUserDialog dialog = new WaitForUserDialog("Choose slice","Please perform carefully your registration then press ok."); - dialog.show(); - }; - - @Override - public boolean edit() { - - List<SourceAndConverter<?>> movingSacs = Arrays.stream(mimg).collect(Collectors.toList()); - - List<SourceAndConverter<?>> fixedSacs = Arrays.stream(fimg).collect(Collectors.toList()); - - List<ConverterSetup> converterSetups = Arrays.stream(mimg).map(src -> SourceAndConverterServices.getSourceAndConverterService().getConverterSetup(src)).collect(Collectors.toList()); - - converterSetups.addAll(Arrays.stream(fimg).map(src -> SourceAndConverterServices.getSourceAndConverterService().getConverterSetup(src)).collect(Collectors.toList())); - - // Launch BigWarp - BigWarpLauncher bwl = new BigWarpLauncher(movingSacs, fixedSacs, "Big Warp", converterSetups); - bwl.set2d(); - bwl.run(); - - // Output bdvh handles -> will be put in the object service - BdvHandle bdvhQ = bwl.getBdvHandleQ(); - BdvHandle bdvhP = bwl.getBdvHandleP(); - - bdvhP.getViewerPanel().state().setViewerTransform(BdvHandleHelper.getViewerTransformWithNewCenter(bdvhP, new double[]{0,0,0})); - bdvhQ.getViewerPanel().state().setViewerTransform(BdvHandleHelper.getViewerTransformWithNewCenter(bdvhQ, new double[]{0,0,0})); - - bdvhQ.getViewerPanel().state().setDisplayMode(DisplayMode.FUSED); - bdvhP.getViewerPanel().state().setDisplayMode(DisplayMode.FUSED); - - SourceAndConverterServices.getBdvDisplayService().pairClosing(bdvhQ,bdvhP); - - bdvhP.getViewerPanel().requestRepaint(); - bdvhQ.getViewerPanel().requestRepaint(); - - bwl.getBigWarp().getLandmarkFrame().repaint(); - - if (rt!=null) { - bwl.getBigWarp().loadLandmarks(BigWarpFileFromRealTransform(rt)); - bwl.getBigWarp().setIsMovingDisplayTransformed(true); - } - - waitForUser.run(); - - rt = bwl.getBigWarp().getBwTransform().getTransformation(); - - bwl.getBigWarp().closeAll(); - - isDone = true; - - return true; - - } - - @Override - public void abort() { - if (task!=null) { - task.cancel(true); - } - } - - public String toString() { - return "Elastix 2D Spline"; - } - -} diff --git a/src/main/java/ch/epfl/biop/registration/sourceandconverter/spline/RealTransformSourceAndConverterRegistration.java b/src/main/java/ch/epfl/biop/registration/sourceandconverter/spline/RealTransformSourceAndConverterRegistration.java deleted file mode 100644 index 8c7e0f18..00000000 --- a/src/main/java/ch/epfl/biop/registration/sourceandconverter/spline/RealTransformSourceAndConverterRegistration.java +++ /dev/null @@ -1,79 +0,0 @@ -package ch.epfl.biop.registration.sourceandconverter.spline; - -import bdv.util.BoundedRealTransform; -import bdv.viewer.SourceAndConverter; -import ch.epfl.biop.java.utilities.roi.types.RealPointList; -import ch.epfl.biop.registration.sourceandconverter.SourceAndConverterRegistration; -import net.imglib2.RealPoint; -import net.imglib2.realtransform.RealTransform; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import sc.fiji.bdvpg.sourceandconverter.transform.SourceRealTransformer; -import sc.fiji.persist.ScijavaGsonHelper; - -import java.util.ArrayList; - -abstract public class RealTransformSourceAndConverterRegistration extends SourceAndConverterRegistration { - - final static Logger logger = LoggerFactory.getLogger(RealTransformSourceAndConverterRegistration.class); - - protected RealTransform rt; - - @Override - public SourceAndConverter[] getTransformedImageMovingToFixed(SourceAndConverter[] img) { - SourceAndConverter[] out = new SourceAndConverter[img.length]; - SourceRealTransformer srt = new SourceRealTransformer(rt); - for (int idx = 0;idx<img.length;idx++) { - out[idx] = srt.apply(img[idx]); - } - return out; - } - - @Override - public RealPointList getTransformedPtsFixedToMoving(RealPointList pts) { - RealTransform innerRT = rt; // To unbox bounded realtransform - - // Unbox bounded transform - if (rt instanceof BoundedRealTransform) { - innerRT = ((BoundedRealTransform)rt).getTransform().copy(); - } - - ArrayList<RealPoint> cvtList = new ArrayList<>(); - for (RealPoint p : pts.ptList) { - RealPoint pt3d = new RealPoint(3); - pt3d.setPosition(new double[]{p.getDoublePosition(0), p.getDoublePosition(1),0}); - innerRT.apply(pt3d, pt3d); - RealPoint cpt = new RealPoint(pt3d.getDoublePosition(0), pt3d.getDoublePosition(1)); - cvtList.add(cpt); - } - - return new RealPointList(cvtList); - } - - public RealTransform getRealTransform() { - return rt; - } - - public void setRealTransform(RealTransform transform) { - this.rt = transform.copy(); - } - - @Override - final public String getTransform() { - //logger.debug("Serializing transform of class "+rt.getClass().getSimpleName()); - String transform = ScijavaGsonHelper.getGson(context).toJson(rt, RealTransform.class); - //logger.debug("Serialization result = "+transform); - return transform; - } - - @Override - final public void setTransform(String serialized_transform) { - setRealTransform(ScijavaGsonHelper.getGson(context).fromJson(serialized_transform, RealTransform.class)); - isDone = true; - } - - public RealTransform getTransformAsRealTransform() { - return rt.copy(); - } - -} diff --git a/src/test/java/ch/epfl/biop/abba/pluginexample/IdentityRegistrationCommand.java b/src/test/java/ch/epfl/biop/abba/pluginexample/IdentityRegistrationCommand.java index ee64da1d..74d847b1 100644 --- a/src/test/java/ch/epfl/biop/abba/pluginexample/IdentityRegistrationCommand.java +++ b/src/test/java/ch/epfl/biop/abba/pluginexample/IdentityRegistrationCommand.java @@ -6,6 +6,8 @@ import org.scijava.plugin.Parameter; import org.scijava.plugin.Plugin; +import java.util.HashMap; + @Plugin(type = Command.class, menuPath = "Plugins>BIOP>Atlas>Multi Image To Atlas>Align>[ABBA Dev] - Your Registration Here!") public class IdentityRegistrationCommand implements Command { @@ -14,7 +16,7 @@ public class IdentityRegistrationCommand implements Command { @Override public void run() { - mp.registerSelectedSlices(this, SourcesProcessorHelper.Identity(), - SourcesProcessorHelper.Identity()); + mp.registerSelectedSlices(IdentityRegistrationPluginExample.class, SourcesProcessorHelper.Identity(), + SourcesProcessorHelper.Identity(), new HashMap<>()); } } diff --git a/src/test/java/ch/epfl/biop/abba/pluginexample/IdentityRegistrationPluginExample.java b/src/test/java/ch/epfl/biop/abba/pluginexample/IdentityRegistrationPluginExample.java index 29abd2e7..0903ebef 100644 --- a/src/test/java/ch/epfl/biop/abba/pluginexample/IdentityRegistrationPluginExample.java +++ b/src/test/java/ch/epfl/biop/abba/pluginexample/IdentityRegistrationPluginExample.java @@ -1,9 +1,8 @@ package ch.epfl.biop.abba.pluginexample; import bdv.viewer.SourceAndConverter; -import ch.epfl.biop.atlas.aligner.MultiSlicePositioner; -import ch.epfl.biop.atlas.aligner.plugin.IABBARegistrationPlugin; -import ch.epfl.biop.atlas.aligner.plugin.RegistrationTypeProperties; +import ch.epfl.biop.registration.plugin.IRegistrationPlugin; +import ch.epfl.biop.registration.plugin.RegistrationTypeProperties; import ch.epfl.biop.java.utilities.roi.types.RealPointList; import net.imglib2.realtransform.RealTransform; import org.scijava.Context; @@ -21,13 +20,12 @@ * is an array of SourceAndConverter, each element of the array being a single channel. * */ -@Plugin(type = IABBARegistrationPlugin.class) +@Plugin(type = IRegistrationPlugin.class) @RegistrationTypeProperties( isEditable = false, - isManual = false, - userInterface = {IdentityRegistrationCommand.class} + isManual = false ) -public class IdentityRegistrationPluginExample implements IABBARegistrationPlugin{ +public class IdentityRegistrationPluginExample implements IRegistrationPlugin { public static final Consumer<String> defaultLog = (string) -> System.out.println(IdentityRegistrationPluginExample.class.getSimpleName()+":"+string); @@ -59,7 +57,7 @@ public void setScijavaContext(Context context) { /** * Any parameter of a registration method has to be set as a String to String dictionnary - * this same dictionnary needs to be returned in {@link IABBARegistrationPlugin#getRegistrationParameters()} + * this same dictionnary needs to be returned in {@link IRegistrationPlugin#getRegistrationParameters()} * for a correct serialization * @param parameters dictionary of parameters */ @@ -69,7 +67,7 @@ public void setRegistrationParameters(Map<String, String> parameters) { } /** - * see {@link IABBARegistrationPlugin#setRegistrationParameters(Map)} + * see {@link IRegistrationPlugin#setRegistrationParameters(Map)} * @return the dictionnary containing the parameters for this registration */ @Override @@ -198,11 +196,6 @@ public RealTransform getTransformAsRealTransform() { return null; // unsupported, but in fact in this case } - @Override - public void setSliceInfo(MultiSlicePositioner.SliceInfo sliceInfo) { - // Can be used to retrieve some info about the slice being registered - } - String errorMessage = "No error"; @Override diff --git a/src/test/java/ch/epfl/biop/abba/pluginexample/py/ExternalIdentityRegistrationPlugin.java b/src/test/java/ch/epfl/biop/abba/pluginexample/py/ExternalIdentityRegistrationPlugin.java index 5b0319f3..ee738ced 100644 --- a/src/test/java/ch/epfl/biop/abba/pluginexample/py/ExternalIdentityRegistrationPlugin.java +++ b/src/test/java/ch/epfl/biop/abba/pluginexample/py/ExternalIdentityRegistrationPlugin.java @@ -1,8 +1,7 @@ package ch.epfl.biop.abba.pluginexample.py; import bdv.viewer.SourceAndConverter; -import ch.epfl.biop.atlas.aligner.MultiSlicePositioner; -import ch.epfl.biop.atlas.aligner.plugin.ExternalABBARegistrationPlugin; +import ch.epfl.biop.registration.plugin.ExternalRegistrationPlugin; import ch.epfl.biop.java.utilities.roi.types.RealPointList; import net.imglib2.realtransform.AffineTransform3D; import net.imglib2.realtransform.RealTransform; @@ -12,7 +11,7 @@ import java.util.HashMap; import java.util.Map; -public class ExternalIdentityRegistrationPlugin implements ExternalABBARegistrationPlugin { +public class ExternalIdentityRegistrationPlugin implements ExternalRegistrationPlugin { Map<String, String> params = new HashMap<>(); @@ -20,11 +19,6 @@ public String getRegistrationTypeName() { return "PyIdentity"; } - @Override - public void setSliceInfo(MultiSlicePositioner.SliceInfo sliceInfo) { - // Do nothing - } - @Override public boolean isManual() { return false; diff --git a/src/test/java/ch/epfl/biop/abba/pluginexample/py/ExternalSimpleRotationRegistrationPlugin.java b/src/test/java/ch/epfl/biop/abba/pluginexample/py/ExternalSimpleRotationRegistrationPlugin.java index cc2417bd..4eee8114 100644 --- a/src/test/java/ch/epfl/biop/abba/pluginexample/py/ExternalSimpleRotationRegistrationPlugin.java +++ b/src/test/java/ch/epfl/biop/abba/pluginexample/py/ExternalSimpleRotationRegistrationPlugin.java @@ -1,13 +1,13 @@ package ch.epfl.biop.abba.pluginexample.py; -import ch.epfl.biop.atlas.aligner.plugin.SimpleABBARegistrationPlugin; +import ch.epfl.biop.registration.plugin.SimpleRegistrationPlugin; import ij.ImagePlus; import net.imglib2.realtransform.AffineTransform3D; import net.imglib2.realtransform.InvertibleRealTransform; import java.util.Map; -public class ExternalSimpleRotationRegistrationPlugin implements SimpleABBARegistrationPlugin { +public class ExternalSimpleRotationRegistrationPlugin implements SimpleRegistrationPlugin { @Override public double getVoxelSizeInMicron() { diff --git a/src/test/java/ch/epfl/biop/abba/pluginexample/py/TestExternalRegistrationPlugin.java b/src/test/java/ch/epfl/biop/abba/pluginexample/py/TestExternalRegistrationPlugin.java index ec32a2f8..863829d1 100644 --- a/src/test/java/ch/epfl/biop/abba/pluginexample/py/TestExternalRegistrationPlugin.java +++ b/src/test/java/ch/epfl/biop/abba/pluginexample/py/TestExternalRegistrationPlugin.java @@ -6,7 +6,7 @@ import ch.epfl.biop.atlas.aligner.SliceSources; import ch.epfl.biop.atlas.aligner.command.ABBAStartCommand; import ch.epfl.biop.atlas.aligner.gui.bdv.BdvMultislicePositionerView; -import ch.epfl.biop.atlas.aligner.plugin.SimpleRegistrationWrapper; +import ch.epfl.biop.registration.plugin.SimpleRegistrationWrapper; import ch.epfl.biop.atlas.mouse.allen.ccfv3p1.command.AllenBrainAdultMouseAtlasCCF2017v3p1Command; import ch.epfl.biop.atlas.struct.Atlas; import ch.epfl.biop.scijava.command.spimdata.SourceFromImagePlusCommand;