コード例 #1
0
class PositionArrayData(FloatArrayData):
    """ An array specifying position. """
    _ui_name = "Array of positions"

    coordinate_system = basic.String(label="Coordinate system",
                                     default="cartesian",
                                     doc="""The coordinate system used to specify the positions.
                                     Eg: 'spherical', 'polar'""")

    coordinate_space = basic.String(label="Coordinate space",
                                    default="None",
                                    doc="The standard space the positions are in, eg, 'MNI', 'colin27'")
コード例 #2
0
class StructuralMRIData(VolumeData):
    """
    Quantitative volumetric data recorded by means of Magnetic Resonance Imaging 
    """
    #TODO: Need data defined ?data = arrays.FloatArray(label = "?Contrast?") ?
    weighting = basic.String(
        label="MRI weighting")  # eg, "T1", "T2", "T2*", "PD", ...
コード例 #3
0
class SensorsMEGData(SensorsData):
    """
    These are actually just SQUIDS. Axial or planar gradiometers are achieved
    by calculating lead fields for two sets of sensors and then subtracting...
    ::
        
                              position  orientation
                                 |           |
                                / \         / \\
                               /   \       /   \\
        file columns: labels, x, y, z,   dx, dy, dz
        
    """
    _ui_name = "MEG sensors"

    __tablename__ = None

    __mapper_args__ = {'polymorphic_identity': MEG_POLYMORPHIC_IDENTITY}

    sensors_type = basic.String(default=MEG_POLYMORPHIC_IDENTITY)

    orientations = arrays.OrientationArray(
        label="Sensor orientations",
        doc="An array representing the orientation of the MEG SQUIDs")

    has_orientation = basic.Bool(default=True, order=-1)
コード例 #4
0
class SensorsEEGData(SensorsData):
    """
    EEG sensor locations are represented as unit vectors, these need to be
    combined with a head(outer-skin) surface to obtain actual sensor locations
    ::
        
                              position
                                 |
                                / \\
                               /   \\
        file columns: labels, x, y, z
        
    """
    _ui_name = "EEG Sensors"

    __tablename__ = None

    __mapper_args__ = {'polymorphic_identity': EEG_POLYMORPHIC_IDENTITY}

    sensors_type = basic.String(default=EEG_POLYMORPHIC_IDENTITY)

    has_orientation = basic.Bool(default=False, order=-1)

    def __init__(self, **kwargs):
        super(SensorsEEGData, self).__init__(**kwargs)
        self.default.reload(
            self.__class__,
            folder_path="sensors",
            file_name="EEG_unit_vectors_BrainProducts_62.txt.bz2")
コード例 #5
0
class VolumeData(MappedType):
    """
    Data having voxels as their elementary units.
    """
    origin = arrays.PositionArray(label="Volume origin coordinates")
    voxel_size = arrays.FloatArray(label="Voxel size")  # need a triplet, xyz
    voxel_unit = basic.String(label="Voxel Measure Unit", default="mm")
コード例 #6
0
class DoubleGaussianData(EquationData):
    """
    A Mexican-hat function approximated by the difference of Gaussians functions.
    """
    _ui_name = "Mexican-hat"

    equation = basic.String(
        label="Double Gaussian Equation",
        default=
        "(amp_1 * exp(-((var-midpoint_1)**2 / (2.0 * sigma_1**2)))) - (amp_2 * exp(-((var-midpoint_2)**2 / (2.0 * sigma_2**2))))",
        locked=True,
        doc=""":math:`amp_1 \\exp\\left(-\\left((x-midpoint_1)^2 / \\left(2.0
        \\sigma_1^2\\right)\\right)\\right) - 
        amp_2 \\exp\\left(-\\left((x-midpoint_2)^2 / \\left(2.0  
        \\sigma_2^2\\right)\\right)\\right)`""")

    parameters = basic.Dict(label="Double Gaussian Parameters",
                            default={
                                "amp_1": 0.5,
                                "sigma_1": 20.0,
                                "midpoint_1": 0.0,
                                "amp_2": 1.0,
                                "sigma_2": 10.0,
                                "midpoint_2": 0.0
                            })
コード例 #7
0
class PulseTrainData(EquationData):
    """
    A pulse train , offseted with respect to the time axis.
    
    **Parameters**:
    
    * :math:`\\tau` :  pulse width or pulse duration
    * :math:`T`     :  pulse repetition period
    * :math:`f`     :  pulse repetition frequency (1/T)
    * duty cycle    :  :math:``\\frac{\\tau}{T}`` (for a square wave: 0.5)
    * onset time    :
    """

    equation = basic.String(label="Pulse Train",
                            default="where((var % T) < tau, amp, 0)",
                            locked=True,
                            doc=""":math:`\\frac{\\tau}{T}
        +\\sum_{n=1}^{\\infty}\\frac{2}{n\\pi}
        \\sin\\left(\\frac{\\pi\\,n\\tau}{T}\\right)
        \\cos\\left(\\frac{2\\pi\\,n}{T} var\\right)`. 
        The starting time is halfway through the first pulse. 
        The phase can be offset t with t - tau/2""")

    # onset is in milliseconds
    # T and tau are in milliseconds as well

    parameters = basic.Dict(default={
        "T": 42.0,
        "tau": 13.0,
        "amp": 1.0,
        "onset": 30.0
    },
                            label="Pulse Train Parameters")
コード例 #8
0
class SensorsMEGData(SensorsData):
    """
    These are actually just SQUIDS. Axial or planar gradiometers are achieved
    by calculating lead fields for two sets of sensors and then subtracting...
    ::
        
                              position  orientation
                                 |           |
                                / \         / \\
                               /   \       /   \\
        file columns: labels, x, y, z,   dx, dy, dz
        
    """
    _ui_name = "MEG sensors"

    __tablename__ = None

    __mapper_args__ = {'polymorphic_identity': MEG_POLYMORPHIC_IDENTITY}

    sensors_type = basic.String(default=MEG_POLYMORPHIC_IDENTITY)

    orientations = arrays.OrientationArray(
        label="Sensor orientations",
        console_default=SensorsData.default.read_data(usecols=(4, 5, 6),
                                                      field="orientations",
                                                      lazy_load=True),
        doc="An array representing the orientation of the MEG SQUIDs")

    has_orientation = basic.Bool(default=True, order=-1)

    def __init__(self, **kwargs):
        super(SensorsMEGData, self).__init__(**kwargs)
        self.default.reload(self.__class__,
                            folder_path="sensors",
                            file_name="meg_channels_reg13.txt.bz2")
コード例 #9
0
class ComplexCoherenceSpectrumData(arrays.MappedArray):
    """
    Result of a NodeComplexCoherence Analysis.
    """

    cross_spectrum = arrays.ComplexArray(
        label="The cross spectrum",
        file_storage=core.FILE_STORAGE_EXPAND,
        doc=""" A complex ndarray that contains the nodes x nodes cross
            spectrum for every frequency frequency and for every segment.""")

    array_data = arrays.ComplexArray(
        label="Complex Coherence",
        file_storage=core.FILE_STORAGE_EXPAND,
        doc="""The complex coherence coefficients calculated from the cross
            spectrum. The imaginary values of this complex ndarray represent the 
            imaginary coherence.""")

    source = time_series.TimeSeries(
        label="Source time-series",
        doc="""Links to the time-series on which the node_coherence is
            applied.""")

    epoch_length = basic.Float(
        label="Epoch length",
        doc="""The timeseries was segmented into equally sized blocks
            (overlapping if necessary), prior to the application of the FFT.
            The segement length determines the frequency resolution of the
            resulting spectra.""")

    segment_length = basic.Float(
        label="Segment length",
        doc="""The timeseries was segmented into equally sized blocks
            (overlapping if necessary), prior to the application of the FFT.
            The segement length determines the frequency resolution of the
            resulting spectra.""")

    #    frequency = arrays.FloatArray(
    #        label = "Frequency",
    #        doc = """DOC ME""")

    windowing_function = basic.String(
        label="Windowing function",
        doc="""The windowing function applied to each time segment prior to
            application of the FFT.""")

    #    number_of_epochs = basic.Integer(
    #        label = "Number of epochs",
    #        doc = """DOC ME""")
    #
    #    number_of_segments = basic.Integer(
    #        label = "Number of segments",
    #        doc = """DOC ME""")

    __generate_table__ = True
コード例 #10
0
class SensorsInternalData(SensorsData):
    """
    Sensors inside the brain...
    """
    _ui_name = "Internal Sensors"

    __tablename__ = None

    __mapper_args__ = {'polymorphic_identity': INTERNAL_POLYMORPHIC_IDENTITY}

    sensors_type = basic.String(default=INTERNAL_POLYMORPHIC_IDENTITY)
コード例 #11
0
class EEGCapData(OpenSurfaceData):
    """
    A surface defining the EEG Cap.
    """
    _ui_name = "EEG Cap"

    surface_type = basic.String(default=EEG_CAP)

    __tablename__ = None

    __mapper_args__ = {'polymorphic_identity': EEG_CAP}
コード例 #12
0
class DiscreteEquationData(EquationData):
    """
    A special case for 'discrete' spaces, such as the regions, where each point
    in the space is effectively just assigned a value.
    """

    equation = basic.String(
        label="Discrete Equation",
        default="var",
        locked=True,
        doc="""The equation defines a function of :math:`x`""")
コード例 #13
0
class FaceSurfaceData(OpenSurfaceData):
    """
    A surface defining the face of a human.
    """
    _ui_name = "Face Surface"

    surface_type = basic.String(default=FACE)

    __tablename__ = None

    __mapper_args__ = {'polymorphic_identity': FACE}
コード例 #14
0
class TimeSeriesData(MappedType):
    """
    Base time-series dataType.
    """

    title = basic.String

    data = arrays.FloatArray(
        label="Time-series data",
        file_storage=core.FILE_STORAGE_EXPAND,
        doc=
        """An array of time-series data, with a shape of [tpts, :], where ':' represents 1 or more dimensions"""
    )

    nr_dimensions = basic.Integer(label="Number of dimension in timeseries",
                                  default=4)

    length_1d, length_2d, length_3d, length_4d = [basic.Integer] * 4

    labels_ordering = basic.List(
        default=["Time", "State Variable", "Space", "Mode"],
        label="Dimension Names",
        doc="""List of strings representing names of each data dimension""")

    labels_dimensions = basic.Dict(
        default={},
        label=
        "Specific labels for each dimension for the data stored in this timeseries.",
        doc=
        """ A dictionary containing mappings of the form {'dimension_name' : [labels for this dimension] }"""
    )
    ## TODO (for Stuart) : remove TimeLine and make sure the correct Period/start time is returned by different monitors in the simulator

    time = arrays.FloatArray(
        file_storage=core.FILE_STORAGE_EXPAND,
        label="Time-series time",
        required=False,
        doc=
        """An array of time values for the time-series, with a shape of [tpts,].
        This is 'time' as returned by the simulator's monitors.""")

    start_time = basic.Float(label="Start Time:")

    sample_period = basic.Float(label="Sample period", default=1.0)

    # Specify the measure unit for sample period (e.g sec, msec, usec, ...)
    sample_period_unit = basic.String(label="Sample Period Measure Unit",
                                      default="ms")

    sample_rate = basic.Float(label="Sample rate",
                              doc="""The sample rate of the timeseries""")

    has_surface_mapping = basic.Bool(default=True)
    has_volume_mapping = basic.Bool(default=False)
コード例 #15
0
class ProjectionSurfaceEEGData(ProjectionData):
    """
    Specific projection, from a CorticalSurface to EEG sensors.
    """

    __tablename__ = None

    __mapper_args__ = {'polymorphic_identity': EEG_POLYMORPHIC_IDENTITY}

    projection_type = basic.String(default=EEG_POLYMORPHIC_IDENTITY)

    sensors = sensors.SensorsEEG
コード例 #16
0
ファイル: surfaces_data.py プロジェクト: tjgood/tvb-library
class CorticalSurfaceData(SurfaceData):
    """
    A surface for describing the Brain Cortical area.
    """

    _ui_name = "A cortical surface"

    surface_type = basic.String(default=CORTICAL, order=-1)

    ##--------------------- FRAMEWORK ATTRIBUTES -----------------------------##
    __tablename__ = None

    __mapper_args__ = {'polymorphic_identity': CORTICAL}
コード例 #17
0
ファイル: surfaces_data.py プロジェクト: tjgood/tvb-library
class SkinAirData(SurfaceData):
    """
    A surface defining the boundary between the skin and the air.
    """

    _ui_name = "Skin"

    surface_type = basic.String(default=OUTER_SKIN)

    ##--------------------- FRAMEWORK ATTRIBUTES -----------------------------##
    __mapper_args__ = {'polymorphic_identity': OUTER_SKIN}

    __generate_table__ = True
コード例 #18
0
ファイル: surfaces_data.py プロジェクト: tjgood/tvb-library
class BrainSkullData(SurfaceData):
    """
    A surface defining the boundary between the brain and the skull.
    """

    _ui_name = "Inside of the skull"

    surface_type = basic.String(default=INNER_SKULL)

    ##--------------------- FRAMEWORK ATTRIBUTES -----------------------------##
    __tablename__ = None

    __mapper_args__ = {'polymorphic_identity': INNER_SKULL}
コード例 #19
0
class WhiteMatterSurfaceData(SurfaceData):
    """
    The boundary between the white and gray matter
    """

    _ui_name = "A white matter surface"

    surface_type = basic.String(default=WHITE_MATTER)

    ##--------------------- FRAMEWORK ATTRIBUTES -----------------------------##
    __tablename__ = None

    __mapper_args__ = {'polymorphic_identity': WHITE_MATTER}
コード例 #20
0
ファイル: surfaces_data.py プロジェクト: tjgood/tvb-library
class SkullSkinData(SurfaceData):
    """
    A surface defining the boundary between the skull and the skin.
    """

    _ui_name = "Outside of the skull"

    surface_type = basic.String(default=OUTER_SKULL)

    ##--------------------- FRAMEWORK ATTRIBUTES -----------------------------##
    __tablename__ = None

    __mapper_args__ = {'polymorphic_identity': OUTER_SKULL}
コード例 #21
0
class WaveletCoefficientsData(arrays.MappedArray):
    """
    This class bundles all the elements of a Wavelet Analysis into a single 
    object, including the input TimeSeries datatype and the output results as 
    arrays (FloatArray)
    """
    #Overwrite attribute from superclass
    array_data = arrays.ComplexArray()

    source = time_series.TimeSeries(label="Source time-series")

    mother = basic.String(
        label="Mother wavelet",
        default="morlet",
        doc="""A string specifying the type of mother wavelet to use,
            default is 'morlet'.""")  # default to 'morlet'

    sample_period = basic.Float(label="Sample period")
    #sample_rate = basic.Integer(label = "")  inversely related

    frequencies = arrays.FloatArray(
        label="Frequencies", doc="A vector that maps scales to frequencies.")

    normalisation = basic.String(label="Normalisation type")
    # 'unit energy' | 'gabor'

    q_ratio = basic.Float(label="Q-ratio", default=5.0)

    amplitude = arrays.FloatArray(label="Amplitude",
                                  file_storage=core.FILE_STORAGE_EXPAND)

    phase = arrays.FloatArray(label="Phase",
                              file_storage=core.FILE_STORAGE_EXPAND)

    power = arrays.FloatArray(label="Power",
                              file_storage=core.FILE_STORAGE_EXPAND)

    __generate_table__ = True
コード例 #22
0
class CosineData(EquationData):
    """
    A Cosine equation.
    """
    
    equation = basic.String(  
        label = "Cosine Equation",
        default = "amp * cos(6.283185307179586 * frequency * var)",
        locked = True,
        doc = """:math:`amp \\cos(2.0 \\pi frequency x)` """)
    
    parameters = basic.Dict( 
        label = "Cosine Parameters",
        default = {"amp": 1.0, "frequency": 0.01}) #kHz #"pi": numpy.pi, 
コード例 #23
0
class LookUpTableData(MappedType):
    """
    Lookup Tables for storing pre-computed functions.
    Specific table subclasses are implemented below.
    
    """
    
    _base_classes = ['LookUpTables']

    table = readers.Table(folder_path = "tables")
    
    equation = basic.String(
        label = "String representation of the precalculated function",
        doc = """A latex representation of the function whose values are stored 
            in the table, with the extra escaping needed for interpretation via sphinx.""")
    
    xmin = arrays.FloatArray(
        label = "x-min",
        console_default = table.read_dimension('min_max', 0, field = "xmin"), 
        doc = """Minimum value""")
        
    xmax = arrays.FloatArray(
        label = "x-max",
        console_default = table.read_dimension('min_max', 1, field = "xmax"), 
        doc = """Maximum value""")
    
    data = arrays.FloatArray(
        label = "data",
        console_default = table.read_dimension('f', field = "data"), 
        doc = """Tabulated values""")
    
    number_of_values = basic.Integer(
        label = "Number of values",
        default = 0,
        doc = """The number of values in the table """)
        
    df = arrays.FloatArray(
        label = "df",
        console_default = table.read_dimension('df', field = "df"), 
        doc = """.""")
     
    dx = arrays.FloatArray(
        label = "dx",
        default = numpy.array([]), 
        doc = """Tabulation step""")    
    
    invdx = arrays.FloatArray(
       label = "invdx",
       default = numpy.array([]),
       doc = """.""")
コード例 #24
0
class StructuralMRIData(MappedArray):
    """
    Quantitative volumetric data recorded by means of Magnetic Resonance Imaging
    """

    # without the field below weighting and volume columns are going to be added to the MAPPED_ARRAY table
    __generate_table__ = True

    array_data = FloatArray(label="contrast")

    weighting = basic.String(
        label="MRI weighting")  # eg, "T1", "T2", "T2*", "PD", ...

    volume = volumes.Volume
コード例 #25
0
class SinusoidData(EquationData):
    """
    A Sinusoid equation.
    """
    
    equation = basic.String(  
        label = "Sinusoid Equation",
        default = "amp * sin(6.283185307179586 * frequency * var)",
        locked = True,
        doc = """:math:`amp \\sin(2.0 \\pi frequency x)` """)
    
    parameters = basic.Dict( 
        label = "Sinusoid Parameters",
        default = {"amp": 1.0, "frequency": 0.01}) #kHz #"pi": numpy.pi,
コード例 #26
0
ファイル: volumes.py プロジェクト: virati/tvb-library
class Volume(types_mapped.MappedType):
    """
    Data defined on a regular grid in three dimensions.

    """
    origin = arrays.PositionArray(label = "Volume origin coordinates")
    voxel_size = arrays.FloatArray(label = "Voxel size") # need a triplet, xyz
    voxel_unit = basic.String(label = "Voxel Measure Unit", default = "mm")

    def _find_summary_info(self):
        summary = {"Volume type": self.__class__.__name__,
                   "Origin": self.origin,
                   "Voxel size": self.voxel_size,
                   "Units": self.voxel_unit}
        return summary
コード例 #27
0
class AlphaData(EquationData):
    """
    An Alpha function belonging to the Exponential function family.
    """
    
    equation = basic.String( 
        label = "Alpha Equation",
        default = "where((var-onset) > 0, (alpha * beta) / (beta - alpha) * (exp(-alpha * (var-onset)) - exp(-beta * (var-onset))), 0.0 * var)",
        locked = True,
        doc = """:math:`(\\alpha * \\beta) / (\\beta - \\alpha) * 
            (\\exp(-\\alpha * (x-onset)) - \\exp(-\\beta * (x-onset)))` for :math:`(x-onset) > 0`""")
    
    parameters = basic.Dict( 
        label = "Alpha Parameters",
        default = {"onset": 0.5, "alpha": 13.0, "beta":  42.0})
コード例 #28
0
class _InputTreeFragment(core.Type):
    """
    This trait-ed class is used to build the input tree for the integrator.
    """
    dynamic_name = types_basic.String(
        label="Parameter configuration name",
        required=True,
        order=1,
        doc="""The name of this parameter configuration""")

    integrator = integrators.Integrator(label="integrator",
                                        required=True,
                                        order=2,
                                        default=integrators.HeunDeterministic,
                                        doc="""The integrator""")
コード例 #29
0
class SensorsInternal(Sensors):
    """
    Sensors inside the brain...
    """
    _ui_name = "Internal Sensors"

    __tablename__ = None

    __mapper_args__ = {'polymorphic_identity': INTERNAL_POLYMORPHIC_IDENTITY}

    sensors_type = types_basic.String(default=INTERNAL_POLYMORPHIC_IDENTITY)

    @classmethod
    def from_file(cls, source_file="seeg_39.txt.bz2", instance=None):
        return super(SensorsInternal, cls).from_file(source_file, instance)
コード例 #30
0
class LinearData(EquationData):
    """
    A linear equation.
    """

    equation = basic.String(label="Linear Equation",
                            default="a * var + b",
                            locked=True,
                            doc=""":math:`result = a * x + b`""")

    parameters = basic.Dict(label="Linear Parameters",
                            default={
                                "a": 1.0,
                                "b": 0.0
                            })