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 test_CGM1(self): # results = {'Overall': {'std': array([0.2023908]), 'values': array([5.84457972, 5.35628479, 5.98072926, 5.92348919, 5.73983361, # 5.75431847]), 'median': array([5.79944909]), 'mean': array([5.76653917])}, 'Context': {'Right': {'std': array([0.24414746]), 'values': array([5.84457972, 5.35628479]), 'median': array([5.60043226]), 'mean': array([5.60043226])}, 'Left': {'std': array([0.10462042]), 'values': array([5.98072926, 5.92348919, 5.73983361, 5.75431847]), 'median': array([5.83890383]), 'mean': array([5.84959263])}}} DATA_PATH,analysisInstance = dataTest1() gps =scores.CGM1_GPS() scf = scores.ScoreFilter(gps,analysisInstance, newNormativeDataset) scf.compute()
def plot_MAP(DATA_PATH, analysis, normativeDataset, exportPdf=False, outputName=None, pointLabelSuffix=None, show=True, title=None, exportPng=False): """ plot_MAP : display the Movement Analysis Profile :param DATA_PATH [str]: path to your data :param analysis [pyCGM2.Processing.analysis.Analysis]: pyCGM2 analysis instance :param normativeDataset [pyCGM2.Report.normativeDatasets]: pyCGM2 normative dataset instance **optional** :param pointLabelSuffix [string]: (None) suffix added to outputs :param exportPdf [bool]: save as pdf (False[default]) :param outputName [string]: name of your pdf file (None[default] export your pdf with name : Global Analysis) :param show [bool]: enable matplotlib show function :param title [string]: change default title of the plot panel """ if outputName is None: outputName = "PyCGM2-Analysis" if exportPdf or exportPng: filenameOut = outputName + "-Map" #compute gps = scores.CGM1_GPS(pointSuffix=pointLabelSuffix) scf = scores.ScoreFilter(gps, analysis, normativeDataset) scf.compute() #plot kv = plotViewers.GpsMapPlotViewer(analysis, pointLabelSuffix=pointLabelSuffix) pf = plotFilters.PlottingFilter() pf.setViewer(kv) if exportPdf: pf.setExport(DATA_PATH, filenameOut, "pdf") if title is not None: pf.setTitle(title + "-Map") fig = pf.plot() if show: plt.show() if exportPng: fig.savefig(DATA_PATH + filenameOut + ".png") return fig, filenameOut + ".png" else: return fig
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 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 __init__(self, workingDirectory): self.workingDirectory = workingDirectory self.null = None c3dValObj = c3dValidation.c3dValidation(workingDirectory) self.measurementNames = c3dValObj.getValidC3dList(True) self.fileNames = c3dValObj.getValidC3dList(False) self.normative_dataset = normativeDatasets.NormativeData( "Schwartz2008", "Free") analysis_per_file = { path.basename(name).replace(".c3d", ""): analysis.makeAnalysis(workingDirectory + "\\", [path.basename(name)]) for name in self.fileNames } self.scores = {} for filename, analysis_obj in analysis_per_file.items(): gps = scores.CGM1_GPS(pointSuffix=None) scf = scores.ScoreFilter(gps, analysis_obj, self.normative_dataset) scf.compute() self.scores[filename] = analysis_obj
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")
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