brainprep.utils: Module that implements tools.

Module that implements tools.

Classes

Bunch(**kwargs)

Container object exposing keys as attributes.

Functions

coerce_to_list(value, expected_type)

Coerce a value into a list when the expected type annotation indicates a list or tuple.

coerce_to_path(value, expected_type)

Recursively convert values to pathlib.Path based on expected type annotations.

find_first_occurrence(input_file, target)

Return the closest parent directory whose name matches target.

find_stack_level()

Return the index of the first stack frame outside the brainprep package.

make_run_id(filename)

Generate a deterministic identifier and a 5-digit short code from a filename.

parse_bids_keys(bids_path[, full_path, ...])

Parse BIDS entities and modality from a filename or path with validation.

print_command(command)

Print command.

print_deprecated(deprecated)

Print deprecated.

print_error(error)

Print error.

print_info(info)

Print info.

print_result(result)

Print result.

print_subtitle(subtitle)

Print subtitle.

print_title(title)

Print title.

print_warn(warn)

Print warn.

sidecar_from_file(image_file)

Infers the corresponding JSON sidecar file for a given NIfTI image file.