Note

This page is a reference documentation. It only explains the function signature, and not how to use it. Please refer to the user guide for the big picture.

brainprep.utils.find_first_occurrence

brainprep.utils.find_first_occurrence(input_file, target)[source]

Return the closest parent directory whose name matches target.

Parameters:
input_filePath

Starting path (file or directory).

targetstr

Name of the directory to search for.

Returns:
Path

The first parent directory named target.

Raises:
ValueError

If no parent directory with the given name is found.