Skip to content

Commit

Permalink
Restore dependencies of current Fiji - I can release now
Browse files Browse the repository at this point in the history
RAIHelper: adds the pixeltype in the argument to avoid blocking in Util.getPixelTypeFromRAI
RayCastPositionerSliderAdder: adds synchronisation in state update
ResampledSource: adapats to change in RAIHelper
  • Loading branch information
NicoKiaru committed Jun 7, 2024
1 parent ee30c16 commit 71e4dc1
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 59 deletions.
14 changes: 8 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -135,14 +135,16 @@
<n5-zstandard.version>1.0.2</n5-zstandard.version>
<org.janelia.n5-zstandard.version>${n5-zstandard.version}</org.janelia.n5-zstandard.version>

<bigwarp.version>9.1.2</bigwarp.version>
<bigwarp.version>9.1.0</bigwarp.version>
<bigdataviewer-core.version>10.4.13</bigdataviewer-core.version>
<bigdataviewer-vistools.version>1.0.0-beta-34</bigdataviewer-vistools.version>

<ejml-core.version>0.41</ejml-core.version>
<ejml-ddense.version>0.41</ejml-ddense.version>
<imglib2-realtransform.version>4.0.1</imglib2-realtransform.version>

<jitk-tps.version>3.0.4</jitk-tps.version>
<!--ejml-core.version>0.25</ejml-core.version>
<ejml-ddense.version>0.25</ejml-ddense.version-->

<jitk-tps.version>3.0.3</jitk-tps.version>

</properties>

Expand Down Expand Up @@ -197,7 +199,7 @@
<version>${bigwarp_fiji.version}</version>
</dependency>

<dependency>
<!--dependency>
<groupId>org.ejml</groupId>
<artifactId>ejml-core</artifactId>
<version>${ejml-core.version}</version>
Expand All @@ -207,7 +209,7 @@
<groupId>org.ejml</groupId>
<artifactId>ejml-ddense</artifactId>
<version>${ejml-ddense.version}</version>
</dependency>
</dependency-->

<!-- Test dependencies -->
<dependency>
Expand Down
33 changes: 12 additions & 21 deletions src/main/java/bdv/util/RAIHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,14 @@
import net.imglib2.img.cell.CellGrid;
import net.imglib2.type.NativeType;
import net.imglib2.type.numeric.ARGBType;
import net.imglib2.type.numeric.RealType;
import net.imglib2.type.numeric.integer.GenericByteType;
import net.imglib2.type.numeric.integer.GenericIntType;
import net.imglib2.type.numeric.integer.GenericLongType;
import net.imglib2.type.numeric.integer.GenericShortType;
import net.imglib2.type.numeric.real.DoubleType;
import net.imglib2.type.numeric.real.FloatType;
import net.imglib2.util.Intervals;
import net.imglib2.util.Util;
import net.imglib2.view.Views;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import static net.imglib2.img.basictypeaccess.AccessFlags.VOLATILE;
import static net.imglib2.type.PrimitiveType.BYTE;
Expand All @@ -69,57 +65,52 @@

public class RAIHelper {

private static Logger logger = LoggerFactory.getLogger(RAIHelper.class);

@SuppressWarnings({ "unchecked", "rawtypes" })
public static <T extends NativeType<T>> RandomAccessibleInterval<T>
wrapAsVolatileCachedCellImg(final RandomAccessibleInterval<T> source,
final int[] blockSize, Object objectSource, int timepoint, int level)
wrapAsVolatileCachedCellImg(final RandomAccessibleInterval<T> source,
final int[] blockSize, Object objectSource, int timepoint, int level, T type)
{

final long[] dimensions = Intervals.dimensionsAsLongArray(source);
final CellGrid grid = new CellGrid(dimensions, blockSize);

final Caches.RandomAccessibleLoader<T> loader =
new Caches.RandomAccessibleLoader<>(Views.zeroMin(source));

final T type = Util.getTypeFromInterval(source);
new Caches.RandomAccessibleLoader<>(Views.zeroMin(source));

final CachedCellImg<T, ?> img;
final Cache<Long, Cell<?>> cache = new GlobalLoaderCache(objectSource,
timepoint, level).withLoader(LoadedCellCacheLoader.get(grid, loader, type,
timepoint, level).withLoader(LoadedCellCacheLoader.get(grid, loader, type,
AccessFlags.setOf(VOLATILE)));

if (GenericByteType.class.isInstance(type)) {
img = new CachedCellImg(grid, type, cache, ArrayDataAccessFactory.get(
BYTE, AccessFlags.setOf(VOLATILE)));
BYTE, AccessFlags.setOf(VOLATILE)));
}
else if (GenericShortType.class.isInstance(type)) {
img = new CachedCellImg(grid, type, cache, ArrayDataAccessFactory.get(
SHORT, AccessFlags.setOf(VOLATILE)));
SHORT, AccessFlags.setOf(VOLATILE)));
}
else if (GenericIntType.class.isInstance(type)) {
img = new CachedCellImg(grid, type, cache, ArrayDataAccessFactory.get(INT,
AccessFlags.setOf(VOLATILE)));
AccessFlags.setOf(VOLATILE)));
}
else if (GenericLongType.class.isInstance(type)) {
img = new CachedCellImg(grid, type, cache, ArrayDataAccessFactory.get(
LONG, AccessFlags.setOf(VOLATILE)));
LONG, AccessFlags.setOf(VOLATILE)));
}
else if (FloatType.class.isInstance(type)) {
img = new CachedCellImg(grid, type, cache, ArrayDataAccessFactory.get(
FLOAT, AccessFlags.setOf(VOLATILE)));
FLOAT, AccessFlags.setOf(VOLATILE)));
}
else if (DoubleType.class.isInstance(type)) {
img = new CachedCellImg(grid, type, cache, ArrayDataAccessFactory.get(
DOUBLE, AccessFlags.setOf(VOLATILE)));
DOUBLE, AccessFlags.setOf(VOLATILE)));
}
else if (ARGBType.class.isInstance(type)) {
img = new CachedCellImg(grid, type, cache, ArrayDataAccessFactory.get(INT,
AccessFlags.setOf(VOLATILE)));
AccessFlags.setOf(VOLATILE)));
}
else {
img = null;
throw new UnsupportedOperationException("Cannot resample RAI (wrapAsVolatileCachedCellImg) of pixel type "+type.getClass().getName());
}

return img;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/bdv/util/ResampledSource.java
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ public Interpolation originInterpolation() {
}

@Override
public RandomAccessibleInterval<T> getSource(int t, int level) {
public RandomAccessibleInterval<T> getSource(int t, int level) { // TODO: shouldn't this be synchronized ?
if (cache) {
if (!cachedRAIs.containsKey(t)) {
cachedRAIs.put(t, new ConcurrentHashMap<>());
Expand All @@ -275,7 +275,7 @@ public RandomAccessibleInterval<T> getSource(int t, int level) {
.dimension(2);

cachedRAIs.get(t).put(level, RAIHelper.wrapAsVolatileCachedCellImg(
nonCached, blockSize, this, t, level));
nonCached, blockSize, this, t, level, this.getType()));
}
return cachedRAIs.get(t).get(level);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,41 +114,43 @@ public void run() {
bdvh.getViewerPanel().revalidate();

slider.addChangeListener((e) -> {
if (zLocations.size() > 0) {
JSlider slider = (JSlider) e.getSource();
int newValue = slider.getValue();
// Plane : slider.getValue() / slider.getMaximum()
if ((currentPosition != newValue) && (newValue != -1)) {
// User slider action: needs update of viewer from currentPosition to
// newValue
currentPosition = newValue;
double shiftZ = zLocations.get(currentPosition);
// Need to shift z by shiftZ

AffineTransform3D at3d = new AffineTransform3D();

// Change the position of the viewer with the new offset
bdvh.getViewerPanel().state().getViewerTransform(at3d);
double[] currentCenter = BdvHandleHelper
.getWindowCentreInCalibratedUnits(bdvh);
double[] newCenter = new double[3];
newCenter[0] = currentCenter[0] + lastDirection.getDoublePosition(0) *
shiftZ;
newCenter[1] = currentCenter[1] + lastDirection.getDoublePosition(1) *
shiftZ;
newCenter[2] = currentCenter[2] + lastDirection.getDoublePosition(2) *
shiftZ;
bdvh.getViewerPanel().state().setViewerTransform(BdvHandleHelper
.getViewerTransformWithNewCenter(bdvh, newCenter));

} // else: Bdv user movement: no update required

synchronized (RayCastPositionerSliderAdder.this) {
if (zLocations.size() > 0) {
JSlider slider = (JSlider) e.getSource();
int newValue = slider.getValue();
// Plane : slider.getValue() / slider.getMaximum()
if ((currentPosition != newValue) && (newValue != -1)) {
// User slider action: needs update of viewer from currentPosition to
// newValue
currentPosition = newValue;
double shiftZ = zLocations.get(currentPosition);
// Need to shift z by shiftZ

AffineTransform3D at3d = new AffineTransform3D();

// Change the position of the viewer with the new offset
bdvh.getViewerPanel().state().getViewerTransform(at3d);
double[] currentCenter = BdvHandleHelper
.getWindowCentreInCalibratedUnits(bdvh);
double[] newCenter = new double[3];
newCenter[0] = currentCenter[0] + lastDirection.getDoublePosition(0) *
shiftZ;
newCenter[1] = currentCenter[1] + lastDirection.getDoublePosition(1) *
shiftZ;
newCenter[2] = currentCenter[2] + lastDirection.getDoublePosition(2) *
shiftZ;
bdvh.getViewerPanel().state().setViewerTransform(BdvHandleHelper
.getViewerTransformWithNewCenter(bdvh, newCenter));

} // else: Bdv user movement: no update required

}
}
});

}

public void updatePositions() {
public synchronized void updatePositions() {

// Find origin and direction of ray - center of the bdv window
double[] c = BdvHandleHelper.getWindowCentreInCalibratedUnits(bdvh);
Expand Down

0 comments on commit 71e4dc1

Please sign in to comment.