libtpccurveio
 All Data Structures Files Functions Variables Enumerations Enumerator Defines
Functions | Variables
dftio.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <math.h>
#include <ctype.h>
#include <string.h>
#include <strings.h>
#include "decpoint.h"
#include "backup.h"
#include "include/dftio.h"
#include "include/dftunit.h"
#include "include/ncifile.h"
#include "include/idwc.h"
#include "include/if.h"
#include "include/csv.h"
Include dependency graph for dftio.c:

Go to the source code of this file.

Functions

int dftRead (char *filename, DFT *data)
int dftFormat (char *fname)
int dftType (FILE *fp)
void dftPrint (DFT *data)
int dftWrite (DFT *data, char *filename)
int dftWriteHTML (DFT *dft, char *fname, int orientation)
int dftWriteXHTML11_doctype (FILE *fp)
int dftWriteXHTML11_head (FILE *fp, char *author_name)
int dft_fill_hdr_from_IFT (DFT *dft, IFT *ift)
int dftGetPmodTitle (DFT *dft, char *title_line)

Variables

int DFT_NR_OF_DECIMALS = 3

Function Documentation

int dft_fill_hdr_from_IFT ( DFT dft,
IFT *  ift 
)

Read certain keys from IFT and set DFT fields accordingly.

Returns:
Returns the nr of identified keys.
Parameters:
dftPointer to allocated DFT struct where information will be written
iftPointer to IFT struct from where information is retrieved

Definition at line 1093 of file dftio.c.

References DFT::decayCorrected, DFT_DECAY_CORRECTED, DFT_DECAY_NOTCORRECTED, Voi::hemisphere, DFT::injectionTime, DFT::isotope, Voi::name, Voi::place, DFT::radiopharmaceutical, DFT::scanStartTime, Voi::size, DFT::studynr, DFT::timeunit, DFT::unit, DFT::voi, and Voi::voiname.

Referenced by dftRead().

int dftFormat ( char *  fname)

Determine the type of DFT file. This will replace dftType(). Note that only some of formats are currently identified, and identification does not mean that dftRead() supports the format.

Returns:
Returns DFT_FORMAT_UNKNOWN or other format id defined in dft.h.
Parameters:
fnamePointer to filename; this string is not modified.

Definition at line 426 of file dftio.c.

References DFT_FORMAT_CSV_UK, DFT_FORMAT_FIT, DFT_FORMAT_IDWC, DFT_FORMAT_IF, DFT_FORMAT_NCI, DFT_FORMAT_PLAIN, DFT_FORMAT_PMOD, DFT_FORMAT_STANDARD, and DFT_FORMAT_UNKNOWN.

Referenced by dftRead().

int dftGetPmodTitle ( DFT dft,
char *  title_line 
)

Read single title line from PMOD files and set DFT fields accordingly.

Returns:
Returns 0 if successful.
Parameters:
dftPointer to allocated DFT struct where information will be written
title_linePointer to string containing the title line; string is not modified

Definition at line 1229 of file dftio.c.

References DFT_TIME_MIDDLE, DFT_TIME_STARTEND, Voi::hemisphere, Voi::name, Voi::place, DFT::timetype, DFT::timeunit, DFT::unit, DFT::voi, and Voi::voiname.

Referenced by dftRead().

void dftPrint ( DFT data)
int dftRead ( char *  filename,
DFT data 
)

Read TAC file contents into specified DFT data structure. Reads standard DFT files, plain DFT files, and some other formats.

Returns:
Returns 0 when successful, in case of error sets dfterrmsg.
Parameters:
filenameName of file to be read
dataPointer to initiated DFT struct where data will be written; any old content is deleted.

Definition at line 108 of file dftio.c.

References _DFT_COMMENT_LEN, DFT::_type, DFT::comments, csv2dft(), csvEmpty(), csvInit(), csvRead(), dft_fill_hdr_from_IFT(), DFT_FORMAT_CSV_INT, DFT_FORMAT_CSV_UK, DFT_FORMAT_FIT, DFT_FORMAT_IDWC, DFT_FORMAT_IF, DFT_FORMAT_IFT, DFT_FORMAT_NCI, DFT_FORMAT_PLAIN, DFT_FORMAT_PMOD, DFT_FORMAT_STANDARD, DFT_FORMAT_UNKNOWN, DFT_NR_OF_DECIMALS, DFT_TIME_END, DFT_TIME_MIDDLE, DFT_TIME_START, DFT_TIME_STARTEND, dftCopyvoi(), dftEmpty(), dfterrmsg, dftFormat(), dftFrametimes(), dftGetPmodTitle(), dftSetmem(), DFT::frameNr, Voi::hemisphere, idwcRead(), ifRead(), DFT::isweight, Voi::name, Voi::place, roikbqRead(), Voi::size, DFT::studynr, DFT::timetype, DFT::timeunit, DFT::unit, DFT::voi, Voi::voiname, DFT::voiNr, DFT::w, DFT::x, DFT::x1, DFT::x2, and Voi::y.

Here is the call graph for this function:

int dftType ( FILE *  fp)

Determine the type of DFT file.

Todo:
Replace calls to dftType() by dftFormat(), but note that return values have changed.
Returns:
0=unknown; 1=normal DFT; 2=plain data; 3=fit file; 4=nci file; 5=KI file

Definition at line 476 of file dftio.c.

int dftWrite ( DFT data,
char *  filename 
)

Write DFT data, usualyy containing regional time-activity curves (TACs) into specified file. The file format specified in data is applied. Number of decimals can be determined by changing global variable DFT_NR_OF_DECIMALS.

Parameters:
dataPointer to DFT struct which contents are to be written
filenameFilename where DFT contents are written. If file exists, original file is renamed to a backup file

Definition at line 563 of file dftio.c.

References DFT::_type, DFT::comments, DFT_FORMAT_HTML, DFT_FORMAT_PLAIN, DFT_FORMAT_PMOD, DFT_FORMAT_STANDARD, DFT_NR_OF_DECIMALS, DFT_TIME_END, DFT_TIME_MIDDLE, DFT_TIME_START, DFT_TIME_STARTEND, DFT_VER, dfterrmsg, dftWriteHTML(), DFT::frameNr, Voi::hemisphere, DFT::isweight, Voi::name, Voi::place, Voi::size, DFT::studynr, DFT::timetype, DFT::timeunit, DFT::unit, DFT::voi, Voi::voiname, DFT::voiNr, DFT::w, DFT::x, DFT::x1, DFT::x2, and Voi::y.

Here is the call graph for this function:

int dftWriteHTML ( DFT dft,
char *  fname,
int  orientation 
)

Write DFT contents in HTML table format If file exists, a backup file (+BACKUP_EXTENSION) is written also. If "stdout" is given as filename, output is directed to stdout In case of an error, description is written in dfterrmsg.

Returns:
Returns 0 if ok.
Parameters:
dftInput DFT
fnameHTML filename
orientationTable orientation: 1=original, 2=transposed

Definition at line 900 of file dftio.c.

References DFT::_type, BACKUP_EXTENSION, DFT_FORMAT_PLAIN, dfterrmsg, dftWriteXHTML11_doctype(), dftWriteXHTML11_head(), DFT::frameNr, Voi::hemisphere, Voi::place, Voi::size, DFT::studynr, DFT::timeunit, DFT::unit, DFT::voi, Voi::voiname, DFT::voiNr, DFT::x, and Voi::y.

Referenced by dftWrite().

Here is the call graph for this function:

int dftWriteXHTML11_doctype ( FILE *  fp)

Write XHTML 1.1 doctype into an opened file pointer.

Returns:
Returns 0 if successful, non-zero in case of a failure.

Definition at line 1032 of file dftio.c.

Referenced by dftWriteHTML().

int dftWriteXHTML11_head ( FILE *  fp,
char *  author_name 
)

Write XHTML 1.1 head for DFT file into an opened file pointer.

Returns:
Returns 0 if successful, non-zero in case of a failure.
Parameters:
fpFile pointer where to write
author_nameAuthor name, for example software name

Definition at line 1049 of file dftio.c.

Referenced by dftWriteHTML().


Variable Documentation

Definition at line 90 of file dftio.c.

Referenced by dftRead(), and dftWrite().