Commit 1f8d60eb authored by Stephane Dallongeville's avatar Stephane Dallongeville
Browse files

fixed possible NPE

parent 15f04320
......@@ -38,6 +38,7 @@ import icy.gui.util.GuiUtil;
import icy.math.ArrayMath;
import icy.plugin.interface_.PluginBundled;
import icy.preferences.XMLPreferences;
import icy.sequence.Sequence;
import icy.util.XLSUtil;
import jxl.write.WritableSheet;
import jxl.write.WritableWorkbook;
......@@ -299,8 +300,16 @@ public class DeformationProfiler extends PluginTrackManagerProcessor implements
private double[][] computeBoxWidth()
{
double[][] result = new double[trackPool.getTrackSegmentList().size()][trackPool.getDisplaySequence()
.getSizeT()];
final Sequence seq = trackPool.getDisplaySequence();
final int sizeT;
// FIX: better to use last detection time point in this case
if (seq == null)
sizeT = trackPool.getLastDetectionTimePoint();
else
sizeT = seq.getSizeT();
double[][] result = new double[trackPool.getTrackSegmentList().size()][sizeT];
for (TrackSegment ts : trackPool.getTrackSegmentList())
{
......@@ -312,8 +321,7 @@ public class DeformationProfiler extends PluginTrackManagerProcessor implements
continue;
final Mesh3D contour = (Mesh3D) det;
double value = contour.toROI(ROIType.POLYGON, trackPool.getDisplaySequence()).getBounds5D().getSizeX()
* contour.pixelSize.x;
double value = contour.toROI(ROIType.POLYGON, seq).getBounds5D().getSizeX() * contour.pixelSize.x;
result[trackIndex][det.getT()] = value;
}
}
......@@ -323,8 +331,16 @@ public class DeformationProfiler extends PluginTrackManagerProcessor implements
private double[][] computeBoxHeight()
{
double[][] result = new double[trackPool.getTrackSegmentList().size()][trackPool.getDisplaySequence()
.getSizeT()];
final Sequence seq = trackPool.getDisplaySequence();
final int sizeT;
// FIX: better to use last detection time point in this case
if (seq == null)
sizeT = trackPool.getLastDetectionTimePoint();
else
sizeT = seq.getSizeT();
double[][] result = new double[trackPool.getTrackSegmentList().size()][sizeT];
for (TrackSegment ts : trackPool.getTrackSegmentList())
{
......@@ -336,8 +352,7 @@ public class DeformationProfiler extends PluginTrackManagerProcessor implements
continue;
final Mesh3D contour = (Mesh3D) det;
double value = contour.toROI(ROIType.POLYGON, trackPool.getDisplaySequence()).getBounds5D().getSizeY()
* contour.pixelSize.y;
double value = contour.toROI(ROIType.POLYGON, seq).getBounds5D().getSizeY() * contour.pixelSize.y;
result[trackIndex][det.getT()] = value;
}
}
......@@ -347,8 +362,16 @@ public class DeformationProfiler extends PluginTrackManagerProcessor implements
private double[][] computeBoxDepth()
{
double[][] result = new double[trackPool.getTrackSegmentList().size()][trackPool.getDisplaySequence()
.getSizeT()];
final Sequence seq = trackPool.getDisplaySequence();
final int sizeT;
// FIX: better to use last detection time point in this case
if (seq == null)
sizeT = trackPool.getLastDetectionTimePoint();
else
sizeT = seq.getSizeT();
double[][] result = new double[trackPool.getTrackSegmentList().size()][sizeT];
for (TrackSegment ts : trackPool.getTrackSegmentList())
{
......@@ -360,8 +383,7 @@ public class DeformationProfiler extends PluginTrackManagerProcessor implements
continue;
final Mesh3D contour = (Mesh3D) det;
double value = contour.toROI(ROIType.POLYGON, trackPool.getDisplaySequence()).getBounds5D().getSizeZ()
* contour.pixelSize.z;
double value = contour.toROI(ROIType.POLYGON, seq).getBounds5D().getSizeZ() * contour.pixelSize.z;
result[trackIndex][det.getT()] = value;
}
}
......@@ -459,8 +481,17 @@ public class DeformationProfiler extends PluginTrackManagerProcessor implements
XLSUtil.setCellString(sheet, 0, 0, "Track \\ Time");
final Sequence seq = trackPool.getDisplaySequence();
final int sizeT;
// FIX: better to use last detection time point in this case
if (seq == null)
sizeT = trackPool.getLastDetectionTimePoint();
else
sizeT = seq.getSizeT();
// time labels
for (int t = 0; t < trackPool.getDisplaySequence().getSizeT(); t++)
for (int t = 0; t < sizeT; t++)
XLSUtil.setCellNumber(sheet, t + 1, 0, t * tScale);
// indexes + data
......@@ -483,8 +514,16 @@ public class DeformationProfiler extends PluginTrackManagerProcessor implements
*/
private double[][] computeConvexity()
{
double[][] result = new double[trackPool.getTrackSegmentList().size()][trackPool.getDisplaySequence()
.getSizeT()];
final Sequence seq = trackPool.getDisplaySequence();
final int sizeT;
// FIX: better to use last detection time point in this case
if (seq == null)
sizeT = trackPool.getLastDetectionTimePoint();
else
sizeT = seq.getSizeT();
double[][] result = new double[trackPool.getTrackSegmentList().size()][sizeT];
for (TrackSegment ts : trackPool.getTrackSegmentList())
{
......@@ -537,8 +576,16 @@ public class DeformationProfiler extends PluginTrackManagerProcessor implements
private double[][] computeDimension(int order)
{
double[][] result = new double[trackPool.getTrackSegmentList().size()][trackPool.getDisplaySequence()
.getSizeT()];
final Sequence seq = trackPool.getDisplaySequence();
final int sizeT;
// FIX: better to use last detection time point in this case
if (seq == null)
sizeT = trackPool.getLastDetectionTimePoint();
else
sizeT = seq.getSizeT();
double[][] result = new double[trackPool.getTrackSegmentList().size()][sizeT];
for (TrackSegment ts : trackPool.getTrackSegmentList())
{
......@@ -559,8 +606,16 @@ public class DeformationProfiler extends PluginTrackManagerProcessor implements
private double[][] computeElongation()
{
double[][] result = new double[trackPool.getTrackSegmentList().size()][trackPool.getDisplaySequence()
.getSizeT()];
final Sequence seq = trackPool.getDisplaySequence();
final int sizeT;
// FIX: better to use last detection time point in this case
if (seq == null)
sizeT = trackPool.getLastDetectionTimePoint();
else
sizeT = seq.getSizeT();
double[][] result = new double[trackPool.getTrackSegmentList().size()][sizeT];
for (TrackSegment ts : trackPool.getTrackSegmentList())
{
......@@ -584,8 +639,16 @@ public class DeformationProfiler extends PluginTrackManagerProcessor implements
private double[][] computeFlatness()
{
double[][] result = new double[trackPool.getTrackSegmentList().size()][trackPool.getDisplaySequence()
.getSizeT()];
final Sequence seq = trackPool.getDisplaySequence();
final int sizeT;
// FIX: better to use last detection time point in this case
if (seq == null)
sizeT = trackPool.getLastDetectionTimePoint();
else
sizeT = seq.getSizeT();
double[][] result = new double[trackPool.getTrackSegmentList().size()][sizeT];
for (TrackSegment ts : trackPool.getTrackSegmentList())
{
......@@ -631,8 +694,16 @@ public class DeformationProfiler extends PluginTrackManagerProcessor implements
{
ExecutorService service = Executors.newCachedThreadPool();
final double[][] result = new double[trackPool.getTrackSegmentList().size()][trackPool.getDisplaySequence()
.getSizeT()];
final Sequence seq = trackPool.getDisplaySequence();
final int sizeT;
// FIX: better to use last detection time point in this case
if (seq == null)
sizeT = trackPool.getLastDetectionTimePoint();
else
sizeT = seq.getSizeT();
final double[][] result = new double[trackPool.getTrackSegmentList().size()][sizeT];
ArrayList<Future<?>> results = new ArrayList<Future<?>>();
......@@ -745,8 +816,16 @@ public class DeformationProfiler extends PluginTrackManagerProcessor implements
*/
private double[][] computeRoundness()
{
double[][] result = new double[trackPool.getTrackSegmentList().size()][trackPool.getDisplaySequence()
.getSizeT()];
final Sequence seq = trackPool.getDisplaySequence();
final int sizeT;
// FIX: better to use last detection time point in this case
if (seq == null)
sizeT = trackPool.getLastDetectionTimePoint();
else
sizeT = seq.getSizeT();
double[][] result = new double[trackPool.getTrackSegmentList().size()][sizeT];
for (TrackSegment ts : trackPool.getTrackSegmentList())
{
......@@ -791,8 +870,16 @@ public class DeformationProfiler extends PluginTrackManagerProcessor implements
*/
private double[][] computeSphericity()
{
double[][] result = new double[trackPool.getTrackSegmentList().size()][trackPool.getDisplaySequence()
.getSizeT()];
final Sequence seq = trackPool.getDisplaySequence();
final int sizeT;
// FIX: better to use last detection time point in this case
if (seq == null)
sizeT = trackPool.getLastDetectionTimePoint();
else
sizeT = seq.getSizeT();
double[][] result = new double[trackPool.getTrackSegmentList().size()][sizeT];
for (TrackSegment ts : trackPool.getTrackSegmentList())
{
......
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