Skip to content
Snippets Groups Projects
Commit 99021566 authored by Stéphane  DALLONGEVILLE's avatar Stéphane DALLONGEVILLE
Browse files

Updated for Icy kernel 2.4.0 (interruptible process)

parent 89eb56df
No related branches found
No related tags found
No related merge requests found
......@@ -11,7 +11,7 @@
</parent>
<artifactId>protocols</artifactId>
<version>3.2.1</version>
<version>3.2.2</version>
<packaging>jar</packaging>
......
......@@ -5,28 +5,44 @@ import icy.plugin.abstract_.Plugin;
import plugins.adufour.blocks.util.VarList;
import plugins.adufour.vars.lang.VarImagePlus;
import plugins.adufour.vars.lang.VarSequence;
import plugins.adufour.vars.util.VarException;
public class ImagePlusToSequence extends Plugin implements IJBlock
{
VarImagePlus vip = new VarImagePlus("IJ ImagePlus", null);
VarSequence vs = new VarSequence("Icy Sequence", null);
VarSequence vs = new VarSequence("Icy Sequence", null);
@Override
public void run()
{
vs.setValue(ImageJUtil.convertToIcySequence(vip.getValue(true), null));
try
{
vs.setValue(ImageJUtil.convertToIcySequence(vip.getValue(true), null));
}
catch (IllegalAccessError e)
{
throw new VarException(vip, e.getMessage());
}
catch (VarException e)
{
throw e;
}
catch (InterruptedException e)
{
Thread.currentThread().interrupt();
}
}
@Override
public void declareInput(VarList inputMap)
{
inputMap.add("IJ ImagePlus", vip);
}
@Override
public void declareOutput(VarList outputMap)
{
outputMap.add("Icy Sequence", vs);
}
}
......@@ -5,6 +5,7 @@ import icy.plugin.abstract_.Plugin;
import plugins.adufour.blocks.util.VarList;
import plugins.adufour.vars.lang.VarImagePlus;
import plugins.adufour.vars.lang.VarSequence;
import plugins.adufour.vars.util.VarException;
public class SequenceToImagePlus extends Plugin implements IJBlock
{
......@@ -14,7 +15,22 @@ public class SequenceToImagePlus extends Plugin implements IJBlock
@Override
public void run()
{
vip.setValue(ImageJUtil.convertToImageJImage(vs.getValue(true), null));
try
{
vip.setValue(ImageJUtil.convertToImageJImage(vs.getValue(true), null));
}
catch (IllegalAccessError e)
{
throw new VarException(vs, e.getMessage());
}
catch (VarException e)
{
throw e;
}
catch (InterruptedException e)
{
Thread.currentThread().interrupt();
}
}
@Override
......
......@@ -24,16 +24,23 @@ public class DilateROI extends MorphROI
@Override
public void run()
{
switch (unit.getValue())
try
{
case PIXELS:
roiOUT.setValue(dilateROI(roiIN.getValue(), x.getValue(), y.getValue(), z.getValue()));
break;
case PERCENTAGE:
roiOUT.setValue(dilateROIByPercentage(roiIN.getValue(), x.getValue(), y.getValue(), z.getValue()));
break;
default:
throw new VarException(unit, "Unsupported unit");
switch (unit.getValue())
{
case PIXELS:
roiOUT.setValue(dilateROI(roiIN.getValue(), x.getValue(), y.getValue(), z.getValue()));
break;
case PERCENTAGE:
roiOUT.setValue(dilateROIByPercentage(roiIN.getValue(), x.getValue(), y.getValue(), z.getValue()));
break;
default:
throw new VarException(unit, "Unsupported unit");
}
}
catch (InterruptedException e)
{
Thread.currentThread().interrupt();
}
}
......@@ -50,8 +57,9 @@ public class DilateROI extends MorphROI
* @param zRadius
* the radius (in pixels) along Z (not used if <code>roi</code> is 2D)
* @return a new set of dilated ROI of type "area"
* @throws InterruptedException
*/
public static ROI[] dilateROI(ROI[] inputRoi, int xRadius, int yRadius, int zRadius)
public static ROI[] dilateROI(ROI[] inputRoi, int xRadius, int yRadius, int zRadius) throws InterruptedException
{
ArrayList<ROI> out = new ArrayList<ROI>(inputRoi.length);
......@@ -81,8 +89,9 @@ public class DilateROI extends MorphROI
* @param zPct
* the percentage (from 0 to 100) to dilate along Z (not used in 2D)
* @return a new set of dilated ROI of type "area"
* @throws InterruptedException
*/
public static ROI[] dilateROIByPercentage(ROI[] inputRoi, int xPct, int yPct, int zPct)
public static ROI[] dilateROIByPercentage(ROI[] inputRoi, int xPct, int yPct, int zPct) throws InterruptedException
{
ArrayList<ROI> out = new ArrayList<ROI>(inputRoi.length);
......@@ -113,8 +122,9 @@ public class DilateROI extends MorphROI
* @param zPct
* the percentage (from 0 to 100) to dilate along Z (not used in 2D)
* @return a new, dilated ROI of type "area"
* @throws InterruptedException
*/
public static ROI dilateROIByPercentage(ROI roi, int xPct, int yPct, int zPct)
public static ROI dilateROIByPercentage(ROI roi, int xPct, int yPct, int zPct) throws InterruptedException
{
int xRadius = percentageToRadiusX(roi, xPct);
int yRadius = percentageToRadiusY(roi, yPct);
......@@ -135,8 +145,9 @@ public class DilateROI extends MorphROI
* @param zRadius
* the radius in pixels along Z (not used if <code>roi</code> is 2D)
* @return a new, dilated ROI of type "area"
* @throws InterruptedException
*/
public static ROI dilateROI(ROI roi, int xRadius, int yRadius, int zRadius)
public static ROI dilateROI(ROI roi, int xRadius, int yRadius, int zRadius) throws InterruptedException
{
int rx = xRadius, rrx = rx * rx;
int ry = yRadius, rry = ry * ry;
......
......@@ -24,16 +24,23 @@ public class ErodeROI extends MorphROI
@Override
public void run()
{
switch (unit.getValue())
try
{
case PIXELS:
roiOUT.setValue(erodeROI(roiIN.getValue(), x.getValue(), y.getValue(), z.getValue()));
break;
case PERCENTAGE:
roiOUT.setValue(erodeROIByPercentage(roiIN.getValue(), x.getValue(), y.getValue(), z.getValue()));
break;
default:
throw new VarException(unit, "Unsupported unit");
switch (unit.getValue())
{
case PIXELS:
roiOUT.setValue(erodeROI(roiIN.getValue(), x.getValue(), y.getValue(), z.getValue()));
break;
case PERCENTAGE:
roiOUT.setValue(erodeROIByPercentage(roiIN.getValue(), x.getValue(), y.getValue(), z.getValue()));
break;
default:
throw new VarException(unit, "Unsupported unit");
}
}
catch (InterruptedException e)
{
Thread.currentThread().interrupt();
}
}
......@@ -50,8 +57,9 @@ public class ErodeROI extends MorphROI
* @param zRadius
* the radius (in pixels) along Z (not used if <code>roi</code> is 2D)
* @return a new set of eroded ROI of type "area"
* @throws InterruptedException
*/
public static ROI[] erodeROI(ROI[] inputRoi, int xRadius, int yRadius, int zRadius)
public static ROI[] erodeROI(ROI[] inputRoi, int xRadius, int yRadius, int zRadius) throws InterruptedException
{
ArrayList<ROI> out = new ArrayList<ROI>(inputRoi.length);
......@@ -81,8 +89,9 @@ public class ErodeROI extends MorphROI
* @param zPct
* the percentage (from 0 to 100) to erode along Z (not used in 2D)
* @return a new set of eroded ROI of type "area"
* @throws InterruptedException
*/
public static ROI[] erodeROIByPercentage(ROI[] inputRoi, int xPct, int yPct, int zPct)
public static ROI[] erodeROIByPercentage(ROI[] inputRoi, int xPct, int yPct, int zPct) throws InterruptedException
{
ArrayList<ROI> out = new ArrayList<ROI>(inputRoi.length);
......@@ -113,8 +122,9 @@ public class ErodeROI extends MorphROI
* @param zPct
* the percentage (from 0 to 100) to dilate along Z (not used in 2D)
* @return a new, dilated ROI of type "area"
* @throws InterruptedException
*/
public static ROI erodeROIByPercentage(ROI roi, int xPct, int yPct, int zPct)
public static ROI erodeROIByPercentage(ROI roi, int xPct, int yPct, int zPct) throws InterruptedException
{
int xRadius = percentageToRadiusX(roi, xPct);
int yRadius = percentageToRadiusY(roi, yPct);
......@@ -135,8 +145,9 @@ public class ErodeROI extends MorphROI
* @param zRadius
* the radius in pixels along Z (not used if <code>roi</code> is 2D)
* @return a new, eroded ROI of type "area"
* @throws InterruptedException
*/
public static ROI erodeROI(ROI roi, int xRadius, int yRadius, int zRadius)
public static ROI erodeROI(ROI roi, int xRadius, int yRadius, int zRadius) throws InterruptedException
{
// The basis of this erosion operator is to remove all pixels within a distance of "radius"
// from the border. Since we have easy access to the contour points of the ROI, we will
......
......@@ -14,34 +14,40 @@ import plugins.adufour.vars.lang.VarROIArray;
public class MergeROI extends Plugin implements ROIBlock
{
VarEnum<BooleanOperator> operation = new VarEnum<BooleanOperator>("Merge operation", BooleanOperator.AND);
VarROIArray roiIn = new VarROIArray("List of ROI");
VarROIArray roiOut = new VarROIArray("Merged ROI");
VarROIArray roiIn = new VarROIArray("List of ROI");
VarROIArray roiOut = new VarROIArray("Merged ROI");
@Override
public void run()
{
roiOut.setValue(new ROI[0]);
List<ROI> rois = Arrays.asList(roiIn.getValue());
ROI merge = ROIUtil.merge(rois, operation.getValue());
if (merge != null) roiOut.add(merge);
try
{
List<ROI> rois = Arrays.asList(roiIn.getValue());
ROI merge = ROIUtil.merge(rois, operation.getValue());
if (merge != null)
roiOut.add(merge);
}
catch (InterruptedException e)
{
Thread.currentThread().interrupt();
}
}
@Override
public void declareInput(VarList inputMap)
{
inputMap.add("List of ROI", roiIn);
inputMap.add("Merge operation", operation);
}
@Override
public void declareOutput(VarList outputMap)
{
outputMap.add("Merged ROI", roiOut);
}
}
......@@ -18,7 +18,14 @@ public class SubtractROI extends Plugin implements ROIBlock
@Override
public void run()
{
roiOut.setValue(subtractROI(roiA.getValue(true), roiB.getValue(true)));
try
{
roiOut.setValue(subtractROI(roiA.getValue(true), roiB.getValue(true)));
}
catch (InterruptedException e)
{
Thread.currentThread().interrupt();
}
}
@Override
......@@ -42,8 +49,10 @@ public class SubtractROI extends Plugin implements ROIBlock
* @param roiB
* ROIs subtracted from the first group of ROIs.
* @return A - B. The group of ROIs resulting from the subtraction from the each element of the group A and each element of the group B.
* @throws InterruptedException
* @throws UnsupportedOperationException
*/
public static ROI[] subtractROI(ROI[] roiA, ROI[] roiB)
public static ROI[] subtractROI(ROI[] roiA, ROI[] roiB) throws UnsupportedOperationException, InterruptedException
{
ArrayList<ROI> out = new ArrayList<ROI>(roiA.length);
......
......@@ -44,11 +44,21 @@ public class SequenceScreenshot extends Plugin implements SequenceBlock
final Canvas2D canvas2D = canvas2DP[0];
for (int t = 0; t < time; t++)
for (int z = 0; z < depth; z++)
out.setImage(t, z, canvas2D.getRenderedImage(t, z, -1, false));
viewer.close();
try
{
for (int t = 0; t < time; t++)
for (int z = 0; z < depth; z++)
out.setImage(t, z, canvas2D.getRenderedImage(t, z, -1, false));
}
catch (InterruptedException e)
{
Thread.currentThread().interrupt();
return;
}
finally
{
viewer.close();
}
seqOut.setValue(out);
}
......
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