示例#1
0
    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
示例#2
0
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")
示例#3
0
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")
示例#4
0
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")
示例#5
0
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