Top

pyprProcessors module

This file contains all data relevant files such as reading simulation phantoms or experimental data. This is the place where you may add personal methods to handle your specific data.

"""
This file contains all data relevant files such as reading simulation
phantoms or experimental data. This is the place where you may add
personal methods to handle your specific data.
"""

import os.path
import sys
import scipy.io as sio

def readDataFromFile(filename):
    """
    Reads data from a file of a certain format.
    This methods reads the data specified in a given file.
    Right now, we assume that this is a .mat file containing
    a variable named "pattern". Generally, this can be extended
    to read any kind of data.

    Input:  
        
        filename     -  Name (string) of the file to be read.
 
    Output: 
        
        dataFromFile -  Matlab structure containing the data.
                            Right now, this is only the data array
                            dataFromFile.data itself.
 
                            We may extend this if the given data is
                            in some container format, e.g., for
                            experimental data this seems plausible
                            where the data container may also contain
                            physicial parameters.

    """
    if not os.path.isfile(filename):
        sys.exit("File not found.")
    else:
        w = sio.loadmat(filename)
        if not 'pattern' in w:
            sys.exit("Input file format invalid: variable pattern not found.")
        else:
            input_data = {}
            input_data["data"] = w["pattern"]
    return input_data

Functions

def readDataFromFile(

filename)

Reads data from a file of a certain format. This methods reads the data specified in a given file. Right now, we assume that this is a .mat file containing a variable named "pattern". Generally, this can be extended to read any kind of data.

Input:

filename     -  Name (string) of the file to be read.

Output:

dataFromFile -  Matlab structure containing the data.
                    Right now, this is only the data array
                    dataFromFile.data itself.

                    We may extend this if the given data is
                    in some container format, e.g., for
                    experimental data this seems plausible
                    where the data container may also contain
                    physicial parameters.
def readDataFromFile(filename):
    """
    Reads data from a file of a certain format.
    This methods reads the data specified in a given file.
    Right now, we assume that this is a .mat file containing
    a variable named "pattern". Generally, this can be extended
    to read any kind of data.

    Input:  
        
        filename     -  Name (string) of the file to be read.
 
    Output: 
        
        dataFromFile -  Matlab structure containing the data.
                            Right now, this is only the data array
                            dataFromFile.data itself.
 
                            We may extend this if the given data is
                            in some container format, e.g., for
                            experimental data this seems plausible
                            where the data container may also contain
                            physicial parameters.

    """
    if not os.path.isfile(filename):
        sys.exit("File not found.")
    else:
        w = sio.loadmat(filename)
        if not 'pattern' in w:
            sys.exit("Input file format invalid: variable pattern not found.")
        else:
            input_data = {}
            input_data["data"] = w["pattern"]
    return input_data