Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import spots from label images #79

Merged
merged 38 commits into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
3d99609
Add commons-math with scope test to pom.xml
stefanhahmann Mar 6, 2024
63ef9df
Add class Covariance that can compute Covariance matrices using an on…
stefanhahmann Mar 6, 2024
d268579
Add class CovarianceMatrix that can compute Covariance matrices using…
stefanhahmann Mar 6, 2024
0780138
Add class Mean and MeansVector that can compute mean(s) using an onli…
stefanhahmann Mar 6, 2024
5689917
Add demo show mean and covariance computation using two-pass and onli…
stefanhahmann Mar 6, 2024
c24ded9
Add a new utility class that contains methods to create Spots from La…
stefanhahmann Mar 6, 2024
f87c6fd
Add new Scijava command to start importing spots from a Fiji Image (a…
stefanhahmann Mar 7, 2024
d2a9c23
Add new Scijava command to start importing spots from a user selected…
stefanhahmann Mar 7, 2024
190c074
Add new Plugin ImportSpotsFromLabelImagePlugin
stefanhahmann Mar 7, 2024
c57dc13
Add new test class MeansVectorTest
stefanhahmann Mar 7, 2024
f63ef62
Remove IllegalArgumentException regarding a condition that should not…
stefanhahmann Mar 7, 2024
0598143
Set active maven profile via settings file
stefanhahmann Mar 8, 2024
ede5eb3
Change settings so that sonar and build job can use 1g ram
stefanhahmann Mar 8, 2024
be20047
Do not create a new context in DemoUtils but reuse an existing one th…
stefanhahmann Mar 8, 2024
5d6a195
Set sigma to default to 2.1 as this seems to yield the best results
stefanhahmann Mar 8, 2024
88e4642
Remove creating new Context() from ExportLabelImageControllerTest
stefanhahmann Mar 8, 2024
5ab71ed
Replace channel index selection for BDV channel import by BDV source …
stefanhahmann Mar 15, 2024
35c4ac7
Change menu entry to "Import spots from label image"
stefanhahmann Mar 15, 2024
6da484f
Make showing progress in the status service more correct.
stefanhahmann Mar 15, 2024
92480dc
An improved version of ImportSpotsFromImgPlusViewDemo that allows to …
stefanhahmann Mar 15, 2024
9bda7fe
Hard code results for Covariance tests instead of using apache common…
stefanhahmann Mar 15, 2024
c2fc794
Streamline the order of params in the methods importSpotsFromImgPlus(…
stefanhahmann Mar 15, 2024
f23adba
Reduce code redundancy by replacing the params frames and voxelDimens…
stefanhahmann Mar 15, 2024
140f4a8
Fix dimensions settings in ImportSpotsFromImgPlusViewDemo
stefanhahmann Mar 15, 2024
7453cba
Move generation of example image from ImportSpotsFromImgPlusViewDemo …
stefanhahmann Mar 15, 2024
82bb062
Change ImportSpotsFromBdvChannelViewDemo so that the actual image to …
stefanhahmann Mar 15, 2024
6ef70f7
Change user input from sigma to ellipsoid scaling factor
stefanhahmann Mar 15, 2024
ceaae37
Reuse means computed in CovarianceMatrix instead of re-computing them…
stefanhahmann Mar 15, 2024
5cf4253
Extract method getSourceNames() to separate method and provide unit test
stefanhahmann Mar 15, 2024
a70e22f
Add method to LineageTreeUtils that allows linking spots in consecuti…
stefanhahmann Mar 19, 2024
3d446f4
Refactored sub-package demo to util in test/../io/importer/labelimage
stefanhahmann Mar 19, 2024
7c72102
Change some debug messages to cover potential plurals of variables
stefanhahmann Mar 19, 2024
6e3cf5b
Remove obsolete imports in test and demo classes
stefanhahmann Mar 19, 2024
63d340f
Add option to link spots with same labels in consecutive frames to Im…
stefanhahmann Mar 19, 2024
225a95a
Add splitting case to method description of linkSpotsWithSameLabel()
stefanhahmann Mar 19, 2024
134e207
Add documentation for importing spots from labels to README.md
stefanhahmann Mar 19, 2024
7d38e04
Add Imports to table of contents of README.md
stefanhahmann Mar 19, 2024
eeac845
Add info regarding linking to import spots from labels section in REA…
stefanhahmann Mar 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .ci/settings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 https://maven.apache.org/xsd/settings-1.0.0.xsd">
<activeProfiles>
<activeProfile>build</activeProfile>
</activeProfiles>
</settings>
1 change: 0 additions & 1 deletion .github/workflows/sonarcloud.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} # Generate a token on Sonarcloud.io, add it to the secrets of this repo with the name SONAR_TOKEN (Settings > Secrets > Actions > add new repository secret)
MAVEN_OPTS: -Xmx4096m
run: |
export DISPLAY=:99
sudo Xvfb -ac :99 -screen 0 1280x1024x24 > /dev/null 2>&1 &
Expand Down
81 changes: 81 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
* [Lineage Tree Classification](#lineage-tree-classification)
* [Parameters](#parameters)
* [Example](#example)
* [Imports](#imports)
* [Import Spots from Label Image](#import-spots-from-label-image)
* [Exports](#exports)
* [Label Image Exporter](#label-image-exporter)
* [GraphML Exporter](#graphml-exporter)
Expand Down Expand Up @@ -215,6 +217,85 @@ Tree2
* The resulting tag set used for coloring the track scheme branch
view. ![Trackscheme Branch View with tags](doc/deep_lineage/lineage_classification/trackscheme_branch_with_tags.png)

## Imports

### Import Spots from Label Image

* You can use the plugin to import spots from a label image representing an instance segmentation into Mastodon. This
may be useful if you have an instance segmentation of cells or other objects, and you want to track them using
Mastodon.
* The label image is expected to contain the spot ids as pixel values.
* The label image is expected to have the same dimensions as the image data in Mastodon.
* Labels are processed frame by frame.
* Multiple blobs with the same id in the same frame are considered to belong to the same spot by this importer. It is
advised to use a unique ids for spots in the same frame.
* The resulting spots are ellipsoids with the semi axes computed from the variance covariance matrix of this pixel
positions of each label.
* The resulting spots may be linked using the linker plugin in Mastodon (`Plugins > Tracking > Linking...`)
or [Elephant](https://elephant-track.github.io/#/?id=linking-workflow).

#### Parameters

* Ellipsoid scaling factor: The scaling factor to apply to the ellipsoids. The default is 1.0. The scaling factor is
applied to the semi axes of the ellipsoids. The ellipsoid scaling factor can be used to increase (>1) or decrease (
&lt;1) the size of the resulting ellipsoid. 1 is equivalent of ellipsoids drawn at 2.2σ.
* Link spots having the same id in consecutive frames: If checked, spots with the same id in consecutive frames are
linked.

#### Instance segmentation as active image in ImageJ

* The label image can be opened in ImageJ and the plugin can be called from the
menu: ![Plugin Import Menu](doc/deep_lineage/import/label_image/imagej/plugin_import_imagej_menu.png)
* Please make sure that the label image is the active image in ImageJ.
* Please make sure that the label image has the same dimensions as the image data in Mastodon.
* You can use the `Image > Properties` command ImageJ to check (and) set the dimensions of the label image.

##### Example

* Example
dataset: [Fluo-C3DL-MDA231 from Cell Tracking Challenge](http://data.celltrackingchallenge.net/training-datasets/Fluo-C3DL-MDA231.zip)
* Extract the file to a folder named `Fluo-C3DL-MDA231`
* Import the image sequence with the actual image into ImageJ contained in folder `Fluo-C3DL-MDA231/01/`
* `File > Import > Image Sequence...`
* Set the dimensions of the image sequence to 512x512x1x30x12 (XYCTZ) using `Image > Properties`
* ![plugin_import_example_1.png](doc/deep_lineage/import/label_image/imagej/plugin_import_example_1.png)
* Open Mastodon from Fiji and create a new project with the image sequence
* `Plugins > Mastodon > new Mastodon project > Use an image opened in ImageJ > Create`
* ![plugin_import_example_2.png](doc/deep_lineage/import/label_image/imagej/plugin_import_example_2.png)
* Import the image sequence encoding the label images into ImageJ contained in folder: `Fluo-C3DL-MDA231/01_ERR_SEG/`
* Set the dimensions of the label image to 512x512x1x30x12 (XYCTZ) using `Image > Properties`
* ![plugin_import_example_3.png](doc/deep_lineage/import/label_image/imagej/plugin_import_example_3.png)
* Open Import window in Mastodon: `Plugins > Imports > Import spots from label image > Import spots from ImageJ image`
* Click `OK` and the spots are imported into Mastodon.
* ![plugin_import_example_4.png](doc/deep_lineage/import/label_image/imagej/plugin_import_example_4.png)

#### Instance segmentation as BDV channel

* The plugin can be called from the
menu: ![Plugin Import Menu](doc/deep_lineage/import/label_image/imagej/plugin_import_imagej_menu.png)

##### Example

* Example
dataset: [Fluo-C3DL-MDA231 from Cell Tracking Challenge](http://data.celltrackingchallenge.net/training-datasets/Fluo-C3DL-MDA231.zip)
* Extract the file to a folder named `Fluo-C3DL-MDA231`
* Import the image sequence with the actual image into ImageJ contained in folder `Fluo-C3DL-MDA231/01/`
* `File > Import > Image Sequence...`
* Set the dimensions of the image sequence to 512x512x1x30x12 (XYCTZ) using `Image > Properties`
* ![plugin_import_example_1.png](doc/deep_lineage/import/label_image/imagej/plugin_import_example_1.png)
* Import the image sequence encoding the label images into ImageJ contained in folder: `Fluo-C3DL-MDA231/01_ERR_SEG/`
* Set the dimensions of the label image to 512x512x1x30x12 (XYCTZ) using `Image > Properties`
* ![plugin_import_example_3.png](doc/deep_lineage/import/label_image/imagej/plugin_import_example_3.png)
* Merge the 2 images into a single image using the `Image > Color > Merge Channels...` command
* ![plugin_import_example_5.png](doc/deep_lineage/import/label_image/imagej/plugin_import_example_5.png)
* Open Mastodon from Fiji and create a new project with merged image
* `Plugins > Mastodon > new Mastodon project > Use an image opened in ImageJ > Create`
* ![plugin_import_example_6.png](doc/deep_lineage/import/label_image/imagej/plugin_import_example_6.png)
* Open Import window: `Plugins > Imports > Import spots from label image > Import spots from BDV channel`
* Select the BDV channel containing the label image
* Click `OK` and the spots are imported into Mastodon.
* ![plugin_import_example_7.png](doc/deep_lineage/import/label_image/imagej/plugin_import_example_7.png)

## Exports

### Label Image Exporter
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 12 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<license.organizationName>Mastodon authors</license.organizationName>
<license.copyrightOwners>Stefan Hahmann</license.copyrightOwners>

<mastodon.version>1.0.0-beta-29</mastodon.version>
<mastodon.version>1.0.0-beta-30-SNAPSHOT</mastodon.version>
<mastodon.group>org.mastodon</mastodon.group>
<!-- with pom-scijava >= 37.1.0, this can be removed again -->
<scijava-common.version>2.97.1</scijava-common.version>
Expand Down Expand Up @@ -201,15 +201,13 @@
<id>build</id>
<build>
<plugins>
<!-- Configure the maven-surefire-plugin to use a larger heap size while running tests. -->
<!-- This is necessary for the tests to run, since there is a memory leak in mastodon. -->
<!-- Can be removed after https://github.com/mastodon-sc/mastodon/issues/225 has been resolved -->
<!-- Configure the maven-surefire-plugin to use a heap size of 1gb while running tests. -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<argLine>-Xmx4096m</argLine>
<argLine>-Xmx1g</argLine>
</configuration>
</plugin>
</plugins>
Expand All @@ -219,6 +217,15 @@
<id>coverage</id>
<build>
<plugins>
<!-- Configure the maven-surefire-plugin to use a heap size of 1gb while running tests for jacoco coverage analysis. -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<argLine>@{argLine} -Xmx1g</argLine>
</configuration>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
package org.mastodon.mamut.io.importer.labelimage;

import org.mastodon.app.ui.ViewMenuBuilder;
import org.mastodon.mamut.ProjectModel;
import org.mastodon.mamut.io.importer.labelimage.ui.ImportSpotsFromImgPlusView;
import org.mastodon.mamut.plugin.MamutPlugin;
import org.mastodon.mamut.io.importer.labelimage.ui.ImportSpotsFromBdvChannelView;
import org.scijava.command.CommandService;
import org.scijava.plugin.Parameter;
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;

import java.util.Collections;
import java.util.List;

import static org.mastodon.app.ui.ViewMenuBuilder.item;
import static org.mastodon.app.ui.ViewMenuBuilder.menu;

@SuppressWarnings( "unused" )
@Plugin( type = MamutPlugin.class )
public class ImportSpotsFromLabelImagePlugin implements MamutPlugin
{
private static final String IMPORT_SPOTS_FROM_IMAGEJ = "Import spots from ImageJ image";

private static final String IMPORT_SPOTS_FROM_BDV_CHANNEL = "Import spots from BDV channel";

private static final String[] SHORT_CUTS = { "not mapped" };

private final AbstractNamedAction imageJImport;

private final AbstractNamedAction bdvChannelImport;

private ProjectModel appModel;

@SuppressWarnings( "unused" )
@Parameter
private CommandService commandService;

@SuppressWarnings( "unused" )
public ImportSpotsFromLabelImagePlugin()
{
imageJImport = new RunnableAction( IMPORT_SPOTS_FROM_IMAGEJ, this::importSpotsFromImageJ );
bdvChannelImport = new RunnableAction( IMPORT_SPOTS_FROM_BDV_CHANNEL, this::importSpotsFromBdvChannel );
}

@Override
public void setAppPluginModel( final ProjectModel appPluginModel )
{
this.appModel = appPluginModel;
}

@Override
public List< ViewMenuBuilder.MenuItem > getMenuItems()
{
return Collections.singletonList(
menu( "Plugins", menu( "Imports",
menu( "Import spots from label image", item( IMPORT_SPOTS_FROM_IMAGEJ ),
item( IMPORT_SPOTS_FROM_BDV_CHANNEL ) ) ) ) );
}

@Override
public void installGlobalActions( Actions actions )
{
actions.namedAction( imageJImport, SHORT_CUTS );
actions.namedAction( bdvChannelImport, SHORT_CUTS );
}

private void importSpotsFromImageJ()
{
commandService.run( ImportSpotsFromImgPlusView.class, true, "projectModel", appModel );
}

private void importSpotsFromBdvChannel()
{
commandService.run( ImportSpotsFromBdvChannelView.class, true, "projectModel", appModel );
}

}
Loading
Loading