def GetSGSpin(SGData, MSgSym):
    """get spin generators from magnetic space group symbol"""
    SpGrp = SGData['SpGrp']
    mSgSym = MSgSym + ' '
    Flds = SpGrp.split()
    iB = 0
    Spn = [1]
    if len(Flds) == 2:
        fld = Flds[1]
        iF = mSgSym[iB:].index(fld[0]) + iB
        jF = mSgSym[iF:].index(fld[-1]) + iF
        if '/' in mSgSym[iF:jF]:
            if "'" in mSgSym[iF:jF]:
                Spn.append(-1)
            else:
                Spn.append(1)
        if "'" == mSgSym[jF + 1]:
            Spn.append(-1)
        else:
            Spn.append(1)
    elif len(Flds) == 3:
        if SGData['SGPtGrp'] == '-3m':
            if not mSgSym.count("'"):
                Spn += [1, 1]
            elif mSgSym.count("'") == 2:
                Spn += [-1, 1]
            elif "3'" in mSgSym:
                Spn += [1, -1]
            else:
                Spn += [-1, -1]
        elif "'" in mSgSym:
            Spn.append(-1)
        else:
            Spn.append(1)
    else:
        for fld in Flds[1:]:
            iF = mSgSym[iB:].index(fld[0]) + iB
            jF = mSgSym[iF:].index(fld[-1]) + iF
            if "'" == mSgSym[jF + 1]:
                Spn.append(-1)
                iB = jF + 2
            else:
                Spn.append(1)
                iB = jF + 1
    Spn.append(1)
    return Spn
