def main(args): DATA_PATH = os.getcwd()+"\\" userSettings = files.openFile(DATA_PATH,args.userFile) manager = ProcessingManager.GaitProcessingConfigManager(userSettings,modelVersion=None) modelledTrials = [str(trialFilename[:-4]+"-pyCGM2modelled.c3d") for trialFilename in manager.modelledTrials] analysisInstance = analysis.makeAnalysis( DATA_PATH,modelledTrials, subjectInfo=manager.subjectInfo, experimentalInfo=manager.experimentalInfo, modelInfo=None, pointLabelSuffix=manager.pointSuffix) plot.plot_spatioTemporal(DATA_PATH,analysisInstance, exportPdf=True, outputName=manager.title) for body in manager.bodyPart: if not manager.consistencyFlag: plot.plot_DescriptiveKinematic(DATA_PATH,analysisInstance,body, manager.normativeData, exportPdf=True, outputName=manager.title, pointLabelSuffix=manager.pointSuffix) try: plot.plot_DescriptiveKinetic(DATA_PATH,analysisInstance,body, manager.normativeData, exportPdf=True,outputName=manager.title, pointLabelSuffix=manager.pointSuffix) except: pass else: plot.plot_ConsistencyKinematic(DATA_PATH,analysisInstance,body, manager.normativeData, exportPdf=True, outputName=manager.title, pointLabelSuffix=manager.pointSuffix) try: plot.plot_ConsistencyKinetic(DATA_PATH,analysisInstance,body, manager.normativeData, exportPdf=True,outputName=manager.title, pointLabelSuffix=manager.pointSuffix) except: pass plot.plot_MAP(DATA_PATH,analysisInstance,manager.normativeData,exportPdf=True,outputName=manager.title,pointLabelSuffix=manager.pointSuffix)
def test_highLevel_gaitPanel_consistencyKinetics(self): DATA_PATH, analysisInstance = dataTest1() normativeDataset = normativeDatasets.NormativeData( "Schwartz2008", "Free") fig = plot.plot_ConsistencyKinetic(DATA_PATH, analysisInstance, "LowerLimb", normativeDataset, pointLabelSuffix=None, type="Gait", exportPdf=False, outputName=None, show=False, title=None) if SHOW: plt.show() return fig
def main(args): NEXUS = ViconNexus.ViconNexus() NEXUS_PYTHON_CONNECTED = NEXUS.Client.IsConnected() if NEXUS_PYTHON_CONNECTED: #-----------------------SETTINGS--------------------------------------- pointSuffix = args.pointSuffix normativeData = { "Author": args.normativeData, "Modality": args.normativeDataModality } if normativeData["Author"] == "Schwartz2008": chosenModality = normativeData["Modality"] nds = normativeDatasets.Schwartz2008( chosenModality ) # modalites : "Very Slow" ,"Slow", "Free", "Fast", "Very Fast" elif normativeData["Author"] == "Pinzone2014": chosenModality = normativeData["Modality"] nds = normativeDatasets.Pinzone2014( chosenModality) # modalites : "Center One" ,"Center Two" consistencyFlag = True if args.consistency else False # --------------------------INPUTS ------------------------------------ DATA_PATH, modelledFilenameNoExt = NEXUS.GetTrialName() modelledFilename = modelledFilenameNoExt + ".c3d" logging.info("data Path: " + DATA_PATH) logging.info("file: " + modelledFilename) # ----- Subject ----- # need subject to find input files subjects = NEXUS.GetSubjectNames() subject = nexusTools.checkActivatedSubject(NEXUS, subjects) logging.info("Subject name : " + subject) # ----- construction of the openMA root instance ----- trialConstructorFilter = nexusFilters.NexusConstructTrialFilter( DATA_PATH, modelledFilenameNoExt, subject) openmaTrial = trialConstructorFilter.build() # --------------------pyCGM2 MODEL ------------------------------ model = files.loadModel(DATA_PATH, subject) modelVersion = model.version # --------------------------PROCESSING -------------------------------- analysisInstance = analysis.makeAnalysis( DATA_PATH, [modelledFilename], pointLabelSuffix=pointSuffix, openmaTrials=[openmaTrial] ) # analysis structure gathering Time-normalized Kinematic and kinetic CGM outputs if not consistencyFlag: if model.m_bodypart in [ enums.BodyPart.LowerLimb, enums.BodyPart.LowerLimbTrunk, enums.BodyPart.FullBody ]: plot.plot_DescriptiveKinetic(DATA_PATH, analysisInstance, "LowerLimb", nds, pointLabelSuffix=pointSuffix, exportPdf=True, outputName=modelledFilename) else: if model.m_bodypart in [ enums.BodyPart.LowerLimb, enums.BodyPart.LowerLimbTrunk, enums.BodyPart.FullBody ]: plot.plot_ConsistencyKinetic(DATA_PATH, analysisInstance, "LowerLimb", nds, pointLabelSuffix=pointSuffix, exportPdf=True, outputName=modelledFilename) else: raise Exception("NO Nexus connection. Turn on Nexus")
def main(): logging.info("------------------------------------------------") logging.info("------------QTM - pyCGM2 Workflow---------------") logging.info("------------------------------------------------") file = "session.xml" sessionXML = files.readXml(os.getcwd() + "\\", file) sessionDate = files.getFileCreationDate(os.getcwd() + "\\" + file) #--------------------------------------------------------------------------- #management of the Processed folder DATA_PATH = os.getcwd() + "\\" + "processed\\" files.createDir(DATA_PATH) staticMeasurement = qtmTools.findStatic(sessionXML) calibrateFilenameLabelled = qtmTools.getFilename(staticMeasurement) if not os.path.isfile(DATA_PATH + calibrateFilenameLabelled): shutil.copyfile(os.getcwd() + "\\" + calibrateFilenameLabelled, DATA_PATH + calibrateFilenameLabelled) logging.info( "qualisys exported c3d file [%s] copied to processed folder" % (calibrateFilenameLabelled)) dynamicMeasurements = qtmTools.findDynamic(sessionXML) for dynamicMeasurement in dynamicMeasurements: reconstructFilenameLabelled = qtmTools.getFilename(dynamicMeasurement) if not os.path.isfile(DATA_PATH + reconstructFilenameLabelled): shutil.copyfile(os.getcwd() + "\\" + reconstructFilenameLabelled, DATA_PATH + reconstructFilenameLabelled) logging.info( "qualisys exported c3d file [%s] copied to processed folder" % (reconstructFilenameLabelled)) acq = btkTools.smartReader( str(DATA_PATH + reconstructFilenameLabelled)) if btkTools.checkForcePlateExist(acq): if "5" in btkTools.smartGetMetadata(acq, "FORCE_PLATFORM", "TYPE"): forceplates.correctForcePlateType5(acq) acq, zeniState = eventDetector.zeni(acq) if zeniState: btkTools.smartWriter( acq, str(DATA_PATH + reconstructFilenameLabelled)) cmd = "Mokka.exe \"%s\"" % (str(DATA_PATH + reconstructFilenameLabelled)) os.system(cmd) # --------------------------GLOBAL SETTINGS ------------------------------------ # global setting ( in user/AppData) if os.path.isfile(pyCGM2.PYCGM2_APPDATA_PATH + "CGM2_2-pyCGM2.settings"): settings = files.openFile(pyCGM2.PYCGM2_APPDATA_PATH, "CGM2_2-pyCGM2.settings") else: settings = files.openFile(pyCGM2.PYCGM2_SETTINGS_FOLDER, "CGM2_2-pyCGM2.settings") # --------------------------MP ------------------------------------ required_mp, optional_mp = qtmTools.SubjectMp(sessionXML) # --Check MP inspectprocedure = inspectProcedures.AnthropometricDataQualityProcedure( required_mp) inspector = inspectFilters.QualityFilter(inspectprocedure) inspector.run() # translators management translators = files.getTranslators(os.getcwd() + "\\", "CGM2_2.translators") if not translators: translators = settings["Translators"] # ikweight ikWeight = files.getIKweightSet(DATA_PATH, "CGM2_2.ikw") if not ikWeight: ikWeight = settings["Fitting"]["Weight"] # --------------------------MODEL CALIBRATION ----------------------- logging.info( "--------------------------MODEL CALIBRATION -----------------------") staticMeasurement = qtmTools.findStatic(sessionXML) calibrateFilenameLabelled = qtmTools.getFilename(staticMeasurement) logging.info("----- CALIBRATION- static file [%s]--" % (calibrateFilenameLabelled)) leftFlatFoot = toBool( staticMeasurement.Left_foot_normalised_to_static_trial.text) rightFlatFoot = toBool( staticMeasurement.Right_foot_normalised_to_static_trial.text) headFlat = toBool(staticMeasurement.Head_normalised_to_static_trial.text) markerDiameter = float(staticMeasurement.Marker_diameter.text) * 1000.0 hjcMethod = settings["Calibration"]["HJC"] pointSuffix = None # Calibration checking # -------------------- acqStatic = btkTools.smartReader(DATA_PATH + calibrateFilenameLabelled) for key in MARKERSETS.keys(): logging.info("[pyCGM2] Checking of the %s" % (key)) # presence ip_presence = inspectProcedures.MarkerPresenceQualityProcedure( acqStatic, markers=MARKERSETS[key]) inspector = inspectFilters.QualityFilter(ip_presence) inspector.run() if ip_presence.markersIn != []: ip_gap = inspectProcedures.GapQualityProcedure( acqStatic, markers=ip_presence.markersIn) inspector = inspectFilters.QualityFilter(ip_gap) inspector.run() ip_swap = inspectProcedures.SwappingMarkerQualityProcedure( acqStatic, markers=ip_presence.markersIn) inspector = inspectFilters.QualityFilter(ip_swap) inspector.run() ip_pos = inspectProcedures.MarkerPositionQualityProcedure( acqStatic, markers=ip_presence.markersIn) inspector = inspectFilters.QualityFilter(ip_pos) # Calibration operation # -------------------- logging.info("[pyCGM2] --- calibration operation ---") model, acqStatic = cgm2_2.calibrate(DATA_PATH, calibrateFilenameLabelled, translators, settings, required_mp, optional_mp, False, leftFlatFoot, rightFlatFoot, headFlat, markerDiameter, hjcMethod, pointSuffix) logging.info("----- CALIBRATION- static file [%s]-----> DONE" % (calibrateFilenameLabelled)) # --------------------------MODEL FITTING ---------------------------------- logging.info( "--------------------------MODEL FITTING ----------------------------------" ) dynamicMeasurements = qtmTools.findDynamic(sessionXML) modelledC3ds = list() eventInspectorStates = list() for dynamicMeasurement in dynamicMeasurements: reconstructFilenameLabelled = qtmTools.getFilename(dynamicMeasurement) logging.info("----Processing of [%s]-----" % (reconstructFilenameLabelled)) mfpa = qtmTools.getForcePlateAssigment(dynamicMeasurement) momentProjection_text = dynamicMeasurement.Moment_Projection.text if momentProjection_text == "Default": momentProjection_text = settings["Fitting"]["Moment Projection"] if momentProjection_text == "Distal": momentProjection = enums.MomentProjection.Distal elif momentProjection_text == "Proximal": momentProjection = enums.MomentProjection.Proximal elif momentProjection_text == "Global": momentProjection = enums.MomentProjection.Global elif momentProjection_text == "JCS": momentProjection = enums.MomentProjection.JCS acq = btkTools.smartReader(DATA_PATH + reconstructFilenameLabelled) # Fitting checking # -------------------- for key in MARKERSETS.keys(): if key != "Calibration markers": logging.info("[pyCGM2] Checking of the %s" % (key)) # presence ip_presence = inspectProcedures.MarkerPresenceQualityProcedure( acq, markers=MARKERSETS[key]) inspector = inspectFilters.QualityFilter(ip_presence) inspector.run() if ip_presence.markersIn != []: ip_gap = inspectProcedures.GapQualityProcedure( acq, markers=ip_presence.markersIn) inspector = inspectFilters.QualityFilter(ip_gap) inspector.run() ip_swap = inspectProcedures.SwappingMarkerQualityProcedure( acq, markers=ip_presence.markersIn) inspector = inspectFilters.QualityFilter(ip_swap) inspector.run() ip_pos = inspectProcedures.MarkerPositionQualityProcedure( acq, markers=ip_presence.markersIn) inspector = inspectFilters.QualityFilter(ip_pos) # filtering # ----------------------- # marker order = int(float(dynamicMeasurement.Marker_lowpass_filter_order.text)) fc = float(dynamicMeasurement.Marker_lowpass_filter_frequency.text) signal_processing.markerFiltering(acq, order=order, fc=fc) # management of force plate type 5 and force plate filtering order = int( float(dynamicMeasurement.Forceplate_lowpass_filter_order.text)) fc = float(dynamicMeasurement.Forceplate_lowpass_filter_frequency.text) if order != 0 and fc != 0: acq = btkTools.smartReader(DATA_PATH + reconstructFilenameLabelled) if btkTools.checkForcePlateExist(acq): if "5" in btkTools.smartGetMetadata(acq, "FORCE_PLATFORM", "TYPE"): forceplates.correctForcePlateType5(acq) signal_processing.markerFiltering(acq, order=order, fc=fc) else: if btkTools.checkForcePlateExist(acq): if "5" in btkTools.smartGetMetadata(acq, "FORCE_PLATFORM", "TYPE"): forceplates.correctForcePlateType5(acq) btkTools.smartWriter(acq, DATA_PATH + reconstructFilenameLabelled) # event checking # ----------------------- inspectprocedureEvents = inspectProcedures.GaitEventQualityProcedure( acq) inspector = inspectFilters.QualityFilter(inspectprocedureEvents) inspector.run() eventInspectorStates.append(inspectprocedureEvents.state) # fitting operation # ----------------------- logging.info("[pyCGM2] --- Fitting operation ---") acqGait = cgm2_2.fitting(model, DATA_PATH, reconstructFilenameLabelled, translators, settings, markerDiameter, pointSuffix, mfpa, momentProjection) outFilename = reconstructFilenameLabelled #[:-4] + "_CGM1.c3d" btkTools.smartWriter(acqGait, str(DATA_PATH + outFilename)) modelledC3ds.append(outFilename) logging.info("----Processing of [%s]-----> DONE" % (reconstructFilenameLabelled)) # --------------------------GAIT PROCESSING ----------------------- if not all(eventInspectorStates): raise Exception( "[pyCGM2] Impossible to run Gait processing. Badly gait event detection. check the log file" ) logging.info( "---------------------GAIT PROCESSING -----------------------") nds = normativeDatasets.Schwartz2008("Free") types = qtmTools.detectMeasurementType(sessionXML) for type in types: modelledTrials = list() for dynamicMeasurement in dynamicMeasurements: if qtmTools.isType(dynamicMeasurement, type): filename = qtmTools.getFilename(dynamicMeasurement) modelledTrials.append(filename) #.replace(".c3d","_CGM1.c3d")) subjectMd = { "patientName": sessionXML.find("Last_name").text + " " + sessionXML.find("First_name").text, "bodyHeight": sessionXML.find("Height").text, "bodyWeight": sessionXML.find("Weight").text, "diagnosis": sessionXML.find("Diagnosis").text, "dob": sessionXML.find("Date_of_birth").text, "sex": sessionXML.find("Sex").text, "test condition": type, "gmfcs": sessionXML.find("Gross_Motor_Function_Classification").text, "fms": sessionXML.find("Functional_Mobility_Scale").text } analysisInstance = analysis.makeAnalysis(DATA_PATH, modelledTrials, subjectInfo=None, experimentalInfo=None, modelInfo=None, pointLabelSuffix=None) title = type # spatiotemporal plot.plot_spatioTemporal(DATA_PATH, analysisInstance, exportPdf=True, outputName=title, show=None, title=title) #Kinematics if model.m_bodypart in [ enums.BodyPart.LowerLimb, enums.BodyPart.LowerLimbTrunk, enums.BodyPart.FullBody ]: plot.plot_DescriptiveKinematic(DATA_PATH, analysisInstance, "LowerLimb", nds, exportPdf=True, outputName=title, pointLabelSuffix=pointSuffix, show=False, title=title) plot.plot_ConsistencyKinematic(DATA_PATH, analysisInstance, "LowerLimb", nds, exportPdf=True, outputName=title, pointLabelSuffix=pointSuffix, show=False, title=title) if model.m_bodypart in [ enums.BodyPart.LowerLimbTrunk, enums.BodyPart.FullBody ]: plot.plot_DescriptiveKinematic(DATA_PATH, analysisInstance, "Trunk", nds, exportPdf=True, outputName=title, pointLabelSuffix=pointSuffix, show=False, title=title) plot.plot_ConsistencyKinematic(DATA_PATH, analysisInstance, "Trunk", nds, exportPdf=True, outputName=title, pointLabelSuffix=pointSuffix, show=False, title=title) if model.m_bodypart in [ enums.BodyPart.UpperLimb, enums.BodyPart.FullBody ]: pass # TODO plot upperlimb panel #Kinetics if model.m_bodypart in [ enums.BodyPart.LowerLimb, enums.BodyPart.LowerLimbTrunk, enums.BodyPart.FullBody ]: plot.plot_DescriptiveKinetic(DATA_PATH, analysisInstance, "LowerLimb", nds, exportPdf=True, outputName=title, pointLabelSuffix=pointSuffix, show=False, title=title) plot.plot_ConsistencyKinetic(DATA_PATH, analysisInstance, "LowerLimb", nds, exportPdf=True, outputName=title, pointLabelSuffix=pointSuffix, show=False, title=title) #MAP plot.plot_MAP(DATA_PATH, analysisInstance, nds, exportPdf=True, outputName=title, pointLabelSuffix=pointSuffix, show=False, title=title) plt.show(False) logging.info("----- Gait Processing -----> DONE")
def pdfGaitReport(DATA_PATH, model, modelledTrials, normativeDataset, pointSuffix, title="gait report"): analysisInstance = analysis.makeAnalysis( DATA_PATH, modelledTrials, type="Gait", emgChannels=None, pointLabelSuffix=None, subjectInfo=None, experimentalInfo=None, modelInfo=None, ) analysis.exportAnalysis(analysisInstance, DATA_PATH, title, mode="Advanced") with PdfPages(DATA_PATH + title + ".pdf") as pdf: # spatiotemporal plot.plot_spatioTemporal(DATA_PATH, analysisInstance, exportPdf=False, outputName=title, show=None, title=title) pdf.savefig() #Kinematics plot.plot_DescriptiveKinematic(DATA_PATH, analysisInstance, "LowerLimb", normativeDataset, exportPdf=False, outputName=title, pointLabelSuffix=pointSuffix, show=False, title=title) pdf.savefig() plot.plot_ConsistencyKinematic(DATA_PATH, analysisInstance, "LowerLimb", normativeDataset, exportPdf=False, outputName=title, pointLabelSuffix=pointSuffix, show=False, title=title) pdf.savefig() plot.plot_DescriptiveKinematic(DATA_PATH, analysisInstance, "Trunk", normativeDataset, exportPdf=False, outputName=title, pointLabelSuffix=pointSuffix, show=False, title=title) pdf.savefig() plot.plot_ConsistencyKinematic(DATA_PATH, analysisInstance, "Trunk", normativeDataset, exportPdf=False, outputName=title, pointLabelSuffix=pointSuffix, show=False, title=title) pdf.savefig() plot.plot_DescriptiveKinematic(DATA_PATH, analysisInstance, "UpperLimb", normativeDataset, exportPdf=False, outputName=title, pointLabelSuffix=pointSuffix, show=False, title=title) pdf.savefig() plot.plot_ConsistencyKinematic(DATA_PATH, analysisInstance, "UpperLimb", normativeDataset, exportPdf=False, outputName=title, pointLabelSuffix=pointSuffix, show=False, title=title) pdf.savefig() #Kinetics plot.plot_DescriptiveKinetic(DATA_PATH, analysisInstance, "LowerLimb", normativeDataset, exportPdf=False, outputName=title, pointLabelSuffix=pointSuffix, show=False, title=title) pdf.savefig() plot.plot_ConsistencyKinetic(DATA_PATH, analysisInstance, "LowerLimb", normativeDataset, exportPdf=False, outputName=title, pointLabelSuffix=pointSuffix, show=False, title=title) pdf.savefig() #MAP plot.plot_MAP(DATA_PATH, analysisInstance, normativeDataset, exportPdf=False, outputName=title, pointLabelSuffix=pointSuffix, show=False, title=title) pdf.savefig()
def pdfGaitReport(DATA_PATH, model, modelledTrials, normativeDataset, pointSuffix, title="gait report"): analysisInstance = analysis.makeAnalysis(DATA_PATH, modelledTrials, subjectInfo=None, experimentalInfo=None, modelInfo=None, pointLabelSuffix=None) with PdfPages(DATA_PATH + title + ".pdf") as pdf: # spatiotemporal plot.plot_spatioTemporal(DATA_PATH, analysisInstance, exportPdf=False, outputName=title, show=None, title=title) pdf.savefig() #Kinematics if model.m_bodypart in [ enums.BodyPart.LowerLimb, enums.BodyPart.LowerLimbTrunk, enums.BodyPart.FullBody ]: plot.plot_DescriptiveKinematic(DATA_PATH, analysisInstance, "LowerLimb", normativeDataset, exportPdf=False, outputName=title, pointLabelSuffix=pointSuffix, show=False, title=title) pdf.savefig() plot.plot_ConsistencyKinematic(DATA_PATH, analysisInstance, "LowerLimb", normativeDataset, exportPdf=False, outputName=title, pointLabelSuffix=pointSuffix, show=False, title=title) pdf.savefig() if model.m_bodypart in [ enums.BodyPart.LowerLimbTrunk, enums.BodyPart.FullBody ]: plot.plot_DescriptiveKinematic(DATA_PATH, analysisInstance, "Trunk", normativeDataset, exportPdf=False, outputName=title, pointLabelSuffix=pointSuffix, show=False, title=title) pdf.savefig() plot.plot_ConsistencyKinematic(DATA_PATH, analysisInstance, "Trunk", normativeDataset, exportPdf=False, outputName=title, pointLabelSuffix=pointSuffix, show=False, title=title) pdf.savefig() if model.m_bodypart in [ enums.BodyPart.UpperLimb, enums.BodyPart.FullBody ]: plot.plot_DescriptiveKinematic(DATA_PATH, analysisInstance, "UpperLimb", normativeDataset, exportPdf=False, outputName=title, pointLabelSuffix=pointSuffix, show=False, title=title) pdf.savefig() plot.plot_ConsistencyKinematic(DATA_PATH, analysisInstance, "UpperLimb", normativeDataset, exportPdf=False, outputName=title, pointLabelSuffix=pointSuffix, show=False, title=title) pdf.savefig() #Kinetics if model.m_bodypart in [ enums.BodyPart.LowerLimb, enums.BodyPart.LowerLimbTrunk, enums.BodyPart.FullBody ]: plot.plot_DescriptiveKinetic(DATA_PATH, analysisInstance, "LowerLimb", normativeDataset, exportPdf=False, outputName=title, pointLabelSuffix=pointSuffix, show=False, title=title) pdf.savefig() plot.plot_ConsistencyKinetic(DATA_PATH, analysisInstance, "LowerLimb", normativeDataset, exportPdf=False, outputName=title, pointLabelSuffix=pointSuffix, show=False, title=title) pdf.savefig() #MAP plot.plot_MAP(DATA_PATH, analysisInstance, normativeDataset, exportPdf=False, outputName=title, pointLabelSuffix=pointSuffix, show=False, title=title) pdf.savefig() plt.show(False) logging.info("----- Gait Processing -----> DONE")
def process_pdf_report(data_path, modelled_trials, title, model, normative_dataset, point_suffix=None): analysisInstance = analysis.makeAnalysis(data_path + "\\", modelled_trials, subjectInfo=None, experimentalInfo=None, modelInfo=None, pointLabelSuffix=None) # spatiotemporal plot.plot_spatioTemporal(data_path, analysisInstance, exportPdf=True, outputName=title, show=None, title=title) # Kinematics if model.m_bodypart in [ enums.BodyPart.LowerLimb, enums.BodyPart.LowerLimbTrunk, enums.BodyPart.FullBody ]: plot.plot_DescriptiveKinematic(data_path, analysisInstance, "LowerLimb", normative_dataset, exportPdf=True, outputName=title, pointLabelSuffix=point_suffix, show=False, title=title) plot.plot_ConsistencyKinematic(data_path, analysisInstance, "LowerLimb", normative_dataset, exportPdf=True, outputName=title, pointLabelSuffix=point_suffix, show=False, title=title) if model.m_bodypart in [ enums.BodyPart.LowerLimbTrunk, enums.BodyPart.FullBody ]: plot.plot_DescriptiveKinematic(data_path, analysisInstance, "Trunk", normative_dataset, exportPdf=True, outputName=title, pointLabelSuffix=point_suffix, show=False, title=title) plot.plot_ConsistencyKinematic(data_path, analysisInstance, "Trunk", normative_dataset, exportPdf=True, outputName=title, pointLabelSuffix=point_suffix, show=False, title=title) if model.m_bodypart in [enums.BodyPart.UpperLimb, enums.BodyPart.FullBody]: pass # TODO plot upperlimb panel # Kinetics if model.m_bodypart in [ enums.BodyPart.LowerLimb, enums.BodyPart.LowerLimbTrunk, enums.BodyPart.FullBody ]: plot.plot_DescriptiveKinetic(data_path, analysisInstance, "LowerLimb", normative_dataset, exportPdf=True, outputName=title, pointLabelSuffix=point_suffix, show=False, title=title) plot.plot_ConsistencyKinetic(data_path, analysisInstance, "LowerLimb", normative_dataset, exportPdf=True, outputName=title, pointLabelSuffix=point_suffix, show=False, title=title) # MAP plot.plot_MAP(data_path, analysisInstance, normative_dataset, exportPdf=True, outputName=title, pointLabelSuffix=point_suffix, show=False, title=title) plt.show(False)
def main(): plt.close("all") parser = argparse.ArgumentParser(description='CGM Normalized Kinetics') parser.add_argument('-nd','--normativeData', type=str, help='normative Data set (Schwartz2008 or Pinzone2014)', default="Schwartz2008") parser.add_argument('-ndm','--normativeDataModality', type=str, help="if Schwartz2008 [VerySlow,SlowFree,Fast,VeryFast] - if Pinzone2014 [CentreOne,CentreTwo]", default="Free") parser.add_argument('-ps','--pointSuffix', type=str, help='suffix of model outputs') parser.add_argument('-c','--consistency', action='store_true', help='consistency plots') args = parser.parse_args() NEXUS = ViconNexus.ViconNexus() NEXUS_PYTHON_CONNECTED = NEXUS.Client.IsConnected() ECLIPSE_MODE = False if not NEXUS_PYTHON_CONNECTED: raise Exception("Vicon Nexus is not running") #-----------------------SETTINGS--------------------------------------- pointSuffix = args.pointSuffix normativeData = {"Author" : args.normativeData, "Modality" : args.normativeDataModality} if normativeData["Author"] == "Schwartz2008": chosenModality = normativeData["Modality"] elif normativeData["Author"] == "Pinzone2014": chosenModality = normativeData["Modality"] nds = normativeDatasets.NormativeData(normativeData["Author"],chosenModality) consistencyFlag = True if args.consistency else False if eclipse.getCurrentMarkedNodes() is not None: LOGGER.logger.info("[pyCGM2] - Script worked with marked node of Vicon Eclipse") # --- acquisition file and path---- DATA_PATH, modelledFilenames =eclipse.getCurrentMarkedNodes() ECLIPSE_MODE = True if not ECLIPSE_MODE: LOGGER.logger.info("[pyCGM2] - Script works with the loaded c3d in vicon Nexus") # --- acquisition file and path---- DATA_PATH, modelledFilenameNoExt = NEXUS.GetTrialName() modelledFilename = modelledFilenameNoExt+".c3d" LOGGER.logger.info( "data Path: "+ DATA_PATH ) LOGGER.logger.info( "file: "+ modelledFilename) # subjects = NEXUS.GetSubjectNames() subject = nexusTools.getActiveSubject(NEXUS) LOGGER.logger.info( "Subject name : " + subject ) if not ECLIPSE_MODE: # btkAcq builder nacf = nexusFilters.NexusConstructAcquisitionFilter(DATA_PATH,modelledFilenameNoExt,subject) acq = nacf.build() outputName = modelledFilename # --------------------------PROCESSING -------------------------------- analysisInstance = analysis.makeAnalysis(DATA_PATH, [modelledFilename], type="Gait", kinematicLabelsDict = None, emgChannels = None, pointLabelSuffix=pointSuffix, btkAcqs=[acq], subjectInfo=None, experimentalInfo=None,modelInfo=None) else: # --------------------------PROCESSING -------------------------------- analysisInstance = analysis.makeAnalysis(DATA_PATH, modelledFilenames, type="Gait", kinematicLabelsDict = None, emgChannels = None, pointLabelSuffix=pointSuffix, subjectInfo=None, experimentalInfo=None,modelInfo=None) outputName = "Eclipse - NormalizedKinetics" if not consistencyFlag: plot.plot_DescriptiveKinetic(DATA_PATH,analysisInstance,"LowerLimb",nds,pointLabelSuffix=pointSuffix, exportPdf=True,outputName=outputName) else: plot.plot_ConsistencyKinetic(DATA_PATH,analysisInstance,"LowerLimb",nds,pointLabelSuffix=pointSuffix, exportPdf=True,outputName=outputName)