diff --git a/fslstats.cc b/fslstats.cc
index 12eb3f964e5e51e3f32fc1aab1508152d5dbfe1d..740afb57fa0c6d268b3378ad6f891db0551729ea 100644
--- a/fslstats.cc
+++ b/fslstats.cc
@@ -9,6 +9,8 @@
 #include "miscmaths/miscmaths.h"
 #include "newimage/newimageall.h"
 #include "newimage/costfns.h"
+#include "utils/fsl_isfinite.h"
+
 
 using namespace NEWIMAGE;
 using namespace MISCMATHS;
@@ -17,12 +19,6 @@ bool masks_used=false;
 bool lthr_used=false;
 bool uthr_used=false;
 
-#if defined ( __CYGWIN__ ) ||  defined (__sun)
-extern "C" { 
-#include <ieeefp.h> //for finite
-}
-#endif
-
 void print_usage(const string& progname) {
   cout << "Usage: fslstats <input> [options]" << endl << endl;
   cout << endl;
@@ -171,7 +167,7 @@ int fmrib_main_float(int argc, char* argv[])
         for (int z=vol.minz(); z<=vol.maxz(); z++)
           for (int y=vol.miny(); y<=vol.maxy(); y++)
             for (int x=vol.minx(); x<=vol.maxx(); x++)
-              if (!finite((double)vol(x,y,z,t)))
+              if (!isfinite((double)vol(x,y,z,t)))
 	        vol(x,y,z,t)=0;
     } else if (sarg=="-m") {
       if (masks_used) cout <<  vol.mean(mask) << " ";