def find_subject_path(sub, check_path=True):
sdirs = config['<STR_LIT>']<EOL>if is_freesurfer_subject_path(sub): return sub<EOL>path = next((p for sd in sdirs for p in [os.path.join(sd, sub)]<EOL>if is_freesurfer_subject_path(p)),<EOL>None)<EOL>if path is not None: return path<EOL>if check_path: return None<EOL>if os.path.isdir(sub): return sub<EOL>return next((p for sd in sdirs for p in [os.path.join(sd, sub)]<EOL>if os.path.isdir(p)),<EOL>sub)<EOL>
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).