[MINC-users] Reading time-width data with minc2 API

Claude LEPAGE claude at bic.mni.mcgill.ca
Fri Aug 7 19:45:20 EDT 2009


Hi Jim,

ok, this one looks like a bug to me.

See libsrc2/dimension.c:

miget_dimension_widths(midimhandle_t dimension,
                       mivoxel_order_t voxel_order,
                       unsigned long array_length,
                       unsigned long start_position,
                       double widths[])
{

  /* Allocate space for the widths array
   */
  widths = (double *) malloc(diff*sizeof(double));

    for (i=start_position; i <= diff; i++) {
      widths[j] = dimension->width;
      j++;
    }

Well, the memory has been allocated from outside, so this malloc
simply redefines widths to be some new location in memory. It ends
up that your array is not updated.

As a quick fix, try to comment out the above malloc line in your 
minc2 library, then rebuild minc2 and relink your application.

If widths is to be allocated from within this function (bad idea),
then you need to pass a double * widths[] and assign it as
*widths = (double*)malloc(...); 

Let me know if this works so that I can commit the change in cvs.

By the way *** IMPORTANT ***, since you are using 4-D volumes, please
update to minc-2.0.18 which fixes internal compression for 4-D volumes.
For some images (fMRI, DTI), this is the difference between 90 minutes
vs 15 seconds to read a volume.

bye

Claude




> Hi List (yet again),
>
>    I have a 4-d volume (time, zspace, yspace, xspace) and I need to
> read the time-related information, specifically the offset and width
> info.  Looking at the volume itself, I can see 34 values each for the
> "time" and "time-width" variables.
>
> "miget_dimension_offsets" (minc2 API) had no trouble pulling in the 34
> "time" values, however, I'm stumped on how to read in the 34
> "time-width" values.  I tried "miget_dimension_widths" and got zeros.
> Am I using the correct API call?  Here's what I'm doing ...
>
> -----------------------------------------------------------
> midimhandle_t		*dimensions;
> double			time_widths[34];
>
> result = miget_dimension_widths(dimensions[0], MI_ORDER_FILE, 34, 0,
> time_widths);
> if ( result == MI_ERROR ) { error("Error returned from
> miget_dimension_widths.\n"); }
> -----------------------------------------------------------
>
>    Forgive the hard-coding of 34 ... I'm testing.  My immediately
> preceding call to "miget_dimension_offsets" (also using dimensions[0])
> worked just fine.  Any idea what's going on here?
>
> Thanks,
>
> -Jim
>
> -- 
> =================================
> Jim Nikelski, Ph.D.
> Postdoctoral Research Fellow
> Bloomfield Centre for Research in Aging
> Lady Davis Institute for Medical Research
> Sir Mortimer B. Davis - Jewish General Hospital
> McGill University
> _______________________________________________
> MINC-users at bic.mni.mcgill.ca
> http://www2.bic.mni.mcgill.ca/mailman/listinfo/minc-users
>


More information about the MINC-users mailing list