def find_subject_path(sub, check_path=True):
    '''
    find_subject_path(sub) yields the full path of a Freesurfer subject with the name given by the
      string sub, if such a subject can be found in the Freesurfer search paths. See also
      add_subject_path.

    If no subject is found, then None is returned.

    The optional argument check_path (default: True) may be set to False to indicate that sanity
    checks regarding the state of the file-system should be skipped. If check_path is set to True,
    then a directory will only be returned if it is a directory on the file-system and it contains
    at least the subdirectories mri/, label/, and surf/. If check_path is set to False, then
    find_subject_path will first search for any directory that satisfies the above requirements,
    and, failing that, will search for any directory matching sub that at least exists. If this also
    fails, then sub itself is returned (i.e., sub is presumed to be a valid path).
    '''
    sdirs = config['freesurfer_subject_paths']
    # if it's a full/relative path already, use it:
    if is_freesurfer_subject_path(sub): return sub
    path = next((p for sd in sdirs for p in [os.path.join(sd, sub)]
                 if is_freesurfer_subject_path(p)),
                None)
    if path is not None: return path
    if check_path: return None
    if os.path.isdir(sub): return sub
    return next((p for sd in sdirs for p in [os.path.join(sd, sub)]
                 if os.path.isdir(p)),
                sub)
find_subject_path(sub) yields the full path of a Freesurfer subject with the name given by the
      string sub, if such a subject can be found in the Freesurfer search paths. See also
      add_subject_path.

    If no subject is found, then None is returned.

    The optional argument check_path (default: True) may be set to False to indicate that sanity
    checks regarding the state of the file-system should be skipped. If check_path is set to True,
    then a directory will only be returned if it is a directory on the file-system and it contains
    at least the subdirectories mri/, label/, and surf/. If check_path is set to False, then
    find_subject_path will first search for any directory that satisfies the above requirements,
    and, failing that, will search for any directory matching sub that at least exists. If this also
    fails, then sub itself is returned (i.e., sub is presumed to be a valid path).