nipype.utils.ram_estimator module

class nipype.utils.ram_estimator.RamEstimator(input_multipliers=None, overhead_gb=0.3, min_gb=0.5, max_gb=8.0)

Bases: object

Base class for Nipype RAM estimators.

A RamEstimator provides a lightweight, user-defined mechanism to estimate the peak RAM usage (in GB) of a Nipype node before execution, based on the node inputs.

The estimator aggregates RAM contributions from selected input traits using user-defined multipliers and returns:

  • an estimated RAM value (mem_gb)

  • a human-readable debug string describing the estimate

The estimator is intended to be attached to a Node or MapNode via the node.ram_estimator attribute and is evaluated automatically when executing workflows with the MultiProcPlugin.

Notes

  • The estimator is only used when running a workflow with MultiProcPlugin (or subclasses thereof).

  • For MapNode instances, the estimator is inherited by all subnodes and evaluated on a single representative iteration. The resulting mem_gb is interpreted as the per-task memory requirement (i.e., the worst-case memory for one mapped job).

  • The debug string produced by the estimator is stored in the node runtime report (_report/report.rst) under the runtime section.

Examples

Define a tool-specific RAM estimator and attach it to a node:

class FlirtRamEstimator(RamEstimator):
    def __init__(self):
        super().__init__(
            input_multipliers={
                'in_file': 32,
                'reference': 4,
            },
            overhead_gb=0.3,
            min_gb=0.5,
            max_gb=4.0
        )

from nipype.interfaces.fsl import FLIRT
from nipype.pipeline.engine import Node

flirt = Node(
    FLIRT(dof=6),
    name="flirt"
)

flirt.ram_estimator = FlirtRamEstimator()
static clamp(value, min_val=None, max_val=None)

Clamp a value between min_val and max_val.

static voxels(path)

Return number of spatial voxels (ignores time dimension).