Skip to content

nltools

The top-level namespace. The six data classes are re-exported here and each has its own page: BrainData, Adjacency, DesignMatrix, Roc, Simulator and SimulateGrid. What follows is everything else import nltools gives you: the function that combines objects, the four functions that read and set the brain space every object falls back on, and the package version.

nltools: a Python toolbox for analyzing neuroimaging data.

Focused on multivariate analyses and built on top of nilearn and scikit-learn, nltools provides high-level data classes — BrainData, Adjacency, and DesignMatrix — that wrap common neuroimaging workflows, alongside a functional core of statistics and algorithms (nltools.algorithms) that the data classes delegate to.

Functions:

Name Description
concatenate

Concatenate a list of BrainData or Adjacency objects.

get_brainspace

Return the current global brain-space configuration.

set_brainspace

Set the global brain-space configuration.

reset_brainspace

Reset the global brain-space configuration to defaults.

with_brainspace

Temporarily change the global brain-space configuration.

Attributes:

Name Type Description
__version__

Attributes

__version__ module-attribute

__version__ = version('nltools')

Functions:

concatenate

concatenate(data)

Concatenate a list of BrainData or Adjacency objects.

Parameters:

Name Type Description Default
data list[BrainData] | list[Adjacency]

Objects to concatenate; all must be of the same class.

required

Returns:

Type Description
BrainData | Adjacency

A single object holding every input in order.

Raises:

Type Description
ValueError

If data is not a list or mixes classes.

get_brainspace

get_brainspace() -> BrainSpaceConfig

Return the current global brain-space configuration.

Returns:

Type Description
BrainSpaceConfig

The active configuration.

set_brainspace

set_brainspace(
    template: TemplateName | None = None,
    resolution: Resolution | None = None,
) -> BrainSpaceConfig

Set the global brain-space configuration.

Call with no arguments to return the current config without mutating it. Call with one or both arguments to mutate the global state; unspecified fields retain their current value.

Parameters:

Name Type Description Default
template str

Template name to set ('default', 'nilearn', 'fmriprep'). If None, keeps the current value.

None
resolution int

Resolution in mm to set. If None, keeps the current value.

None

Returns:

Type Description
BrainSpaceConfig

The new (or unchanged) current configuration.

reset_brainspace

reset_brainspace() -> BrainSpaceConfig

Reset the global brain-space configuration to defaults.

Returns:

Type Description
BrainSpaceConfig

The default configuration ('default' template, 2 mm).

with_brainspace

with_brainspace(
    template: TemplateName | None = None,
    resolution: Resolution | None = None,
) -> Iterator[BrainSpaceConfig]

Temporarily change the global brain-space configuration.

Restores the previous configuration on exit, even if an exception is raised inside the block.

Parameters:

Name Type Description Default
template str

Template name for the duration of the block.

None
resolution int

Resolution in mm for the duration of the block.

None

Yields:

Type Description
BrainSpaceConfig

The configuration active inside the block.