-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implemented generic assembly of blocks for the trivial case
- Loading branch information
1 parent
f5c295c
commit e2cb2da
Showing
5 changed files
with
175 additions
and
8 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
8 changes: 0 additions & 8 deletions
8
render-ws-java-client/src/main/java/org/janelia/render/client/newsolver/Assembler.java
This file was deleted.
Oops, something went wrong.
26 changes: 26 additions & 0 deletions
26
...t/src/main/java/org/janelia/render/client/newsolver/assembly/Affine2DZBlockAssembler.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,26 @@ | ||
package org.janelia.render.client.newsolver.assembly; | ||
|
||
import java.util.List; | ||
|
||
import org.janelia.render.client.newsolver.BlockData; | ||
import org.janelia.render.client.newsolver.blockfactories.ZBlockFactory; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import mpicbg.models.AffineModel2D; | ||
|
||
public class Affine2DZBlockAssembler extends Assembler< AffineModel2D, ZBlockFactory > | ||
{ | ||
|
||
public Affine2DZBlockAssembler( final List<BlockData<?, AffineModel2D, ?, ZBlockFactory>> blocks, final int startId) | ||
{ | ||
super( blocks, startId ); | ||
} | ||
|
||
@Override | ||
public void assemble( ) | ||
{ | ||
} | ||
|
||
private static final Logger LOG = LoggerFactory.getLogger(Affine2DZBlockAssembler.class); | ||
} |
97 changes: 97 additions & 0 deletions
97
...-ws-java-client/src/main/java/org/janelia/render/client/newsolver/assembly/Assembler.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,97 @@ | ||
package org.janelia.render.client.newsolver.assembly; | ||
|
||
import java.util.HashSet; | ||
import java.util.List; | ||
|
||
import org.janelia.render.client.newsolver.BlockData; | ||
import org.janelia.render.client.newsolver.blockfactories.BlockFactory; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import mpicbg.models.CoordinateTransform; | ||
|
||
public abstract class Assembler< R extends CoordinateTransform, F extends BlockFactory< F > > | ||
{ | ||
final List<BlockData<?, R, ?, F> > blocks; | ||
|
||
int id; | ||
|
||
public Assembler( final List<BlockData<?, R, ?, F> > blocks, final int startId ) | ||
{ | ||
this.id = startId; | ||
this.blocks = blocks; | ||
} | ||
|
||
public AssemblyMaps< R > getAssembly() | ||
{ | ||
AssemblyMaps< R > am; | ||
|
||
// the trivial case of a single block, would crash with the code below | ||
if ( ( am = handleTrivialCase() ) != null ) | ||
return am; | ||
else | ||
am = new AssemblyMaps< R >(); | ||
|
||
assemble(); | ||
|
||
return null; | ||
} | ||
|
||
public abstract void assemble(); | ||
|
||
/** | ||
* | ||
* @return - the result of the trivial case if it was a single block | ||
*/ | ||
protected AssemblyMaps< R > handleTrivialCase() | ||
{ | ||
if ( blocks.size() == 1 ) | ||
{ | ||
LOG.info( "Assembler: only a single block, no solve across blocks necessary." ); | ||
|
||
final AssemblyMaps< R > am = new AssemblyMaps< R >(); | ||
|
||
final BlockData< ?, R, ?, F > solveItem = blocks.get( 0 ); | ||
|
||
for ( int z = solveItem.minZ(); z <= solveItem.maxZ(); ++z ) | ||
{ | ||
// there is no overlap with any other solveItem (should be beginning or end of the entire stack) | ||
final HashSet< String > tileIds = solveItem.zToTileId().get( z ); | ||
|
||
// if there are none, we continue with the next | ||
if ( tileIds.size() == 0 ) | ||
continue; | ||
|
||
am.zToTileIdGlobal.putIfAbsent( z, new HashSet<>() ); | ||
|
||
for ( final String tileId : tileIds ) | ||
{ | ||
am.zToTileIdGlobal.get( z ).add( tileId ); | ||
am.idToTileSpecGlobal.put( tileId, solveItem.rtsc().getTileSpec( tileId ) ); | ||
am.idToFinalModelGlobal.put( tileId, solveItem.idToNewModel().get( tileId ) ); | ||
} | ||
} | ||
|
||
return am; | ||
} | ||
else | ||
{ | ||
return null; | ||
} | ||
} | ||
|
||
/* | ||
public static ResolvedTileSpecCollection combineAllTileSpecs( final List< BlockData<?, ?, ?, ?> > allItems ) | ||
{ | ||
final ResolvedTileSpecCollection rtsc = new ResolvedTileSpecCollection(); | ||
// TODO trautmane - improve this | ||
// this should automatically get rid of duplicates due to the common tileId | ||
for ( BlockData<?, ?, ?, ?> block : allItems ) | ||
block.rtsc().getTileSpecs().forEach( tileSpec -> rtsc.addTileSpecToCollection( tileSpec ) ); | ||
return rtsc; | ||
}*/ | ||
|
||
private static final Logger LOG = LoggerFactory.getLogger(Assembler.class); | ||
} |
18 changes: 18 additions & 0 deletions
18
...-java-client/src/main/java/org/janelia/render/client/newsolver/assembly/AssemblyMaps.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,18 @@ | ||
package org.janelia.render.client.newsolver.assembly; | ||
|
||
import java.util.HashMap; | ||
import java.util.HashSet; | ||
import java.util.List; | ||
|
||
import org.janelia.alignment.spec.TileSpec; | ||
|
||
import mpicbg.models.CoordinateTransform; | ||
import net.imglib2.util.Pair; | ||
|
||
public class AssemblyMaps< R extends CoordinateTransform > | ||
{ | ||
final public HashMap< String, R > idToFinalModelGlobal = new HashMap<>(); | ||
final public HashMap< String, TileSpec > idToTileSpecGlobal = new HashMap<>(); | ||
final public HashMap<Integer, HashSet<String> > zToTileIdGlobal = new HashMap<>(); | ||
final public HashMap< String, List< Pair< String, Double > > > idToErrorMapGlobal = new HashMap<>(); | ||
} |