Author: Cinly OOI (---.cmbg.cable.ntl.com)
Date: 10-06-08 19:55
Dear All,
Can I mix nifti_image_read_bricks() with nifti_image_write_bricks() ??
The test program below failed at second nifti_image_read_bricks() unexpectedly. Can someone have a look at tell me where I go wrong?
OUTPUT:
----------------
++ WARNING: nifti_read_buffer(/tmp/a.nii):
data bytes needed = 96
data bytes input = 0
number missing = 96 (set to 0)
** failed to read brick 1 from file '/tmp/a.nii'
** NWAD: no brick data to write (0x0,0,0)
----------------
"** failed ..." : second nifti_image_read_bricks()
"* NWAD ..." : second nifti_image_write_bricks(). Expected, since read() failed.
However, if we remove all nifti_image_write_bricks() read will succeed.
TEST_PROGRAM
-------------------
void main() {
nifti_image *nim = calloc(1, sizeof(nifti_image));
nim->dim[0] = nim->ndim = 4;
nim->dim[1] = nim->nx = 4;
nim->dim[2] = nim->ny = 3;
nim->dim[3] = nim->nz = 2;
nim->dim[4] = nim->nt = 2;
nim->dim[5] = nim->nu = 1;
nim->dim[6] = nim->nv = 1;
nim->dim[7] = nim->nw = 1;
nim->nvox = nim->nx * nim->ny * nim->nz * nim->nt;
nim->datatype = NIFTI_TYPE_FLOAT32;
nim->nbyper = sizeof(float);
nim->data = malloc(48 * sizeof(float));
nifti_set_filenames(nim, "/tmp/a.nii", 0, 0);
nifti_image_write(nim);
nifti_image_free(nim);
nim = nifti_image_read("/tmp/a.nii", 0);
nifti_brick_list NBL;
int vol = 0;
nifti_image_load_bricks(nim, 1, &vol, &NBL);
nifti_image_write_bricks(nim, &NBL);
vol = 1;
nifti_image_load_bricks(nim, 1, &vol, &NBL); //FAIL
nifti_image_write_bricks(nim, &NBL);
}
|
|