TomMaullin / crtoolbox

2 stars 1 forks source link

The Confidence Regions Toolbox

Table of Contents

Background

The crtoolbox is a Python-based software package designed to provide Confidence Regions (CRs) for excursion sets derived from neuroimaging data. At present, the methods provided are those proposed in Sommerfeld, et al. 2017, Bowring, et al. 2021 and Maullin-Sapey, et al. 2022. These methods provide CRs for 2D and 3D regression coefficient images, Cohen's d effect size images, and conjunction or disjunction images. For each approach, estimated inner and outer sets are constructed for an excursion set of interest. These estimated sets, together known as Confidence Regions, are designed to bound the true excursion set with a user-specified level of confidence.

Further detail on CRs, alongside an extensive demonstration of the crtoolbox, can be found in the crtoolbox_demo repository, which originally formed part of the Beyond Blobology course at the Organization for Human Brain Mapping conference 2023. Please Note: The function calls described in this practical have only been tested with the crtoolbox==0.1.6 version. Later versions may not be compatible.

Install

To install the crtoolbox please use pip:

pip install crtoolbox

Usage

At present the crtoolbox consists of several standalone functions, which may be used together to generate CRs. The most relevant of these are detailed below. Full docstrings for each function can be found in the files linked.

File Handling

The following functions can be used for file manipulation and handling:

These functions may be found in crtoolbox.lib.fileio.

Effect Size images

The following functions can be used for regression and effect size estimation for either 2d or 3d images.

Please note that the residuals and standard deviation images output by regression and cohens are not the same; regression outputs regression residuals and the MLE for the standard deviation, whilst cohens outputs transformed residuals (generated according to method 2 of Bowring, et al. 2021) alongside their standard deviation.

These functions may be found in crtoolbox.lib.regression and crtoolbox.lib.cohens, respectively.

Generating CRs

The following function is used to generate confidence regions. It supports both 2d and 3d images.

This function may be found in crtoolbox.generate.

Coverage Assessment

The below function may be used to check whether the CRs correctly bound the underlying true excursion set (note this is only useful for simulation settings). It uses both a binary inclusion check and the interpolation methods outlines in Bowring, et al. 2019.

This function may be found in crtoolbox.coverage.

Working with Boundaries

The below function may be useful for developing the tool.

This function may be found in crtoolbox.lib.boundary.

Displaying Volumes

The below functions can be used to display various images in an interactive format.

display_volume, display_crs

These functions may be found in crtoolbox.lib.display.

Data Simulation

The crtoolbox currently contains custom code for generating simulated data which may be useful for testing and demonstration. The below sections provide detail on the available 2D and 3D simulated datasets respectively.

2D Data Simulation

The below classes can be used to generate 2D signals:

The above classes will create objects representing each of the signal types. An image of the signal can be viewed using the plot method. Noise can also be generated using the Noise class.

To use the above classes to generate data the generate_data_2D function can be used:

The classes for signal generation and noise generation, as well as the generate_data_2D function, may be found in crtoolbox.tests.generate_2d_data.

3D Data Simulation

The below function can be used to generate 3D simulated data resembling real-world fMRI images.

For further detail on the pipeline used to generate these images, see Maullin-Sapey & Nichols. 2022. The generate_data function may be found in crtoolbox.tests.generate_ni_data.

License

MIT