[MINC-users] basic volume_io question

Peter Savadjiev petersv@bic.mni.mcgill.ca
Fri Jan 28 15:49:06 2005


Hi,

I'm trying to create a 4D volume with the following snippet of code:

  Volume out;
  STRING names[4];
  int  sizes[4];
  int s2[4];

  sizes[0] = 90;
  sizes[1] = 40;
  sizes[2] = 96;
  sizes[3] = 128;

  names[0] = "time";
  names[1] = "zspace";
  names[2] = "yspace";
  names[3] = "xspace";

  out = create_volume( 4,names, FLOAT, FALSE,0,1);
  set_volume_sizes(out, sizes);
  alloc_volume_data(out);


Apparently, everything is correct. Yet, when I run the code I get the
following error:

Error: cannot allocate array data until size specified.

if I insert

  get_volume_sizes(out, s2);
  printf("%d %d %d %d\n", s2[0],s2[1],s2[2],s2[3]);

between the calls to set_volume_sizes and alloc_volume_data, the sizes are
printed correctly, which tells me that set_volume_sizes works properly.

Could please anyone give me an idea what may be going wrong?

Thank you very much for your help,

Peter