pcntoolkit.util.output#

Classes#

Module Contents#

class Errors#
BLR_ERROR_NO_DESIGN_MATRIX_CREATED = 'No design matrix created'#
BLR_HYPERPARAMETER_VECTOR_INVALID_LENGTH = 'Hyperparameter vector invalid length'#
BLR_MODEL_NOT_FITTED = 'Model must be fitted before computing log probabilities'#
BLR_X_NOT_PROVIDED = 'X is not provided'#
ENSURE_POSITIVE_DISTRIBUTION = 'Distribution for {name} needs to be positive.'#
ERROR_ARGUMENT_SPECIFIED_TWICE = 'Argument {key} is specified twice.'#
ERROR_BASIS_FUNCTION_NOT_FITTED = 'Basis function is not fitted. Please fit the basis function first.'#
ERROR_BATCH_EFFECTS_NOT_LIST = 'Items of the batch_effect dict be a list or a string, not {batch_effect_type}'#
ERROR_BATCH_SIZE_AND_N_BATCHES_MISMATCH = 'Batch size ({batch_size}) and number of batches ({n_batches}) are both specified, but do not...#
ERROR_BLR_CG_NOT_SUPPORTED_WITH_WARP = "The 'cg' optimizer requires analytical gradients, which are not implemented for warped models....#
ERROR_BLR_HYPERPARAMETER_VECTOR_INVALID_LENGTH = 'Hyperparameter vector invalid length'#
ERROR_BLR_PENALTY_NOT_RECOGNIZED = "Requested penalty ({penalty}) not recognized, choose between 'L1' or 'L2'."#
ERROR_BLR_POWELL = "Powell optimizer failed. We recommend running your code again and setting optimizer='l-bfgs-b'."#
ERROR_BLR_TRANSFER_NOT_IMPLEMENTED = 'BLR transfer not implemented'#
ERROR_BLR_VAR_X_NOT_PROVIDED = 'Variance of covariates (var_X) is required for models with variance.'#
ERROR_BLR_WARPS_NOT_PROVIDED = 'A list of warp functions is required'#
ERROR_CDF_SHAPE = 'CDF shape {cdf_shape} does not match data shape {data_shape}'#
ERROR_CROSS_VALIDATION_FOLDS = 'If cross-validation is enabled, cv_folds must be greater than 1'#
ERROR_DATA_MUST_BE_1D = 'Data must be a 1D array or a N-dimensional array with a single column'#
ERROR_ENVIRONMENT_NOT_FOUND = 'Environment {environment} not found. Please specify the path to the python environment using...#
ERROR_FILE_NOT_FOUND = 'File not found: {path}'#
ERROR_HBRDATA_X_NOT_PROVIDED = 'X must be provided'#
ERROR_HBR_COULD_NOT_LOAD_IDATA = 'Could not load idata from {path}'#
ERROR_HBR_FITTED_BUT_NO_IDATA = 'HBR model is fitted but does not have idata. This should not happen.'#
ERROR_HBR_Y_NOT_PROVIDED = 'y must be provided for z-score computation'#
ERROR_MODEL_NOT_FITTED = 'Model needs to be fitted before it can be transferred'#
ERROR_MULTIPLE_COVARIATE_DIMS = 'Multiple covariate dimensions found: {covariate_dims}'#
ERROR_NO_ENVIRONMENT_SPECIFIED = 'No python environment specified. Please specify the path to the python environment using the...#
ERROR_PARSING_TIME_LIMIT = 'Cannot parse {time_limit_str} as time limit'#
ERROR_PREDICT_DATA_NOT_SUPPORTED_FOR_CROSS_VALIDATION = 'Predict with cross-validation is not supported. Please use fit_predict instead.'#
ERROR_PREDICT_DATA_REQUIRED = 'Predict data is required for fit_predict without cross-validation'#
ERROR_PREDICT_DATA_REQUIRED_FOR_FIT_PREDICT_WITHOUT_CROSS_VALIDATION = 'Predict data is required for fit_predict without cross-validation'#
ERROR_SCALER_NOT_FITTED = 'Scaler must be fitted before {method}'#
ERROR_SCALER_TYPE_NOT_FOUND = "Dictionary must contain 'scaler_type' key"#
ERROR_SOURCE_ARRAY_NOT_FOUND = 'Source array {source_array_name} does not exist in the data.'#
ERROR_SUBMITTING_JOB = 'Error submitting job {job_id}: {stderr}'#
ERROR_UNKNOWN_CLASS = 'Unknown class {class_name}'#
ERROR_UNKNOWN_DISTRIBUTION = 'Unknown distribution ({dist_name})'#
ERROR_UNKNOWN_FUNCTION = 'Unknown function {func}'#
ERROR_UNKNOWN_LIKELIHOOD = 'Unsupported likelihood ({likelihood})'#
ERROR_UNKNOWN_MAPPING = 'Unknown mapping ({mapping})'#
ERROR_UNKNOWN_SCALER_TYPE = 'Undefined scaler type: {scaler_type}'#
ERROR_WARP_STRING_INVALID = 'Invalid warp string: {warp_string}'#
ERROR_Y_NOT_FOUND = 'y not found in data'#
ERROR_ZSCORES_INVERSE = 'Z-scores inverse has invalid shape: Z_shape={Z_shape}, X_shape={X_shape}'#
HBR_MODEL_NOT_FITTED = 'HBR model is not fitted'#
INVALID_ENVIRONMENT = 'The python environment {environment} is invalid because it has no /bin/python file. Please...#
NORMATIVE_MODEL_CONFIGURATION_PROBLEMS = Multiline-String#
Show Value
"""The following problems have been detected in the normative model configuration:
{problems}"""
NO_FLOAT_DATA_TYPE = 'Only float data types currently handled, not {data_type}'#
OFFSETS_NOT_1D = 'Offsets must be a 1-d array or list'#
OFFSET_NOT_VALID = 'Invalid list of offsets provided'#
REGRESSION_MODEL_CONFIGURATION_PROBLEMS = Multiline-String#
Show Value
"""The following problems have been detected in the regression model configuration:
{problems}"""
SAMPLE_BATCH_EFFECTS = 'Cannot sample {n_samples} batch effects, because some batch effects have more levels than the...#
UNKNOWN_FILE_TYPE = 'Unknown file type: {filename}'#
WB_COMMAND_FAILED = 'wb_command failed with error: {error}'#
WB_COMMAND_NOT_FOUND = 'wb_command not found in PATH'#
class Messages#
BLR_HYPERPARAMETERS_HAVE_NOT_CHANGED = 'Hyperparameters have not changed, exiting'#
BLR_RESTARTING_ESTIMATION_AT_HYP = 'Restarting estimation at hyp = {hyp}, due to: {e}'#
COMPUTING_CENTILES = 'Computing centiles for {n_models} response variables.'#
COMPUTING_CENTILES_MODEL = 'Computing centiles for {model_name}.'#
COMPUTING_LOGP = 'Computing log-probabilities for {n_models} response variables.'#
COMPUTING_LOGP_MODEL = 'Computing log-probabilities for {model_name}.'#
COMPUTING_YHAT = 'Computing yhat for {n_models} response variables.'#
COMPUTING_YHAT_MODEL = 'Computing yhat for {model_name}.'#
COMPUTING_ZSCORES = 'Computing z-scores for {n_models} response variables.'#
COMPUTING_ZSCORES_MODEL = 'Computing z-scores for {model_name}.'#
DATASET_CREATED = Multiline-String#
Show Value
"""Dataset "{name}" created.
    - {n_observations} observations
    - {n_subjects} unique subjects
    - {n_covariates} covariates
    - {n_response_vars} response variables
    - {n_batch_effects} batch effects:
    {batch_effects}
    """
EXECUTING_CALLABLE = 'Executing callable, attempt {attempt} of {total}.'#
EXECUTION_FAILED = Multiline-String#
Show Value
"""Execution of callable failed, attempt {attempt} of {total} with error:
{error}"""
EXECUTION_SUCCESSFUL = 'Execution of callable successful, attempt {attempt} of {total}.'#
EXTRACTING_CIFTI_SURFACE_DATA = 'Extracting cifti surface data to {outstem} ...'#
EXTRACTING_CIFTI_VOLUME_DATA = 'Extracting cifti volume data to {niiname} ...'#
FITTING_AND_PREDICTING_MODEL = 'Fitting and predicting model for {model_name}.'#
FITTING_AND_PREDICTING_MODELS = 'Fitting and predicting {n_models} response variables.'#
FITTING_MODEL = 'Fitting model for {model_name}.'#
FITTING_MODELS = 'Fitting models on {n_models} response variables.'#
GENERATING_MASK_AUTOMATICALLY = 'Generating mask automatically ...'#
HARMONIZING_DATA = 'Harmonizing data on {n_models} response variables.'#
HARMONIZING_DATA_MODEL = 'Harmonizing data for {model_name}.'#
JOB_STATUS_LINE = '{:<11} {:<9} {:<10} {:<9} {:<14}'#
JOB_STATUS_MONITOR = Multiline-String#
Show Value
"""
---------------------------------------------------------
              PCNtoolkit Job Status Monitor ®
---------------------------------------------------------
Task ID: {task_id}
---------------------------------------------------------
Job ID      Name          State      Time      Nodes
---------------------------------------------------------
"""
JOB_STATUS_SUMMARY = Multiline-String#
Show Value
"""
---------------------------------------------------------
Total active jobs: {total_active_jobs}
Total completed jobs: {total_completed_jobs}
Total failed jobs: {total_failed_jobs}
---------------------------------------------------------
"""
LOADING_CALLABLE = 'Loading callable from {path}.'#
LOADING_DATA = 'Loading data from {path}.'#
LOADING_DATA_UNDER_KFOLD_CV = 'Automatically loading data under KFold CV is not implemented yet. Please load the data using...#
LOADING_ROI_MASK = 'Loading ROI mask ...'#
LOADING_RUNNER_STATE = Multiline-String#
Show Value
"""Loading runner state from:
       {runner_file}"""
LOG_DIR_CREATED = Multiline-String#
Show Value
"""Log directory created:
       {log_dir}"""
NORMATIVE_MODEL_CONFIGURATION_VALID = 'Configuration of normative model is valid.'#
NO_LOG_DIR_SPECIFIED = 'No log directory specified. Using default log directory: {log_dir}'#
NO_MORE_RUNNING_JOBS = Multiline-String#
Show Value
"""
---------------------------------------------------------
No more running jobs!
---------------------------------------------------------
"""
NO_PYTHON_PATH_SPECIFIED = 'No python path specified. Using interpreter path of current process: {python_path}'#
NO_TEMP_DIR_SPECIFIED = 'No temporary directory specified. Using default temporary directory: {temp_dir}'#
PREDICTING_MODEL = 'Making predictions on {model_name}.'#
PREDICTING_MODELS = 'Making predictions on {n_models} response variables.'#
REGRESSION_MODEL_CONFIGURATION_VALID = 'Configuration of regression model is valid.'#
RUNNER_LOADED = Multiline-String#
Show Value
"""Runner loaded
---------------------------------------------------------Active jobs: {n_active_jobs}
Finished jobs: {n_finished_jobs}
Failed jobs: {n_failed_jobs}
---------------------------------------------------------"""
SAVING_CENTILES = Multiline-String#
Show Value
"""Saving centiles to:
       {save_dir}."""
SAVING_MODEL = Multiline-String#
Show Value
"""Saving model to:
       {save_dir}."""
SAVING_RESULTS = Multiline-String#
Show Value
"""Saving results to:
       {save_dir}."""
SAVING_RUNNER_STATE = Multiline-String#
Show Value
"""Saving runner state to:
       {runner_file}"""
SAVING_STATISTICS = Multiline-String#
Show Value
"""Saving statistics to:
       {save_dir}."""
SAVING_ZSCORES = Multiline-String#
Show Value
"""Saving z-scores to:
       {save_dir}."""
SYNTHESIZING_DATA = 'Synthesizing data for {n_models} response variables.'#
SYNTHESIZING_DATA_MODEL = 'Synthesizing data for {model_name}.'#
TASK_ID_CREATED = 'Task ID created: {task_id}'#
TEMP_DIR_CREATED = Multiline-String#
Show Value
"""Temporary directory created:
       {temp_dir}"""
TRANSFERRING_MODEL = 'Transferring model for {model_name}.'#
TRANSFERRING_MODELS = 'Transferring models on {n_models} response variables.'#
class Output#
classmethod error(message: str, *args, **kwargs) str#

Print error message

classmethod get_show_messages() bool#
classmethod get_show_pid() bool#
classmethod get_show_timestamp() bool#
classmethod get_show_warnings() bool#
classmethod print(message: str, *args, **kwargs) None#

Print message only if show_messages mode is enabled

classmethod set_show_messages(value: bool) None#
classmethod set_show_pid(value: bool) None#
classmethod set_show_timestamp(value: bool) None#
classmethod set_show_warnings(value: bool) None#
classmethod warning(message: str, *args, category: type = UserWarning, **kwargs) None#

Print warning only if show_warnings mode is enabled.

class Warnings#
BATCH_SIZE_AND_N_BATCHES_SPECIFIED = 'Batch size and number of batches specified. Batch size will be ignored.'#
BLR_BATCH_EFFECTS_NOT_PROVIDED = 'batch_effects is not provided, setting self.batch_effects to zeros'#
BLR_CG_NOT_SUPPORTED_WITH_HETEROSKEDASTIC = "The 'cg' optimizer requires analytical gradients, which are not implemented for heteroskedastic...#
BLR_CG_NOT_SUPPORTED_WITH_WARP = "The 'cg' optimizer requires analytical gradients, which are not implemented for warped models....#
BLR_ESTIMATION_OF_POSTERIOR_DISTRIBUTION_FAILED = Multiline-String#
Show Value
"""Posterior estimation failed:
{error}.
The optimizer could not find a stable solution. Retrying optimization."""
BLR_VAR_X_NOT_PROVIDED = 'var_X is not provided, setting self.var_X to zeros'#
BLR_Y_NOT_PROVIDED = 'y is not provided, setting self.y to zeros'#
CENTILES_ALREADY_COMPUTED_FOR_CENTILES = 'Centiles are already computed for {dataset_name} for centiles {centiles}, skipping computation....#
DATA_ALREADY_SCALED = 'Data is already scaled, skipping scaling back to original scale.'#
DATA_NOT_SCALED = 'Data is not scaled, skipping scaling back to original scale.'#
DIR_DOES_NOT_EXIST = '{dir_attr_str} ({dir_attr}) does not exist, creating it for you.'#
ERROR_GETTING_JOB_STATUSES = 'Error getting job statuses: {stderr}'#
ERROR_PARSING_JOB_STATUS_LINE = 'Error parsing job status line: {line} - {error}'#
ERROR_SUBMITTING_JOB = 'Error submitting job {job_id}: {stderr}'#
EXTRA_COVARIATES = 'The dataset {dataset_name} has too many covariates: {covariates}'#
EXTRA_RESPONSE_VARS = 'The dataset {dataset_name} has too many response variables: {response_vars}'#
HBR_BATCH_EFFECTS_NOT_PROVIDED = 'batch_effects is not provided, setting self.batch_effects to zeros'#
LOADING_DATA_NOT_SUPPORTED_FOR_CROSS_VALIDATION = 'Automatic data loading by the Runner is not supported for cross-validation.'#
LOAD_CIFTI_GENERIC_EXCEPTION = 'A general exception occurred while loading CIFTI file: {}'#
LOAD_NIFTI_GENERIC_EXCEPTION = 'A general exception occurred while loading NIFTI file: {}'#
MISSING_COVARIATES = 'The dataset {dataset_name} is missing the following covariates: {covariates}'#
MODEL_MIGRATION_APPLIED = 'This model was saved with PCNtoolkit v{saved_version}, but you are running v{current_version}....#
MODEL_SAVED_WITH_NEWER_VERSION = 'This model was saved with PCNtoolkit v{saved_version}, but you are running v{current_version}....#
MULTIPLE_BATCH_EFFECT_SUMMARY = "Multiple batch effect dimensions found. The summary printout currently uses the first dimension...#
MULTIPLE_JOBS_FOUND_FOR_JOB_ID = 'Multiple jobs found for job ID {job_id}: {job_name}. Please check the job statuses and try again.'#
NO_COVARIATES = 'No covariates provided for dataset {dataset_name}.'#
NO_RESPONSE_VARS = 'No response variables provided for dataset {dataset_name}. Please provide a list of response...#
PREDICT_DATA_NOT_USED_IN_KFOLD_CROSS_VALIDATION = 'Predict data not used in k-fold cross-validation'#
REMOVE_NAN_SET_TO_FALSE = 'Warning: remove_NAN is set to False. Missing (NaN) values may cause errors during model...#
RENAMED = "'{old_name}' has been renamed to '{new_name}'."#
RESPONSE_VAR_NOT_FOUND = 'Response variable {response_var} not found in dataset {dataset_name}. Setting to NaN.'#
SUBJECT_ID_MULTIPLE_COLUMNS = 'Subject ID file contains multiple columns. Using the first column for subject IDs.'#
SUBJECT_ID_UNEXPECTED_SHAPE = 'Subject ID data has an unexpected shape. Expected 1D array or 2D array with one column. Using...#
SYNTHESIZE_N_SAMPLES_IGNORED = '{n_samples} sample(s) ignored because data is provided.'#
THRIVELINES_ALREADY_COMPUTED_FOR = 'Thrivelines are already computed for {dataset_name} for offsets {offsets}, skipping...#
TOO_FEW_OBSERVATIONS = 'Cannot compute {statistic}: {n_valid} valid observation(s) found after removing NaN/Inf values,...#
TRANSFER_DATA_FEWER_BATCH_EFFECTS = 'Transfer data contain fewer batch effect levels than training data. This may lead to biased results.'#
UNKNOWN_BATCH_EFFECTS = 'The dataset {dataset_name} has unknown batch effects: {batch_effects}'#