def test_gaitMeanOnlyKineticPlotPanel(self): # ----DATA----- DATA_PATH = pyCGM2.TEST_DATA_PATH+"GaitData\CGM1-NormalGaitData-Events\Hånnibøl Lecter\\" modelledFilenames = ["gait Trial 01.c3d","gait Trial 02.c3d"] #---- Analysis #-------------------------------------------------------------------------- modelInfo=None subjectInfo=None experimentalInfo=None analysis1 = analysis.makeAnalysis(DATA_PATH,modelledFilenames) analysis2 = analysis.makeAnalysis(DATA_PATH,modelledFilenames) kv = ComparisonPlotViewers.KineticsPlotComparisonViewer([analysis1,analysis2],"Right", ["ana1","ana2"]) kv.setConcretePlotFunction(plot.gaitMeanPlot) kv.setNormativeDataset(normativeDatasets.Schwartz2008("Free")) # filter pf = plotFilters.PlottingFilter() pf.setViewer(kv) pf.plot()
def test_gaitConsistencyKinematicPlotPanel(self): # ----DATA----- DATA_PATH = pyCGM2.TEST_DATA_PATH+"GaitData\CGM1-NormalGaitData-Events\Hånnibøl Lecter\\" modelledFilenames = ["gait Trial 01.c3d","gait Trial 02.c3d"] #---- Analysis #-------------------------------------------------------------------------- modelInfo=None subjectInfo=None experimentalInfo=None analysisInstance = analysis.makeAnalysis(DATA_PATH,modelledFilenames) # viewer kv = plotViewers.NormalizedKinematicsPlotViewer(analysisInstance) kv.setConcretePlotFunction(plot.gaitConsistencyPlot) kv.setNormativeDataset(normativeDatasets.Schwartz2008("Free")) # filter pf = plotFilters.PlottingFilter() pf.setViewer(kv) pf.plot()
def test_singleAnalysis(self): # ----DATA----- DATA_PATH = pyCGM2.TEST_DATA_PATH + "GaitData\CGM1-NormalGaitData-Events\Hånnibøl Lecter\\" modelledFilenames = ["gait Trial 01.c3d", "gait Trial 02.c3d"] #---- Analysis #-------------------------------------------------------------------------- modelInfo = None subjectInfo = None experimentalInfo = None analysisInstance = analysis.makeAnalysis(DATA_PATH, modelledFilenames) ndp = normativeDatasets.Schwartz2008("Free") gps = scores.CGM1_GPS() scf = scores.ScoreFilter(gps, analysisInstance, ndp) scf.compute() # viewer kv = plotViewers.GpsMapPlotViewer(analysisInstance) # filter pf = plotFilters.PlottingFilter() pf.setViewer(kv) pf.plot()
def gaitDescriptiveKinematicPlotPanel(cls): # ----DATA----- DATA_PATH = pyCGM2.TEST_DATA_PATH+"operations\\plot\\gaitPlot\\" modelledFilenames = ["gait Trial 03 - viconName.c3d"] #---- c3d manager #-------------------------------------------------------------------------- c3dmanagerProcedure = c3dManager.UniqueC3dSetProcedure(DATA_PATH,modelledFilenames) cmf = c3dManager.C3dManagerFilter(c3dmanagerProcedure) cmf.enableEmg(False) trialManager = cmf.generate() #---- Analysis #-------------------------------------------------------------------------- modelInfo=None subjectInfo=None experimentalInfo=None analysisInstance = analysis.makeAnalysis("Gait", "CGM1.0", DATA_PATH,modelledFilenames,None, None, None) # viewer kv = plotViewers.LowerLimbKinematicsPlotViewer(analysisInstance) kv.setConcretePlotFunction(plot.gaitDescriptivePlot) kv.setNormativeDataset(normativeDatasets.Schwartz2008("Free")) # filter pf = plotFilters.PlottingFilter() pf.setViewer(kv) pf.plot() plt.show()
def test_descriptiveKinematicPlotPanel_savePngAndPdf(self): # ----DATA----- DATA_PATH = pyCGM2.TEST_DATA_PATH+"GaitData\CGM1-NormalGaitData-Events\Hånnibøl Lecter\\" modelledFilenames = ["gait Trial 01.c3d","gait Trial 02.c3d"] DATA_PATH_OUT = pyCGM2.TEST_DATA_PATH_OUT+"GaitData\CGM1-NormalGaitData-Events\Hånnibøl Lecter\\" files.createDir(DATA_PATH_OUT) modelInfo=None subjectInfo=None experimentalInfo=None analysisInstance = analysis.makeAnalysis(DATA_PATH,modelledFilenames) # viewer kv = plotViewers.NormalizedKinematicsPlotViewer(analysisInstance) kv.setConcretePlotFunction(plot.descriptivePlot) kv.setNormativeDataset(normativeDatasets.Schwartz2008("Free")) # filter pf = plotFilters.PlottingFilter() pf.setViewer(kv) pf.setExport(DATA_PATH_OUT,"test_descriptiveKinematicPlotPanel","png") pf.plot() # filter pf = plotFilters.PlottingFilter() pf.setViewer(kv) pf.setExport(DATA_PATH_OUT,"test_descriptiveKinematicPlotPanel","pdf") pf.plot()
def create_pdf_report(session_xml, data_path, model): normative_dataset = normativeDatasets.Schwartz2008("Free") measurement_types = qtmTools.detectMeasurementType(session_xml) for measurement_type in measurement_types: modelledTrials = get_modelled_trials(session_xml, measurement_type) process_pdf_report(data_path, modelledTrials, measurement_type, model, normative_dataset)
def normativeData(self): normativeData = { "Author": self._userSettings["NormativeData"]["Author"], "Modality": self._userSettings["NormativeData"]["Modality"] } 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) return nds
def gaitMeanOnlyKineticPlotPanel(cls): # ----DATA----- DATA_PATH = pyCGM2.TEST_DATA_PATH+"operations\\plot\\gaitPlot\\" modelledFilenames = ["gait Trial 03 - viconName.c3d"] #---- c3d manager #-------------------------------------------------------------------------- c3dmanagerProcedure = c3dManager.UniqueC3dSetProcedure(DATA_PATH,modelledFilenames) cmf = c3dManager.C3dManagerFilter(c3dmanagerProcedure) cmf.enableEmg(False) trialManager = cmf.generate() #---- Analysis #-------------------------------------------------------------------------- modelInfo=None subjectInfo=None experimentalInfo=None analysis1 = gaitSmartFunctions.make_analysis(trialManager, cgm.CGM1LowerLimbs.ANALYSIS_KINEMATIC_LABELS_DICT, cgm.CGM1LowerLimbs.ANALYSIS_KINETIC_LABELS_DICT, modelInfo,subjectInfo,experimentalInfo) analysis2 = gaitSmartFunctions.make_analysis(trialManager, cgm.CGM1LowerLimbs.ANALYSIS_KINEMATIC_LABELS_DICT, cgm.CGM1LowerLimbs.ANALYSIS_KINETIC_LABELS_DICT, modelInfo,subjectInfo,experimentalInfo) kv = plotViewers.multipleAnalyses_LowerLimbKineticsPlotViewer([analysis1,analysis2],"Right", ["ana1","ana2"]) kv.setConcretePlotFunction(plot.gaitMeanPlot) kv.setNormativeDataset(normativeDatasets.Schwartz2008("Free")) # filter pf = plotFilters.PlottingFilter() pf.setViewer(kv) pf.plot() plt.show()
def gaitDescriptiveKinematicPlotPanel(cls): # ----DATA----- DATA_PATH = pyCGM2.TEST_DATA_PATH+"operations\\plot\\gaitPlot\\" modelledFilenames = ["gait Trial 03 - viconName.c3d"] #---- c3d manager #-------------------------------------------------------------------------- c3dmanagerProcedure = c3dManager.UniqueC3dSetProcedure(DATA_PATH,modelledFilenames) cmf = c3dManager.C3dManagerFilter(c3dmanagerProcedure) cmf.enableEmg(False) trialManager = cmf.generate() #---- Analysis #-------------------------------------------------------------------------- modelInfo=None subjectInfo=None experimentalInfo=None analysis = gaitSmartFunctions.make_analysis(trialManager, cgm.CGM1LowerLimbs.ANALYSIS_KINEMATIC_LABELS_DICT, cgm.CGM1LowerLimbs.ANALYSIS_KINETIC_LABELS_DICT, modelInfo,subjectInfo,experimentalInfo) # viewer kv = plotViewers.LowerLimbKinematicsPlotViewer(analysis) kv.setConcretePlotFunction(plot.gaitDescriptivePlot) kv.setNormativeDataset(normativeDatasets.Schwartz2008("Free")) # filter pf = plotFilters.PlottingFilter() pf.setViewer(kv) pf.plot() ka = annotator.Annotator(pf.fig) ka.IncreasedRange(0,40,10,40, "Context", timing="Throughout Cycle") print(ka.getAnnotations()) plt.show()
def singleAnalysis(cls): # ----DATA----- DATA_PATH = pyCGM2.TEST_DATA_PATH+"operations\\plot\\gaitPlot\\" modelledFilenames = ["gait Trial 03 - viconName.c3d"] #---- c3d manager #-------------------------------------------------------------------------- c3dmanagerProcedure = c3dManager.UniqueC3dSetProcedure(DATA_PATH,modelledFilenames) cmf = c3dManager.C3dManagerFilter(c3dmanagerProcedure) cmf.enableEmg(False) trialManager = cmf.generate() #---- Analysis #-------------------------------------------------------------------------- modelInfo=None subjectInfo=None experimentalInfo=None analysis = gaitSmartFunctions.make_analysis(trialManager, cgm.CGM1LowerLimbs.ANALYSIS_KINEMATIC_LABELS_DICT, cgm.CGM1LowerLimbs.ANALYSIS_KINETIC_LABELS_DICT, modelInfo,subjectInfo,experimentalInfo) ndp = normativeDatasets.Schwartz2008("Free") gps =scores.CGM1_GPS() scf = scores.ScoreFilter(gps,analysis, ndp) scf.compute() # viewer kv = plotViewers.GpsMapPlotViewer(analysis) # filter pf = plotFilters.PlottingFilter() pf.setViewer(kv) pf.setPath(DATA_PATH) pf.setPdfName(str("map")) pf.plot() plt.show()
def test_fullBody(self): # ----DATA----- DATA_PATH = pyCGM2.TEST_DATA_PATH+"GaitData\\CGM1-NormalGaitData-Events\\cgm1-fullbody\\" modelledFilenames = ["gait1.c3d","gait2.c3d"] DATA_PATH_OUT = pyCGM2.TEST_DATA_PATH_OUT+"GaitData\\CGM1-NormalGaitData-Events\\cgm1-fullbody\\" files.createDir(DATA_PATH_OUT) nds = normativeDatasets.Schwartz2008("Free") analysisInstance = analysis.makeAnalysis(DATA_PATH,modelledFilenames) plot.plot_DescriptiveKinematic(DATA_PATH,analysisInstance,"LowerLimb", nds, pointLabelSuffix=None, type="Gait", exportPdf=False, outputName=None, show=True, title=None) plot.plot_DescriptiveKinematic(DATA_PATH,analysisInstance,"Trunk", nds, pointLabelSuffix=None, type="Gait", exportPdf=False, outputName=None, show=True, title=None) plot.plot_DescriptiveKinematic(DATA_PATH,analysisInstance,"UpperLimb", nds, pointLabelSuffix=None, type="Gait", exportPdf=False, outputName=None, show=True, title=None)
def test_Schwartz2008(self): nds = normativeDatasets.NormativeData("Schwartz2008", "Free") nds2 = normativeDatasets.Schwartz2008("Free") nds2.constructNormativeData() np.testing.assert_almost_equal(nds.data["PelvisAngles"]["mean"], nds2.data["Pelvis.Angles"]["mean"], decimal=3) np.testing.assert_almost_equal(nds.data["HipAngles"]["mean"], nds2.data["Hip.Angles"]["mean"], decimal=3) np.testing.assert_almost_equal(nds.data["KneeAngles"]["mean"], nds2.data["Knee.Angles"]["mean"], decimal=3) np.testing.assert_almost_equal(nds.data["AnkleAngles"]["mean"], nds2.data["Ankle.Angles"]["mean"], decimal=3) np.testing.assert_almost_equal(nds.data["FootProgressAngles"]["mean"], nds2.data["Foot.Angles"]["mean"], decimal=3) np.testing.assert_almost_equal(nds.data["HipMoment"]["mean"], nds2.data["Hip.Moment"]["mean"], decimal=3) np.testing.assert_almost_equal(nds.data["KneeMoment"]["mean"], nds2.data["Knee.Moment"]["mean"], decimal=3) np.testing.assert_almost_equal(nds.data["AnkleMoment"]["mean"], nds2.data["Ankle.Moment"]["mean"], decimal=3) np.testing.assert_almost_equal(nds.data["HipPower"]["mean"], nds2.data["Hip.Power"]["mean"], decimal=3) np.testing.assert_almost_equal(nds.data["KneePower"]["mean"], nds2.data["Knee.Power"]["mean"], decimal=3) np.testing.assert_almost_equal(nds.data["AnklePower"]["mean"], nds2.data["Ankle.Power"]["mean"], decimal=3)
def singleAnalysis(cls): # ----DATA----- DATA_PATH = pyCGM2.TEST_DATA_PATH + "operations\\plot\\gaitPlot\\" modelledFilenames = ["gait Trial 03 - viconName.c3d"] #---- c3d manager #-------------------------------------------------------------------------- c3dmanagerProcedure = c3dManager.UniqueC3dSetProcedure( DATA_PATH, modelledFilenames) cmf = c3dManager.C3dManagerFilter(c3dmanagerProcedure) cmf.enableEmg(False) trialManager = cmf.generate() #---- Analysis #-------------------------------------------------------------------------- modelInfo = None subjectInfo = None experimentalInfo = None analysisInstance = analysis.makeAnalysis("Gait", "CGM1.0", DATA_PATH, modelledFilenames, None, None, None) ndp = normativeDatasets.Schwartz2008("Free") gps = scores.CGM1_GPS() scf = scores.ScoreFilter(gps, analysisInstance, ndp) scf.compute() # viewer kv = plotViewers.GpsMapPlotViewer(analysisInstance) # filter pf = plotFilters.PlottingFilter() pf.setViewer(kv) pf.setPath(DATA_PATH) pf.setPdfName(str("map")) pf.plot() plt.show()
def gaitDescriptiveKinematicPlotPanel_recorded(cls): # ----DATA----- DATA_PATH = pyCGM2.TEST_DATA_PATH+"operations\\plot\\gaitPlot\\" modelledFilenames = ["gait Trial 03 - viconName.c3d"] #---- c3d manager #-------------------------------------------------------------------------- c3dmanagerProcedure = c3dManager.UniqueC3dSetProcedure(DATA_PATH,modelledFilenames) cmf = c3dManager.C3dManagerFilter(c3dmanagerProcedure) cmf.enableEmg(False) trialManager = cmf.generate() #---- Analysis #-------------------------------------------------------------------------- modelInfo=None subjectInfo=None experimentalInfo=None analysis = gaitSmartFunctions.make_analysis(trialManager, cgm.CGM1LowerLimbs.ANALYSIS_KINEMATIC_LABELS_DICT, cgm.CGM1LowerLimbs.ANALYSIS_KINETIC_LABELS_DICT, modelInfo,subjectInfo,experimentalInfo) # viewer kv = plotViewers.LowerLimbKinematicsPlotViewer(analysis) kv.setConcretePlotFunction(plot.gaitDescriptivePlot) kv.setNormativeDataset(normativeDatasets.Schwartz2008("Free")) # filter pf = plotFilters.PlottingFilter() pf.setViewer(kv) pf.setExport("C:\\Users\\HLS501\\Desktop\\","test","png") pf.plot() plt.show()
def main(sessionFilename, createPDFReport=True): logging.info("------------------------------------------------") logging.info("------------QTM - pyCGM2 Workflow---------------") logging.info("------------------------------------------------") sessionXML = files.readXml(os.getcwd() + "\\", sessionFilename) sessionDate = files.getFileCreationDate(os.getcwd() + "\\" + sessionFilename) #--------------------------------------------------------------------------- #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)) 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_3-pyCGM2.settings"): settings = files.openFile(pyCGM2.PYCGM2_APPDATA_PATH, "CGM2_3-pyCGM2.settings") else: settings = files.openFile(pyCGM2.PYCGM2_SETTINGS_FOLDER, "CGM2_3-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_3.translators") if not translators: translators = settings["Translators"] # ikweight ikWeight = files.getIKweightSet(DATA_PATH, "CGM2_3.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 = utils.toBool( sessionXML.Left_foot_normalised_to_static_trial.text) rightFlatFoot = utils.toBool( sessionXML.Right_foot_normalised_to_static_trial.text) headFlat = utils.toBool(sessionXML.Head_normalised_to_static_trial.text) markerDiameter = float(sessionXML.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_3.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) ik_flag = True modelledC3ds = list() eventInspectorStates = list() for dynamicMeasurement in dynamicMeasurements: # reconstructFilenameLabelled = qtmTools.getFilename(dynamicMeasurement) reconstructFilenameLabelled = qtmTools.getFilename(dynamicMeasurement) logging.info("----Processing of [%s]-----" % (reconstructFilenameLabelled)) mfpa = qtmTools.getForcePlateAssigment(dynamicMeasurement) momentProjection_text = sessionXML.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_marker = int( float(dynamicMeasurement.Marker_lowpass_filter_order.text)) fc_marker = float( dynamicMeasurement.Marker_lowpass_filter_frequency.text) # force plate order_fp = int( float(dynamicMeasurement.Forceplate_lowpass_filter_order.text)) fc_fp = float( dynamicMeasurement.Forceplate_lowpass_filter_frequency.text) # 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_3.fitting(model, DATA_PATH, reconstructFilenameLabelled, translators, settings, ik_flag, markerDiameter, pointSuffix, mfpa, momentProjection, fc_lowPass_marker=fc_marker, order_lowPass_marker=order_marker, fc_lowPass_forcePlate=fc_fp, order_lowPass_forcePlate=order_fp) outFilename = reconstructFilenameLabelled 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 -----------------------") if createPDFReport: 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) report.pdfGaitReport(DATA_PATH, model, modelledTrials, nds, pointSuffix, title=type) logging.info("----- Gait Processing -----> DONE")
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 main(): plt.close("all") parser = argparse.ArgumentParser( description='CGM plot Normalized Kinematics') 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() if NEXUS_PYTHON_CONNECTED: #-----------------------SETTINGS--------------------------------------- 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 pointSuffix = args.pointSuffix # --------------------------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) # --------------------pyCGM2 MODEL ------------------------------ model = files.loadModel(DATA_PATH, subject) modelVersion = model.version # ----- construction of the openMA root instance ----- trialConstructorFilter = nexusFilters.NexusConstructTrialFilter( DATA_PATH, modelledFilenameNoExt, subject) openmaTrial = trialConstructorFilter.build() # --------------------------PROCESSING -------------------------------- analysisInstance = analysis.makeAnalysis(DATA_PATH, [modelledFilename], pointLabelSuffix=pointSuffix, openmaTrials=[openmaTrial]) if not consistencyFlag: if model.m_bodypart in [ enums.BodyPart.LowerLimb, enums.BodyPart.LowerLimbTrunk, enums.BodyPart.FullBody ]: plot.plot_DescriptiveKinematic(DATA_PATH, analysisInstance, "LowerLimb", nds, pointLabelSuffix=pointSuffix, exportPdf=True, outputName=modelledFilename) #plot_DescriptiveKinematic(DATA_PATH,analysis,bodyPart,normativeDataset,pointLabelSuffix=None,type="Gait",exportPdf=False,outputName=None): if model.m_bodypart in [ enums.BodyPart.LowerLimbTrunk, enums.BodyPart.FullBody ]: plot.plot_DescriptiveKinematic(DATA_PATH, analysisInstance, "Trunk", nds, pointLabelSuffix=pointSuffix, exportPdf=True, outputName=modelledFilename) if model.m_bodypart in [ enums.BodyPart.UpperLimb, enums.BodyPart.FullBody ]: pass # TODO plot upperlimb panel else: if model.m_bodypart in [ enums.BodyPart.LowerLimb, enums.BodyPart.LowerLimbTrunk, enums.BodyPart.FullBody ]: plot.plot_ConsistencyKinematic(DATA_PATH, analysisInstance, "LowerLimb", nds, pointLabelSuffix=pointSuffix, exportPdf=True, outputName=modelledFilename) if model.m_bodypart in [ enums.BodyPart.LowerLimbTrunk, enums.BodyPart.FullBody ]: plot.plot_ConsistencyKinematic(DATA_PATH, analysisInstance, "Trunk", nds, pointLabelSuffix=pointSuffix, exportPdf=True, outputName=modelledFilename) if model.m_bodypart in [ enums.BodyPart.UpperLimb, enums.BodyPart.FullBody ]: pass # TODO plot upperlimb panel else: raise Exception("NO Nexus connection. Turn on Nexus")
def main(): plt.close("all") parser = argparse.ArgumentParser(description='CGM plotMAP') 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') args = parser.parse_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" # --------------------------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], None, None, None, pointLabelSuffix=pointSuffix, openmaTrials=[openmaTrial] ) # analysis structure gathering Time-normalized Kinematic and kinetic CGM outputs plot.plot_MAP(DATA_PATH, analysisInstance, nds, exportPdf=True, outputName=modelledFilename, pointLabelSuffix=pointSuffix) else: raise Exception("NO Nexus connection. Turn on Nexus")
def GpsCGM1Test(cls): # ----DATA----- DATA_PATH = pyCGM2.TEST_DATA_PATH + "operations\\analysis\\gps\\" reconstructedFilenameLabelledNoExt = "gait Trial 03 - viconName" reconstructedFilenameLabelled = reconstructedFilenameLabelledNoExt + ".c3d" logging.info("data Path: " + DATA_PATH) logging.info("reconstructed file: " + reconstructedFilenameLabelled) modelledFilenames = [reconstructedFilenameLabelled] #---- c3d manager #-------------------------------------------------------------------------- c3dmanagerProcedure = c3dManager.UniqueC3dSetProcedure( DATA_PATH, modelledFilenames) cmf = c3dManager.C3dManagerFilter(c3dmanagerProcedure) cmf.enableEmg(False) trialManager = cmf.generate() #---- GAIT CYCLES FILTER #-------------------------------------------------------------------------- cycleBuilder = cycle.GaitCyclesBuilder( spatioTemporalTrials=trialManager.spatioTemporal["Trials"], kinematicTrials=trialManager.kinematic["Trials"], kineticTrials=trialManager.kinetic["Trials"], emgTrials=trialManager.emg["Trials"]) cyclefilter = cycle.CyclesFilter() cyclefilter.setBuilder(cycleBuilder) cycles = cyclefilter.build() #---- GAIT ANALYSIS FILTER #-------------------------------------------------------------------------- # ----INFOS----- modelInfo = {"type": "S01"} subjectInfo = None experimentalInfo = None pointLabelSuffix = "" pointLabelSuffixPlus = pointLabelSuffix if pointLabelSuffix == "" else "_" + pointLabelSuffix kinematicLabelsDict = { 'Left': [ "LHipAngles" + pointLabelSuffixPlus, "LKneeAngles" + pointLabelSuffixPlus, "LAnkleAngles" + pointLabelSuffixPlus, "LFootProgressAngles" + pointLabelSuffixPlus, "LPelvisAngles" + pointLabelSuffixPlus ], 'Right': [ "RHipAngles" + pointLabelSuffixPlus, "RKneeAngles" + pointLabelSuffixPlus, "RAnkleAngles" + pointLabelSuffixPlus, "RFootProgressAngles" + pointLabelSuffixPlus, "RPelvisAngles" + pointLabelSuffixPlus ] } kineticLabelsDict = { 'Left': [ "LHipMoment" + pointLabelSuffixPlus, "LKneeMoment" + pointLabelSuffixPlus, "LAnkleMoment" + pointLabelSuffixPlus, "LHipPower" + pointLabelSuffixPlus, "LKneePower" + pointLabelSuffixPlus, "LAnklePower" + pointLabelSuffixPlus ], 'Right': [ "RHipMoment" + pointLabelSuffixPlus, "RKneeMoment" + pointLabelSuffixPlus, "RAnkleMoment" + pointLabelSuffixPlus, "RHipPower" + pointLabelSuffixPlus, "RKneePower" + pointLabelSuffixPlus, "RAnklePower" + pointLabelSuffixPlus ] } analysisBuilder = analysis.GaitAnalysisBuilder( cycles, kinematicLabelsDict=kinematicLabelsDict, kineticLabelsDict=kineticLabelsDict, subjectInfos=subjectInfo, modelInfos=modelInfo, experimentalInfos=experimentalInfo) analysisFilter = analysis.AnalysisFilter() analysisFilter.setBuilder(analysisBuilder) analysisFilter.setInfo(model=modelInfo) analysisFilter.build() analysisInstance = analysisFilter.analysis ## --- GPS ---- ndp = normativeDatasets.Schwartz2008("Free") gps = scores.CGM1_GPS() scf = scores.ScoreFilter(gps, analysisInstance, ndp) scf.compute() xlsExport = exporter.XlsAnalysisExportFilter() xlsExport.setAnalysisInstance(analysisInstance) xlsExport.export("gpsTest2", path=DATA_PATH, mode="Advanced")
# coding: utf-8 #pytest -s --disable-pytest-warnings test_GPS.py::Test_GPS::test_CGM1 # from __future__ import unicode_literals import pyCGM2 from pyCGM2.Lib import analysis from pyCGM2.Processing import scores from pyCGM2.Report import normativeDatasets normativeDataset = normativeDatasets.Schwartz2008("Free") newNormativeDataset = normativeDatasets.NormativeData("Schwartz2008","Free") emgChannels=['Voltage.EMG1','Voltage.EMG2','Voltage.EMG3','Voltage.EMG4','Voltage.EMG5', 'Voltage.EMG6','Voltage.EMG7','Voltage.EMG8','Voltage.EMG9','Voltage.EMG10'] muscles=['RF','RF','VL','VL','HAM', 'HAM','TI','TI','SOL','SOL'] contexts=['Left','Right','Left','Right','Left', 'Right','Left','Right','Left','Right'] normalActivityEmgs=['RECFEM','RECFEM', None,None,None, None,None,None,None,None] def dataTest1(): DATA_PATH = pyCGM2.TEST_DATA_PATH + "GaitData//CGM1-NormalGaitData-Events//Hannibal Lecter\\" modelledFilenames = ["gait Trial 01.c3d", "gait Trial 02.c3d"] analysisInstance = analysis.makeAnalysis(DATA_PATH,
def gaitProcessing(DATA_PATH, modelledFilenames, modelVersion, modelInfo, subjectInfo, experimentalInfo, normativeData, pointSuffix, outputPath=None, outputFilename="gaitProcessing", exportXls=False, plot=True, plotDisplay=True): if outputPath is None: outputPath= DATA_PATH if isinstance(modelledFilenames,str) or isinstance(modelledFilenames,unicode): modelledFilenames = [modelledFilenames] #---- c3d manager #-------------------------------------------------------------------------- c3dmanagerProcedure = c3dManager.UniqueC3dSetProcedure(DATA_PATH,modelledFilenames) cmf = c3dManager.C3dManagerFilter(c3dmanagerProcedure) cmf.enableEmg(False) trialManager = cmf.generate() #---- make analysis #----------------------------------------------------------------------- # pycgm2-filter pipeline are gathered in a single function if modelVersion in["CGM1.0","CGM1.1","CGM2.1","CGM2.2","CGM2.2e","CGM2.3","CGM2.3e","CGM2.4","CGM2.4e"]: if modelVersion in ["CGM2.4","CGM2.4e"]: cgm.CGM1LowerLimbs.ANALYSIS_KINEMATIC_LABELS_DICT["Left"].append("LForeFootAngles") cgm.CGM1LowerLimbs.ANALYSIS_KINEMATIC_LABELS_DICT["Right"].append("RForeFootAngles") analysis = gaitSmartFunctions.make_analysis(trialManager, cgm.CGM1LowerLimbs.ANALYSIS_KINEMATIC_LABELS_DICT, cgm.CGM1LowerLimbs.ANALYSIS_KINETIC_LABELS_DICT, modelInfo, subjectInfo, experimentalInfo, pointLabelSuffix=pointSuffix) #---- normative dataset #----------------------------------------------------------------------- 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" #---- GPS gps =scores.CGM1_GPS(pointSuffix= pointSuffix) scf = scores.ScoreFilter(gps,analysis, nds) scf.compute() #---- export #----------------------------------------------------------------------- files.saveAnalysis(analysis,outputPath,outputFilename) if exportXls: exportFilter = exporter.XlsAnalysisExportFilter() exportFilter.setAnalysisInstance(analysis) exportFilter.export(outputFilename, path=outputPath,excelFormat = "xls",mode="Advanced") #---- plot panels #----------------------------------------------------------------------- if plot: gaitSmartFunctions.cgm_gaitPlots(modelVersion,analysis,trialManager.kineticFlag, outputPath,outputFilename, pointLabelSuffix=pointSuffix, normativeDataset=nds ) if plotDisplay: plt.show() return analysis