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
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 + "CGM2_2.translators"): translators = files.openFile(DATA_PATH, "CGM2_2.translators") else: translators = None # localIkWeight if os.path.isfile(DATA_PATH + "CGM2_2.ikw"): localIkWeight = files.openFile(DATA_PATH, "CGM2_2.ikw") else: localIkWeight = None if args.vskFile: vsk = vskTools.Vsk(str(DATA_PATH + args.vskFile)) else: vsk = None # --- Manager ---- manager = ModelManager.CGM2_2ConfigManager( userSettings, localInternalSettings=internalSettings, localTranslators=translators, localIkWeight=localIkWeight, vsk=vsk) manager.contruct() finalSettings = manager.getFinalSettings() files.prettyDictPrint(finalSettings) logging.info("=============Calibration=============") model, finalAcqStatic = cgm2_2.calibrate(DATA_PATH, manager.staticTrial, manager.translators, finalSettings, manager.requiredMp, manager.optionalMp, True, manager.leftFlatFoot, manager.rightFlatFoot, manager.headFlat, manager.markerDiameter, manager.hjcMethod, 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 = cgm2_2.fitting(model, DATA_PATH, reconstructFilenameLabelled, manager.translators, finalSettings, 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("CGM2.2 [%s].completeSettings" % i): i += 1 filename = "CGM2.2 [" + str(i) + "].completeSettings" files.saveJson(DATA_PATH, filename, finalSettings) logging.info("---->complete settings (%s) exported" % (filename)) raw_input("Press return to exit..")
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