pcntoolkit.normative#

Module providing entry points for fitting and predicting with normative models from the command line.

Functions#

entrypoint(*args)

fit(→ None)

Fit a new normative model.

fit_predict(→ None)

Fit a normative model and predict response variables.

get_argparser(→ argparse.ArgumentParser)

Get an argument parser for the normative modeling functions.

get_conf_dict_from_args(→ dict[str, ...)

Parse the arguments and return a dictionary with the configuration options.

load_data(→ pcntoolkit.dataio.norm_data.NormData)

Load the data from the configuration dictionary.

load_response_vars(→ tuple[numpy.ndarray, ...)

Load response variables from file. This will load the data and mask it if

load_test_data(→ pcntoolkit.dataio.norm_data.NormData)

Load the test data from the file specified in the configuration dictionary.

main(→ None)

Main function to run the normative modeling functions.

make_synthetic_data(→ None)

Create synthetic data for testing.

predict(→ None)

Predict response variables using a saved normative model.

Module Contents#

entrypoint(*args)#
fit(conf_dict: dict) None#

Fit a new normative model.

Parameters:

conf_dict – Dictionary containing configuration options

fit_predict(conf_dict: dict) None#

Fit a normative model and predict response variables.

Parameters:

conf_dict – Dictionary containing configuration options

get_argparser() argparse.ArgumentParser#

Get an argument parser for the normative modeling functions.

Returns:

argparse.ArgumentParser: The argument parser

get_conf_dict_from_args() dict[str, str | int | float | bool]#

Parse the arguments and return a dictionary with the configuration options.

Raises:

ValueError: Raised if an argument is specified twice.

Returns:

dict[str, str | int | float | bool]: A dictionary with the configuration option, parsed to the correct type.

load_data(conf_dict: dict) pcntoolkit.dataio.norm_data.NormData#

Load the data from the configuration dictionary.

Returns:

NormData: NormData object containing the data

load_response_vars(datafile: str, maskfile: str | None = None, vol: bool = True) tuple[numpy.ndarray, numpy.ndarray | None]#

Load response variables from file. This will load the data and mask it if necessary. If the data is in ascii format it will be converted into a numpy array. If the data is in neuroimaging format it will be reshaped into a 2D array (observations x variables) and a mask will be created if necessary.

Parameters:
  • datafile – File containing the response variables

  • maskfile – Mask file (nifti only)

  • vol – If True, load the data as a 4D volume (nifti only)

Returns Y:

Response variables

Returns volmask:

Mask file (nifti only)

load_test_data(conf_dict: dict) pcntoolkit.dataio.norm_data.NormData#

Load the test data from the file specified in the configuration dictionary.

Args:

conf_dict (dict): dictionary containing the configuration options

Returns:

NormData: NormData object containing the test data

main(*args) None#

Main function to run the normative modeling functions.

Raises:

ValueError: If the function specified in the configuration dictionary is unknown.

make_synthetic_data() None#

Create synthetic data for testing.

predict(conf_dict: dict) None#

Predict response variables using a saved normative model.

Parameters:

conf_dict – Dictionary containing configuration options