[MINC-users] default slice min/max in mincreshape?

Andrew Janke a.janke at gmail.com
Mon Jun 4 02:32:24 EDT 2012


Hi Peter (and others),

Thanks for the pointer.

> mincreshape is trying to avoid having a range of zero which could
> potentially lead to divide by zero situations for less-than-perfect apps
> reading the output file. Unfortunately, the arbitrary value that it picks
> is too big for your file.
>
> The guilty code is in progs/mincreshape/copy_data.c, function
> get_block_min_and_max(). There is a block of code in there that sets
> variable default_extreme to 1.0 for the maximum and 0.0 for the minimum.
> This could either be changed to a much smaller number (to preserve the
> original intention), or mincreshape could scan all of the min and max to
> determine a file-specific default min and max (although you probably don't
> want to use the global max here - probably 1% of the range or something).
> Note that the choice of 0.0 for the min could also be a problem for files
> that have are shifted up and have a narrow range.

I don't think the problem is quite as straight forward as the above
(although setting a smaller number will work -- and eventually break
somewhere else). The problem seems to be that nothing is defined at
the start.  If you do this:

(first make a file that will break things)

   mincreshape -dimrange zspace=50,10 /usr/local/bic/share/model.mnc /tmp/10.mnc
   mincmath -mult -const 0.000001 /tmp/10.mnc /tmp/small.mnc

Now reshape:

   mincreshape -dimrange zspace=0,40 /tmp/small.mnc /tmp/out.mnc
   mincheader /tmp/out.mnc

...

 image-min = 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ;

 image-max = 1.50176742592221e-11, 1.4706592772461e-11, 1.47731739408916e-11,
    1.29191933176351e-11, 1.38217782687002e-11, 1.35282269390157e-11,
    1.30565671507807e-11, 1.26761793835777e-11, 1.26660561800091e-11,
    1.35031529091316e-11, 1.36272934702302e-11, 1.30031373028565e-11,
    1.26079339468883e-11, 1.29919927604189e-11, 1.28181591844077e-11,
    1.270971845851e-11, 1.27311934672496e-11, 1.36087412976983e-11,
    1.34799824270089e-11, 1.27816067975376e-11, 1.27816067975376e-11,
    1.27816067975376e-11, 1.27816067975376e-11, 1.27816067975376e-11,
    1.27816067975376e-11, 1.27816067975376e-11, 1.27816067975376e-11,
    1.27816067975376e-11, 1.27816067975376e-11, 1.27816067975376e-11,
    1.27816067975376e-11, 1.27816067975376e-11, 1.27816067975376e-11,
    1.27816067975376e-11, 1.27816067975376e-11, 1.27816067975376e-11,
    1.27816067975376e-11, 1.27816067975376e-11, 1.27816067975376e-11,
    1.27816067975376e-11 ;

Things are fine.

Now if you add those same slices on the front:

   mincreshape -dimrange zspace=-10,40 /tmp/small.mnc /tmp/out.mnc
   mincheader /tmp/out.mnc

   ...

 image-max = 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1.50176742592221e-11,
    1.4706592772461e-11, 1.47731739408916e-11, 1.29191933176351e-11,
    1.38217782687002e-11, 1.35282269390157e-11, 1.30565671507807e-11,
    1.26761793835777e-11, 1.26660561800091e-11, 1.35031529091316e-11,
    1.36272934702302e-11, 1.30031373028565e-11, 1.26079339468883e-11,
    1.29919927604189e-11, 1.28181591844077e-11, 1.270971845851e-11,
    1.27311934672496e-11, 1.36087412976983e-11, 1.34799824270089e-11,
    1.27816067975376e-11, 1.27816067975376e-11, 1.27816067975376e-11,
    1.27816067975376e-11, 1.27816067975376e-11, 1.27816067975376e-11,
    1.27816067975376e-11, 1.27816067975376e-11, 1.27816067975376e-11,
    1.27816067975376e-11, 1.27816067975376e-11 ;

Things break.

So to me it's a problem with an unitialised variable. The correct fix
from what I can see it to scan into the volume looking for the first
real block and using the minimum of that. This seems to be what
happens for following data but I haven't looked into things long
enough to figure out how it picks up the value from the last block.


a


More information about the MINC-users mailing list