Author: rick reynolds (---.nimh.nih.gov)
Date: 08-09-07 09:36
Hi Souheil,
The type of data stored in the 'datatype' field is generally
named with the number of bytes it occupies, and is listed in
nifti1.h under the NIFTI_TYPE_* codes (or DT_*). For example,
consider NIFTI_TYPE_FLOAT32. That is explicitly a 32 bit
float. Also, for data of that type, the bitpix field would be
set to 32, again indicating 32 bits per value.
To be sure that float is 32 bits on your machine, sizeof(float)
operator should return 4 (bytes). e.g.
printf("my float size is %ld\n", sizeof(float));
Malloc returns an address that is suitably aligned for any
type of variable (based on that CPU). So there is no question
of whether the words are aligned. That memory space is then
populated with the data.
As far as swapping goes, the only point of swapping is to get
into the same endian that the CPU you are using applies. No
swap is done on a write simply because data is written out in
the endian of the CPU that is running the code. The library
routines will figure it out again when that new dataset is
read.
---
Basically, if you use the library to read the dataset, all you
have to do is then access and play with the data, with the
condition that you can support the given datatype.
The data should already be suitable (aligned and swapped) for
your CPU, assuming it can handle the given type.
- rick
|
|