Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore NaNs in images when computing intensity-related features. #286

Merged
merged 1 commit into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading