cerebralcortex.core.metadata_manager.stream package

Submodules

cerebralcortex.core.metadata_manager.stream.data_descriptor module

class DataDescriptor[source]

Bases: object

from_json(obj)[source]

Cast DataDescriptor class object into json

Parameters:obj (DataDescriptor) – object of a data descriptor class
Returns:
Return type:self
set_attribute(key, value)[source]

Attributes field is option in metadata object. Arbitrary number or attributes could be attached to a DataDescriptor

Parameters:
  • key (str) – key of an attribute
  • value (str) – value of an attribute
Returns:

Return type:

self

Raises:

ValueError – if key/value are missing

set_name(value)[source]

Name of data descriptor

Parameters:value (str) – name
Returns:
Return type:self
set_type(value: str)[source]

Type of a data descriptor

Parameters:value (str) – type
Returns:
Return type:self

cerebralcortex.core.metadata_manager.stream.metadata module

class Metadata[source]

Bases: object

add_annotation(annotation: str)[source]

Add annotation stream name

Parameters:annotation (str) – name of annotation or list of strings
Returns:self
add_dataDescriptor(dd: cerebralcortex.core.metadata_manager.stream.data_descriptor.DataDescriptor)[source]

Add data description of a stream

Parameters:dd (DataDescriptor) – data descriptor
Returns:self
add_input_stream(input_stream: str)[source]

Add input streams that were used to derive a new stream

Parameters:input_stream (str) – name of input stream OR list of input_stream names
Returns:self
add_module(mod: cerebralcortex.core.metadata_manager.stream.module_info.ModuleMetadata)[source]

Add module metadata

Parameters:mod (ModuleMetadata) – module metadata
Returns:self
from_json_file(metadata: dict) → List[source]

Convert dict (json) objects into Metadata class objects

Parameters:dict (json_list) – metadata dict
Returns:metadata class object
Return type:Metadata
from_json_sql(metadata_json: dict) → List[source]

Convert dict (json) objects into Metadata class objects

Parameters:dict (json_list) – metadata dict
Returns:metadata class object
Return type:Metadata
get_dataDescriptor(name)[source]

get data descriptor by name

Parameters:name (str) –
Returns:DataDescriptor object
get_hash() → str[source]

Get the unique hash of metadata. Hash is generated based on “stream-name + data_descriptor + module-metadata”

Returns:hash id of metadata
Return type:str
get_hash_by_json(metadata: dict = None) → str[source]

Get the unique hash of metadata. Hash is generated based on “stream-name + data_descriptor + module-metadata”

Parameters:metadata – only pass this if this method is used on a dict object outside of Metadata class
Returns:hash id of metadata
Return type:str
get_name()[source]

Returns: name of a stream

is_valid() → bool[source]

check whether all required fields are set

Returns:True if fields are set or throws an exception in case of missing values
Return type:bool
Exception:
ValueError: if metadata fields are not set
set_description(stream_description: str)[source]

Add stream description

Parameters:stream_description (str) – textual description of a stream
Returns:self
set_name(value: str)[source]

set name of a stream

Parameters:value (str) – name of a stream
Returns:self
set_study_name(value: str)[source]

set study name

Parameters:value (str) – study name
Returns:self
to_json() → dict[source]

Convert MetaData object into a dict (json) object

Returns:dict form of MetaData object
Return type:dict

cerebralcortex.core.metadata_manager.stream.module_info module

class ModuleMetadata[source]

Bases: object

from_json(obj)[source]

Cast ModuleMetadata class object into json

Parameters:obj (ModuleMetadata) – object of a ModuleMetadata class
Returns:
Return type:self
set_attribute(key: str, value: str)[source]

Attributes field is option in metadata object. Arbitrary number or attributes could be attached to a DataDescriptor

Parameters:
  • key (str) – key of an attribute
  • value (str) – value of an attribute
Returns:

Return type:

self

Raises:

ValueError – if key/value are missing

set_author(key, value)[source]

set author key/value pair. For example, key=name, value=md2k

Parameters:
  • key (str) – author metadata key
  • value (str) – author metadata value
Returns:

Return type:

self

set_authors(authors)[source]

set author key/value pair. For example, key=name, value=md2k

Parameters:authors (list[dict]) – List of authors names and emails ids in dict. For example, authors = [{“ali”:”ali@gmail.com”}, {“nasir”:”nasir@gmail.com”}]
Returns:
Return type:self
set_name(value)[source]

name of the module

Parameters:value (str) – name
Returns:
Return type:self
set_version(value)[source]

version of the module

Parameters:value (str) – version
Returns:
Return type:self

Module contents

class Metadata[source]

Bases: object

add_annotation(annotation: str)[source]

Add annotation stream name

Parameters:annotation (str) – name of annotation or list of strings
Returns:self
add_dataDescriptor(dd: cerebralcortex.core.metadata_manager.stream.data_descriptor.DataDescriptor)[source]

Add data description of a stream

Parameters:dd (DataDescriptor) – data descriptor
Returns:self
add_input_stream(input_stream: str)[source]

Add input streams that were used to derive a new stream

Parameters:input_stream (str) – name of input stream OR list of input_stream names
Returns:self
add_module(mod: cerebralcortex.core.metadata_manager.stream.module_info.ModuleMetadata)[source]

Add module metadata

Parameters:mod (ModuleMetadata) – module metadata
Returns:self
from_json_file(metadata: dict) → List[source]

Convert dict (json) objects into Metadata class objects

Parameters:dict (json_list) – metadata dict
Returns:metadata class object
Return type:Metadata
from_json_sql(metadata_json: dict) → List[source]

Convert dict (json) objects into Metadata class objects

Parameters:dict (json_list) – metadata dict
Returns:metadata class object
Return type:Metadata
get_dataDescriptor(name)[source]

get data descriptor by name

Parameters:name (str) –
Returns:DataDescriptor object
get_hash() → str[source]

Get the unique hash of metadata. Hash is generated based on “stream-name + data_descriptor + module-metadata”

Returns:hash id of metadata
Return type:str
get_hash_by_json(metadata: dict = None) → str[source]

Get the unique hash of metadata. Hash is generated based on “stream-name + data_descriptor + module-metadata”

Parameters:metadata – only pass this if this method is used on a dict object outside of Metadata class
Returns:hash id of metadata
Return type:str
get_name()[source]

Returns: name of a stream

is_valid() → bool[source]

check whether all required fields are set

Returns:True if fields are set or throws an exception in case of missing values
Return type:bool
Exception:
ValueError: if metadata fields are not set
set_description(stream_description: str)[source]

Add stream description

Parameters:stream_description (str) – textual description of a stream
Returns:self
set_name(value: str)[source]

set name of a stream

Parameters:value (str) – name of a stream
Returns:self
set_study_name(value: str)[source]

set study name

Parameters:value (str) – study name
Returns:self
to_json() → dict[source]

Convert MetaData object into a dict (json) object

Returns:dict form of MetaData object
Return type:dict
class DataDescriptor[source]

Bases: object

from_json(obj)[source]

Cast DataDescriptor class object into json

Parameters:obj (DataDescriptor) – object of a data descriptor class
Returns:
Return type:self
set_attribute(key, value)[source]

Attributes field is option in metadata object. Arbitrary number or attributes could be attached to a DataDescriptor

Parameters:
  • key (str) – key of an attribute
  • value (str) – value of an attribute
Returns:

Return type:

self

Raises:

ValueError – if key/value are missing

set_name(value)[source]

Name of data descriptor

Parameters:value (str) – name
Returns:
Return type:self
set_type(value: str)[source]

Type of a data descriptor

Parameters:value (str) – type
Returns:
Return type:self
class ModuleMetadata[source]

Bases: object

from_json(obj)[source]

Cast ModuleMetadata class object into json

Parameters:obj (ModuleMetadata) – object of a ModuleMetadata class
Returns:
Return type:self
set_attribute(key: str, value: str)[source]

Attributes field is option in metadata object. Arbitrary number or attributes could be attached to a DataDescriptor

Parameters:
  • key (str) – key of an attribute
  • value (str) – value of an attribute
Returns:

Return type:

self

Raises:

ValueError – if key/value are missing

set_author(key, value)[source]

set author key/value pair. For example, key=name, value=md2k

Parameters:
  • key (str) – author metadata key
  • value (str) – author metadata value
Returns:

Return type:

self

set_authors(authors)[source]

set author key/value pair. For example, key=name, value=md2k

Parameters:authors (list[dict]) – List of authors names and emails ids in dict. For example, authors = [{“ali”:”ali@gmail.com”}, {“nasir”:”nasir@gmail.com”}]
Returns:
Return type:self
set_name(value)[source]

name of the module

Parameters:value (str) – name
Returns:
Return type:self
set_version(value)[source]

version of the module

Parameters:value (str) – version
Returns:
Return type:self