Skip to content

Commit

Permalink
Move LazySpimSource to BdvUtils
Browse files Browse the repository at this point in the history
  • Loading branch information
tischi committed Mar 8, 2019
1 parent 1363490 commit ea29e3c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 95 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,13 @@
<dependency>
<groupId>de.embl.cba</groupId>
<artifactId>table-utils</artifactId>
<version>0.2.04</version>
<version>0.2.06</version>
</dependency>

<dependency>
<groupId>de.embl.cba</groupId>
<artifactId>bdv-utils</artifactId>
<version>0.2.07</version>
<version>0.2.08</version>
</dependency>

</dependencies>
Expand Down
9 changes: 3 additions & 6 deletions src/main/java/de/embl/cba/platynereis/GeneSearch.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@

import bdv.VolatileSpimSource;
import bdv.tools.transformation.TransformedSource;
import bdv.viewer.Source;
import de.embl.cba.bdv.utils.BdvUtils;

import de.embl.cba.bdv.utils.sources.LazySpimSource;
import de.embl.cba.platynereis.utils.Utils;
import de.embl.cba.tables.modelview.images.ImageSourcesModel;
import de.embl.cba.tables.modelview.images.SourceAndMetadata;
import net.imglib2.RandomAccessibleInterval;
import net.imglib2.type.NativeType;
import net.imglib2.type.numeric.RealType;

import javax.swing.*;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.Map;
Expand Down Expand Up @@ -78,12 +77,10 @@ public Map< String, Double > runSearchAndGetLocalExpression()

public RandomAccessibleInterval< ? > getRandomAccessibleInterval( SourceAndMetadata sourceAndMetadata )
{
final PlatynereisImageSourcesModel.LazySpimSource lazySpimSource =
( PlatynereisImageSourcesModel.LazySpimSource ) sourceAndMetadata.source();
final LazySpimSource lazySpimSource = ( LazySpimSource ) sourceAndMetadata.source();
final TransformedSource transformedSource = (TransformedSource) lazySpimSource.wrappedSource();
final VolatileSpimSource wrappedSource = ( VolatileSpimSource ) transformedSource.getWrappedSource();
final RandomAccessibleInterval< ? > rai = wrappedSource.nonVolatile().getSource( 0, 0 );

return rai;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,12 @@
package de.embl.cba.platynereis;

import bdv.BigDataViewer;
import bdv.tools.brightness.ConverterSetup;
import bdv.viewer.Interpolation;
import bdv.viewer.Source;
import bdv.viewer.SourceAndConverter;
import de.embl.cba.bdv.utils.sources.LazySpimSource;
import de.embl.cba.tables.modelview.images.ImageSourcesModel;
import de.embl.cba.tables.modelview.images.SourceAndMetadata;
import de.embl.cba.tables.modelview.images.SourceMetadata;
import mpicbg.spim.data.SpimData;
import mpicbg.spim.data.SpimDataException;
import mpicbg.spim.data.XmlIoSpimData;
import mpicbg.spim.data.sequence.VoxelDimensions;
import net.imglib2.RandomAccessibleInterval;
import net.imglib2.RealRandomAccessible;
import net.imglib2.realtransform.AffineTransform3D;
import net.imglib2.type.numeric.NumericType;

import java.io.File;
import java.util.*;
Expand Down Expand Up @@ -128,83 +119,6 @@ private SpimData openSpimData( File file )
}
}

class LazySpimSource< T extends NumericType< T > > implements Source< T >
{
private final String name;
private final File file;
private Source< T > source;

public LazySpimSource( String name, File file )
{
this.name = name;
this.file = file;
}

public Source< T > wrappedSource()
{
if ( source == null )
{
final SpimData spimData = openSpimData( file );
final List< ConverterSetup > converterSetups = new ArrayList<>();
final List< SourceAndConverter< ? > > sources = new ArrayList<>();
BigDataViewer.initSetups( spimData, converterSetups, sources );

source = ( Source< T > ) sources.get( 0 ).asVolatile().getSpimSource();
}

return source;
}

@Override
public boolean isPresent( int t )
{
if ( t == 0 ) return true;
return false;
}

@Override
public RandomAccessibleInterval< T > getSource( int t, int level )
{
return wrappedSource().getSource( t, level );
}

@Override
public RealRandomAccessible< T > getInterpolatedSource( int t, int level, Interpolation method )
{
return wrappedSource().getInterpolatedSource( t, level, method );
}

@Override
public void getSourceTransform( int t, int level, AffineTransform3D transform )
{
wrappedSource().getSourceTransform( t, level, transform );
}

@Override
public T getType()
{
return wrappedSource().getType();
}

@Override
public String getName()
{
return wrappedSource().getName();
}

@Override
public VoxelDimensions getVoxelDimensions()
{
return wrappedSource().getVoxelDimensions();
}

@Override
public int getNumMipmapLevels()
{
return wrappedSource().getNumMipmapLevels();
}
}

public void addSource( File file )
{
final String imageId = sourceName( file );
Expand Down

0 comments on commit ea29e3c

Please sign in to comment.