@nyio.importer('<STR_LIT>')<EOL>def subject(sid, subjects_path=None, meta_data=None, default_alignment='<STR_LIT>'):
if subjects_path is None:<EOL><INDENT>if os.path.isdir(str(sid)):<EOL><INDENT>(fdir, fnm) = os.path.split(str(sid))<EOL>try: sid = to_subject_id(fnm)<EOL>except Exception: sid = None<EOL>pth = fdir<EOL><DEDENT>else:<EOL><INDENT>sid = to_subject_id(sid)<EOL>fnm = str(sid)<EOL>fdir = find_subject_path(sid)<EOL>if fdir is None: raise ValueError('<STR_LIT>' % sid)<EOL>pth = os.path.split(fdir)[<NUM_LIT:0>]<EOL><DEDENT><DEDENT>else:<EOL><INDENT>if sid is None:<EOL><INDENT>(pth, fnm) = os.path.split(subjects_path)<EOL><DEDENT>else:<EOL><INDENT>sid = to_subject_id(sid)<EOL>fnm = str(sid)<EOL>fdir = subjects_path<EOL><DEDENT><DEDENT>fdir = os.path.abspath(os.path.join(pth, fnm))<EOL>if fdir in subject._cache: return subject._cache[fdir]<EOL>sub = Subject(sid, fdir, meta_data=meta_data, default_alignment=default_alignment).persist()<EOL>if isinstance(sub, Subject): subject._cache[fdir] = sub<EOL>return sub<EOL>
subject(sid) yields a HCP Subject object for the subject with the given subject id; sid may be a
  path to a subject or a subject id, in which case the subject paths are searched for it.
subject(None, path) yields a non-standard HCP subject at the given path.
subject(sid, path) yields the specific HCP Subject at the given path.

Subjects are cached and not reloaded.  Note that subects returned by subject() are always
persistent Immutable objects; this means that you must create a transient version of the subject
to modify it via the member function sub.transient(). Better, you can make copies of the objects
with desired modifications using the copy method.

This function works with the neuropythy.hcp.auto_download() function; if you have enabled auto-
downloading, then subjects returned from this subject may be downloading themselves lazily.