From fa93944386ff066765f476d41c037945d96d6152 Mon Sep 17 00:00:00 2001 From: Matthew Webster <mwebster@fmrib.ox.ac.uk> Date: Mon, 11 Jun 2007 09:58:04 +0000 Subject: [PATCH] whirlgif --- fslanimate | 8 ++++---- fslstats.cc | 17 +++++++++++++++-- sliceanimate | 12 ++++++------ 3 files changed, 25 insertions(+), 12 deletions(-) diff --git a/fslanimate b/fslanimate index e20827e..2af213a 100755 --- a/fslanimate +++ b/fslanimate @@ -56,12 +56,12 @@ $FSLDIR/bin/avwsplit $im for fnm in `$FSLDIR/bin/imglob vol*` ; do num=`$FSLDIR/bin/remove_ext $fnm | sed 's/vol//'`; export num; echo $num; - $FSLDIR/bin/slicer $fnm -s 2 -a ${iout}_$num.pgm - ${FSLCONVERT} ${iout}_$num.pgm ${iout}_$num.gif - rm -f ${iout}_$num.pgm + $FSLDIR/bin/slicer $fnm -s 2 -a ${iout}_$num.png + ${FSLDIR}/bin/pngappend ${iout}_$num.png ${iout}_$num.gif + rm -f ${iout}_$num.png done -$FSLDIR/bin/gifmerge -15 -l0 ${iout}_*.gif > ${iout}.gif +$FSLDIR/bin/whirlgif -o ${iout}.gif -time 15 -loop 0 ${iout}_*.gif mv $tmpdir/${iout}.gif ${imoutdir}/${iout}.gif diff --git a/fslstats.cc b/fslstats.cc index dc25d87..d8cc418 100644 --- a/fslstats.cc +++ b/fslstats.cc @@ -20,6 +20,12 @@ 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: avwstats++ <input> [options]" << endl << endl; cout << endl; @@ -43,6 +49,7 @@ void print_usage(const string& progname) { cout << "-p <n> : output nth percentile (n between 0 and 100)" << endl; cout << "-P <n> : output nth percentile (for nonzero voxels)" << endl; cout << "-a : use absolute values of all image intensities"<< endl; + cout << "-n : treat NaN or Inf as zero for subsequent stats" << endl; cout << "-k <mask> : use the specified image (filename) for masking - overrides lower and upper thresholds" << endl; cout << "-h <nbins> : output a histogram (for the thresholded/masked voxels only) with nbins" << endl; cout << "-H <nbins> <min> <max> : output a histogram (for the thresholded/masked voxels only) with nbins and histogram limits of min and max" << endl; @@ -160,8 +167,14 @@ int fmrib_main_float(int argc, char* argv[]) while (narg<argc) { sarg=argv[narg]; - - if (sarg=="-m") { + if (sarg=="-n") { + for (int t=vol.mint(); t<=vol.maxt(); t++) + 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))) + vol(x,y,z,t)=0; + } else if (sarg=="-m") { if (masks_used) cout << vol.mean(mask) << " "; else cout << vol.mean() << " "; } else if (sarg=="-M") { diff --git a/sliceanimate b/sliceanimate index 3d14a4f..269b13d 100755 --- a/sliceanimate +++ b/sliceanimate @@ -2,9 +2,9 @@ # sliceanimate - make animated gif of a volume, slice at a time # -# Stephen Smith and Mark Jenkinson, FMRIB Image Analysis Group +# Stephen Smith, Mark Jenkinson and Matthew Webster FMRIB Image Analysis Group # -# Copyright (C) 1999-2004 University of Oxford +# Copyright (C) 1999-2007 University of Oxford # # SHCOPYRIGHT @@ -25,16 +25,16 @@ tmpdir=/tmp while [ $n -lt $nn ] ; do # echo $FSLDIR/bin/slicer $volname $@ -z -$n $tmpdir/${tmpnam} - $FSLDIR/bin/slicer $volname $@ -z -$n $tmpdir/${tmpnam} + $FSLDIR/bin/slicer $volname $@ -z -$n $tmpdir/${tmpnam}.png snum=`echo "0000${n}" | sed 's/^.*\(....\)$/\1/'`; echo slice $snum - ${FSLCONVERT} $tmpdir/$tmpnam $tmpdir/${bnm}_slice${snum}.gif + ${FSLDIR}/bin/pngappend $tmpdir/${tmpnam}.png $tmpdir/${bnm}_slice${snum}.gif n=`echo $n + 1 | bc`; done -rm -f $tmpdir/${tmpnam} +rm -f $tmpdir/${tmpnam}.png -$FSLDIR/bin/gifmerge -l1000 -35 $tmpdir/${bnm}_slice*.gif > ${volname}_sliceanim.gif +$FSLDIR/bin/whirlgif -o ${volname}_sliceanim.gif -time 35 -loop 0 $tmpdir/${bnm}_slice*.gif rm -f $tmpdir/${bnm}_slice*.gif -- GitLab