Skip to content

Commit

Permalink
Ignore NaNs in images when computing intensity-related features.
Browse files Browse the repository at this point in the history
Fix #258
  • Loading branch information
tinevez committed Jul 6, 2023
1 parent 90544a7 commit 8b63ac5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,12 @@ public final void process( final Spot spot )
final IterableInterval< T > neighborhood = SpotUtil.iterable( outterRoi, spot, img );
double outterSum = 0.;
for ( final T t : neighborhood )
outterSum += t.getRealDouble();
{
final double val = t.getRealDouble();
if ( Double.isNaN( val ) )
continue;
outterSum += val;
}

final String sumFeature = makeFeatureKey( TOTAL_INTENSITY, channel );
final double innterSum = spot.getFeature( sumFeature );
Expand Down Expand Up @@ -143,7 +148,10 @@ public final void process( final Spot spot )
if ( dist2 > radius2 )
{
nOut++;
sumOut += cursor.get().getRealDouble();
final double val = cursor.get().getRealDouble();
if ( Double.isNaN( val ) )
continue;
sumOut += val;
}
}
meanOut = sumOut / nOut;
Expand All @@ -159,3 +167,4 @@ public final void process( final Spot spot )
spot.putFeature( makeFeatureKey( SNR, channel ), snr );
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,12 @@ public void process( final Spot spot )
final DoubleArray intensities = new DoubleArray();

for ( final T pixel : neighborhood )
intensities.addValue( pixel.getRealDouble() );
{
final double val = pixel.getRealDouble();
if ( Double.isNaN( val ) )
continue;
intensities.addValue( val );
}

Util.quicksort( intensities.getArray(), 0, intensities.size() - 1 );
spot.putFeature( SpotIntensityMultiCAnalyzerFactory.makeFeatureKey( MEAN_INTENSITY, channel ), Double.valueOf( TMUtils.average( intensities ) ) );
Expand Down

0 comments on commit 8b63ac5

Please sign in to comment.