kwneuro.util

Common utility functions

Attributes

Functions

normalize_path(→ pathlib.Path)

Accepts a path as a string or Path object, expands the tilde (~),

create_estimate_volume_resource(...)

Creates an InMemoryVolumeResource from a numpy array of scalar estimates,

update_volume_metadata(, intent_name, Any])

Use the convenience of nibabel's header class to update volume metadata.

deep_equal_allclose(→ bool)

Recursively compares two objects, including nested lists, tuples,

Module Contents

kwneuro.util.PathLike
kwneuro.util.normalize_path(path_input: PathLike) pathlib.Path

Accepts a path as a string or Path object, expands the tilde (~), and returns a resolved, absolute Path object.

kwneuro.util.create_estimate_volume_resource(array: numpy.typing.NDArray[Any], reference_volume: kwneuro.resource.VolumeResource, intent_name: str) kwneuro.resource.VolumeResource

Creates an InMemoryVolumeResource from a numpy array of scalar estimates, using the affine and metadata of a reference volume.

kwneuro.util.update_volume_metadata(metadata: dict[str, Any], volume_data_array: numpy.ndarray, intent_code: int | str | None = None, intent_params: Any = (), intent_name: str = '') dict[str, Any]

Use the convenience of nibabel’s header class to update volume metadata. If intent_code is not provided then we don’t modify the intent parameters.

kwneuro.util.deep_equal_allclose(obj1: Any, obj2: Any) bool

Recursively compares two objects, including nested lists, tuples, and dicts. Uses np.allclose for numpy arrays. NaN’s are considered equal.