The Virtual Brain Project

Table Of Contents

Previous topic

analyzers Package

Next topic

config Package

This Page

basic Package

arguments_serialisation

This is a framework helper module. Some framework datatypes have functions that will be called via http by the TVB GUI. These functions will receive some arguments as strings and return json serializable structures usually dicts. This module contains functions to parse those strings and construct those responses.

tvb.basic.arguments_serialisation.parse_slice(slice_string)[source]

Parse a slicing expression >>> parse_slice(”::1, :”) (slice(None, None, 1), slice(None, None, None)) >>> parse_slice(“2”) 2 >>> parse_slice(“[2]”) 2

tvb.basic.arguments_serialisation.postprocess_voxel_ts(ts, slices, background_value=None, background_min=None, background_max=None, label=None)[source]

Read TimeLine from TS and prepare the result for TSVolumeViewer.

Parameters:
  • ts – TS instance, with read_data_slice method
  • slices – slices for reading from H5
Returns:

A complex dictionary with information about current voxel.

tvb.basic.arguments_serialisation.preprocess_space_parameters(x, y, z, max_x, max_y, max_z)[source]

Covert ajax call parameters into numbers and validate them.

Parameters:
  • x – coordinate
  • y – coordinate
  • z – coordinate that will be reversed
  • max_x – maximum x accepted value
  • max_y – maximum y accepted value
  • max_z – maximum z accepted value
Returns:

(x, y, z) as integers, Z reversed

tvb.basic.arguments_serialisation.preprocess_time_parameters(t1, t2, time_length)[source]

Covert ajax call parameters into numbers and validate them.

Parameters:
  • t1 – start time
  • t2 – end time
  • time_length – maximum time length in current TS
Returns:

(t1, t2, t2-t1) as numbers

tvb.basic.arguments_serialisation.slice_str(slice_or_tuple)[source]
>>> slice_str(slice(1, None, 2))
'1::2'
>>> slice_str((slice(None, None, 2), slice(None), 4))
'::2, :, 4'
Does not handle ... yet

profile

TVB Profile Manager (top level in TVB profile & settings).

This class is responsible for referring towards application settings, based on current running environment (e.g. dev vs deployment), or developer profile choice (e.g. web vs console).

class tvb.basic.profile.TvbProfile[source]

ENUM-like class with current TVB profile and accepted values.

ALL = ['LIBRARY_PROFILE', 'COMMAND_PROFILE', 'WEB_PROFILE', 'MATLAB_PROFILE', 'TEST_POSTGRES_PROFILE', 'TEST_SQLITE_PROFILE', 'TEST_LIBRARY_PROFILE']
COMMAND_PROFILE = 'COMMAND_PROFILE'
CURRENT_PROFILE_NAME = None
LIBRARY_PROFILE = 'LIBRARY_PROFILE'
MATLAB_PROFILE = 'MATLAB_PROFILE'
REGISTERED_PROFILES = {}
TEST_LIBRARY_PROFILE = 'TEST_LIBRARY_PROFILE'
TEST_POSTGRES_PROFILE = 'TEST_POSTGRES_PROFILE'
TEST_SQLITE_PROFILE = 'TEST_SQLITE_PROFILE'
WEB_PROFILE = 'WEB_PROFILE'
current = <tvb.basic.config.profile_settings.BaseSettingsProfile object at 0x7f7229de1f10>
env = <tvb.basic.config.environment.Environment instance at 0x7f7229d743f8>
static is_first_run()[source]
static is_library_mode(new_profile=None)[source]
classmethod set_profile(selected_profile, in_operation=False, run_init=True)[source]

Sets TVB profile and do related initializations.

tvb.basic.profile.cleanup_metapath()[source]

Restore sys.meta_path, as some profiles (Library) are adding something

readers

This module contains basic reading mechanism for default DataType fields.

class tvb.basic.readers.FileReader(file_path)[source]

Bases: object

Read one or multiple numpy arrays from a text/bz2 file.

read_array(dtype=<type 'numpy.float64'>, skip_rows=0, use_cols=None, matlab_data_name=None)[source]
read_gain_from_brainstorm()[source]
class tvb.basic.readers.H5Reader(h5_path)[source]

Bases: object

Read one or many numpy arrays from a H5 file.

read_field(field, log_exception=True)[source]
read_optional_field(field)[source]
exception tvb.basic.readers.ReaderException[source]

Bases: exceptions.Exception

class tvb.basic.readers.ZipReader(zip_path)[source]

Bases: object

Read one or many numpy arrays from a ZIP archive.

read_array_from_file(file_name, dtype=<type 'numpy.float64'>, skip_rows=0, use_cols=None, matlab_data_name=None)[source]
read_optional_array_from_file(file_name, dtype=<type 'numpy.float64'>, skip_rows=0, use_cols=None, matlab_data_name=None)[source]
tvb.basic.readers.copy_zip_entry_into_temp(source, file_suffix, buffer_size=1048576)[source]

Copy a ZIP Entry into a new file created under system temporary folder.

Parameters:
  • source – ZipEntry
  • file_suffix – String suffix to be added to the temporary file name
  • buffer_size – Buffer size used when copying the file-content
Returns:

the path towards the new file.

tvb.basic.readers.try_get_absolute_path(relative_module, file_suffix)[source]
Parameters:
  • relative_module – python module to be imported. When import of this fails, we will return the file_suffix
  • file_suffix – In case this is already an absolute path, return it immediately, otherwise append it after the module path
Returns:

Try to build an absolute path based on a python module and a file-suffix