brainprep.utils.utils: Module that contains some utility functions.

Module that contains some utility functions.

Functions

check_run_fn(bids_path, entities[, full_path])

Scan the folder containing a BIDS file and verify that the run entity associated with the file appears exactly once among all matching files.

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.

sidecar_from_file(image_file)

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