ncigt-fil
|
Functions to read and write image and data files. More...
Functions | |
void | copy_data_obj (DATA_OBJ *dest, DATA_OBJ *src) |
void | display_params (SCAN_INFO hdr) |
void | dump_out (char *name, int nc_out, int nf_out, int nz_out, int ny_out, int nx_out, short temp, COMPLEX *bin) |
void | free_data_obj (DATA_OBJ *data_obj) |
void | init_data_obj (DATA_OBJ *data) |
int | read_nd_data (char *filename, char **ptr, char *frmt, int *size, int *szI) |
int | read_nd_data2 (char *filename, DATA_OBJ *dat) |
int | write_nd_data (char *filename, void *bin, char *frmt, int size, int *sz) |
int | write_nd_data2 (char *filename, DATA_OBJ *dat) |
Functions to read and write image and data files.
The library provides a number of functions to pass data back and forth between C and Matlab.
One method is the .nd data format, which is a straight forward way to save real or complex multi-dimensional data. The .nd file format is:
Version 2 allows meta-data describing the data to also be stored.
Alternatively, one can use the dump_out function to write memory contents to disk. This format writes the raw binary data in one file, and then writes an associated text file describing the format of the data.
void copy_data_obj | ( | DATA_OBJ * | dest, |
DATA_OBJ * | src | ||
) |
clone a copy of a data object
if dest is a clean object, then the memory will be allocated.
if not, (i.e. dest has pre-allocated data memory) the copy will proceed if (dest->init >= src->init).
void display_params | ( | SCAN_INFO | hdr | ) |
Display some of the scan parameters contained in the SCAN_INFO header
void dump_out | ( | char * | name, |
int | nc_out, | ||
int | nf_out, | ||
int | nz_out, | ||
int | ny_out, | ||
int | nx_out, | ||
short | temp, | ||
COMPLEX * | bin | ||
) |
Write data to file, for debugging. The fuection output two files, one file is a binary format with the data. The second, with suffix '_dims' records the data structure (number of coils, frames, Nz, Ny, Nx, etc.). Data can be read in to Matlab using read_dump .
name | output filename |
nc_out | number of coils |
nf_out | number of temporal frames |
nz_out | number of slices |
ny_out | size along phase-encode dimension |
nx_out | size along read-out dimension |
temp | (unused) |
bin | the data to write to disk |
void free_data_obj | ( | DATA_OBJ * | data_obj | ) |
release all allocated memory associated with the input data object.
void init_data_obj | ( | DATA_OBJ * | data | ) |
initialize the data points and array values for an empty data object
int read_nd_data | ( | char * | filename, |
char ** | ptr, | ||
char * | frmt, | ||
int * | size, | ||
int * | szI | ||
) |
import/read an N-D data array file (output by savend)
Usage:
filename | Output filename. |
ptr | pointer to the data buffer to read data to. |
frmt | pointer the file format char field. |
size | pointer the returned number of dimensions in the data. |
szI | pointer to an array that holds the number of elements in dimension. |
int read_nd_data2 | ( | char * | filename, |
DATA_OBJ * | dat | ||
) |
import/read an N-D data array file (output by savend)
Usage:
This version (version 2) can read meta-data stored at the end of the file.
filename | Output filename. |
dat | pointer to the data object to populate. |
int write_nd_data | ( | char * | filename, |
void * | bin, | ||
char * | frmt, | ||
int | size, | ||
int * | sz | ||
) |
write an N-D data array to disk suitable for readnd
Usage:
Returns a 0 if read is successful, a non-zero value otherwise. Error messages are reported to STDERR.
filename | input data filename |
bin | a pointer to the output data |
frmt | a format descriptor of the data type: 'char', 'intr', 'intc', 'fltr', 'fltc', 'dblr', or 'dblc'. |
size | the number of dimensions spanned by the data |
sz | the number of elements in each dimension |
int write_nd_data2 | ( | char * | filename, |
DATA_OBJ * | dat | ||
) |
export/write an N-D data array file (to be read by readnd) along with any associated meta-data
Usage:
This version (version 2) will append meta-data stored in the img.metadata field of the object
filename | Output filename. |
dat | pointer to the data object to write. |