next up previous
Next: write_analyze_header() Up: Brain Volume I/O Handling Previous: close_file()

write_volume()  

Write an entire volume



Synopsis


int
write_volume( char *filename, header *hdr, void *data)


Description
Writes a VAPET, XPRIME or ANALYZE file.

The header is automatically created. For analyze files, ".hdr" and ".img" is appended to the file name.

If hdr->compressed is set, the volume will be compressed by piping the output through gzip (hdr->compressed==GZIP) or compress (hdr->compressed == COMPRESS).

The output file type is determined from hdr->filetype. Typically the header->filetype is filled out by read_header() or read_volume().

If the global variable auto_convert is TRUE (which is the default setting), and if the machine has INTEL endian format, the data will be reversen in endian mode before writing. It is assumed that non-INTEL format is used in all binary image files on disk.

Before the file is written, the min and max entries are set according to the data type (the volume is scanned), unless the global int "no_auto_minmax" is set to true.

Usage

This example program converts a file to float format. Th input file may be compressed and in any supported data format, any supported file format, and any rank.

 
#include "volio.h"

int 
main (int argc, char *argv[]) {
  header *hdr;
  void *data; 

  if (read_volume(argv[1], hdr, (void**) &data)) 
    exit(1);
  if (convert_volume(hdr, (void**) &data, T_FLOAT))
    exit(1);
  if (write_volume(argv[2], hdr, (void**) &data))
    exit(1);

  free_header(hdr);
  free(data);
}

Revision


1.0  29/10-96    Ulrik Kjems  initial code
1.1  15/10-96    Ulrik Kjems  made hdr->filetype determine type
1.101            UK           allowed compressed files
1.102            UK           allowed XPRIME files
1.2              UK           auto min/max setting


Program listing






Ulrik Kjems
6/3/1998