Q: Dear MINC User Community

I have been developing a piece of software to analyse neuro PET images under MINC 1.5 and it is nearly complete other than one outstanding problem that I have.

The PET images that I am using are converted from MINC and have a 4th (time) dimension and are converted from ECAT using ecattominc.

I need to manipulate data across the temporal aspect and so I would like to load in the entire 4D image into memory space at once.

The problem is I do not know how to access the image data voxels for a time, t.

As a result I am working around by extracting frame by frame, writing to temporary file, and reading back in again. This is inefficient and worse still is causing me all sorts of bother with normalisation such that my voxel values become scewed.

Please can someone tell me how to access / index 4D image voxel data directly in MINC 1.5.

At present I am using the following code to assign an index 4D array of image data called voxel[][][][] by first pulling out a frame then a slice of that frame and making new assignments:

 signed short int* image;
 …
 image = malloc(vol4d→nrows * vol4d→ncols * sizeof(*image));
 for (t=0; t<vol4d→nframes; t++)
 {
   /* Extract the frame and perform the copy */
   extractFrame(mincId, icvId, framefile, vol4d, &vol3d, t);
   openFrame(framefile, NC_NOWRITE, &tempIcvId, &tempMincId, &vol3d);
   for (i=0; i<vol3d.nslices; i++)
   {
     getSlice(tempIcvId, &vol3d, i, image);
     for (j=0; j<vol4d→nrows; j++)
     {
       for (k=0; k<vol4d→ncols; k++)
       {
         /* Make the assignment */
         index = j*vol4d→ncols+k;
         vol4d→voxel[t][i][j][k]=image[index];
         …
       }
     }
   }
 }

Where the methods extractFrame(), openFrame() and getSlice() are methods written by myself which save a frame to file, open that frame for reading and read a slice from that file respectively. In the struct for the Volume4d datatype I have: signed short int ****voxel;

Surely there must be an easier and cleaner way?

Any help with this matter / relevant documentation would be very much appreciated.

Also if anyone has any knowledge of the normalisation process which goes on in loading images under MINC 1.5 I would love to discuss with you. I could potentially stick with my current workaround and solve the problem by modifying the normalisation parameters.
http://www.bic.mni.mcgill.ca/pipermail/minc-users/2008-December/002314.html

A: If you want a simple way to read things all in and then out and not worry about the voxel data type, then if you are sticking with MINC 1.X I have attached a few files that should give some examples of how to do this with volume_io. The first gives a quick howto with volume_io, the second is a makefile to suit and the third is not as well commented but shows what to do to extend the first example to 4D.

the volume_io manuals and the likes are here:

  http://en.wikibooks.org/wiki/MINC/Reference/MINC1-volumeio-programmers-reference

However I would recommend that you use MINC 2.0 instead but it is probably a little late for that now! There are some examples for that here:

  http://en.wikibooks.org/wiki/MINC/Tutorials#Programming_with_the_MINC_toolkit