TheVirtualBrain:

TheDocumentationwebsite.

Table Of Contents

Previous topic

neocom Package

Next topic

project_versions Package

This Page

neotraits Package

_h5accessors

class tvb.core.neotraits._h5accessors.Accessor(trait_attribute, h5file, name=None)[source]

Bases: builtins.object

load()[source]
store(val)[source]
class tvb.core.neotraits._h5accessors.DataSet(trait_attribute, h5file, name=None, expand_dimension=-1)[source]

Bases: tvb.core.neotraits._h5accessors.Accessor

A dataset in a h5 file that corresponds to a traited NArray.

append(data, close_file=True, grow_dimension=None)[source]

Method to be called when it is necessary to write slices of data for a large dataset, eg. TimeSeries. Metdata for such datasets is written only at file close time, see H5File.close method.

get_cached_metadata()[source]

Returns cached properties of this dataset, like min max mean etc. This cache is useful for large, expanding datasets, when we want to avoid loading the whole dataset just to compute a max.

load()[source]
shape[source]
store(data)[source]
class tvb.core.neotraits._h5accessors.DataSetMetaData(min, max, mean, is_finite=True, has_complex=False)[source]

Bases: builtins.object

simple container for dataset metadata Useful as a cache of global min max values. Viewers rely on these for colorbars.

classmethod from_array(array)[source]
classmethod from_dict(dikt)[source]
merge(other)[source]
to_dict()[source]
class tvb.core.neotraits._h5accessors.EquationScalar(trait_attribute, h5file, name=None)[source]

Bases: tvb.core.neotraits._h5accessors.Accessor

An attribute in a h5 file that corresponds to a traited Equation.

KEY_PARAMETERS = 'parameters'
KEY_TYPE = 'type'
load()[source]
store(data)[source]
class tvb.core.neotraits._h5accessors.Json(trait_attribute, h5file, name=None, json_encoder=None, json_decoder=None)[source]

Bases: tvb.core.neotraits._h5accessors.Scalar

A python json like data structure accessor This works with simple Attr(list) Attr(dict) List(of=...)

load()[source]
store(val)[source]

stores a json in the h5 metadata

class tvb.core.neotraits._h5accessors.JsonFinal(trait_attribute, h5file, name=None)[source]

Bases: tvb.core.neotraits._h5accessors.Json

A python json like data structure accessor meant to be used with Final(dict)

class StateVariablesDecoder[source]

Bases: json.decoder.JSONDecoder

dict_array(dictionary)[source]
class JsonFinal.StateVariablesEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)[source]

Bases: json.encoder.JSONEncoder

default(o)[source]
class tvb.core.neotraits._h5accessors.JsonRange(trait_attribute, h5file, name=None)[source]

Bases: tvb.core.neotraits._h5accessors.Scalar

Stores and loads a Range in the form of a json in h5.

load()[source]
store(val)[source]
class tvb.core.neotraits._h5accessors.Reference(trait_attribute, h5file, name=None)[source]

Bases: tvb.core.neotraits._h5accessors.Uuid

A reference to another h5 file Corresponds to a contained datatype

store(val)[source]

The reference is stored as a gid in the metadata. :param val: a datatype or a uuid.UUID gid

class tvb.core.neotraits._h5accessors.ReferenceList(trait_attribute, h5file, name=None, json_encoder=None, json_decoder=None)[source]

Bases: tvb.core.neotraits._h5accessors.Json

store(val)[source]
class tvb.core.neotraits._h5accessors.Scalar(trait_attribute, h5file, name=None)[source]

Bases: tvb.core.neotraits._h5accessors.Accessor

A scalar in a h5 file that corresponds to a traited attribute. Serialized as a global h5 attribute

load()[source]
store(val)[source]
class tvb.core.neotraits._h5accessors.SparseMatrix(trait_attribute, h5file, name=None)[source]

Bases: tvb.core.neotraits._h5accessors.Accessor

Stores and loads a scipy.sparse csc or csr matrix in h5.

constructors = {'csr': <class 'scipy.sparse.csr.csr_matrix'>, 'csc': <class 'scipy.sparse.csc.csc_matrix'>}
get_metadata()[source]
load()[source]
store(mtx)[source]
class tvb.core.neotraits._h5accessors.SparseMatrixMetaData(minimum, maximum, mean, format, dtype, shape)[source]

Bases: tvb.core.neotraits._h5accessors.DataSetMetaData

Essential metadata for interpreting a sparse matrix stored in h5

classmethod from_array(mtx)[source]
classmethod from_dict(dikt)[source]
static parse_shape(shapestr)[source]
to_dict()[source]
class tvb.core.neotraits._h5accessors.Uuid(trait_attribute, h5file, name=None)[source]

Bases: tvb.core.neotraits._h5accessors.Scalar

load()[source]
store(val)[source]

_h5core

class tvb.core.neotraits._h5core.H5File(path)[source]

Bases: builtins.object

A H5 based file format. This class implements reading and writing to a specific h5 based file format. A subclass of this defines a new file format.

KEY_WRITTEN_BY = 'written_by'
close()[source]
determine_datatype_from_file()[source]
static determine_type(path)[source]
classmethod file_name_base()[source]
static from_file(path)[source]
gather_references(datatype_cls=None)[source]
get_class_path()[source]
static get_metadata_param(path, param)[source]
static h5_class_from_file(path)[source]
is_new_file = False
iter_accessors()[source]
iter_datasets()[source]
load_generic_attributes()[source]
load_into(datatype)[source]
read_subtype_attr()[source]
static remove_metadata_param(file_path, param)[source]
store(datatype, scalars_only=False, store_references=True)[source]
store_generic_attributes(generic_attributes, create=True)[source]
store_metadata_param(key, value)[source]
class tvb.core.neotraits._h5core.ViewModelH5(path, view_model)[source]

Bases: tvb.core.neotraits._h5core.H5File

gather_datatypes_references()[source]

Mind that ViewModelH5 stores references towards ViewModel objects (eg. Coupling) as Reference attributes, and references towards existent Datatypes (eg. Connectivity) as Uuid. Thus, the method gather_references will return only references towards other ViewModels, and we need this method to gather also datatypes references.

db

class tvb.core.neotraits.db.HasTraitsIndex[source]

Bases: sqlalchemy.orm.decl_api.DeclarativeBase

create_date
get_subtype_attr()[source]
gid
id
title
type_
tvb.core.neotraits.db.ensure_float(data)[source]
tvb.core.neotraits.db.ensure_int(data)[source]
tvb.core.neotraits.db.from_ndarray(array)[source]
tvb.core.neotraits.db.prepare_array_shape_meta(shape_array)[source]

forms

class tvb.core.neotraits.forms.ArrayField(trait_attribute, name=None, disabled=False)[source]

Bases: tvb.core.neotraits.forms.TraitField

template = 'form_fields/str_field.html'
value[source]
class tvb.core.neotraits.forms.BoolField(trait_attribute, name=None, disabled=False)[source]

Bases: tvb.core.neotraits.forms.TraitField

template = 'form_fields/bool_field.html'
class tvb.core.neotraits.forms.Field(name, disabled=False, required=False, label='', doc='', default=None)[source]

Bases: builtins.object

fill_from_post(post_data)[source]

deserialize form a post dictionary

template = None
validate()[source]

validation besides the deserialization from post

value[source]
class tvb.core.neotraits.forms.FloatField(trait_attribute, name=None, disabled=False)[source]

Bases: tvb.core.neotraits.forms.TraitField

max = None
min = None
step = 'any'
template = 'form_fields/number_field.html'
class tvb.core.neotraits.forms.Form[source]

Bases: builtins.object

fields[source]
fill_from_post(form_data)[source]
fill_from_single_post_param(**param)[source]
fill_from_trait(trait)[source]

Sets data for all traited fields from a trait instance. Note that FormFields are not TraitFields, so this does not work recursively Override to fill in sub-forms

fill_trait(datatype)[source]

Copies the value of the TraitFields to the corresponding Attr-ibutes of the given trait instance Note that FormFields are not TraitFields, so this does not work recursively Override to fill in sub-forms

fill_trait_partially(datatype, fields=None)[source]
get_errors_dict()[source]
get_subform_key()[source]

If the current form can be used as subform, this method should return the proper value from SubformsEnum.

trait_fields[source]
validate()[source]
class tvb.core.neotraits.forms.FormField(form_class, name, label='', doc='')[source]

Bases: tvb.core.neotraits.forms.Field

fill_from_post(post_data)[source]
template = 'form_fields/form_field.html'
validate()[source]
class tvb.core.neotraits.forms.HiddenField(trait_attribute, name=None, disabled=False)[source]

Bases: tvb.core.neotraits.forms.TraitField

template = 'form_fields/hidden_field.html'
class tvb.core.neotraits.forms.IntField(trait_attribute, name=None, disabled=False)[source]

Bases: tvb.core.neotraits.forms.TraitField

max = None
min = None
template = 'form_fields/number_field.html'
class tvb.core.neotraits.forms.MultiSelectField(trait_attribute, name=None, disabled=False)[source]

Bases: tvb.core.neotraits.forms.TraitField

options()[source]

to be used from template, assumes self.data is set

template = 'form_fields/checkbox_field.html'
class tvb.core.neotraits.forms.Option

Bases: builtins.tuple

Option(id, value, label, checked)

checked

Alias for field number 3

id

Alias for field number 0

label

Alias for field number 2

value

Alias for field number 1

class tvb.core.neotraits.forms.SelectField(trait_attribute, name=None, disabled=False, choices=None, display_none_choice=True, subform=None, display_subform=True, ui_values=None)[source]

Bases: tvb.core.neotraits.forms.TraitField

missing_value = 'explicit-None-value'
options()[source]

to be used from template, assumes self.data is set

subform_prefix = 'subform_'
template = 'form_fields/radio_field.html'
value[source]
class tvb.core.neotraits.forms.StrField(trait_attribute, name=None, disabled=False)[source]

Bases: tvb.core.neotraits.forms.TraitField

template = 'form_fields/str_field.html'
class tvb.core.neotraits.forms.TraitDataTypeSelectField(trait_attribute, name=None, conditions=None, draw_dynamic_conditions_buttons=True, has_all_option=False, show_only_all_option=False)[source]

Bases: tvb.core.neotraits.forms.TraitField

from_trait(trait, f_name)[source]
get_dynamic_filters[source]
get_form_filters[source]
missing_value = 'explicit-None-value'
options()[source]
template = 'form_fields/datatype_select_field.html'
class tvb.core.neotraits.forms.TraitField(trait_attribute, name=None, disabled=False)[source]

Bases: tvb.core.neotraits.forms.Field

from_trait(trait, f_name)[source]
class tvb.core.neotraits.forms.TraitUploadField(traited_attribute, required_type, name, disabled=False)[source]

Bases: tvb.core.neotraits.forms.TraitField

template = 'form_fields/upload_field.html'

h5

uploader_view_model

class tvb.core.neotraits.uploader_view_model.UploaderViewModel(**kwargs)[source]

Bases: tvb.core.neotraits.view_model.ViewModel

data_subject : tvb.core.neotraits.uploader_view_model.UploaderViewModel.data_subject = Str(field_type=<class ‘str’>, default=’John Doe’, required=True)

encrypted_aes_key : tvb.core.neotraits.uploader_view_model.UploaderViewModel.encrypted_aes_key = Str(field_type=<class ‘str’>, default=None, required=False)
Check our demo notebook on how to produce this key and how we expect your files to be encrypted

operation_group_gid : tvb.core.neotraits.view_model.ViewModel.operation_group_gid = Attr(field_type=<class ‘uuid.UUID’>, default=None, required=False)

ranges : tvb.core.neotraits.view_model.ViewModel.ranges = Attr(field_type=<class ‘str’>, default=None, required=False)

range_values : tvb.core.neotraits.view_model.ViewModel.range_values = Attr(field_type=<class ‘str’>, default=None, required=False)

is_metric_operation : tvb.core.neotraits.view_model.ViewModel.is_metric_operation = Attr(field_type=<class ‘bool’>, default=False, required=True)

gid : tvb.basic.neotraits._core.HasTraits.gid = Attr(field_type=<class ‘uuid.UUID’>, default=None, required=True)

REQUIRED_TYPE = None
data_subject
encrypted_aes_key

view_model

class tvb.core.neotraits.view_model.DataTypeGidAttr(linked_datatype, field_type=<class 'uuid.UUID'>, filters=None, default=None, doc='', label='', required=True, final=False, choices=None)[source]

Bases: tvb.basic.neotraits._attr.Attr

Keep a GID but also link the type of DataType it should point to

class tvb.core.neotraits.view_model.EquationAttr(field_type, default=None, doc='', label='', required=True, final=False, choices=None)[source]

Bases: tvb.basic.neotraits._attr.Attr

# TODO: there are places where we need eq params as a nested form. Figure out a proper model

class tvb.core.neotraits.view_model.Str(field_type=<class 'str'>, default=None, doc='', label='', required=True, final=False, choices=None)[source]

Bases: tvb.basic.neotraits._attr.Attr

class tvb.core.neotraits.view_model.ViewModel(**kwargs)[source]

Bases: tvb.basic.neotraits._core.HasTraits

operation_group_gid : tvb.core.neotraits.view_model.ViewModel.operation_group_gid = Attr(field_type=<class ‘uuid.UUID’>, default=None, required=False)

ranges : tvb.core.neotraits.view_model.ViewModel.ranges = Attr(field_type=<class ‘str’>, default=None, required=False)

range_values : tvb.core.neotraits.view_model.ViewModel.range_values = Attr(field_type=<class ‘str’>, default=None, required=False)

is_metric_operation : tvb.core.neotraits.view_model.ViewModel.is_metric_operation = Attr(field_type=<class ‘bool’>, default=False, required=True)

gid : tvb.basic.neotraits._core.HasTraits.gid = Attr(field_type=<class ‘uuid.UUID’>, default=None, required=True)

is_metric_operation

An Attr declares the following about the attribute it describes: * the type * a default value shared by all instances * if the value might be missing * documentation It will resolve to attributes on the instance.

linked_has_traits()[source]
operation_group_gid

An Attr declares the following about the attribute it describes: * the type * a default value shared by all instances * if the value might be missing * documentation It will resolve to attributes on the instance.

range_values

An Attr declares the following about the attribute it describes: * the type * a default value shared by all instances * if the value might be missing * documentation It will resolve to attributes on the instance.

ranges

An Attr declares the following about the attribute it describes: * the type * a default value shared by all instances * if the value might be missing * documentation It will resolve to attributes on the instance.

tvb.core.neotraits.view_model.replace_nan_values(input_data)[source]

Replace NAN values with a given values