kwneuro.util module

Common utility functions

kwneuro.util.create_estimate_volume_resource(array, reference_volume, intent_name)

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

Parameters:
Return type:

VolumeResource

kwneuro.util.deep_equal_allclose(obj1, obj2)

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

Parameters:
Return type:

bool

kwneuro.util.normalize_path(path_input)

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

Parameters:

path_input (Path | str)

Return type:

Path

kwneuro.util.update_volume_metadata(metadata, volume_data_array, intent_code=None, intent_params=(), intent_name='')

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.

Parameters:
Return type:

dict[str, Any]