The Virtual Brain Project

Table Of Contents

Previous topic

logger Package

Next topic

adapters Package

This Page

core Package

This is an abstract package.

It should be capable of managing (store, create, repeat, log, etc.) a generic and abstract workFlow of algorithms.

Make sure that all the code you add to this package is abstract!!!! You’ve been warned! No dependencies towards specific adapters should be included here.



Synchronization annotation. We try to mimic the same behavior as Java has with keyword synchronized, for methods.


Decorator that makes sure a function is executed in a ‘user’ environment, removing any TVB specific configurations that alter either LD_LIBRARY_PATH or LD_RUN_PATH.


This module is called in a new process by the rpserver: Example: python 4 user_name_label 4 is the operation id stored in the DataBase in the table “OPERATIONS” It gets the algorithm, and the adapter with its parameters from database. And finally launches the computation. The results of the computation will be stored by the adapter itself.


Event attached to the local queue for executing an operation, when we will have resources available.


Created on Nov 1, 2011

Parameters:datatype_index_class – class of datatype index; to search for a remover class for this.

Update removers dictionary.


class tvb.core.utils.TVBJSONEncoder(*, 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

Custom encoder class. Referring towards “to_json” method, when found, or default behaviour otherwise.

tvb.core.utils.date2string(date_input, complex_format=True, date_format=None)[source]

Convert date into string, after internal format


Extract the first doc entry from a matlab file.

tvb.core.utils.format_bytes_human(size, si=False)[source]
  • size – size in kilobytes
  • si – if True use SI units (multiple of 1000 not 1024)

a String with [number] [memory unit measure]

tvb.core.utils.format_timedelta(timedelta, most_significant2=True)[source]

Format a datetime.timedelta. :param timedelta: object timedelta to format :param most_significant2: Will show only the 2 most significant units (ex: hours, minutes). Default True.


Generate new Global Unique Identifier. This identifier should be unique per each station, and unique for different machines.


Check If MATLAB is installed on current system. Return True or False. Return True, when MATLAB executable is found in Path.

tvb.core.utils.get_unique_file_name(storage_folder, file_name, try_number=0)[source]

Compute non-existent file name, in storage_folder. Try file_name, and if already exists, try adding a number.


From JSON with Unicodes, return a dictionary having strings as keys. Loading from DB a JSON will return instead of string keys, unicodes.


Prepare a File System Path for passing into an URL.

tvb.core.utils.prepare_time_slice(total_time_length, max_length=10000)[source]

Limit the time dimension when retrieving from TS. If total time length is greater than MAX, then retrieve only the last part of the TS

  • total_time_length – TS time dimension
  • max_length – limiting number of TS steps

python slice

tvb.core.utils.store_list_data(data_list, file_name, storage_folder, overwrite=False)[source]

Write a list into a file using CSV writer. CSV writer, better than numpy, write also Strings

tvb.core.utils.string2array(input_data_str, split_char, dtype=None)[source]
Given an input string first try to load it using JSON and if that fails,
meaning some weird array is given by the user, fall-back to _custom_string2array.

Convert given string into boolean value.

tvb.core.utils.string2date(string_input, complex_format=True, date_format=None)[source]

Read date from string, after internal format


Retrieve File System Path from encoded URL (inverse of path2url_part).