Skip to content

Commit fef8d49

Browse files
committed
first commit
0 parents  commit fef8d49

15 files changed

Lines changed: 2211 additions & 0 deletions

File tree

.gitignore

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/target/
2+
pom.xml.tag
3+
pom.xml.releaseBackup
4+
pom.xml.next
5+
.DS_Store
6+
.classpath
7+
.project
8+
.settings/
9+
/samples/
10+
*.ucls
11+
.idea/
12+
*.iml
13+
doc/
14+
*.bak
15+
debug.yaml
16+
/bin/

.vscode/launch.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"type": "java",
9+
"name": "Attach to Remote Program",
10+
"request": "attach",
11+
"hostName": "localhost",
12+
"port": "5000"
13+
},
14+
{
15+
"type": "java",
16+
"name": "Current File",
17+
"request": "launch",
18+
"mainClass": "${file}"
19+
},
20+
{
21+
"type": "java",
22+
"name": "PluginExampleTestDrive",
23+
"request": "launch",
24+
"mainClass": "org.mastodon.mamut.example.plugin.PluginExampleTestDrive",
25+
"projectName": "mastodon-averoflab"
26+
}
27+
]
28+
}

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"java.format.settings.url": "imglib2-coding-style.xml"
3+
}

LICENSE

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
BSD 2-Clause License
2+
3+
Copyright (c) 2023, Mastodon Science
4+
5+
Redistribution and use in source and binary forms, with or without
6+
modification, are permitted provided that the following conditions are met:
7+
8+
1. Redistributions of source code must retain the above copyright notice, this
9+
list of conditions and the following disclaimer.
10+
11+
2. Redistributions in binary form must reproduce the above copyright notice,
12+
this list of conditions and the following disclaimer in the documentation
13+
and/or other materials provided with the distribution.
14+
15+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
19+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
22+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
23+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# mastodon-averoflab
2+
Mastodon plugins for Averof Lab.

imglib2-coding-style.xml

Lines changed: 399 additions & 0 deletions
Large diffs are not rendered by default.

pom.xml

Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<parent>
8+
<groupId>org.scijava</groupId>
9+
<artifactId>pom-scijava</artifactId>
10+
<version>37.0.0</version>
11+
</parent>
12+
13+
<!-- Of course, make sure to replace `mastodon-plugin-example` by whatever your own
14+
artifact is going to be called. -->
15+
16+
<groupId>org.elephant</groupId>
17+
<artifactId>mastodon-averoflab</artifactId>
18+
<version>0.1.0</version>
19+
20+
<name>Mastodon Averof Lab plugin</name>
21+
<description>A collection of Mastodon plugins for Averof lab.</description>
22+
<url>https://github.com/elephant-track/mastodon-averoflab</url>
23+
<inceptionYear>2024</inceptionYear>
24+
<organization>
25+
<name>ELEPHANT</name>
26+
<url>https://elephant-track.github.io</url>
27+
</organization>
28+
<licenses>
29+
<license>
30+
<name>Simplified BSD License</name>
31+
<url>https://opensource.org/licenses/BSD-2-Clause</url>
32+
<distribution>repo</distribution>
33+
</license>
34+
</licenses>
35+
36+
<!-- Below we include all the main mastodon artifacts as dependencies, in case you
37+
need them in your plugin. Feel free to remove what you do not need. -->
38+
39+
<properties>
40+
41+
<mastodon.group>org.mastodon</mastodon.group>
42+
<mastodon-collection.version>1.0.0-beta-25</mastodon-collection.version>
43+
<mastodon-graph.version>1.0.0-beta-25</mastodon-graph.version>
44+
<mastodon.version>1.0.0-beta-27</mastodon.version>
45+
<!-- <mastodon-ellipsoid-fitting.version>0.4.0</mastodon-ellipsoid-fitting.version> -->
46+
<!-- <mastodon-tracking.version>1.0.0-beta-14</mastodon-tracking.version> -->
47+
<!-- <mastodon-selection-creator.version>0.0.7</mastodon-selection-creator.version> -->
48+
<!-- <mastodon-pasteur.version>1.0.0-beta-7</mastodon-pasteur.version> -->
49+
<!-- <mastodon-tomancak.version>0.4.0</mastodon-tomancak.version> -->
50+
51+
<package-name>org.mastodon</package-name>
52+
53+
<license.licenseName>bsd_2</license.licenseName>
54+
<license.projectName>Mastodon Averof Lab</license.projectName>
55+
<license.organizationName>ELEPHANT</license.organizationName>
56+
<license.copyrightOwners>Ko Sugawara</license.copyrightOwners>
57+
58+
<!-- <releaseProfiles>deploy-to-scijava</releaseProfiles> -->
59+
60+
</properties>
61+
62+
<mailingLists>
63+
<mailingList>
64+
<name>Image.sc Forum</name>
65+
<archive>https://forum.image.sc/tags/mastodon</archive>
66+
</mailingList>
67+
</mailingLists>
68+
69+
<!-- Here as well, replace `mastodon-plugin-example` by the name of your own artifact. -->
70+
71+
<scm>
72+
<connection>scm:git:git://github.com/elephant-track/mastodon-averoflab</connection>
73+
<developerConnection>scm:git:git@github.com:elephant-track/mastodon-averoflab</developerConnection>
74+
<tag>HEAD</tag>
75+
<url>https://github.com/elephant-track/mastodon-averoflab</url>
76+
</scm>
77+
<issueManagement>
78+
<system>GitHub</system>
79+
<url>https://github.com/elephant-track/mastodon-averoflab/issues</url>
80+
</issueManagement>
81+
<ciManagement>
82+
<system>Travis CI</system>
83+
<url>https://travis-ci.com/elephant-track/mastodon-averoflab</url>
84+
</ciManagement>
85+
86+
<!-- And of course, list yourself as developer below, instead of me. -->
87+
88+
<developers>
89+
<developer>
90+
<id>ksugar</id>
91+
<name>Ko Sugawara</name>
92+
<email>ko.sugawara@riken.jp</email>
93+
<url>https://github.com/ksugar/</url>
94+
<organization>Institut Pasteur</organization>
95+
<organizationUrl>https://www.bdr.riken.jp/</organizationUrl>
96+
<roles>
97+
<role>developer</role>
98+
</roles>
99+
</developer>
100+
</developers>
101+
102+
<contributors>
103+
<contributor>
104+
<name>grrrr</name>
105+
</contributor>
106+
</contributors>
107+
108+
<repositories>
109+
<repository>
110+
<id>scijava.public</id>
111+
<url>https://maven.scijava.org/content/groups/public</url>
112+
</repository>
113+
</repositories>
114+
115+
<dependencies>
116+
117+
<dependency>
118+
<groupId>${mastodon.group}</groupId>
119+
<artifactId>mastodon-collection</artifactId>
120+
<version>${mastodon-collection.version}</version>
121+
</dependency>
122+
<dependency>
123+
<groupId>${mastodon.group}</groupId>
124+
<artifactId>mastodon-graph</artifactId>
125+
<version>${mastodon-graph.version}</version>
126+
</dependency>
127+
<dependency>
128+
<groupId>${mastodon.group}</groupId>
129+
<artifactId>mastodon</artifactId>
130+
<version>${mastodon.version}</version>
131+
</dependency>
132+
<!-- <dependency>
133+
<groupId>${mastodon.group}</groupId>
134+
<artifactId>mastodon-ellipsoid-fitting</artifactId>
135+
<version>${mastodon-ellipsoid-fitting.version}</version>
136+
</dependency>
137+
<dependency>
138+
<groupId>${mastodon.group}</groupId>
139+
<artifactId>mastodon-tracking</artifactId>
140+
<version>${mastodon-tracking.version}</version>
141+
</dependency>
142+
<dependency>
143+
<groupId>${mastodon.group}</groupId>
144+
<artifactId>mastodon-selection-creator</artifactId>
145+
<version>${mastodon-selection-creator.version}</version>
146+
</dependency>
147+
<dependency>
148+
<groupId>${mastodon.group}</groupId>
149+
<artifactId>mastodon-pasteur</artifactId>
150+
<version>${mastodon-pasteur.version}</version>
151+
</dependency>
152+
<dependency>
153+
<groupId>${mastodon.group}</groupId>
154+
<artifactId>mastodon-tomancak</artifactId>
155+
<version>${mastodon-tomancak.version}</version>
156+
</dependency> -->
157+
158+
</dependencies>
159+
</project>
Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
/*******************************************************************************
2+
* Copyright (C) 2024, Ko Sugawara
3+
* All rights reserved.
4+
*
5+
* Redistribution and use in source and binary forms, with or without
6+
* modification, are permitted provided that the following conditions are met:
7+
*
8+
* 1. Redistributions of source code must retain the above copyright notice,
9+
* this list of conditions and the following disclaimer.
10+
*
11+
* 2. Redistributions in binary form must reproduce the above copyright notice,
12+
* this list of conditions and the following disclaimer in the documentation
13+
* and/or other materials provided with the distribution.
14+
*
15+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
19+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25+
* POSSIBILITY OF SUCH DAMAGE.
26+
******************************************************************************/
27+
package org.elephant.mamut.plugin;
28+
29+
import java.awt.event.ActionEvent;
30+
import java.util.Collections;
31+
import java.util.HashSet;
32+
import java.util.List;
33+
import java.util.Map;
34+
import java.util.Set;
35+
36+
import org.mastodon.app.ui.ViewMenuBuilder.MenuItem;
37+
import org.mastodon.mamut.KeyConfigScopes;
38+
import org.mastodon.mamut.MamutMenuBuilder;
39+
import org.mastodon.mamut.ProjectModel;
40+
import org.mastodon.mamut.model.ModelGraph;
41+
import org.mastodon.mamut.model.Spot;
42+
import org.mastodon.mamut.plugin.MamutPlugin;
43+
import org.mastodon.model.tag.ObjTagMap;
44+
import org.mastodon.model.tag.TagSetStructure.Tag;
45+
import org.mastodon.model.tag.TagSetStructure.TagSet;
46+
import org.mastodon.ui.keymap.KeyConfigContexts;
47+
import org.scijava.plugin.Plugin;
48+
import org.scijava.ui.behaviour.io.gui.CommandDescriptionProvider;
49+
import org.scijava.ui.behaviour.io.gui.CommandDescriptions;
50+
import org.scijava.ui.behaviour.util.AbstractNamedAction;
51+
import org.scijava.ui.behaviour.util.Actions;
52+
53+
@Plugin( type = ConflictDetectorPlugin.class )
54+
public class ConflictDetectorPlugin implements MamutPlugin
55+
{
56+
57+
private final static String ACTION_NAME = "conflict detector";
58+
59+
private ConflictDetectorAction action;
60+
61+
@Override
62+
public void setAppPluginModel( final ProjectModel projectModel )
63+
{
64+
this.action = new ConflictDetectorAction( projectModel );
65+
}
66+
67+
@Override
68+
public void installGlobalActions( final Actions actions )
69+
{
70+
final String keyboardShortcut = "not mapped";
71+
72+
actions.namedAction( action, keyboardShortcut );
73+
74+
}
75+
76+
private static class ConflictDetectorAction extends AbstractNamedAction
77+
{
78+
79+
private static final long serialVersionUID = 1L;
80+
81+
private final ProjectModel projectModel;
82+
83+
private final ModelGraph graph;
84+
85+
final double[] pos = new double[ 3 ];
86+
87+
private ConflictDetectorAction( final ProjectModel projectModel )
88+
{
89+
super( ACTION_NAME );
90+
this.projectModel = projectModel;
91+
this.graph = projectModel.getModel().getGraph();
92+
}
93+
94+
@Override
95+
public void actionPerformed( final ActionEvent e )
96+
{
97+
TagSet tagSet = projectModel.getModel().getTagSetModel().getTagSetStructure().getTagSets().stream()
98+
.filter( ts -> ts.getName().equals( "Duplicate" ) ).findFirst().orElse( null );
99+
Tag tag = tagSet.getTags().stream().filter( t -> t.label().equals( "duplicate" ) ).findFirst().orElse( null );
100+
ObjTagMap< Spot, Tag > tagMap = projectModel.getModel().getTagSetModel().getVertexTags().tags( tagSet );
101+
for ( int t = projectModel.getMinTimepoint(); t <= projectModel.getMaxTimepoint(); t++ )
102+
{
103+
final int time = t;
104+
Set< String > hashSet = new HashSet<>();
105+
graph.vertices().stream().filter( spot -> spot.getTimepoint() == time ).forEach( spot -> {
106+
spot.localize( pos );
107+
String hash = GeoHash3D.geoHashStringWithCharacterPrecision( pos[ 0 ], pos[ 1 ], pos[ 2 ], 4 );
108+
if ( hashSet.contains( hash ) )
109+
{
110+
tagMap.set( spot, tag );
111+
System.out.println( "Conflict: " + spot );
112+
}
113+
hashSet.add( hash );
114+
} );
115+
}
116+
}
117+
}
118+
119+
@Plugin( type = Descriptions.class )
120+
public static class Descriptions extends CommandDescriptionProvider
121+
{
122+
public Descriptions()
123+
{
124+
super( KeyConfigScopes.MAMUT, KeyConfigContexts.MASTODON );
125+
}
126+
127+
@Override
128+
public void getCommandDescriptions( final CommandDescriptions descriptions )
129+
{
130+
final String actionName = ACTION_NAME;
131+
final String[] keyboardShortcut = new String[] { "not mapped" };
132+
final String description = "Detect conflicts.";
133+
descriptions.add( actionName, keyboardShortcut, description );
134+
}
135+
136+
}
137+
138+
@Override
139+
public List< MenuItem > getMenuItems()
140+
{
141+
final String actionName = ACTION_NAME;
142+
final MenuItem menuItem = MamutMenuBuilder.makeFullMenuItem(
143+
actionName,
144+
"Plugins", "Averof Lab" );
145+
return Collections.singletonList( menuItem );
146+
}
147+
148+
@Override
149+
public Map< String, String > getMenuTexts()
150+
{
151+
final String actionName = ACTION_NAME;
152+
return Collections.singletonMap(
153+
actionName,
154+
"Detect conflicts" );
155+
}
156+
}

0 commit comments

Comments
 (0)