Commit 68a3cb16 authored by Stéphane  DALLONGEVILLE's avatar Stéphane DALLONGEVILLE
Browse files

Updated for Icy kernel 2.4.0 (interruptible process)

parent 735c4326
......@@ -42,24 +42,31 @@ public class ROITo3DStack extends Plugin implements ROIBlock, PluginLibrary, Plu
final ROI[] rois = input.getValue();
final List<ROI> result = new ArrayList<ROI>();
if (rois != null)
try
{
final int maxZ = sizeZ.getValue().intValue() - 1;
if (maxZ < 0)
throw new VarException(sizeZ, "Size Z field should be > 0");
for (ROI roi : rois)
if (rois != null)
{
// only convert 2D roi
if (roi instanceof ROI2D)
result.add(ROIUtil.convertToStack((ROI2D) roi, 0, maxZ));
else
// otherwise we add them directly to the result
result.add(roi);
final int maxZ = sizeZ.getValue().intValue() - 1;
if (maxZ < 0)
throw new VarException(sizeZ, "Size Z field should be > 0");
for (ROI roi : rois)
{
// only convert 2D roi
if (roi instanceof ROI2D)
result.add(ROIUtil.convertToStack((ROI2D) roi, 0, maxZ));
else
// otherwise we add them directly to the result
result.add(roi);
}
}
}
output.setValue(result.toArray(new ROI[result.size()]));
output.setValue(result.toArray(new ROI[result.size()]));
}
catch (InterruptedException e)
{
Thread.currentThread().interrupt();
}
}
@Override
......
......@@ -38,16 +38,23 @@ public class ROIToMask extends Plugin implements ROIBlock, PluginLibrary, Plugin
@Override
public void run()
{
final ROI[] rois = input.getValue();
final List<ROI> result = new ArrayList<ROI>();
try
{
final ROI[] rois = input.getValue();
final List<ROI> result = new ArrayList<ROI>();
if (rois != null)
{
for (ROI roi : rois)
result.add(ROIUtil.convertToMask(roi));
}
if (rois != null)
output.setValue(result.toArray(new ROI[result.size()]));
}
catch (InterruptedException e)
{
for (ROI roi : rois)
result.add(ROIUtil.convertToMask(roi));
Thread.currentThread().interrupt();
}
output.setValue(result.toArray(new ROI[result.size()]));
}
@Override
......
......@@ -35,16 +35,23 @@ public class ROIToShape extends Plugin implements ROIBlock, PluginLibrary, Plugi
@Override
public void run()
{
final ROI[] rois = input.getValue();
final List<ROI> result = new ArrayList<ROI>();
try
{
final ROI[] rois = input.getValue();
final List<ROI> result = new ArrayList<ROI>();
if (rois != null)
{
for (ROI roi : rois)
result.add(ROIUtil.convertToShape(roi, -1));
}
if (rois != null)
output.setValue(result.toArray(new ROI[result.size()]));
}
catch (InterruptedException e)
{
for (ROI roi : rois)
result.add(ROIUtil.convertToShape(roi, -1));
Thread.currentThread().interrupt();
}
output.setValue(result.toArray(new ROI[result.size()]));
}
@Override
......
......@@ -14,6 +14,7 @@ import plugins.adufour.vars.lang.VarEnum;
import plugins.adufour.vars.lang.VarInteger;
import plugins.adufour.vars.lang.VarROIArray;
import plugins.adufour.vars.lang.VarSequence;
import plugins.adufour.vars.util.VarException;
import plugins.stef.roi.bloc.RoiBlocks;
/**
......@@ -78,10 +79,18 @@ public class RoiToSequence extends Plugin implements ROIBlock, PluginLibrary, Pl
@Override
public void run()
{
varOut.setValue(
ROIUtil.convertToSequence(CollectionUtil.asList(inputROI.getValue()), sizeX.getValue().intValue(),
sizeY.getValue().intValue(), sizeC.getValue().intValue(), sizeZ.getValue().intValue(),
sizeT.getValue().intValue(), dataType.getValue(), labeled.getValue().booleanValue()));
try
{
varOut.setValue(
ROIUtil.convertToSequence(CollectionUtil.asList(inputROI.getValue()), sizeX.getValue().intValue(),
sizeY.getValue().intValue(), sizeC.getValue().intValue(), sizeZ.getValue().intValue(),
sizeT.getValue().intValue(), dataType.getValue(), labeled.getValue().booleanValue()));
}
catch (InterruptedException e)
{
// ignore
throw new VarException(varOut, e.getMessage());
}
}
@Override
......
......@@ -34,10 +34,17 @@ public class BooleanOperationROI extends Plugin implements ROIBlock, PluginLibra
@Override
public void run()
{
final List<ROI> result = doBooleanOperation(CollectionUtil.asList(roiSet1.getValue()),
CollectionUtil.asList(roiSet2.getValue()), op.getValue());
try
{
final List<ROI> result = doBooleanOperation(CollectionUtil.asList(roiSet1.getValue()),
CollectionUtil.asList(roiSet2.getValue()), op.getValue());
output.setValue(result.toArray(new ROI[result.size()]));
output.setValue(result.toArray(new ROI[result.size()]));
}
catch (InterruptedException e)
{
Thread.currentThread().interrupt();
}
}
@Override
......@@ -70,8 +77,11 @@ public class BooleanOperationROI extends Plugin implements ROIBlock, PluginLibra
* @param op
* boolean operation to apply
* @return result ROIs from the given boolean operation between the 2 sets of ROI
* @throws InterruptedException
* @throws UnsupportedOperationException
*/
public static List<ROI> doBooleanOperation(Collection<ROI> roiSetA, Collection<ROI> roiSetB, BooleanOperator op)
throws UnsupportedOperationException, InterruptedException
{
final List<ROI> result = new ArrayList<ROI>();
......
......@@ -3,14 +3,13 @@
*/
package plugins.stef.roi.bloc.op;
import java.util.ArrayList;
import java.util.List;
import icy.plugin.abstract_.Plugin;
import icy.plugin.interface_.PluginBundled;
import icy.plugin.interface_.PluginLibrary;
import icy.roi.ROI;
import java.util.ArrayList;
import java.util.List;
import plugins.adufour.blocks.tools.roi.ROIBlock;
import plugins.adufour.blocks.util.VarList;
import plugins.adufour.vars.lang.VarBoolean;
......@@ -39,20 +38,27 @@ public class FilterROIBySize extends Plugin implements ROIBlock, PluginLibrary,
final double max = maximumSize.getValue().doubleValue();
final boolean border = incBorder.getValue().booleanValue();
for (ROI roi : roiSet)
try
{
if (roi != null)
for (ROI roi : roiSet)
{
double num = roi.getNumberOfPoints();
if (border)
num += roi.getNumberOfContourPoints();
if (roi != null)
{
double num = roi.getNumberOfPoints();
if (border)
num += roi.getNumberOfContourPoints();
if ((num >= min) && (num <= max))
result.add(roi);
if ((num >= min) && (num <= max))
result.add(roi);
}
}
}
output.setValue(result.toArray(new ROI[result.size()]));
output.setValue(result.toArray(new ROI[result.size()]));
}
catch (InterruptedException e)
{
Thread.currentThread().interrupt();
}
}
@Override
......
......@@ -48,10 +48,17 @@ public class LogicalOperationROI extends Plugin implements ROIBlock, PluginLibra
@Override
public void run()
{
final List<ROI> result = doLogicalOperation(CollectionUtil.asList(roiSetA.getValue()),
CollectionUtil.asList(roiSetB.getValue()), op.getValue(), copyRois.getValue());
try
{
final List<ROI> result = doLogicalOperation(CollectionUtil.asList(roiSetA.getValue()),
CollectionUtil.asList(roiSetB.getValue()), op.getValue(), copyRois.getValue());
output.setValue(result.toArray(new ROI[result.size()]));
output.setValue(result.toArray(new ROI[result.size()]));
}
catch (InterruptedException e)
{
Thread.currentThread().interrupt();
}
}
@Override
......@@ -87,9 +94,10 @@ public class LogicalOperationROI extends Plugin implements ROIBlock, PluginLibra
* @param copyRois
* perform a copy of originals ROIs (so they are never modified)
* @return result ROIs from the given logical operation between the 2 sets of ROI
* @throws InterruptedException
*/
public static List<ROI> doLogicalOperation(Collection<ROI> roiSetA, Collection<ROI> roiSetB, LogicOperator logicOp,
boolean copyRois)
boolean copyRois) throws InterruptedException
{
final List<ROI> result = new ArrayList<ROI>();
final Map<ROI, SoftReference<BooleanMask2D>> masks2d = new HashMap<>();
......
......@@ -50,10 +50,18 @@ public class MoveROIToSequence extends Plugin implements ROIBlock, PluginLibrary
final boolean t = translate.getValue().booleanValue();
final boolean s = scale.getValue().booleanValue();
for (int r = 0; r < rois.length; r++)
result[r] = ROIUtil.adjustToSequence(rois[r], srcSeq, dstSeq, t, s);
try
{
for (int r = 0; r < rois.length; r++)
result[r] = ROIUtil.adjustToSequence(rois[r], srcSeq, dstSeq, t, s);
roiResultSet.setValue(result);
}
catch (InterruptedException e)
{
Thread.currentThread().interrupt();
}
roiResultSet.setValue(result);
}
@Override
......
......@@ -39,32 +39,39 @@ public class Scale2xROI extends Plugin implements ROIBlock, PluginLibrary, Plugi
final int f = factor.getValue().intValue();
final boolean sz = scaleZ.getValue().booleanValue();
if (rois != null)
try
{
for (ROI roi : rois)
if (rois != null)
{
if (roi != null)
for (ROI roi : rois)
{
ROI r = roi;
// number of iteration needed
int it = Math.abs(f);
// duplicate it as we expect a new ROI here
if (it == 0)
r = r.getCopy();
else
if (roi != null)
{
// scale
while (it-- > 0)
r = ROIUtil.get2XScaled(r, sz, f < 0);
}
ROI r = roi;
// number of iteration needed
int it = Math.abs(f);
result.add(r);
// duplicate it as we expect a new ROI here
if (it == 0)
r = r.getCopy();
else
{
// scale
while (it-- > 0)
r = ROIUtil.get2XScaled(r, sz, f < 0);
}
result.add(r);
}
}
}
}
output.setValue(result.toArray(new ROI[result.size()]));
output.setValue(result.toArray(new ROI[result.size()]));
}
catch (InterruptedException e)
{
Thread.currentThread().interrupt();
}
}
@Override
......
......@@ -38,15 +38,22 @@ public class SeparateROIComponents extends Plugin implements ROIBlock, PluginLib
final ROI[] rois = input.getValue();
final List<ROI> result = new ArrayList<ROI>();
if (rois != null)
try
{
for (ROI roi : rois)
for (ROI comp : ROIUtil.getConnectedComponents(roi))
if (comp != null)
result.add(comp);
}
if (rois != null)
{
for (ROI roi : rois)
for (ROI comp : ROIUtil.getConnectedComponents(roi))
if (comp != null)
result.add(comp);
}
output.setValue(result.toArray(new ROI[result.size()]));
output.setValue(result.toArray(new ROI[result.size()]));
}
catch (InterruptedException e)
{
Thread.currentThread().interrupt();
}
}
@Override
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment