def main(args):
    DATA_PATH = os.getcwd()+"\\"

    # User Settings
    if os.path.isfile(DATA_PATH + args.userFile):
        userSettings = files.openFile(DATA_PATH,args.userFile)
    else:
        raise Exception ("user setting file not found")

    # internal (expert) Settings
    if args.expertFile:
        if os.path.isfile(DATA_PATH + args.expertFile):
            internalSettings = files.openFile(DATA_PATH,args.expertFile)
        else:
            raise Exception ("expert setting file not found")
    else:
        internalSettings = None

    # translators
    if os.path.isfile(DATA_PATH + "CGM1_1.translators"):
        translators = files.openFile(DATA_PATH,"CGM1_1.translators")
    else:
        translators = None


    # --- Manager ----
    manager = ModelManager.CGM1_1ConfigManager(userSettings,localInternalSettings=internalSettings,localTranslators=translators)
    manager.contruct()
    finalSettings = manager.getFinalSettings()
    files.prettyDictPrint(finalSettings)


    logging.info("=============Calibration=============")
    model,finalAcqStatic = cgm1_1.calibrate(DATA_PATH,
        manager.staticTrial,
        manager.translators,
        manager.requiredMp,
        manager.optionalMp,
        manager.leftFlatFoot,
        manager.rightFlatFoot,
        manager.markerDiameter,
        manager.pointSuffix,
        displayCoordinateSystem=True)



    btkTools.smartWriter(finalAcqStatic, str(DATA_PATH+finalSettings["Calibration"]["StaticTrial"]))#[:-4]+"-pyCGM2modelled.c3d"))
    logging.info("Static Calibration -----> Done")

    manager.updateMp(model)
    #files.prettyDictPrint(manager.finalSettings)

    logging.info("=============Fitting=============")
    for trial in manager.dynamicTrials:
        mfpa = None if trial["Mfpa"] == "Auto" else trial["Mfpa"]
        reconstructFilenameLabelled = trial["File"]

        acqGait = cgm1_1.fitting(model,DATA_PATH, reconstructFilenameLabelled,
            manager.translators,
            manager.markerDiameter,
            manager.pointSuffix,
            mfpa,
            manager.momentProjection,
            displayCoordinateSystem=True)

        btkTools.smartWriter(acqGait, str(DATA_PATH+reconstructFilenameLabelled))#[:-4]+"-pyCGM2modelled.c3d"))
        logging.info("---->dynamic trial (%s) processed" %(reconstructFilenameLabelled))

    logging.info("=============Writing of final Settings=============")
    i = 0
    while os.path.exists("CGM1.1 [%s].completeSettings" % i):
        i += 1
    filename = "CGM1.1 [" + str(i)+"].completeSettings"
    files.saveJson(DATA_PATH, filename, finalSettings)
    logging.info("---->complete settings (%s) exported" %(filename))


    raw_input("Press return to exit..")
Example #2
0
def getCGMmanager(CGMversion,
                  userSettings,
                  internalSettings=None,
                  translators=None,
                  localIkWeight=None,
                  vsk=None):

    # --- Manager ----
    if model == "CGM1.0":
        manager = ModelManager.CGM1ConfigManager(
            userSettings,
            localInternalSettings=internalSettings,
            localTranslators=translators,
            localIkWeight=localIkWeight,
            vsk=vsk)

    elif model == "CGM1.1":
        manager = ModelManager.CGM1_1ConfigManager(
            userSettings,
            localInternalSettings=internalSettings,
            localTranslators=translators,
            localIkWeight=localIkWeight,
            vsk=vsk)

    elif model == "CGM2.1":
        manager = ModelManager.CGM2_1ConfigManager(
            userSettings,
            localInternalSettings=internalSettings,
            localTranslators=translators,
            localIkWeight=localIkWeight,
            vsk=vsk)

    elif model == "CGM2.2":
        manager = ModelManager.CGM2_2ConfigManager(
            userSettings,
            localInternalSettings=internalSettings,
            localTranslators=translators,
            localIkWeight=localIkWeight,
            vsk=vsk)

    elif model == "CGM2.3":
        manager = ModelManager.CGM2_3ConfigManager(
            userSettings,
            localInternalSettings=internalSettings,
            localTranslators=translators,
            localIkWeight=localIkWeight,
            vsk=vsk)

    elif model == "CGM2.4":
        manager = ModelManager.CGM2_4ConfigManager(
            userSettings,
            localInternalSettings=internalSettings,
            localTranslators=translators,
            localIkWeight=localIkWeight,
            vsk=vsk)

    elif model == "CGM2.5":
        manager = ModelManager.CGM2_5ConfigManager(
            userSettings,
            localInternalSettings=internalSettings,
            localTranslators=translators,
            localIkWeight=localIkWeight,
            vsk=vsk)
    else:
        raise Exception(
            "[pyCGM2] : Model version not known (choice CGM1.0 to CGM2.5 )")

    manager.contruct()

    return manager
Example #3
0
def main(args):
    DATA_PATH = os.getcwd() + "\\"

    # User Settings
    if os.path.isfile(DATA_PATH + args.userFile):
        userSettings = files.openFile(DATA_PATH, args.userFile)
    else:
        raise Exception("user setting file not found")

    # internal (expert) Settings
    if args.expertFile:
        if os.path.isfile(DATA_PATH + args.expertFile):
            internalSettings = files.openFile(DATA_PATH, args.expertFile)
        else:
            raise Exception("expert setting file not found")
    else:
        internalSettings = None

    # translators
    if os.path.isfile(DATA_PATH + "CGM1_1.translators"):
        translators = files.openFile(DATA_PATH, "CGM1_1.translators")
    else:
        translators = None

    # --- Manager ----
    manager = ModelManager.CGM1_1ConfigManager(
        userSettings,
        localInternalSettings=internalSettings,
        localTranslators=translators)
    manager.contruct()
    finalSettings = manager.getFinalSettings()
    #    files.prettyDictPrint(finalSettings)

    #    logging.info("=============Calibration=============")
    model, finalAcqStatic = cgm1_1.calibrate(DATA_PATH,
                                             manager.staticTrial,
                                             manager.translators,
                                             manager.requiredMp,
                                             manager.optionalMp,
                                             manager.leftFlatFoot,
                                             manager.rightFlatFoot,
                                             manager.headFlat,
                                             manager.markerDiameter,
                                             manager.pointSuffix,
                                             displayCoordinateSystem=True)

    btkTools.smartWriter(
        finalAcqStatic,
        str(DATA_PATH + finalSettings["Calibration"]["StaticTrial"][:-4]) +
        '.C3D')  #+"-pyCGM2modelled.c3d"
    #    logging.info("Static Calibration -----> Done")

    manager.updateMp(model)
    #files.prettyDictPrint(manager.finalSettings)

    #    logging.info("=============Fitting=============")
    for trial in manager.dynamicTrials:
        mfpa = None if trial["Mfpa"] == "Auto" else trial["Mfpa"]
        reconstructFilenameLabelled = trial["File"]

        acqGait = cgm1_1.fitting(model,
                                 DATA_PATH,
                                 reconstructFilenameLabelled,
                                 manager.translators,
                                 manager.markerDiameter,
                                 manager.pointSuffix,
                                 mfpa,
                                 manager.momentProjection,
                                 displayCoordinateSystem=True)

        btkTools.smartWriter(
            acqGait,
            str(DATA_PATH + reconstructFilenameLabelled[:-4]) +
            '.C3D')  #+"-pyCGM2modelled.c3d"
Example #4
0
def getCGMmanager(CGMversion,
                  userSettings,
                  internalSettings=None,
                  translators=None,
                  localIkWeight=None,
                  vsk=None):
    """
    return CGM settings

    :param CGMversion [str]:  CGM version name
    :param userSettings [dict]:  content of the userSettings yaml file


    **optional**
    :param internalSettings [dict]: content of the internalSettings yaml file
    :param translators [dict]: content of the translators file
    :param localIkWeight [dict]: content of the localIkweight file
    :param vsk [file]: vsk file

    **Return**
    :param [dict]:  eventual CGM settings

    """

    # --- Manager ----
    if model == "CGM1.0":
        manager = ModelManager.CGM1ConfigManager(
            userSettings,
            localInternalSettings=internalSettings,
            localTranslators=translators,
            localIkWeight=localIkWeight,
            vsk=vsk)

    elif model == "CGM1.1":
        manager = ModelManager.CGM1_1ConfigManager(
            userSettings,
            localInternalSettings=internalSettings,
            localTranslators=translators,
            localIkWeight=localIkWeight,
            vsk=vsk)

    elif model == "CGM2.1":
        manager = ModelManager.CGM2_1ConfigManager(
            userSettings,
            localInternalSettings=internalSettings,
            localTranslators=translators,
            localIkWeight=localIkWeight,
            vsk=vsk)

    elif model == "CGM2.2":
        manager = ModelManager.CGM2_2ConfigManager(
            userSettings,
            localInternalSettings=internalSettings,
            localTranslators=translators,
            localIkWeight=localIkWeight,
            vsk=vsk)

    elif model == "CGM2.3":
        manager = ModelManager.CGM2_3ConfigManager(
            userSettings,
            localInternalSettings=internalSettings,
            localTranslators=translators,
            localIkWeight=localIkWeight,
            vsk=vsk)

    elif model == "CGM2.4":
        manager = ModelManager.CGM2_4ConfigManager(
            userSettings,
            localInternalSettings=internalSettings,
            localTranslators=translators,
            localIkWeight=localIkWeight,
            vsk=vsk)

    elif model == "CGM2.5":
        manager = ModelManager.CGM2_5ConfigManager(
            userSettings,
            localInternalSettings=internalSettings,
            localTranslators=translators,
            localIkWeight=localIkWeight,
            vsk=vsk)
    else:
        raise Exception(
            "[pyCGM2] : Model version not known (choice CGM1.0 to CGM2.5 )")

    manager.contruct()

    return manager