API Documentation

All modules above listed are under the “sct_dbtool” namespace.

Contents:

sct_dbtool.api – Server API

class sct_dbtool.api.APIClient(user: str, password: str, hostname='tristano.neuro.polymtl.ca', port=80)[source]

The API client for the web management tool. This API client contains code only for retrieving the entire JSON dataset.

Parameters:
  • user – username for the web management.
  • password – password for the web management.
  • hostname – the hostname for the web management.
  • port – the port of the web management.
classmethod from_config(config: Dict)[source]

Use this class method to create a new API client from a configuration dictionary.

Parameters:config – the configuration.
Returns:a new configured APIClient instance.
get_dataset() → List[Dict][source]

Retrieves the entire dataset from the server.

Returns:list of items from the dataset.

sct_dbtool.sanity – Sanity Checks

class sct_dbtool.sanity.CheckEmptyDemographics(db_path: str)[source]

This check will verify if the demographics field is present.

check(item: Dict)[source]

Implement this function in the sub-classes to add the specific checks.

Parameters:item – each item of the database
class sct_dbtool.sanity.CheckFilesystemDB(db_path: str)[source]

This check will verify if all files in file system are present in the database.

check(item: Dict)[source]

Implement this function in the sub-classes to add the specific checks.

Parameters:item – each item of the database
teardown()[source]

This function is called after finishing the checking on all database items. Before collecting diagnostic messages.

class sct_dbtool.sanity.CheckLabelVolumeConsistency(db_path: str)[source]

This check will verify if the label is consistent with the volume (shapes).

check(item: Dict)[source]

Implement this function in the sub-classes to add the specific checks.

Parameters:item – each item of the database
class sct_dbtool.sanity.CheckLabelVolumePath(db_path: str)[source]

This check will verify if the label volume exists in the file system.

check(item: Dict)[source]

Implement this function in the sub-classes to add the specific checks.

Parameters:item – each item of the database
class sct_dbtool.sanity.CheckMainVolumeNibabel(db_path: str)[source]

This check will verify if nibabel is able to open the main volume.

check(item: Dict)[source]

Implement this function in the sub-classes to add the specific checks.

Parameters:item – each item of the database
class sct_dbtool.sanity.CheckMainVolumePath(db_path: str)[source]

This check will verify if the main volume exists in the file system.

check(item: Dict)[source]

Implement this function in the sub-classes to add the specific checks.

Parameters:item – each item of the database
class sct_dbtool.sanity.Diagnostic(category: str, check_name: str, message: str, item: Dict)[source]

This is a data class to represent the diagnostics.

Parameters:
  • category – the diagnostic category (warning, error, info)
  • check_name – the name of the check that generated the diagnostic.
  • message – message generated by the check.
  • item – the item related to the diagnostic.
class sct_dbtool.sanity.SanityCheck(category: str, db_path: str)[source]

Extend this class to implement new sanity checks.

Parameters:
  • category – category of the check (warning, error or info).
  • db_path – the path to the database.
add_diagnostic(msg: str, item: Dict)[source]

Add a new diagnostic message for the item.

Parameters:
  • msg – message with details about the diagnostic.
  • item – item who generated the diagnostic.
check(item: Dict)[source]

Implement this function in the sub-classes to add the specific checks.

Parameters:item – each item of the database
collect_diagnostics() → List[sct_dbtool.sanity.Diagnostic][source]

This method will collect all diagnostics generated by each checking.

Returns:a list of diagnostics.
teardown()[source]

This function is called after finishing the checking on all database items. Before collecting diagnostic messages.

sct_dbtool.sanity.class_inheritors(klass: Type) → Set[Type][source]

This method will search for all classes inheriting from the SanityCheck class.

Parameters:klass – the class to search for childs.
Returns:list of the classes.
sct_dbtool.sanity.sanity_check(api_client: sct_dbtool.api.APIClient, arguments: Dict)[source]

Main entry-point for the sanity checking.

Parameters:
  • api_client – a configured instance of APIClient.
  • arguments – the CLI arguments.

sct_dbtool.setup – CLI setup entry-point

sct_dbtool.setup.read_setup()[source]

Read the system configuration file.

Returns:a dict with the configuration parameters.
sct_dbtool.setup.setup(arguments: Dict)[source]

This method will ask user input to configure the system with the hostname, username, etc, for the web management access.

Parameters:arguments – the CLI arguments.

sct_dbtool.main – Main CLI entry-point

Naval Fate.

Usage:
sct_dbtool sanity <db_path> sct_dbtool setup sct_dbtool (-h | –help) sct_dbtool –version
Options:
-h –help Show this screen –version Show version