From 57c6e0258462a8edf76bc33e89875289b5efe2fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Ulman?= Date: Fri, 27 May 2022 12:58:45 +0200 Subject: [PATCH 01/10] Shuffling menu items inside the Plugins submenu --- .../org/mastodon/mamut/tomancak/TomancakPlugins.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/mastodon/mamut/tomancak/TomancakPlugins.java b/src/main/java/org/mastodon/mamut/tomancak/TomancakPlugins.java index 642c3cc5..ccd79bf6 100644 --- a/src/main/java/org/mastodon/mamut/tomancak/TomancakPlugins.java +++ b/src/main/java/org/mastodon/mamut/tomancak/TomancakPlugins.java @@ -164,14 +164,16 @@ public List< ViewMenuBuilder.MenuItem > getMenuItems() return Arrays.asList( menu( "Plugins", menu( "Tomancak lab", - item( EXPORT_PHYLOXML ), - item( FLIP_DESCENDANTS ), - item( INTERPOLATE_SPOTS ), item( LABEL_SELECTED_SPOTS ), item( COPY_TAG ), item( TWEAK_DATASET_PATH ), - item( COMPACT_LINEAGE_VIEW ), - item( SORT_TREE )) ) ); + item( COMPACT_LINEAGE_VIEW )), + menu( "Trees Management", + item( INTERPOLATE_SPOTS ), + item( FLIP_DESCENDANTS ), + item( SORT_TREE )), + menu( "Exports", + item( EXPORT_PHYLOXML )) ) ); } @Override From ba8d0ac85344314e54d1b3fd4db64ea3da7e8cec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Ulman?= Date: Mon, 18 Jul 2022 19:09:44 +0200 Subject: [PATCH 02/10] Shuffling menu items continued --- .../org/mastodon/mamut/tomancak/TomancakPlugins.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/mastodon/mamut/tomancak/TomancakPlugins.java b/src/main/java/org/mastodon/mamut/tomancak/TomancakPlugins.java index ccd79bf6..3b58d0f5 100644 --- a/src/main/java/org/mastodon/mamut/tomancak/TomancakPlugins.java +++ b/src/main/java/org/mastodon/mamut/tomancak/TomancakPlugins.java @@ -163,17 +163,18 @@ public List< ViewMenuBuilder.MenuItem > getMenuItems() { return Arrays.asList( menu( "Plugins", - menu( "Tomancak lab", - item( LABEL_SELECTED_SPOTS ), - item( COPY_TAG ), - item( TWEAK_DATASET_PATH ), + item( COPY_TAG ), + menu( "Auxiliary Displays", item( COMPACT_LINEAGE_VIEW )), menu( "Trees Management", + item( LABEL_SELECTED_SPOTS ), item( INTERPOLATE_SPOTS ), item( FLIP_DESCENDANTS ), item( SORT_TREE )), menu( "Exports", - item( EXPORT_PHYLOXML )) ) ); + item( EXPORT_PHYLOXML )) ), + menu( "File", + item( TWEAK_DATASET_PATH )) ); } @Override From 01406764c2129e2a85d12363711cbdd10a4b09fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Ulman?= Date: Mon, 18 Jul 2022 19:13:20 +0200 Subject: [PATCH 03/10] identifing constants/strings adopted to the menu layout, TWEAK_DATASET_PATH_KEYS moved always to the end of the blocks because it is now part of the File menu entry, not Plugins --- .../mamut/tomancak/TomancakPlugins.java | 45 +++++++++---------- 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/src/main/java/org/mastodon/mamut/tomancak/TomancakPlugins.java b/src/main/java/org/mastodon/mamut/tomancak/TomancakPlugins.java index 3b58d0f5..8c86480d 100644 --- a/src/main/java/org/mastodon/mamut/tomancak/TomancakPlugins.java +++ b/src/main/java/org/mastodon/mamut/tomancak/TomancakPlugins.java @@ -63,23 +63,23 @@ @Plugin( type = MamutPlugin.class ) public class TomancakPlugins extends AbstractContextual implements MamutPlugin { - private static final String EXPORT_PHYLOXML = "[tomancak] export phyloxml for selection"; - private static final String FLIP_DESCENDANTS = "[tomancak] flip descendants"; - private static final String COPY_TAG = "[tomancak] copy tag"; - private static final String INTERPOLATE_SPOTS = "[tomancak] interpolate spots"; - private static final String TWEAK_DATASET_PATH = "[tomancak] tweak dataset path"; - private static final String LABEL_SELECTED_SPOTS = "[tomancak] label spots"; - private static final String COMPACT_LINEAGE_VIEW = "[tomancak] lineage tree view"; - private static final String SORT_TREE = "[tomancak] sort tree"; + private static final String EXPORT_PHYLOXML = "[exports] export phyloxml for selection"; + private static final String FLIP_DESCENDANTS = "[trees] flip descendants"; + private static final String COPY_TAG = "copy tag"; + private static final String INTERPOLATE_SPOTS = "[trees] interpolate missing spots"; + private static final String LABEL_SELECTED_SPOTS = "[trees] label selected spots"; + private static final String COMPACT_LINEAGE_VIEW = "[displays] show compact lineage"; + private static final String SORT_TREE = "[trees] sort lineage tree"; + private static final String TWEAK_DATASET_PATH = "fix project image path"; private static final String[] EXPORT_PHYLOXML_KEYS = { "not mapped" }; private static final String[] FLIP_DESCENDANTS_KEYS = { "not mapped" }; private static final String[] COPY_TAG_KEYS = { "not mapped" }; private static final String[] INTERPOLATE_SPOTS_KEYS = { "not mapped" }; - private static final String[] TWEAK_DATASET_PATH_KEYS = { "not mapped" }; private static final String[] LABEL_SELECTED_SPOTS_KEYS = { "not mapped" }; private static final String[] COMPACT_LINEAGE_VIEW_KEYS = { "not mapped" }; private static final String[] SORT_TREE_KEYS = { "not mapped" }; + private static final String[] TWEAK_DATASET_PATH_KEYS = { "not mapped" }; private static Map< String, String > menuTexts = new HashMap<>(); @@ -128,14 +128,14 @@ public void getCommandDescriptions( final CommandDescriptions descriptions ) private final AbstractNamedAction interpolateSpotsAction; - private final AbstractNamedAction tweakDatasetPathAction; - private final AbstractNamedAction labelSelectedSpotsAction; private final AbstractNamedAction lineageTreeViewAction; private final AbstractNamedAction sortTreeAction; + private final AbstractNamedAction tweakDatasetPathAction; + private MamutPluginAppModel pluginAppModel; public TomancakPlugins() @@ -144,10 +144,10 @@ public TomancakPlugins() flipDescendantsAction = new RunnableAction( FLIP_DESCENDANTS, this::flipDescendants ); copyTagAction = new RunnableAction( COPY_TAG, this::copyTag ); interpolateSpotsAction = new RunnableAction( INTERPOLATE_SPOTS, this::interpolateSpots ); - tweakDatasetPathAction = new RunnableAction( TWEAK_DATASET_PATH, this::tweakDatasetPath ); labelSelectedSpotsAction = new RunnableAction( LABEL_SELECTED_SPOTS, this::labelSelectedSpots ); lineageTreeViewAction = new RunnableAction( COMPACT_LINEAGE_VIEW, this::showLineageView ); sortTreeAction = new RunnableAction( SORT_TREE, this::sortTree ); + tweakDatasetPathAction = new RunnableAction( TWEAK_DATASET_PATH, this::tweakDatasetPath ); updateEnabledActions(); } @@ -190,10 +190,10 @@ public void installGlobalActions( final Actions actions ) actions.namedAction( flipDescendantsAction, FLIP_DESCENDANTS_KEYS ); actions.namedAction( copyTagAction, COPY_TAG_KEYS ); actions.namedAction( interpolateSpotsAction, INTERPOLATE_SPOTS_KEYS ); - actions.namedAction( tweakDatasetPathAction, TWEAK_DATASET_PATH_KEYS ); actions.namedAction( labelSelectedSpotsAction, LABEL_SELECTED_SPOTS_KEYS ); actions.namedAction( lineageTreeViewAction, COMPACT_LINEAGE_VIEW_KEYS ); actions.namedAction( sortTreeAction, SORT_TREE_KEYS ); + actions.namedAction( tweakDatasetPathAction, TWEAK_DATASET_PATH_KEYS ); } private void updateEnabledActions() @@ -203,10 +203,10 @@ private void updateEnabledActions() flipDescendantsAction.setEnabled( appModel != null ); copyTagAction.setEnabled( appModel != null ); interpolateSpotsAction.setEnabled( appModel != null ); - tweakDatasetPathAction.setEnabled( appModel != null ); labelSelectedSpotsAction.setEnabled( appModel != null ); lineageTreeViewAction.setEnabled( appModel != null ); sortTreeAction.setEnabled( appModel != null ); + tweakDatasetPathAction.setEnabled( appModel != null ); } private void exportPhyloXml() @@ -239,15 +239,6 @@ private void interpolateSpots() } } - private void tweakDatasetPath() - { - if ( pluginAppModel != null ) - { - final MamutProject project = pluginAppModel.getWindowManager().getProjectManager().getProject(); - new DatasetPathDialog( null, project ).setVisible( true ); - } - } - private void labelSelectedSpots() { if ( pluginAppModel != null ) @@ -295,4 +286,12 @@ private void showLineageView() { frame.setVisible(true); } + private void tweakDatasetPath() + { + if ( pluginAppModel != null ) + { + final MamutProject project = pluginAppModel.getWindowManager().getProjectManager().getProject(); + new DatasetPathDialog( null, project ).setVisible( true ); + } + } } From 90769f6bbcb3ae3084f6a92567113e41f14d6118 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Ulman?= Date: Mon, 18 Jul 2022 19:14:32 +0200 Subject: [PATCH 04/10] menu items descriptions made a bit clearer --- .../java/org/mastodon/mamut/tomancak/TomancakPlugins.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/mastodon/mamut/tomancak/TomancakPlugins.java b/src/main/java/org/mastodon/mamut/tomancak/TomancakPlugins.java index 8c86480d..b452a49e 100644 --- a/src/main/java/org/mastodon/mamut/tomancak/TomancakPlugins.java +++ b/src/main/java/org/mastodon/mamut/tomancak/TomancakPlugins.java @@ -110,13 +110,13 @@ public Descriptions() public void getCommandDescriptions( final CommandDescriptions descriptions ) { descriptions.add( EXPORT_PHYLOXML, EXPORT_PHYLOXML_KEYS, "Export subtree to PhyloXML format." ); - descriptions.add( FLIP_DESCENDANTS, FLIP_DESCENDANTS_KEYS, "Flip children in trackscheme graph." ); + descriptions.add( FLIP_DESCENDANTS, FLIP_DESCENDANTS_KEYS, "Flip children of the currently selected spot in trackscheme graph." ); descriptions.add( COPY_TAG, COPY_TAG_KEYS, "Copy tags: everything that has tag A assigned gets B assigned." ); - descriptions.add( INTERPOLATE_SPOTS, INTERPOLATE_SPOTS_KEYS, "Interpolate missing spots." ); - descriptions.add( TWEAK_DATASET_PATH, TWEAK_DATASET_PATH_KEYS, "Set the path to the BDV data and whether it is relative or absolute." ); + descriptions.add( INTERPOLATE_SPOTS, INTERPOLATE_SPOTS_KEYS, "Along each track, new spot is inserted to every time points with no spots." ); descriptions.add( LABEL_SELECTED_SPOTS, LABEL_SELECTED_SPOTS_KEYS, "Set label for all selected spots." ); descriptions.add( COMPACT_LINEAGE_VIEW, COMPACT_LINEAGE_VIEW_KEYS, "Show compact representation of the lineage tree."); descriptions.add( SORT_TREE, SORT_TREE_KEYS, "Sort selected node according to tagged anchors."); + descriptions.add( TWEAK_DATASET_PATH, TWEAK_DATASET_PATH_KEYS, "Allows to insert new path to the BDV data and whether it is relative or absolute." ); } } From 12cf1ddbe8a238b299e35fe5ac56c302fdd5bfd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Ulman?= Date: Mon, 18 Jul 2022 19:15:14 +0200 Subject: [PATCH 05/10] labels of menu items follow This Naming Scheme Just Like Main Mastodon Menus --- .../mastodon/mamut/tomancak/TomancakPlugins.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/mastodon/mamut/tomancak/TomancakPlugins.java b/src/main/java/org/mastodon/mamut/tomancak/TomancakPlugins.java index b452a49e..67735e38 100644 --- a/src/main/java/org/mastodon/mamut/tomancak/TomancakPlugins.java +++ b/src/main/java/org/mastodon/mamut/tomancak/TomancakPlugins.java @@ -85,14 +85,14 @@ public class TomancakPlugins extends AbstractContextual implements MamutPlugin static { - menuTexts.put( EXPORT_PHYLOXML, "Export phyloXML for selection" ); - menuTexts.put( FLIP_DESCENDANTS, "Flip descendants" ); - menuTexts.put( COPY_TAG, "Copy Tag..." ); - menuTexts.put( INTERPOLATE_SPOTS, "Interpolate missing spots" ); - menuTexts.put( TWEAK_DATASET_PATH, "Edit BDV XML path..." ); - menuTexts.put( LABEL_SELECTED_SPOTS, "Label selected spots..." ); - menuTexts.put( COMPACT_LINEAGE_VIEW, "Show compact lineage" ); - menuTexts.put( SORT_TREE, "Sort lineage tree..." ); + menuTexts.put( EXPORT_PHYLOXML, "Export phyloXML for Selection" ); + menuTexts.put( FLIP_DESCENDANTS, "Flip Descendants" ); + menuTexts.put( COPY_TAG, "Copy Tag" ); + menuTexts.put( INTERPOLATE_SPOTS, "Interpolate Missing Spots" ); + menuTexts.put( LABEL_SELECTED_SPOTS, "Label Selected Spots" ); + menuTexts.put( COMPACT_LINEAGE_VIEW, "Show Compact Lineage" ); + menuTexts.put( SORT_TREE, "Sort Lineage Tree" ); + menuTexts.put( TWEAK_DATASET_PATH, "Fix Image Path" ); } /* From 33cf326d97aba6305b5ba97c73d3f25a7a12dabc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Ulman?= Date: Mon, 18 Jul 2022 19:25:46 +0200 Subject: [PATCH 06/10] the "Merge projects" dialog (and plugin) is now registered in the same file with the all remaining plugins in this repository --- .../mamut/tomancak/TomancakPlugins.java | 45 ++++- .../mamut/tomancak/merging/MergingPlugin.java | 158 ------------------ 2 files changed, 44 insertions(+), 159 deletions(-) delete mode 100644 src/main/java/org/mastodon/mamut/tomancak/merging/MergingPlugin.java diff --git a/src/main/java/org/mastodon/mamut/tomancak/TomancakPlugins.java b/src/main/java/org/mastodon/mamut/tomancak/TomancakPlugins.java index 67735e38..688cb135 100644 --- a/src/main/java/org/mastodon/mamut/tomancak/TomancakPlugins.java +++ b/src/main/java/org/mastodon/mamut/tomancak/TomancakPlugins.java @@ -49,6 +49,9 @@ import org.mastodon.mamut.plugin.MamutPluginAppModel; import org.mastodon.mamut.project.MamutProject; import org.mastodon.mamut.tomancak.compact_lineage.CompactLineageFrame; +import org.mastodon.mamut.tomancak.merging.Dataset; +import org.mastodon.mamut.tomancak.merging.MergeDatasets; +import org.mastodon.mamut.tomancak.merging.MergingDialog; import org.mastodon.mamut.tomancak.sort_tree.SortTreeDialog; import org.mastodon.model.SelectionModel; import org.mastodon.ui.keymap.CommandDescriptionProvider; @@ -70,6 +73,7 @@ public class TomancakPlugins extends AbstractContextual implements MamutPlugin private static final String LABEL_SELECTED_SPOTS = "[trees] label selected spots"; private static final String COMPACT_LINEAGE_VIEW = "[displays] show compact lineage"; private static final String SORT_TREE = "[trees] sort lineage tree"; + private static final String MERGE_PROJECTS = "merge projects"; private static final String TWEAK_DATASET_PATH = "fix project image path"; private static final String[] EXPORT_PHYLOXML_KEYS = { "not mapped" }; @@ -79,6 +83,7 @@ public class TomancakPlugins extends AbstractContextual implements MamutPlugin private static final String[] LABEL_SELECTED_SPOTS_KEYS = { "not mapped" }; private static final String[] COMPACT_LINEAGE_VIEW_KEYS = { "not mapped" }; private static final String[] SORT_TREE_KEYS = { "not mapped" }; + private static final String[] MERGE_PROJECTS_KEYS = { "not mapped" }; private static final String[] TWEAK_DATASET_PATH_KEYS = { "not mapped" }; private static Map< String, String > menuTexts = new HashMap<>(); @@ -92,6 +97,7 @@ public class TomancakPlugins extends AbstractContextual implements MamutPlugin menuTexts.put( LABEL_SELECTED_SPOTS, "Label Selected Spots" ); menuTexts.put( COMPACT_LINEAGE_VIEW, "Show Compact Lineage" ); menuTexts.put( SORT_TREE, "Sort Lineage Tree" ); + menuTexts.put( MERGE_PROJECTS, "Merge Two Projects" ); menuTexts.put( TWEAK_DATASET_PATH, "Fix Image Path" ); } @@ -116,6 +122,7 @@ public void getCommandDescriptions( final CommandDescriptions descriptions ) descriptions.add( LABEL_SELECTED_SPOTS, LABEL_SELECTED_SPOTS_KEYS, "Set label for all selected spots." ); descriptions.add( COMPACT_LINEAGE_VIEW, COMPACT_LINEAGE_VIEW_KEYS, "Show compact representation of the lineage tree."); descriptions.add( SORT_TREE, SORT_TREE_KEYS, "Sort selected node according to tagged anchors."); + descriptions.add( MERGE_PROJECTS, MERGE_PROJECTS_KEYS, "Merge two Mastodon projects into one." ); descriptions.add( TWEAK_DATASET_PATH, TWEAK_DATASET_PATH_KEYS, "Allows to insert new path to the BDV data and whether it is relative or absolute." ); } } @@ -134,6 +141,8 @@ public void getCommandDescriptions( final CommandDescriptions descriptions ) private final AbstractNamedAction sortTreeAction; + private final AbstractNamedAction mergeProjectsAction; + private final AbstractNamedAction tweakDatasetPathAction; private MamutPluginAppModel pluginAppModel; @@ -147,6 +156,7 @@ public TomancakPlugins() labelSelectedSpotsAction = new RunnableAction( LABEL_SELECTED_SPOTS, this::labelSelectedSpots ); lineageTreeViewAction = new RunnableAction( COMPACT_LINEAGE_VIEW, this::showLineageView ); sortTreeAction = new RunnableAction( SORT_TREE, this::sortTree ); + mergeProjectsAction = new RunnableAction( MERGE_PROJECTS, this::mergeProjects ); tweakDatasetPathAction = new RunnableAction( TWEAK_DATASET_PATH, this::tweakDatasetPath ); updateEnabledActions(); } @@ -174,7 +184,8 @@ public List< ViewMenuBuilder.MenuItem > getMenuItems() menu( "Exports", item( EXPORT_PHYLOXML )) ), menu( "File", - item( TWEAK_DATASET_PATH )) ); + item( TWEAK_DATASET_PATH ), + item( MERGE_PROJECTS )) ); } @Override @@ -193,6 +204,7 @@ public void installGlobalActions( final Actions actions ) actions.namedAction( labelSelectedSpotsAction, LABEL_SELECTED_SPOTS_KEYS ); actions.namedAction( lineageTreeViewAction, COMPACT_LINEAGE_VIEW_KEYS ); actions.namedAction( sortTreeAction, SORT_TREE_KEYS ); + actions.namedAction( mergeProjectsAction, MERGE_PROJECTS_KEYS ); actions.namedAction( tweakDatasetPathAction, TWEAK_DATASET_PATH_KEYS ); } @@ -206,6 +218,7 @@ private void updateEnabledActions() labelSelectedSpotsAction.setEnabled( appModel != null ); lineageTreeViewAction.setEnabled( appModel != null ); sortTreeAction.setEnabled( appModel != null ); + mergeProjectsAction.setEnabled( appModel != null ); tweakDatasetPathAction.setEnabled( appModel != null ); } @@ -286,6 +299,36 @@ private void showLineageView() { frame.setVisible(true); } + private MergingDialog mergingDialog; + + private void mergeProjects() + { + if ( mergingDialog == null ) + mergingDialog = new MergingDialog( null ); + mergingDialog.onMerge( () -> + { + try + { + final String pathA = mergingDialog.getPathA(); + final String pathB = mergingDialog.getPathB(); + final double distCutoff = mergingDialog.getDistCutoff(); + final double mahalanobisDistCutoff = mergingDialog.getMahalanobisDistCutoff(); + final double ratioThreshold = mergingDialog.getRatioThreshold(); + + final Dataset dsA = new Dataset( pathA ); + final Dataset dsB = new Dataset( pathB ); + pluginAppModel.getWindowManager().getProjectManager().open( new MamutProject( null, dsA.project().getDatasetXmlFile() ) ); + final MergeDatasets.OutputDataSet output = new MergeDatasets.OutputDataSet( pluginAppModel.getAppModel().getModel() ); + MergeDatasets.merge( dsA, dsB, output, distCutoff, mahalanobisDistCutoff, ratioThreshold ); + } + catch( final Exception e ) + { + e.printStackTrace(); + } + } ); + mergingDialog.setVisible( true ); + } + private void tweakDatasetPath() { if ( pluginAppModel != null ) diff --git a/src/main/java/org/mastodon/mamut/tomancak/merging/MergingPlugin.java b/src/main/java/org/mastodon/mamut/tomancak/merging/MergingPlugin.java deleted file mode 100644 index 1c62b19b..00000000 --- a/src/main/java/org/mastodon/mamut/tomancak/merging/MergingPlugin.java +++ /dev/null @@ -1,158 +0,0 @@ -/*- - * #%L - * mastodon-tomancak - * %% - * Copyright (C) 2018 - 2021 Tobias Pietzsch - * %% - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * #L% - */ -package org.mastodon.mamut.tomancak.merging; - -import static org.mastodon.app.ui.ViewMenuBuilder.item; -import static org.mastodon.app.ui.ViewMenuBuilder.menu; - -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.mastodon.app.ui.ViewMenuBuilder; -import org.mastodon.mamut.MamutAppModel; -import org.mastodon.mamut.plugin.MamutPlugin; -import org.mastodon.mamut.plugin.MamutPluginAppModel; -import org.mastodon.mamut.project.MamutProject; -import org.mastodon.ui.keymap.CommandDescriptionProvider; -import org.mastodon.ui.keymap.CommandDescriptions; -import org.mastodon.ui.keymap.KeyConfigContexts; -import org.scijava.AbstractContextual; -import org.scijava.plugin.Plugin; -import org.scijava.ui.behaviour.util.AbstractNamedAction; -import org.scijava.ui.behaviour.util.Actions; -import org.scijava.ui.behaviour.util.RunnableAction; - -@Plugin( type = MamutPlugin.class ) -public class MergingPlugin extends AbstractContextual implements MamutPlugin -{ - private static final String MERGE_PROJECTS = "[tomancak] merge projects"; - - private static final String[] MERGE_PROJECTS_KEYS = { "not mapped" }; - - private static Map< String, String > menuTexts = new HashMap<>(); - - static - { - menuTexts.put( MERGE_PROJECTS, "Merge Projects..." ); - } - - /* - * Command descriptions for all provided commands - */ - @Plugin( type = CommandDescriptionProvider.class ) - public static class Descriptions extends CommandDescriptionProvider - { - public Descriptions() - { - super( KeyConfigContexts.TRACKSCHEME, KeyConfigContexts.BIGDATAVIEWER ); - } - - @Override - public void getCommandDescriptions( final CommandDescriptions descriptions ) - { - descriptions.add( MERGE_PROJECTS, MERGE_PROJECTS_KEYS, "Merge two Mastodon projects." ); - } - } - - private final AbstractNamedAction mergeProjectsAction; - - private MamutPluginAppModel pluginAppModel; - - public MergingPlugin() - { - mergeProjectsAction = new RunnableAction( MERGE_PROJECTS, this::mergeProjects ); - updateEnabledActions(); - } - - @Override - public void setAppPluginModel( final MamutPluginAppModel model ) - { - this.pluginAppModel = model; - updateEnabledActions(); - } - - @Override - public List< ViewMenuBuilder.MenuItem > getMenuItems() - { - return Arrays.asList( - menu( "Plugins", - menu( "Tomancak lab", - item( MERGE_PROJECTS ) ) ) ); - } - - @Override - public Map< String, String > getMenuTexts() - { - return menuTexts; - } - - @Override - public void installGlobalActions( final Actions actions ) - { - actions.namedAction( mergeProjectsAction, MERGE_PROJECTS_KEYS ); - } - - private void updateEnabledActions() - { - final MamutAppModel appModel = ( pluginAppModel == null ) ? null : pluginAppModel.getAppModel(); - mergeProjectsAction.setEnabled( appModel != null ); - } - - private MergingDialog mergingDialog; - - private void mergeProjects() - { - if ( mergingDialog == null ) - mergingDialog = new MergingDialog( null ); - mergingDialog.onMerge( () -> - { - try - { - final String pathA = mergingDialog.getPathA(); - final String pathB = mergingDialog.getPathB(); - final double distCutoff = mergingDialog.getDistCutoff(); - final double mahalanobisDistCutoff = mergingDialog.getMahalanobisDistCutoff(); - final double ratioThreshold = mergingDialog.getRatioThreshold(); - - final Dataset dsA = new Dataset( pathA ); - final Dataset dsB = new Dataset( pathB ); - pluginAppModel.getWindowManager().getProjectManager().open( new MamutProject( null, dsA.project().getDatasetXmlFile() ) ); - final MergeDatasets.OutputDataSet output = new MergeDatasets.OutputDataSet( pluginAppModel.getAppModel().getModel() ); - MergeDatasets.merge( dsA, dsB, output, distCutoff, mahalanobisDistCutoff, ratioThreshold ); - } - catch( final Exception e ) - { - e.printStackTrace(); - } - } ); - mergingDialog.setVisible( true ); - } -} From 4e04d6d252765f77cce38ad9377e15e2205411b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Ulman?= Date: Mon, 18 Jul 2022 20:07:42 +0200 Subject: [PATCH 07/10] cosmetics in the dialogs for File->Merge and File->FixPath --- .../org/mastodon/mamut/tomancak/DatasetPathDialog.java | 4 ++-- .../mastodon/mamut/tomancak/merging/MergingDialog.java | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/mastodon/mamut/tomancak/DatasetPathDialog.java b/src/main/java/org/mastodon/mamut/tomancak/DatasetPathDialog.java index 09a776fa..9c805852 100644 --- a/src/main/java/org/mastodon/mamut/tomancak/DatasetPathDialog.java +++ b/src/main/java/org/mastodon/mamut/tomancak/DatasetPathDialog.java @@ -77,7 +77,7 @@ public DatasetPathDialog( final Frame owner, final MamutProject project ) c.gridy = 0; c.gridx = 0; c.weightx = 0.0; - content.add( new JLabel( "BDV dataset path" ), c ); + content.add( new JLabel( "Current BDV dataset path: " ), c ); final JTextField pathTextField = new JTextField( project.getDatasetXmlFile().getAbsolutePath() ); c.gridx = 1; @@ -94,7 +94,7 @@ public DatasetPathDialog( final Frame owner, final MamutProject project ) ++c.gridy; c.gridx = 0; - content.add( new JLabel( "store absolute path" ), c ); + content.add( new JLabel( "Store as absolute path: " ), c ); final JCheckBox storeAbsoluteCheckBox = new JCheckBox(); storeAbsoluteCheckBox.setSelected( !project.isDatasetXmlPathRelative() ); c.gridx = 1; diff --git a/src/main/java/org/mastodon/mamut/tomancak/merging/MergingDialog.java b/src/main/java/org/mastodon/mamut/tomancak/merging/MergingDialog.java index 6feb768f..f72b7052 100644 --- a/src/main/java/org/mastodon/mamut/tomancak/merging/MergingDialog.java +++ b/src/main/java/org/mastodon/mamut/tomancak/merging/MergingDialog.java @@ -91,7 +91,7 @@ public MergingDialog( final Frame owner ) c.gridy = 0; c.gridx = 0; - content.add( new JLabel( "Project A" ), c ); + content.add( new JLabel( "Project A: " ), c ); pathATextField = new JTextField( "" ); c.gridx = 1; c.anchor = GridBagConstraints.LINE_START; @@ -103,7 +103,7 @@ public MergingDialog( final Frame owner ) ++c.gridy; c.gridx = 0; - content.add( new JLabel( "Project B" ), c ); + content.add( new JLabel( "Project B: " ), c ); pathBTextField = new JTextField( "" ); c.gridx = 1; content.add( pathBTextField, c ); @@ -114,21 +114,21 @@ public MergingDialog( final Frame owner ) ++c.gridy; c.gridx = 0; - content.add( new JLabel( "absolute distance cutoff" ), c ); + content.add( new JLabel( "Absolute distance cutoff: " ), c ); distCutoffTextField = new JTextField( "1000" ); c.gridx = 1; content.add( distCutoffTextField, c ); ++c.gridy; c.gridx = 0; - content.add( new JLabel( "mahalanobis distance cutoff" ), c ); + content.add( new JLabel( "Mahalanobis distance cutoff: " ), c ); mahalanobisDistCutoffTextField = new JTextField( "1" ); c.gridx = 1; content.add( mahalanobisDistCutoffTextField, c ); ++c.gridy; c.gridx = 0; - content.add( new JLabel( "ratio threshold" ), c ); + content.add( new JLabel( "Ratio threshold: " ), c ); ratioThresholdTextField = new JTextField( "2" ); c.gridx = 1; content.add( ratioThresholdTextField, c ); From dd6b6328f147aaa2696457a39b1547ddb79169b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Ulman?= Date: Mon, 18 Jul 2022 20:31:09 +0200 Subject: [PATCH 08/10] introduced subpackages and moved relevant files into them --- src/main/java/org/mastodon/mamut/tomancak/TomancakPlugins.java | 3 +++ .../org/mastodon/mamut/tomancak/{ => export}/MakePhyloXml.java | 2 +- .../java/org/mastodon/mamut/tomancak/merging/MergeModels.java | 2 +- .../mamut/tomancak/{ => sort_tree}/FlipDescendants.java | 2 +- .../java/org/mastodon/mamut/tomancak/sort_tree/SortTree.java | 1 - .../mamut/tomancak/{ => spots}/InterpolateMissingSpots.java | 2 +- 6 files changed, 7 insertions(+), 5 deletions(-) rename src/main/java/org/mastodon/mamut/tomancak/{ => export}/MakePhyloXml.java (99%) rename src/main/java/org/mastodon/mamut/tomancak/{ => sort_tree}/FlipDescendants.java (98%) rename src/main/java/org/mastodon/mamut/tomancak/{ => spots}/InterpolateMissingSpots.java (99%) diff --git a/src/main/java/org/mastodon/mamut/tomancak/TomancakPlugins.java b/src/main/java/org/mastodon/mamut/tomancak/TomancakPlugins.java index 688cb135..41653171 100644 --- a/src/main/java/org/mastodon/mamut/tomancak/TomancakPlugins.java +++ b/src/main/java/org/mastodon/mamut/tomancak/TomancakPlugins.java @@ -49,10 +49,13 @@ import org.mastodon.mamut.plugin.MamutPluginAppModel; import org.mastodon.mamut.project.MamutProject; import org.mastodon.mamut.tomancak.compact_lineage.CompactLineageFrame; +import org.mastodon.mamut.tomancak.export.MakePhyloXml; import org.mastodon.mamut.tomancak.merging.Dataset; import org.mastodon.mamut.tomancak.merging.MergeDatasets; import org.mastodon.mamut.tomancak.merging.MergingDialog; +import org.mastodon.mamut.tomancak.sort_tree.FlipDescendants; import org.mastodon.mamut.tomancak.sort_tree.SortTreeDialog; +import org.mastodon.mamut.tomancak.spots.InterpolateMissingSpots; import org.mastodon.model.SelectionModel; import org.mastodon.ui.keymap.CommandDescriptionProvider; import org.mastodon.ui.keymap.CommandDescriptions; diff --git a/src/main/java/org/mastodon/mamut/tomancak/MakePhyloXml.java b/src/main/java/org/mastodon/mamut/tomancak/export/MakePhyloXml.java similarity index 99% rename from src/main/java/org/mastodon/mamut/tomancak/MakePhyloXml.java rename to src/main/java/org/mastodon/mamut/tomancak/export/MakePhyloXml.java index 6b3f126a..f4d0a531 100644 --- a/src/main/java/org/mastodon/mamut/tomancak/MakePhyloXml.java +++ b/src/main/java/org/mastodon/mamut/tomancak/export/MakePhyloXml.java @@ -26,7 +26,7 @@ * POSSIBILITY OF SUCH DAMAGE. * #L% */ -package org.mastodon.mamut.tomancak; +package org.mastodon.mamut.tomancak.export; import java.io.File; import java.io.FileOutputStream; diff --git a/src/main/java/org/mastodon/mamut/tomancak/merging/MergeModels.java b/src/main/java/org/mastodon/mamut/tomancak/merging/MergeModels.java index 31976a33..007ab3cd 100644 --- a/src/main/java/org/mastodon/mamut/tomancak/merging/MergeModels.java +++ b/src/main/java/org/mastodon/mamut/tomancak/merging/MergeModels.java @@ -36,7 +36,7 @@ import org.mastodon.mamut.model.Model; import org.mastodon.mamut.model.ModelGraph; import org.mastodon.mamut.model.Spot; -import org.mastodon.mamut.tomancak.InterpolateMissingSpots; +import org.mastodon.mamut.tomancak.spots.InterpolateMissingSpots; import org.mastodon.mamut.tomancak.merging.MergeDatasets.OutputDataSet; import org.mastodon.mamut.tomancak.merging.MergeTags.TagSetStructureMaps; import org.mastodon.model.tag.ObjTags; diff --git a/src/main/java/org/mastodon/mamut/tomancak/FlipDescendants.java b/src/main/java/org/mastodon/mamut/tomancak/sort_tree/FlipDescendants.java similarity index 98% rename from src/main/java/org/mastodon/mamut/tomancak/FlipDescendants.java rename to src/main/java/org/mastodon/mamut/tomancak/sort_tree/FlipDescendants.java index a2e3ea49..018902f0 100644 --- a/src/main/java/org/mastodon/mamut/tomancak/FlipDescendants.java +++ b/src/main/java/org/mastodon/mamut/tomancak/sort_tree/FlipDescendants.java @@ -26,7 +26,7 @@ * POSSIBILITY OF SUCH DAMAGE. * #L% */ -package org.mastodon.mamut.tomancak; +package org.mastodon.mamut.tomancak.sort_tree; import org.mastodon.graph.ref.OutgoingEdges; import org.mastodon.mamut.MamutAppModel; diff --git a/src/main/java/org/mastodon/mamut/tomancak/sort_tree/SortTree.java b/src/main/java/org/mastodon/mamut/tomancak/sort_tree/SortTree.java index f886643b..b5ae3f66 100644 --- a/src/main/java/org/mastodon/mamut/tomancak/sort_tree/SortTree.java +++ b/src/main/java/org/mastodon/mamut/tomancak/sort_tree/SortTree.java @@ -35,7 +35,6 @@ import org.mastodon.mamut.model.Model; import org.mastodon.mamut.model.ModelGraph; import org.mastodon.mamut.model.Spot; -import org.mastodon.mamut.tomancak.FlipDescendants; import java.util.*; import java.util.concurrent.locks.ReentrantReadWriteLock; diff --git a/src/main/java/org/mastodon/mamut/tomancak/InterpolateMissingSpots.java b/src/main/java/org/mastodon/mamut/tomancak/spots/InterpolateMissingSpots.java similarity index 99% rename from src/main/java/org/mastodon/mamut/tomancak/InterpolateMissingSpots.java rename to src/main/java/org/mastodon/mamut/tomancak/spots/InterpolateMissingSpots.java index 9ea6cb2b..9bc180c1 100644 --- a/src/main/java/org/mastodon/mamut/tomancak/InterpolateMissingSpots.java +++ b/src/main/java/org/mastodon/mamut/tomancak/spots/InterpolateMissingSpots.java @@ -26,7 +26,7 @@ * POSSIBILITY OF SUCH DAMAGE. * #L% */ -package org.mastodon.mamut.tomancak; +package org.mastodon.mamut.tomancak.spots; import static net.imglib2.util.LinAlgHelpers.rows; From dde59b7af6c361fbd6b6ca93254a028a9433c16e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Ulman?= Date: Tue, 19 Jul 2022 22:41:56 +0200 Subject: [PATCH 09/10] concluded to tag commands with the repo/group they belong to, made sure that grouping by keywords could work, that items include common keywords --- .../mamut/tomancak/TomancakPlugins.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/main/java/org/mastodon/mamut/tomancak/TomancakPlugins.java b/src/main/java/org/mastodon/mamut/tomancak/TomancakPlugins.java index 41653171..62844d88 100644 --- a/src/main/java/org/mastodon/mamut/tomancak/TomancakPlugins.java +++ b/src/main/java/org/mastodon/mamut/tomancak/TomancakPlugins.java @@ -69,15 +69,15 @@ @Plugin( type = MamutPlugin.class ) public class TomancakPlugins extends AbstractContextual implements MamutPlugin { - private static final String EXPORT_PHYLOXML = "[exports] export phyloxml for selection"; - private static final String FLIP_DESCENDANTS = "[trees] flip descendants"; - private static final String COPY_TAG = "copy tag"; - private static final String INTERPOLATE_SPOTS = "[trees] interpolate missing spots"; - private static final String LABEL_SELECTED_SPOTS = "[trees] label selected spots"; - private static final String COMPACT_LINEAGE_VIEW = "[displays] show compact lineage"; - private static final String SORT_TREE = "[trees] sort lineage tree"; - private static final String MERGE_PROJECTS = "merge projects"; - private static final String TWEAK_DATASET_PATH = "fix project image path"; + private static final String EXPORT_PHYLOXML = "[tomancak] export phyloxml for selection"; + private static final String FLIP_DESCENDANTS = "[tomancak] flip lineage descendants"; + private static final String COPY_TAG = "[tomancak] copy tag"; + private static final String INTERPOLATE_SPOTS = "[tomancak] interpolate missing spots"; + private static final String LABEL_SELECTED_SPOTS = "[tomancak] label selected spots"; + private static final String COMPACT_LINEAGE_VIEW = "[tomancak] show compact lineage"; + private static final String SORT_TREE = "[tomancak] sort lineage tree"; + private static final String MERGE_PROJECTS = "[tomancak] merge projects"; + private static final String TWEAK_DATASET_PATH = "[tomancak] fix project image path"; private static final String[] EXPORT_PHYLOXML_KEYS = { "not mapped" }; private static final String[] FLIP_DESCENDANTS_KEYS = { "not mapped" }; From 7d2b55302a2ca3f0c89368f1f26e9145e5a94ee7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Ulman?= Date: Tue, 19 Jul 2022 22:48:36 +0200 Subject: [PATCH 10/10] introduced F2 key-binding for LABEL_SELECTED_SPOTS action --- src/main/java/org/mastodon/mamut/tomancak/TomancakPlugins.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/mastodon/mamut/tomancak/TomancakPlugins.java b/src/main/java/org/mastodon/mamut/tomancak/TomancakPlugins.java index 62844d88..8f2b79c1 100644 --- a/src/main/java/org/mastodon/mamut/tomancak/TomancakPlugins.java +++ b/src/main/java/org/mastodon/mamut/tomancak/TomancakPlugins.java @@ -83,7 +83,7 @@ public class TomancakPlugins extends AbstractContextual implements MamutPlugin private static final String[] FLIP_DESCENDANTS_KEYS = { "not mapped" }; private static final String[] COPY_TAG_KEYS = { "not mapped" }; private static final String[] INTERPOLATE_SPOTS_KEYS = { "not mapped" }; - private static final String[] LABEL_SELECTED_SPOTS_KEYS = { "not mapped" }; + private static final String[] LABEL_SELECTED_SPOTS_KEYS = { "F2" }; private static final String[] COMPACT_LINEAGE_VIEW_KEYS = { "not mapped" }; private static final String[] SORT_TREE_KEYS = { "not mapped" }; private static final String[] MERGE_PROJECTS_KEYS = { "not mapped" };