readData: Reload Saved Datasets in different Formats.

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/readData.r

Description

The function offers the possibility to read a ".txt", ".dat", ".dat.gz", ".pet" or ".fif" file. Furthermore the graphics formats ".tif", ".tiff", ".pgm", ".ppm", ".png", ".pnm", ".gif", ".jpg" and ".jpeg" are supported.

Usage

1
readData(inputfile, DebugLevel = "Normal")

Arguments

inputfile

(character) inputfile gives the name of the file to read, including the pathname to the file. The extension of the name of the file specifies the format. Currently ".txt", ".dat", ".dat.gz", ".fif", ".pet" and the graphic formats ".tif", ".tiff", ".pgm", ".ppm", ".png", ".pnm", ".gif", ".jpg" and ".jpeg" are supported. See below to details to get more information about the formats.

DebugLevel

(character) This parameter controls the level of output. Defaults to DebugLevel="Normal" for a standard level output. Alternative implementations are "Detail" if it is desirable to show almost all output on screen or "HardCore" for no information at all.

Details

In the following different supported formats of inputfile are explained.

".tif", ".tiff", ".pgm", ".ppm", ".png", ".pnm", ".gif", ".jpg" and ".jpeg"
For using these graphic formats the R package adimpro is necessary. See there, to get more information about these formats.

".txt"
Reads files in ASCII format without header, which contain only the raw data. The R-routine read.table is used. Returns a matrix.

".dat" and ".gz"
Read files in ASCII format that contain a header with three or four rows followed by the data. Compared to ".txt" the advantage is that is possible to save and load higher-dimensional data. Furthermore important values are saved, that are needed for Radon and the inverse Radon Transformation. If the extension ".gz" is specified, then files in ".dat" format will be read which were additionally compressed by 'gzip'.
Assuming the data are two-dimensional, then the header has to be only of the following form:

Description: char (optional)
SignalDim: int int
XYmin: double double
DeltaXY: double double
... and after the header follow the raw data

Explanation of the parameters:

Description: Can be a short description of the data. It is possible
to leave out this parameter. In this case the first
line of the file begins with 'SignalDim'.
SignalDim: In case of 2-dim data 'SignalDim' is the number of
rows and columns of the array, but also a greater
dimension is permissible.
XYmin: Leftmost coordinate and lowest coordinate of the
data.
DeltaXY: Quantization steps in image, in x and y-direction.

If the dimension of data is greater than two, the number of 'SignalDim', 'XYmin' and 'DeltaXY' should be increase appropriately.

.pet
Reads a picture in ".pet" format (raw float with header) from the file e.g. inputfile = "FileName.pet" (binary format). The ".pet"-file has to be of the following structure: The first part contains a header and the second part the data, e.g. an image. Only the values of the parameter are saved in the header and not the parameter names.

Description: (80-byte character) Should be a short description
of image.
XSamples: (integer) Number of rows of array.
YSamples: (integer) Number of columns of array.
Xmin: (float) Leftmost coordinate in original image.
Ymin: (float) Lowest coordinate in original image.
DeltaX: (float) Quantization steps in original image (x).
DeltaY: (float) Quantization steps in original image (y).

The dimension of the data should be not greater than two.
The ".pet" and the sequencing ".fif" format will be used in the iradonIT method to store iteration-steps and to read a references image.

.fif
Reads a picture in ".fif" format (raw float with header) from the file e.g. inputfile = "FileName.fif" (binary format). The ".fif"-file has to be of the following structure: The first part contains a header and the second part the data, e.g. an image. At first, the values of the following parameters are saved in the file:

FIFIdType: (integer) ID used to restore FIF:17737:'\0''\0''E''I'.
FileName: (100-byte character) Name used for saving this image.
Description: See above.
Date: (10-byte character) Date (YYYY-MM-DD).
XSamples: See above.
YSamples: See above.
ArrayType: (integer) Defines the format number: 1 for Real or
2 for Complex. Complex matrices are determined by A=a_{i,j}
where a_{i,2n} is the imaginary part to the real value
a_{i,2n-1}, i=1,…,M, j=1,…,2N, n=1,…,N.
Xmin: (float) See above.
Ymin: (float) See above.
DeltaX: (float) See above.
DeltaY: (float) See above.
SignalMin: (float) Lowest signal value in the array.
SignalMax: (float) Highest signal value in the array.

After this header the data are following.

Value

In case of inputfile="/.../FileName.txt", ".tif", ".tiff", ".pgm", ".ppm", ".png", ".pnm", ".gif", ".jpg" and ".jpeg" only a matrix (image) will be returned.

In case of inputfile="/.../FileName.dat", ".dat.gz", ".pet" and ".fif" a list will be returned, with

Signal

The image or the array that was read.

Header

Is a list of values specified through the file format.

In case of inputfile="/.../FileName.dat", ".dat.gz" and ".pet" $Header contain the following list elements: Description (if ".dat" or ".dat.gz" is used then optional), SignalDim, XYmin and DeltaXY.
In case of inputfile="/.../FileName.fif" $Header contain the following list elements: FIFIdType, FileName, Description, Date, SignalDim, ArrayType, XYmin, DeltaXY and SignalMinMax.

Author(s)

Joern Schulz, jschulz78@web.de.

References

Schulz, Joern, Diploma Thesis: Analyse von PET Daten unter Einsatz adaptiver Glaettungsverfahren, Humboldt-Universitaet zu Berlin, Institut fuer Mathematik, 2006.

See Also

writeData, iradon

Examples

1
2
3
4
5
P <- phantom()
writeData(P, "Phantom.pet", fileOverwrite="YES" )
P.new <- readData("Phantom.pet", DebugLevel = "Normal")
viewData(P.new$Signal)
rm(P, P.new)

PET documentation built on May 2, 2019, 2:43 a.m.