Пример #1
0
    def userSettingsOnly(cls):

        DATA_PATH = pyCGM2.TEST_DATA_PATH + "Configurator\\CGM1\\onlyUserSettings\\"

        #internalSettings = files.openFile(pyCGM2_GLOBAL_SETTINGS_PATH,"CGM1-pyCGM2.settings")

        userSettings = files.openFile(DATA_PATH, "CGM1.userSettings")

        manager = ModelManager.CGM1ConfigManager(userSettings)
        manager.contruct()
        manager.getFinalSettings()
Пример #2
0
    def customTranslators(cls):

        DATA_PATH = pyCGM2.TEST_DATA_PATH + "Configurator\\CGM1\\customTranslators\\"

        #internalSettings = files.openFile(pyCGM2_GLOBAL_SETTINGS_PATH,"CGM1-pyCGM2.settings")

        userSettings = files.openFile(DATA_PATH, "CGM1.userSettings")
        translators = files.openFile(DATA_PATH, "CGM1.translators")

        manager = ModelManager.CGM1ConfigManager(userSettings,
                                                 localTranslators=translators)
        manager.contruct()
        manager.getFinalSettings()
Пример #3
0
    def mpFromVsk(cls):

        DATA_PATH = pyCGM2.TEST_DATA_PATH + "Configurator\\CGM1\\vskIn\\"

        #internalSettings = files.openFile(pyCGM2_GLOBAL_SETTINGS_PATH,"CGM1-pyCGM2.settings")

        userSettings = files.openFile(DATA_PATH, "CGM1.userSettings")

        vsk = vskTools.Vsk(str(DATA_PATH + "CGM1.vsk"))

        manager = ModelManager.CGM1ConfigManager(userSettings, vsk=vsk)
        manager.contruct()
        manager.getFinalSettings()
Пример #4
0
    def allCustom(cls):

        DATA_PATH = pyCGM2.TEST_DATA_PATH + "Configurator\\CGM1\\allCustom\\"

        #internalSettings = files.openFile(pyCGM2_GLOBAL_SETTINGS_PATH,"CGM1-pyCGM2.settings")

        userSettings = files.openFile(DATA_PATH, "CGM1.userSettings")
        translators = files.openFile(DATA_PATH, "CGM1.translators")
        customAdvancedSettings = files.openFile(DATA_PATH,
                                                "CGM1-pyCGM2.settings")
        vsk = vskTools.Vsk(str(DATA_PATH + "CGM1.vsk"))

        manager = ModelManager.CGM1ConfigManager(
            userSettings,
            localInternalSettings=customAdvancedSettings,
            localTranslators=translators,
            vsk=vsk)
        manager.contruct()
        manager.getFinalSettings()
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..")
Пример #6
0
def get_calibration_arguments_and_model_manager(model_type, data_path,
                                                session_xml, point_suffix):
    settings = get_settings(model_type)
    translators = settings["Translators"]
    required_mp, optional_mp = qtmTools.SubjectMp(session_xml)

    static_session_xml_soup = utils.find_static(session_xml)
    calibration_filename = qtmTools.getFilename(static_session_xml_soup)

    leftFlatFoot = toBool(static_session_xml_soup.Left_foot_flat)
    rightFlatFoot = toBool(static_session_xml_soup.Right_foot_flat)
    headFlat = toBool(static_session_xml_soup.Head_flat)
    markerDiameter = float(
        static_session_xml_soup.Marker_diameter.text) * 1000.0

    dynamic_measurements = qtmTools.findDynamic(session_xml)
    user_settings = {
        "Calibration": {
            "Left flat foot": leftFlatFoot,
            "Right flat foot": rightFlatFoot,
            "Head flat": headFlat,
            "StaticTrial": calibration_filename
        },
        "Global": {
            "Marker diameter": markerDiameter,
            "Point suffix": point_suffix
        },
        "MP": {
            "Required": required_mp,
            "Optional": optional_mp
        },
        "Fitting": {
            "Trials": dynamic_measurements
        }
    }
    if model_type == "CGM1":
        model_manager = ModelManager.CGM1ConfigManager(
            user_settings,
            localInternalSettings=settings,
            localTranslators={"Translators": translators})
        model_manager.contruct()
        calibration_arguments = (
            data_path + "\\",
            model_manager.staticTrial,
            model_manager.translators,
            model_manager.requiredMp,
            model_manager.optionalMp,
            model_manager.leftFlatFoot,
            model_manager.rightFlatFoot,
            model_manager.headFlat,
            model_manager.markerDiameter,
            model_manager.pointSuffix,
        )
    elif model_type == "CGM2_3":
        model_manager = ModelManager.CGM2_3ConfigManager(
            user_settings,
            localInternalSettings=settings,
            localTranslators={"Translators": translators})
        model_manager.contruct()
        finalSettings = model_manager.getFinalSettings()
        calibration_arguments = (
            data_path + "\\",
            model_manager.staticTrial,
            model_manager.translators,
            finalSettings,
            model_manager.requiredMp,
            model_manager.optionalMp,
            model_manager.enableIK,
            model_manager.leftFlatFoot,
            model_manager.rightFlatFoot,
            model_manager.headFlat,
            model_manager.markerDiameter,
            model_manager.hjcMethod,
            model_manager.pointSuffix,
        )
    else:
        raise Exception(
            "Processing for model_type={} is not implemented".format(
                model_type))
    return calibration_arguments, model_manager
Пример #7
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"
Пример #8
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
Пример #9
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