I decided that since I need to determine remainders on hundreds of
files, I would modify avwmaths myself. I attach diff output, in case
it's of any use.
Regards
Rolf
On Fri, Feb 23, 2007 at 03:46:24PM +0000, Steve Smith wrote:
> Hi - I would use avwmaths++
> Given that you can force the output datatype to be int with "-odt
> int", it should be straightforward to do this with a few simple calls
> to avwmaths++
> Cheers, Steve.
>
>
> On 23 Feb 2007, at 15:30, Rolf Heckemann wrote:
>
> >I'm looking for a way to obtain the remainder of a division in
> >avwmaths, ideally like this:
> >
> >avwmaths elevens -mod tens ones
> >
> >Is there a way to obtain this result using the current version?
> >Alternatively, could I request this as a feature for avwmaths?
> >
> >Thanks
> >
> >Rolf Heckemann
>
>
> ------------------------------------------------------------------------
> ---
> Stephen M. Smith, Professor of Biomedical Engineering
> Associate Director, Oxford University FMRIB Centre
>
> FMRIB, JR Hospital, Headington, Oxford OX3 9DU, UK
> +44 (0) 1865 222726 (fax 222717)
> [log in to unmask] http://www.fmrib.ox.ac.uk/~steve
> ------------------------------------------------------------------------
> ---
--
Rolf A Heckemann (Dr. med.)
Research Associate
Division of Neuroscience and Mental Health
MRC Clinical Sciences Centre
Imperial College
Hammersmith Hospital Campus
Du Cane Road
London W12 0HS
United Kingdom
--- avwmaths-old.c 2007-03-02 14:44:37.000000000 +0000
+++ avwmaths.c 2007-03-02 14:23:01.000000000 +0000
@@ -89,6 +89,7 @@
printf("-sub : subtract following input from current image\n");
printf("-mul : multiply current image by following input\n");
printf("-div : divide current image by following input\n");
+ printf("-mod : find remainder of division of current image by following input\n");
printf("-mas : use (following image>0) to mask current image\n");
printf("-thr : use following number to threshold current image (zero anything below the number)\n");
printf("-uthr : use following number to upper-threshold current image (zero anything above the number)\n");
@@ -359,6 +360,34 @@
}
/* }}} */
+ else if (!strncmp(argv[i], "-mod", 4))
+ /* {{{ remainder */
+
+{
+ i++;
+ if ( ! isavw(argv[i],&tmpd) )
+ {
+ if (tmpd!=0)
+ for(j=0;j<size;j++)
+ in[0][j]=(int)in[0][j]%(int)floor(tmpd);
+ else
+ for(j=0;j<size;j++)
+ in[0][j]=0;
+ }
+ else
+ {
+ avw_read(argv[i],&im2);
+ in[1]=im2.i;
+ for(j=0;j<size;j++)
+ if (in[1][j%(im2.x*im2.y*im2.z*im2.t)]!=0)
+ in[0][j]=(int)in[0][j]%(int)in[1][j%(im2.x*im2.y*im2.z*im2.t)];
+ else
+ in[0][j]=0;
+ free(in[1]);
+ }
+}
+
+/* }}} */
else if (!strncmp(argv[i], "-thr", 4))
/* {{{ threshold */
|