def to_subject_id(s):
    '''
    to_subject_id(s) coerces the given string or number into an integer subject id. If s is not a
      valid subejct id, raises an exception.
    '''
    if not pimms.is_number(s) and not pimms.is_str(s):
        raise ValueError('invalid type for subject id: %s' % str(type(s)))
    if pimms.is_str(s):
        try: s = os.path.expanduser(s)
        except Exception: pass
        if os.path.isdir(s): s = s.split(os.sep)[-1]
    s = int(s)
    if s > 999999 or s < 100000:
        raise ValueError('subject ids must be 6-digit integers whose first digit is > 0')
    return s
def to_subject_id ( s ) : if not pimms . is_number ( s ) and not pimms . is_str ( s ) : raise ValueError ( 'invalid type for subject id: %s' % str ( type ( s ) ) ) if pimms . is_str ( s ) : try : s = os . path . expanduser ( s ) except Exception : pass if os . path . isdir ( s ) : s = s . split ( os . sep ) [ - 1 ] s = int ( s ) if s > 999999 or s < 100000 : raise ValueError ( 'subject ids must be 6-digit integers whose first digit is > 0' ) return s
to_subject_id(s) coerces the given string or number into an integer subject id. If s is not a
      valid subejct id, raises an exception.