-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #46 from Noam-Dori/import_spots_from_labels
Implemented label image to spot ellipsoid plugin
- Loading branch information
Showing
3 changed files
with
199 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
src/test/java/org/mastodon/mamut/segment/ImportSpotFromLabelsControllerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package org.mastodon.mamut.segment; | ||
|
||
import bdv.util.AbstractSource; | ||
import bdv.util.RandomAccessibleIntervalSource; | ||
import mpicbg.spim.data.sequence.FinalVoxelDimensions; | ||
import mpicbg.spim.data.sequence.TimePoint; | ||
import mpicbg.spim.data.sequence.VoxelDimensions; | ||
import net.imglib2.RandomAccess; | ||
import net.imglib2.img.Img; | ||
import net.imglib2.img.array.ArrayImgFactory; | ||
import net.imglib2.realtransform.AffineTransform3D; | ||
import net.imglib2.type.numeric.integer.IntType; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.mastodon.mamut.model.Model; | ||
import org.mastodon.mamut.model.Spot; | ||
import org.mastodon.mamut.model.branch.ModelBranchGraph; | ||
import org.scijava.Context; | ||
|
||
import java.util.Collections; | ||
import java.util.Iterator; | ||
import java.util.List; | ||
|
||
import static org.junit.Assert.assertTrue; | ||
|
||
public class ImportSpotFromLabelsControllerTest | ||
{ | ||
private Model model; | ||
|
||
private int timepoint; | ||
|
||
@Before | ||
public void setUp() | ||
{ | ||
model = new Model(); | ||
ModelBranchGraph modelBranchGraph = model.getBranchGraph(); | ||
modelBranchGraph.graphRebuilt(); | ||
timepoint = 0; | ||
} | ||
|
||
@Test | ||
public void testGetEllipsoidFromImage() { | ||
AbstractSource<IntType> img = createImage(); | ||
|
||
Context context = new Context(true); | ||
TimePoint timePoint = new TimePoint( timepoint ); | ||
List< TimePoint > timePoints = Collections.singletonList( timePoint ); | ||
VoxelDimensions voxelDimensions = new FinalVoxelDimensions("um", 0.16, 0.16, 1); | ||
ImportSpotFromLabelsController controller = new ImportSpotFromLabelsController(model, timePoints, img, context, voxelDimensions, 2.2); | ||
|
||
controller.createSpotsFromLabels(); | ||
|
||
Iterator<Spot> iter = model.getGraph().vertices().iterator(); | ||
assertTrue(iter.hasNext()); | ||
|
||
Spot s = iter.next(); | ||
|
||
s.getDoublePosition(0); | ||
} | ||
|
||
private static AbstractSource< IntType > createImage() | ||
{ | ||
Img<IntType> img = new ArrayImgFactory<>(new IntType()).create(4, 4, 4); | ||
RandomAccess<IntType> ra = img.randomAccess(); | ||
ra.setPositionAndGet(1, 1, 1).set(1); | ||
ra.setPositionAndGet(2, 2, 2).set(1); | ||
ra.setPositionAndGet(3, 3, 3).set(1); | ||
|
||
return new RandomAccessibleIntervalSource<>( img, new IntType(), new AffineTransform3D(), "Segmentation" ); | ||
} | ||
} |