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.
readData(inputfile, DebugLevel = "Normal")
(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.
(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.
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
The image or the array that was read.
Is a list of values specified through the file format.
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:'\(\backslash 0\)''\(\backslash 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,\ldots,M\), \(j=1,\ldots,2N\), \(n=1,\ldots,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.
Schulz, Joern, Diploma Thesis: Analyse von PET Daten unter Einsatz adaptiver Glaettungsverfahren, Humboldt-Universitaet zu Berlin, Institut fuer Mathematik, 2006.
# NOT RUN {
P <- phantom()
writeData(P, "Phantom.pet", fileOverwrite="YES" )
P.new <- readData("Phantom.pet", DebugLevel = "Normal")
viewData(P.new$Signal)
rm(P, P.new)
# }
Run the code above in your browser using DataLab