Skip to content
Snippets Groups Projects
Commit 9082063f authored by Daniel Felipe González Obando's avatar Daniel Felipe González Obando
Browse files

Refactoring on plugin to add x, y and c projections

- git ignoring settings.xml and workspace folder
- Updated pom to 1.8.0 snapshot
- Updated pom parten to 1.0.4 to use Icy 2.1.3
- Implemented ProjectionCalculator to separate logic from plugin
- Updated Projection plugin to use ProjectionCalculator
parent 34fdd30e
No related branches found
No related tags found
No related merge requests found
/target target/
workspace/
.settings/
setting.xml
.project .project
.classpath .classpath
*.prefs *.prefs
*.jardesc *.jardesc
*.jar *.jar
.settings/ \ No newline at end of file
\ No newline at end of file
...@@ -8,12 +8,12 @@ ...@@ -8,12 +8,12 @@
<parent> <parent>
<groupId>org.bioimageanalysis.icy</groupId> <groupId>org.bioimageanalysis.icy</groupId>
<artifactId>parent-pom-plugin</artifactId> <artifactId>parent-pom-plugin</artifactId>
<version>1.0.1</version> <version>1.0.4</version>
</parent> </parent>
<!-- Project Information --> <!-- Project Information -->
<artifactId>intensity-projection</artifactId> <artifactId>intensity-projection</artifactId>
<version>1.7.0-SNAPSHOT</version> <version>1.8.0-SNAPSHOT</version>
<packaging>jar</packaging> <packaging>jar</packaging>
...@@ -77,7 +77,6 @@ ...@@ -77,7 +77,6 @@
<dependency> <dependency>
<groupId>org.bioimageanalysis.icy</groupId> <groupId>org.bioimageanalysis.icy</groupId>
<artifactId>protocols</artifactId> <artifactId>protocols</artifactId>
<version>${protocols.version}</version>
</dependency> </dependency>
</dependencies> </dependencies>
......
package org.bioimageanalysis.icy.image.projection;
/**
* Indicates the direction on which the projection should be performed.
*
* @author Daniel Felipe Gonzalez Obando
*/
public enum ProjectionAxis
{
X("x"), Y("y"), Z("z"), T("t"), C("c");
private String name;
ProjectionAxis(String name)
{
this.name = name;
}
@Override
public String toString()
{
return name;
}
}
/**
*
*/
package org.bioimageanalysis.icy.image.projection;
/**
* Represents the operation to be applied when performing an intensity projection on a sequence.
*
* @author Daniel Felipe Gonzalez Obando
*/
public enum ProjectionOperationType
{
MAX("Maximum"), MEAN("Average"), MED("Median"), MIN("Minimum"), STD("Standard Deviation"), SATSUM("Saturated Sum");
private final String description;
ProjectionOperationType(String description)
{
this.description = description;
}
@Override
public String toString()
{
return description;
}
}
/**
*
*/
package org.bioimageanalysis.icy.image.projection.util;
/**
* A Progress event listener that handles events associating a value and a message to them.
*
* @author Daniel Felipe Gonzalez Obando
*/
public interface MessageProgressListener
{
/**
* A method handling progress events with a value and a message.
*
* @param progress
* The progress value from 0.0 to 1.0. {@link Double#NaN} value should be taken as no change and -1.0 as indeterminate progress.
* @param message
* The event message. A null value should be taken as no change on the message.
*/
void onProgress(double progress, String message);
}
package org.bioimageanalysis.icy.image.projection.util;
import java.util.concurrent.atomic.AtomicBoolean;
import icy.sequence.Sequence;
/**
* This class allows to optimally access randomly around a {@link Sequence}. Instances of this class can perform reading and writing operations on
* non-contiguous positions of the sequence without incurring in important performance issues. When a set of modifications to pixel data is performed a call to
* {@link #commitChanges()} must be made in order to make this changes permanent of the image and let other resources using the image be aware of to these
* changes.
*
* @author Daniel Felipe Gonzalez Obando
*/
public class SequenceCursor
{
private Sequence seq;
private VolumetricImageCursor[] volumeCursors;
private AtomicBoolean sequenceChanged;
/**
* Creates a cursor for the given sequence {@code seq}.
*/
public SequenceCursor(Sequence seq)
{
this.seq = seq;
this.volumeCursors = new VolumetricImageCursor[seq.getSizeT()];
this.sequenceChanged = new AtomicBoolean();
this.currentT = -1;
}
/**
* Retrieves the intensity of the channel {@code c} of the pixel located at position ({@code x}, {@code y}, {@code z}) at time {@code t}.
*
* @param x
* Position in the X-axis.
* @param y
* Position in the Y-axis.
* @param z
* Position in the Z-axis.
* @param t
* Time point index.
* @param c
* Channel index.
* @return Intensity value at specified position.
* @throws IndexOutOfBoundsException
* If the position is not in the image.
* @throws RuntimeException
* If the data type is not a valid format.
*/
public double get(int x, int y, int z, int t, int c) throws IndexOutOfBoundsException, RuntimeException
{
return getVolumeCursor(t).get(x, y, z, c);
}
/**
* Sets the intensity of the channel {@code c} of the pixel located at position ({@code x}, {@code y}, {@code z}) at time {@code t}.
*
* @param x
* Position in the X-axis.
* @param y
* Position in the Y-axis.
* @param z
* Position in the Z-axis.
* @param t
* Time point index.
* @param c
* Channel index.
* @param val
* Intensity value to set.
* @throws IndexOutOfBoundsException
* If the position is not in the image.
* @throws RuntimeException
* If the data type is not a valid format.
*/
public synchronized void set(int x, int y, int z, int t, int c, double val)
throws IndexOutOfBoundsException, RuntimeException
{
getVolumeCursor(t).set(x, y, z, c, val);
sequenceChanged.set(true);
}
/**
* Sets the intensity of the channel {@code c} of the pixel located at position ({@code x}, {@code y}, {@code z}) at time {@code t}. This method limits the
* value of the intensity according to the image data type value range.
*
* @param x
* Position in the X-axis.
* @param y
* Position in the Y-axis.
* @param z
* Position in the Z-axis.
* @param t
* Time point index.
* @param c
* Channel index.
* @param val
* Intensity value to set.
* @throws IndexOutOfBoundsException
* If the position is not in the image.
* @throws RuntimeException
* If the data type is not a valid format.
*/
public synchronized void setSafe(int x, int y, int z, int t, int c, double val)
throws IndexOutOfBoundsException, RuntimeException
{
getVolumeCursor(t).setSafe(x, y, z, c, val);
sequenceChanged.set(true);
}
private int currentT;
private VolumetricImageCursor currentCursor;
private synchronized VolumetricImageCursor getVolumeCursor(int t) throws IndexOutOfBoundsException
{
if (currentT != t)
{
if (volumeCursors[t] == null)
{
volumeCursors[t] = new VolumetricImageCursor(seq, t);
}
currentCursor = volumeCursors[t];
currentT = t;
}
return currentCursor;
}
/**
* This method should be called after a set of intensity changes have been made to the target sequence. This methods allows other resources using the target
* sequence to be informed about the changes made to it.
*/
public synchronized void commitChanges()
{
if (sequenceChanged.get())
{
for (int i = 0; i < volumeCursors.length; i++)
{
if (volumeCursors[i] != null)
volumeCursors[i].commitChanges();
}
sequenceChanged.set(false);
}
}
@Override
public String toString()
{
return "last T=" + currentT + " " + currentCursor != null ? currentCursor.toString() : "";
}
}
package org.bioimageanalysis.icy.image.projection.util;
import java.util.concurrent.atomic.AtomicBoolean;
import icy.image.IcyBufferedImageCursor;
import icy.sequence.Sequence;
import icy.sequence.VolumetricImage;
/**
* This class allows to optimally access randomly around an {@link VolumetricImage}. Instances of this class can perform reading and writing operations on
* non-contiguous positions of the volume without incurring in important performance issues. When a set of modifications to pixel data is performed a call to
* {@link #commitChanges()} must be made in order to make this changes permanent of the image and let other resources using the image be aware of to these
* changes.
*
* @author Daniel Felipe Gonzalez Obando
*/
public class VolumetricImageCursor
{
private VolumetricImage vol;
private AtomicBoolean volumeChanged;
private IcyBufferedImageCursor[] planeCursors;
/**
* Creates a cursor on the given volume {@code vol}.
*
* @param vol
* Target volume.
*/
public VolumetricImageCursor(VolumetricImage vol)
{
this.vol = vol;
planeCursors = new IcyBufferedImageCursor[vol.getSize()];
volumeChanged = new AtomicBoolean(false);
currentZ = -1;
}
/**
* Creates a cursor on the volume at time position {@code t} in the given sequence {@code seq}.
*
* @param seq
* Target sequence.
* @param t
* Time position where the volume is located in {@code seq}.
*/
public VolumetricImageCursor(Sequence seq, int t)
{
this(seq.getVolumetricImage(t));
}
/**
* Retrieves the intensity of the channel {@code c} of the pixel located at position ({@code x}, {@code y}, {@code z}).
*
* @param x
* Position in the X-axis.
* @param y
* Position in the Y-axis.
* @param z
* Position in the Z-axis.
* @param c
* Channel index.
* @return Intensity value at specified position.
* @throws IndexOutOfBoundsException
* If the position is not in the image.
* @throws RuntimeException
* If the data type is not a valid format.
*/
public double get(int x, int y, int z, int c) throws IndexOutOfBoundsException, RuntimeException
{
return getPlaneCursor(z).get(x, y, c);
}
/**
* Sets the intensity of the channel {@code c} of the pixel located at position ({@code x}, {@code y}, {@code z}).
*
* @param x
* Position in the X-axis.
* @param y
* Position in the Y-axis.
* @param z
* Position in the Z-axis.
* @param c
* Channel index.
* @param val
* Intensity value to set.
* @throws IndexOutOfBoundsException
* If the position is not in the image.
* @throws RuntimeException
* If the data type is not a valid format.
*/
public synchronized void set(int x, int y, int z, int c, double val)
throws IndexOutOfBoundsException, RuntimeException
{
getPlaneCursor(z).set(x, y, c, val);
volumeChanged.set(true);
}
/**
* Sets the intensity of the channel {@code c} of the pixel located at position ({@code x}, {@code y}, {@code z}). This method limits the
* value of the intensity according to the image data type value range.
*
* @param x
* Position in the X-axis.
* @param y
* Position in the Y-axis.
* @param z
* Position in the Z-axis.
* @param c
* Channel index.
* @param val
* Intensity value to set.
* @throws IndexOutOfBoundsException
* If the position is not in the image.
* @throws RuntimeException
* If the data type is not a valid format.
*/
public synchronized void setSafe(int x, int y, int z, int c, double val)
throws IndexOutOfBoundsException, RuntimeException
{
getPlaneCursor(z).setSafe(x, y, c, val);
volumeChanged.set(true);
}
private IcyBufferedImageCursor currentCursor;
private int currentZ;
private synchronized IcyBufferedImageCursor getPlaneCursor(int z) throws IndexOutOfBoundsException
{
if (currentZ != z)
{
if (planeCursors[z] == null)
{
planeCursors[z] = new IcyBufferedImageCursor(vol.getImage(z));
}
currentCursor = planeCursors[z];
currentZ = z;
}
return currentCursor;
}
/**
* This method should be called after a set of intensity changes have been made to the target volume. This methods allows other resources using the target
* volume to be informed about the changes made to it.
*/
public synchronized void commitChanges()
{
if (volumeChanged.get())
{
for (int i = 0; i < planeCursors.length; i++)
{
if (planeCursors[i] != null)
planeCursors[i].commitChanges();
}
volumeChanged.set(false);
}
}
@Override
public String toString()
{
return "last Z=" + currentZ + " " + currentCursor != null ? currentCursor.toString() : "";
}
}
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment