def test_sample0(self):

        DATA_PATH = MAIN_PATH = pyCGM2.TEST_DATA_PATH + "GaitModels\CGM1\\fullBody-native-noOptions\\"
        staticFilename = "static.c3d"

        acqStatic = btkTools.smartReader(DATA_PATH + staticFilename)

        markerDiameter = 14
        leftFlatFoot = False
        rightFlatFoot = False
        headStraight = False
        pointSuffix = "test"

        vskFile = vskTools.getVskFiles(DATA_PATH)
        vsk = vskTools.Vsk(DATA_PATH + "New Subject.vsk")
        required_mp, optional_mp = vskTools.getFromVskSubjectMp(vsk,
                                                                resetFlag=True)

        # calibration according CGM1
        model, finalAcqStatic = cgm1.calibrate(DATA_PATH,
                                               staticFilename,
                                               None,
                                               required_mp,
                                               optional_mp,
                                               leftFlatFoot,
                                               rightFlatFoot,
                                               headStraight,
                                               markerDiameter,
                                               pointSuffix,
                                               displayCoordinateSystem=True)

        # no fitting operation, only checking of forceplateAssembly
        gaitFilename = "gait1.c3d"
        acqGait = btkTools.smartReader(DATA_PATH + gaitFilename)
        mfpa = None

        mappedForcePlate = forceplates.matchingFootSideOnForceplate(acqGait,
                                                                    mfpa=mfpa)
        forceplates.addForcePlateGeneralEvents(acqGait, mappedForcePlate)
        logging.warning("Manual Force plate assignment : %s" %
                        mappedForcePlate)

        # assembly foot and force plate
        modelFilters.ForcePlateAssemblyFilter(
            model,
            acqGait,
            mappedForcePlate,
            leftSegmentLabel="Left Foot",
            rightSegmentLabel="Right Foot").compute(
                pointLabelSuffix=pointSuffix)

        testingUtils.plotComparisonOfPoint(acqGait, "RGroundReactionForce",
                                           "test")
        testingUtils.plotComparisonOfPoint(acqGait, "RGroundReactionMoment",
                                           "test")
Beispiel #2
0
    def test_FullBody_noOptions(self):
        DATA_PATH = MAIN_PATH = pyCGM2.TEST_DATA_PATH + "LowLevel\\uncropped data\\cgm1\\"
        staticFilename = "static.c3d"

        DATA_PATH_OUT = pyCGM2.TEST_DATA_PATH_OUT+"LowLevel\\uncropped data\\cgm1\\"
        files.createDir(DATA_PATH_OUT)

        markerDiameter=14
        leftFlatFoot = True
        rightFlatFoot = True
        headStraight = True
        pointSuffix = ""

        vskFile = vskTools.getVskFiles(DATA_PATH)
        vsk = vskTools.Vsk(DATA_PATH + "New Subject.vsk")
        required_mp,optional_mp = vskTools.getFromVskSubjectMp(vsk, resetFlag=True)

        model,finalAcqStatic = cgm1.calibrate(DATA_PATH,
            staticFilename,
            None,
            required_mp,
            optional_mp,
            leftFlatFoot,
            rightFlatFoot,
            headStraight,
            markerDiameter,
            pointSuffix,
            displayCoordinateSystem=True)

        # btkTools.smartWriter(finalAcqStatic, str( staticFilename[:-4]+"-pyCGM2modelled.c3d"))
        # logging.info("Static Calibration -----> Done")

        gaitFilename="gait1.c3d"

        acqGait0 = btkTools.smartReader(DATA_PATH +  gaitFilename)
        trackingMarkers = model.getTrackingMarkers(acqGait0)
        validFrames,vff,vlf = btkTools.findValidFrames(acqGait0,trackingMarkers)


        mfpa = None
        reconstructFilenameLabelled = gaitFilename


        acqGait = cgm1.fitting(model,DATA_PATH, reconstructFilenameLabelled,
            None,
            markerDiameter,
            pointSuffix,
            mfpa,
            enums.MomentProjection.Proximal,
            displayCoordinateSystem=True)

        btkTools.smartWriter(acqGait, DATA_PATH_OUT+"//gait1-processed.c3d")
Beispiel #3
0
    def test_CGM1_FullBody_noOptions_uncorrectUpperLimbMarker(self):
        DATA_PATH = pyCGM2.TEST_DATA_PATH + "Scenarii\different static and dynamic marker set\CGM1-fullBody\\"
        staticFilename = "static.c3d"

        acqStatic = btkTools.smartReader(DATA_PATH + staticFilename)

        markerDiameter = 14
        leftFlatFoot = False
        rightFlatFoot = False
        headStraight = False
        pointSuffix = "test"

        vskFile = vskTools.getVskFiles(DATA_PATH)
        vsk = vskTools.Vsk(DATA_PATH + "New Subject.vsk")
        required_mp, optional_mp = vskTools.getFromVskSubjectMp(vsk,
                                                                resetFlag=True)

        model, finalAcqStatic, error = cgm1.calibrate(
            DATA_PATH,
            staticFilename,
            None,
            required_mp,
            optional_mp,
            leftFlatFoot,
            rightFlatFoot,
            headStraight,
            markerDiameter,
            pointSuffix,
            displayCoordinateSystem=True)

        # btkTools.smartWriter(finalAcqStatic, str( staticFilename[:-4]+"-pyCGM2modelled.c3d"))
        LOGGER.logger.info("Static Calibration -----> Done")

        # case 1 -  one marker on the upper limb misses
        gaitFilename = "gait1_noRFIN.c3d"
        mfpa = None
        reconstructFilenameLabelled = gaitFilename

        acqGait, error = cgm1.fitting(model,
                                      DATA_PATH,
                                      reconstructFilenameLabelled,
                                      None,
                                      markerDiameter,
                                      pointSuffix,
                                      mfpa,
                                      enums.MomentProjection.Proximal,
                                      displayCoordinateSystem=True)

        assert model.m_bodypart == enums.BodyPart.FullBody
    def test_CGM1_FullBody_noOptions_noFP(self):
        DATA_PATH = pyCGM2.TEST_DATA_PATH + "GaitModels\CGM1\\fullBody-native-noOptions - noFP\\"
        staticFilename = "static.c3d"

        acqStatic = btkTools.smartReader(DATA_PATH +  staticFilename)


        markerDiameter=14
        leftFlatFoot = False
        rightFlatFoot = False
        headStraight = False
        pointSuffix = "test"

        vskFile = vskTools.getVskFiles(DATA_PATH)
        vsk = vskTools.Vsk(DATA_PATH + "New Subject.vsk")
        required_mp,optional_mp = vskTools.getFromVskSubjectMp(vsk, resetFlag=True)

        model,finalAcqStatic = cgm1.calibrate(DATA_PATH,
            staticFilename,
            None,
            required_mp,
            optional_mp,
            leftFlatFoot,
            rightFlatFoot,
            headStraight,
            markerDiameter,
            pointSuffix,
            displayCoordinateSystem=True)


        # btkTools.smartWriter(finalAcqStatic, str( staticFilename[:-4]+"-pyCGM2modelled.c3d"))
        # logging.info("Static Calibration -----> Done")

        gaitFilename="gait1.c3d"

        mfpa = None
        reconstructFilenameLabelled = gaitFilename

        acqGait = cgm1.fitting(model,DATA_PATH, reconstructFilenameLabelled,
            None,
            markerDiameter,
            pointSuffix,
            mfpa,
            enums.MomentProjection.Proximal,
            displayCoordinateSystem=True)

        btkTools.smartWriter(acqGait, "gait1-pyCGM2modelled.c3d")
Beispiel #5
0
def main(sessionFilename,
         createPDFReport=True,
         checkEventsInMokka=True,
         anomalyException=False):

    detectAnomaly = False

    LOGGER.set_file_handler("pyCGM2-QTM-Workflow.log")

    LOGGER.logger.info("------------QTM - pyCGM2 Workflow---------------")

    sessionXML = files.readXml(os.getcwd() + "\\", sessionFilename)
    sessionDate = files.getFileCreationDate(os.getcwd() + "\\" +
                                            sessionFilename)

    #---------------------------------------------------------------------------
    #management of the Processed foldercd
    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)
        LOGGER.logger.info(
            "qualisys exported c3d file [%s] copied to processed folder" %
            (calibrateFilenameLabelled))

    if qtmTools.findKneeCalibration(
            sessionXML, "Left") is not None or qtmTools.findKneeCalibration(
                sessionXML, "Right") is not None:
        LOGGER.logger.info(
            " the %s not accept functional knee calibration !!" % (MODEL))

    dynamicMeasurements = qtmTools.findDynamic(sessionXML)
    for dynamicMeasurement in dynamicMeasurements:
        reconstructFilenameLabelled = qtmTools.getFilename(dynamicMeasurement)

        # marker
        order_marker = int(
            float(dynamicMeasurement.Marker_lowpass_filter_order.text))
        fc_marker = float(
            dynamicMeasurement.Marker_lowpass_filter_frequency.text)

        if not os.path.isfile(DATA_PATH + reconstructFilenameLabelled):
            shutil.copyfile(os.getcwd() + "\\" + reconstructFilenameLabelled,
                            DATA_PATH + reconstructFilenameLabelled)
            LOGGER.logger.info(
                "qualisys exported c3d file [%s] copied to processed folder" %
                (reconstructFilenameLabelled))

            acq = btkTools.smartReader(
                str(DATA_PATH + reconstructFilenameLabelled))

            acq, zeniState = eventDetector.zeni(
                acq,
                fc_lowPass_marker=fc_marker,
                order_lowPass_marker=order_marker)

            if zeniState:
                btkTools.smartWriter(
                    acq, str(DATA_PATH + reconstructFilenameLabelled))
                if checkEventsInMokka:
                    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 + "CGM1-pyCGM2.settings"):
        settings = files.openFile(pyCGM2.PYCGM2_APPDATA_PATH,
                                  "CGM1-pyCGM2.settings")
    else:
        settings = files.openFile(pyCGM2.PYCGM2_SETTINGS_FOLDER,
                                  "CGM1-pyCGM2.settings")

    # --------------------------MP ------------------------------------
    required_mp, optional_mp = qtmTools.SubjectMp(sessionXML)

    #  translators management
    translators = files.getTranslators(os.getcwd() + "\\", "CGM1.translators")
    if not translators: translators = settings["Translators"]

    # --------------------------MODEL CALIBRATION -----------------------
    LOGGER.logger.info(
        "--------------------------MODEL CALIBRATION -----------------------")
    staticMeasurement = qtmTools.findStatic(sessionXML)
    calibrateFilenameLabelled = qtmTools.getFilename(staticMeasurement)

    LOGGER.logger.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
    pointSuffix = None

    acqStatic = btkTools.smartReader(DATA_PATH + calibrateFilenameLabelled)

    # Calibration operation
    # --------------------
    model, acqStatic, detectAnomaly = cgm1.calibrate(
        DATA_PATH,
        calibrateFilenameLabelled,
        translators,
        required_mp,
        optional_mp,
        leftFlatFoot,
        rightFlatFoot,
        headFlat,
        markerDiameter,
        pointSuffix,
        anomalyException=anomalyException)
    LOGGER.logger.info("----- CALIBRATION-  static file [%s]-----> DONE" %
                       (calibrateFilenameLabelled))

    # --------------------------MODEL FITTING ----------------------------------
    LOGGER.logger.info(
        "--------------------------MODEL FITTING ----------------------------------"
    )
    dynamicMeasurements = qtmTools.findDynamic(sessionXML)
    modelledC3ds = list()

    for dynamicMeasurement in dynamicMeasurements:
        reconstructFilenameLabelled = qtmTools.getFilename(dynamicMeasurement)

        LOGGER.logger.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

        acq = btkTools.smartReader(DATA_PATH + reconstructFilenameLabelled)

        # 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)

        if dynamicMeasurement.First_frame_to_process.text != "":
            vff = int(dynamicMeasurement.First_frame_to_process.text)
        else:
            vff = None

        if dynamicMeasurement.Last_frame_to_process.text != "":
            vlf = int(dynamicMeasurement.Last_frame_to_process.text)
        else:
            vlf = None

        # fitting operation
        # -----------------------
        acqGait, detectAnomaly = cgm1.fitting(
            model,
            DATA_PATH,
            reconstructFilenameLabelled,
            translators,
            markerDiameter,
            pointSuffix,
            mfpa,
            momentProjection,
            fc_lowPass_marker=fc_marker,
            order_lowPass_marker=order_marker,
            fc_lowPass_forcePlate=fc_fp,
            order_lowPass_forcePlate=order_fp,
            anomalyException=anomalyException,
            frameInit=vff,
            frameEnd=vlf)

        outFilename = reconstructFilenameLabelled
        btkTools.smartWriter(acqGait, str(DATA_PATH + outFilename))
        modelledC3ds.append(outFilename)

        LOGGER.logger.info("----Processing of [%s]-----> DONE" %
                           (reconstructFilenameLabelled))

    # --------------------------GAIT PROCESSING -----------------------

    LOGGER.logger.info(
        "---------------------GAIT PROCESSING -----------------------")
    if createPDFReport:
        nds = normativeDatasets.NormativeData("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)
                    # event checking
                    # -----------------------
                    acq = btkTools.smartReader(DATA_PATH + filename)
                    geap = AnomalyDetectionProcedure.GaitEventAnomalyProcedure(
                    )
                    adf = AnomalyFilter.AnomalyDetectionFilter(
                        acq, filename, geap)
                    anomaly_events = adf.run()
                    if anomaly_events["ErrorState"]:
                        detectAnomaly = True
                        LOGGER.logger.warning(
                            "file [%s] not used for generating the gait report. bad gait event detected"
                            % (filename))
                    else:
                        modelledTrials.append(filename)
            try:
                report.pdfGaitReport(DATA_PATH,
                                     model,
                                     modelledTrials,
                                     nds,
                                     pointSuffix,
                                     title=type)
                LOGGER.logger.error("Generation of Gait report complete")
            except:
                LOGGER.logger.error("Generation of Gait report failed")

    LOGGER.logger.info(
        "-------------------------------------------------------")
    if detectAnomaly:
        LOGGER.logger.error(
            "Anomalies has been detected - Find Error messages, then check warning message in the log file"
        )
    else:
        LOGGER.logger.info("workflow return with no detected anomalies")
Beispiel #6
0
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 foldercd
    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 + "CGM1-pyCGM2.settings"):
        settings = files.openFile(pyCGM2.PYCGM2_APPDATA_PATH,
                                  "CGM1-pyCGM2.settings")
    else:
        settings = files.openFile(pyCGM2.PYCGM2_SETTINGS_FOLDER,
                                  "CGM1-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() + "\\", "CGM1.translators")
    if not translators: translators = settings["Translators"]

    # --------------------------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
    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 = cgm1.calibrate(DATA_PATH, calibrateFilenameLabelled,
                                      translators, required_mp, optional_mp,
                                      leftFlatFoot, rightFlatFoot, headFlat,
                                      markerDiameter, 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 = 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

        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 = cgm1.fitting(model,
                               DATA_PATH,
                               reconstructFilenameLabelled,
                               translators,
                               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 test_FullBody_noOptions_global(self):
        DATA_PATH = MAIN_PATH = pyCGM2.TEST_DATA_PATH + "GaitModels\\CGM1\\LowerLimb-medMed_Yprogression\\"
        staticFilename = "static.c3d"

        acqStatic = btkTools.smartReader(DATA_PATH + staticFilename)

        markerDiameter = 14
        leftFlatFoot = False
        rightFlatFoot = False
        headStraight = False
        pointSuffix = "test"

        vskFile = vskTools.getVskFiles(DATA_PATH)
        vsk = vskTools.Vsk(DATA_PATH + "Subject.vsk")
        required_mp, optional_mp = vskTools.getFromVskSubjectMp(vsk,
                                                                resetFlag=True)

        model, finalAcqStatic = cgm1.calibrate(DATA_PATH,
                                               staticFilename,
                                               None,
                                               required_mp,
                                               optional_mp,
                                               leftFlatFoot,
                                               rightFlatFoot,
                                               headStraight,
                                               markerDiameter,
                                               pointSuffix,
                                               displayCoordinateSystem=True)

        # btkTools.smartWriter(finalAcqStatic, str( staticFilename[:-4]+"-pyCGM2modelled.c3d"))
        # logging.info("Static Calibration -----> Done")

        gaitFilename = "gait1.Global.c3d"

        mfpa = "RLX"
        reconstructFilenameLabelled = gaitFilename

        acqGait = cgm1.fitting(model,
                               DATA_PATH,
                               reconstructFilenameLabelled,
                               None,
                               markerDiameter,
                               pointSuffix,
                               mfpa,
                               enums.MomentProjection.Global,
                               displayCoordinateSystem=True)

        testingUtils.plotComparison_ForcePanel(acqGait, None, "test", "Left")
        testingUtils.plotComparison_ForcePanel(acqGait, None, "test", "Right")

        gaitFilename = "gait2.Global.c3d"

        mfpa = "XLR"
        reconstructFilenameLabelled = gaitFilename

        acqGait = cgm1.fitting(model,
                               DATA_PATH,
                               reconstructFilenameLabelled,
                               None,
                               markerDiameter,
                               pointSuffix,
                               mfpa,
                               enums.MomentProjection.Global,
                               displayCoordinateSystem=True)

        testingUtils.plotComparison_ForcePanel(acqGait, None, "test", "Left")
        testingUtils.plotComparison_ForcePanel(acqGait, None, "test", "Right")
Beispiel #8
0
    def test_issue_signAbdAddOffset(self):

        DATA_PATH = pyCGM2.TEST_DATA_PATH + "Issues\\StephenM\\signedAbdAdd-KadMed\\"
        staticFilename = "Static.c3d"
        acqStatic = btkTools.smartReader(str(DATA_PATH + staticFilename))

        markerDiameter = 14
        leftFlatFoot = True
        rightFlatFoot = True
        headStraight = True
        pointSuffix = "test"

        vskFile = vskTools.getVskFiles(DATA_PATH)
        vsk = vskTools.Vsk(DATA_PATH + "Nick.vsk")
        required_mp, optional_mp = vskTools.getFromVskSubjectMp(vsk,
                                                                resetFlag=True)
        # required_mp={
        # 'Bodymass'   : 65.0,
        # 'LeftLegLength' : 800.0,
        # 'RightLegLength' : 800.0 ,
        # 'LeftKneeWidth' : 120.0,
        # 'RightKneeWidth' : 120.0,
        # 'LeftAnkleWidth' : 100.0,
        # 'RightAnkleWidth' : 100.0,
        # 'LeftSoleDelta' : 0,
        # 'RightSoleDelta' : 0,
        # 'LeftShoulderOffset'   : 40,
        # 'LeftElbowWidth' : 74,
        # 'LeftWristWidth' : 55 ,
        # 'LeftHandThickness' : 34 ,
        # 'RightShoulderOffset'   : 40,
        # 'RightElbowWidth' : 74,
        # 'RightWristWidth' : 55 ,
        # 'RightHandThickness' : 34}
        #
        # optional_mp={
        # 'InterAsisDistance'   :  0,#0,
        # 'LeftAsisTrocanterDistance' :  0,#0,
        # 'LeftTibialTorsion' :  0,#0,
        # 'LeftThighRotation' :  0,#0,
        # 'LeftShankRotation' : 0,#0,ipdb
        # 'RightAsisTrocanterDistance' : 0,#0,
        # 'RightTibialTorsion' :  0,#0,
        # 'RightThighRotation' :  0,#0,
        # 'RightShankRotation' : 0}

        model, finalAcqStatic = cgm1.calibrate(DATA_PATH,
                                               staticFilename,
                                               None,
                                               required_mp,
                                               optional_mp,
                                               leftFlatFoot,
                                               rightFlatFoot,
                                               headStraight,
                                               markerDiameter,
                                               pointSuffix,
                                               displayCoordinateSystem=True)

        testingUtils.test_offset(
            model.mp_computed["LeftThighRotationOffset"],
            acqStatic,
            "LThighRotation",
            decimal=1)  # not enought accurate but unsignificant
        testingUtils.test_offset(model.mp_computed["RightThighRotationOffset"],
                                 acqStatic,
                                 "RThighRotation",
                                 decimal=1)
        testingUtils.test_offset(model.mp_computed["LeftShankRotationOffset"],
                                 acqStatic,
                                 "LShankRotation",
                                 decimal=1)
        testingUtils.test_offset(model.mp_computed["RightShankRotationOffset"],
                                 acqStatic,
                                 "RShankRotation",
                                 decimal=1)
        testingUtils.test_offset(model.mp_computed["LeftTibialTorsionOffset"],
                                 acqStatic,
                                 "LTibialTorsion",
                                 decimal=1)
        testingUtils.test_offset(model.mp_computed["RightTibialTorsionOffset"],
                                 acqStatic,
                                 "RTibialTorsion",
                                 decimal=1)
        testingUtils.test_offset(model.mp_computed["LeftAnkleAbAddOffset"],
                                 acqStatic,
                                 "LAnkleAbAdd",
                                 decimal=1)
        testingUtils.test_offset(model.mp_computed["RightAnkleAbAddOffset"],
                                 acqStatic,
                                 "RAnkleAbAdd",
                                 decimal=1)
        testingUtils.test_offset(
            model.mp_computed["LeftStaticPlantFlexOffset"],
            acqStatic,
            "LStaticPlantFlex",
            decimal=1)
        testingUtils.test_offset(
            model.mp_computed["RightStaticPlantFlexOffset"],
            acqStatic,
            "RStaticPlantFlex",
            decimal=1)
        testingUtils.test_offset(model.mp_computed["LeftStaticRotOffset"],
                                 acqStatic,
                                 "LStaticRotOff",
                                 decimal=1)
        testingUtils.test_offset(model.mp_computed["RightStaticRotOffset"],
                                 acqStatic,
                                 "RStaticRotOff",
                                 decimal=1)
Beispiel #9
0
    def test_Kad_noOptions(self):
        DATA_PATH = pyCGM2.TEST_DATA_PATH + "GaitModels\CGM1\\kad-noOptions\\"
        staticFilename = "static.c3d"
        acqStatic = btkTools.smartReader(DATA_PATH +  staticFilename)

        markerDiameter=14
        leftFlatFoot = False
        rightFlatFoot = False
        headStraight = False
        pointSuffix = "test"

        # vskFile = vskTools.getVskFiles(DATA_PATH)
        # vsk = vskTools.Vsk(str(DATA_PATH + "PIG-KAD.vsk"))
        # required_mp,optional_mp = vskTools.getFromVskSubjectMp(vsk, resetFlag=True)

        required_mp={
        'Bodymass'   : 71.0,
        'LeftLegLength' : 860.0,
        'RightLegLength' : 865.0 ,
        'LeftKneeWidth' : 102.0,
        'RightKneeWidth' : 103.4,
        'LeftAnkleWidth' : 75.3,
        'RightAnkleWidth' : 72.9,
        'LeftSoleDelta' : 0,
        'RightSoleDelta' : 0,
        'LeftShoulderOffset'   : 40,
        'LeftElbowWidth' : 74,
        'LeftWristWidth' : 55 ,
        'LeftHandThickness' : 34 ,
        'RightShoulderOffset'   : 40,
        'RightElbowWidth' : 74,
        'RightWristWidth' : 55 ,
        'RightHandThickness' : 34}

        optional_mp={
        'InterAsisDistance'   :  0,#0,
        'LeftAsisTrocanterDistance' :  0,#0,
        'LeftTibialTorsion' :  0,#0,
        'LeftThighRotation' :  0,#0,
        'LeftShankRotation' : 0,#0,
        'RightAsisTrocanterDistance' : 0,#0,
        'RightTibialTorsion' :  0,#0,
        'RightThighRotation' :  0,#0,
        'RightShankRotation' : 0}

        model,finalAcqStatic,error = cgm1.calibrate(DATA_PATH,
            staticFilename,
            None,
            required_mp,
            optional_mp,
            leftFlatFoot,
            rightFlatFoot,
            headStraight,
            markerDiameter,
            pointSuffix,
            displayCoordinateSystem=True)


        testingUtils.test_offset(model.mp_computed["LeftThighRotationOffset"],acqStatic,"LThighRotation", decimal=3)
        testingUtils.test_offset(model.mp_computed["RightThighRotationOffset"],acqStatic,"RThighRotation", decimal=3)
        testingUtils.test_offset(model.mp_computed["LeftShankRotationOffset"],acqStatic,"LShankRotation", decimal=3)
        testingUtils.test_offset(model.mp_computed["RightShankRotationOffset"],acqStatic,"RShankRotation", decimal=3)
        testingUtils.test_offset(model.mp_computed["LeftTibialTorsionOffset"],acqStatic,"LTibialTorsion", decimal=3)
        testingUtils.test_offset(model.mp_computed["RightTibialTorsionOffset"],acqStatic,"RTibialTorsion", decimal=3)
        testingUtils.test_offset(model.mp_computed["LeftAnkleAbAddOffset"],acqStatic,"LAnkleAbAdd", decimal=3)
        testingUtils.test_offset(model.mp_computed["RightAnkleAbAddOffset"],acqStatic,"RAnkleAbAdd", decimal=3)
        testingUtils.test_offset(model.mp_computed["LeftStaticPlantFlexOffset"],acqStatic,"LStaticPlantFlex", decimal=3)
        testingUtils.test_offset(model.mp_computed["RightStaticPlantFlexOffset"],acqStatic,"RStaticPlantFlex", decimal=3)
        testingUtils.test_offset(model.mp_computed["LeftStaticRotOffset"],acqStatic,"LStaticRotOff", decimal=3)
        testingUtils.test_offset(model.mp_computed["RightStaticRotOffset"],acqStatic,"RStaticRotOff", decimal=3)

        np.testing.assert_equal(model.getSegment("Left Thigh").getReferential("TF").static.getNode_byLabel("LHJC").m_desc ,"Davis")
        np.testing.assert_equal(model.getSegment("Right Thigh").getReferential("TF").static.getNode_byLabel("RHJC").m_desc ,"Davis")
        np.testing.assert_equal(model.getSegment("Left Thigh").getReferential("TF").static.getNode_byLabel("LKJC").m_desc ,"KAD")
        np.testing.assert_equal(model.getSegment("Right Thigh").getReferential("TF").static.getNode_byLabel("RKJC").m_desc ,"KAD")
        np.testing.assert_equal(model.getSegment("Left Shank").getReferential("TF").static.getNode_byLabel("LKJC").m_desc ,"KAD")
        np.testing.assert_equal(model.getSegment("Right Shank").getReferential("TF").static.getNode_byLabel("RKJC").m_desc ,"KAD")
        np.testing.assert_equal(model.getSegment("Left Shank").getReferential("TF").static.getNode_byLabel("LAJC").m_desc ,"KAD")
        np.testing.assert_equal(model.getSegment("Right Shank").getReferential("TF").static.getNode_byLabel("RAJC").m_desc ,"KAD")
        np.testing.assert_equal(model.getSegment("Left Foot").getReferential("TF").static.getNode_byLabel("LAJC").m_desc ,"KAD")
        np.testing.assert_equal(model.getSegment("Right Foot").getReferential("TF").static.getNode_byLabel("RAJC").m_desc ,"KAD")

        # btkTools.smartWriter(finalAcqStatic, str( staticFilename[:-4]+"-pyCGM2modelled.c3d"))
        # LOGGER.logger.info("Static Calibration -----> Done")

        gaitFilename="gait1.c3d"

        mfpa = None
        reconstructFilenameLabelled = gaitFilename

        acqGait,error = cgm1.fitting(model,DATA_PATH, reconstructFilenameLabelled,
            None,
            markerDiameter,
            pointSuffix,
            mfpa,
            enums.MomentProjection.Proximal,
            displayCoordinateSystem=True)

        testingUtils.test_point(acqGait,"LHipAngles","LHipAngles_test",decimal = 3)
        testingUtils.test_point(acqGait,"LKneeAngles","LKneeAngles_test",decimal = 2)
        testingUtils.test_point(acqGait,"LAnkleAngles","LAnkleAngles_test",decimal = 2)
        testingUtils.test_point(acqGait,"RHipAngles","RHipAngles_test",decimal = 2)
        testingUtils.test_point(acqGait,"RKneeAngles","RKneeAngles_test",decimal = 2)
        testingUtils.test_point(acqGait,"RAnkleAngles","RAnkleAngles_test",decimal = 2)
Beispiel #10
0
    def test_FullBody_noOptions(self):
        DATA_PATH = pyCGM2.TEST_DATA_PATH + "GaitModels\CGM1\\fullBody-native-Options\\"
        staticFilename = "static.c3d"

        acqStatic = btkTools.smartReader(DATA_PATH +  staticFilename)


        markerDiameter=14
        leftFlatFoot = True
        rightFlatFoot = True
        headStraight = True
        pointSuffix = "test"

        vskFile = vskTools.getVskFiles(DATA_PATH)
        vsk = vskTools.Vsk(DATA_PATH + "New Subject.vsk")
        required_mp,optional_mp = vskTools.getFromVskSubjectMp(vsk, resetFlag=True)

        model,finalAcqStatic,error = cgm1.calibrate(DATA_PATH,
            staticFilename,
            None,
            required_mp,
            optional_mp,
            leftFlatFoot,
            rightFlatFoot,
            headStraight,
            markerDiameter,
            pointSuffix,
            displayCoordinateSystem=True)


        testingUtils.test_offset(model.mp_computed["LeftThighRotationOffset"],acqStatic,"LThighRotation", decimal=3)
        testingUtils.test_offset(model.mp_computed["RightThighRotationOffset"],acqStatic,"RThighRotation", decimal=3)
        testingUtils.test_offset(model.mp_computed["LeftShankRotationOffset"],acqStatic,"LShankRotation", decimal=3)
        testingUtils.test_offset(model.mp_computed["RightShankRotationOffset"],acqStatic,"RShankRotation", decimal=3)
        testingUtils.test_offset(model.mp_computed["LeftTibialTorsionOffset"],acqStatic,"LTibialTorsion", decimal=3)
        testingUtils.test_offset(model.mp_computed["RightTibialTorsionOffset"],acqStatic,"RTibialTorsion", decimal=3)
        testingUtils.test_offset(model.mp_computed["LeftAnkleAbAddOffset"],acqStatic,"LAnkleAbAdd", decimal=3)
        testingUtils.test_offset(model.mp_computed["RightAnkleAbAddOffset"],acqStatic,"RAnkleAbAdd", decimal=3)
        testingUtils.test_offset(model.mp_computed["LeftStaticPlantFlexOffset"],acqStatic,"LStaticPlantFlex", decimal=3)
        testingUtils.test_offset(model.mp_computed["RightStaticPlantFlexOffset"],acqStatic,"RStaticPlantFlex", decimal=3)
        testingUtils.test_offset(model.mp_computed["LeftStaticRotOffset"],acqStatic,"LStaticRotOff", decimal=3)
        testingUtils.test_offset(model.mp_computed["RightStaticRotOffset"],acqStatic,"RStaticRotOff", decimal=3)


        np.testing.assert_equal(model.getSegment("Left Thigh").getReferential("TF").static.getNode_byLabel("LHJC").m_desc ,"Davis")
        np.testing.assert_equal(model.getSegment("Right Thigh").getReferential("TF").static.getNode_byLabel("RHJC").m_desc ,"Davis")
        np.testing.assert_equal(model.getSegment("Left Thigh").getReferential("TF").static.getNode_byLabel("LKJC").m_desc ,"Chord")
        np.testing.assert_equal(model.getSegment("Right Thigh").getReferential("TF").static.getNode_byLabel("RKJC").m_desc ,"Chord")
        np.testing.assert_equal(model.getSegment("Left Shank").getReferential("TF").static.getNode_byLabel("LKJC").m_desc ,"Chord")
        np.testing.assert_equal(model.getSegment("Right Shank").getReferential("TF").static.getNode_byLabel("RKJC").m_desc ,"Chord")
        np.testing.assert_equal(model.getSegment("Left Shank").getReferential("TF").static.getNode_byLabel("LAJC").m_desc ,"Chord")
        np.testing.assert_equal(model.getSegment("Right Shank").getReferential("TF").static.getNode_byLabel("RAJC").m_desc ,"Chord")
        np.testing.assert_equal(model.getSegment("Left Foot").getReferential("TF").static.getNode_byLabel("LAJC").m_desc ,"Chord")
        np.testing.assert_equal(model.getSegment("Right Foot").getReferential("TF").static.getNode_byLabel("RAJC").m_desc ,"Chord")


        testingUtils.test_point(finalAcqStatic,"LPelvisAngles","LPelvisAngles_test",decimal = 3)
        testingUtils.test_point(finalAcqStatic,"RPelvisAngles","RPelvisAngles_test",decimal = 3)
        testingUtils.test_point(finalAcqStatic,"LHipAngles","LHipAngles_test",decimal = 3)
        testingUtils.test_point(finalAcqStatic,"LKneeAngles","LKneeAngles_test",decimal = 2)
        testingUtils.test_point(finalAcqStatic,"LAnkleAngles","LAnkleAngles_test",decimal = 2)
        testingUtils.test_point(finalAcqStatic,"RHipAngles","RHipAngles_test",decimal = 3)
        testingUtils.test_point(finalAcqStatic,"RKneeAngles","RKneeAngles_test",decimal = 2)
        testingUtils.test_point(finalAcqStatic,"RAnkleAngles","RAnkleAngles_test",decimal = 2)
        testingUtils.test_point(finalAcqStatic,"LFootProgressAngles","LFootProgressAngles_test",decimal = 2)
        testingUtils.test_point(finalAcqStatic,"RFootProgressAngles","RFootProgressAngles_test",decimal = 2)

        testingUtils.test_point(finalAcqStatic,"LThoraxAngles","LThoraxAngles_test",decimal = 2)
        testingUtils.test_point(finalAcqStatic,"RThoraxAngles","RThoraxAngles_test",decimal = 2)
        testingUtils.test_point(finalAcqStatic,"LSpineAngles","LSpineAngles_test",decimal = 2)
        testingUtils.test_point(finalAcqStatic,"RSpineAngles","RSpineAngles_test",decimal = 2)
        testingUtils.test_point(finalAcqStatic,"LShoulderAngles","LShoulderAngles_test",decimal = 2)
        testingUtils.test_point(finalAcqStatic,"RShoulderAngles","RShoulderAngles_test",decimal = 2)
        testingUtils.test_point(finalAcqStatic,"LElbowAngles","LElbowAngles_test",decimal = 2)
        testingUtils.test_point(finalAcqStatic,"RElbowAngles","RElbowAngles_test",decimal = 2)
        testingUtils.test_point(finalAcqStatic,"LHeadAngles","LHeadAngles_test",decimal = 3)
        testingUtils.test_point(finalAcqStatic,"RHeadAngles","RHeadAngles_test",decimal = 3)


        # btkTools.smartWriter(finalAcqStatic, str( staticFilename[:-4]+"-pyCGM2modelled.c3d"))
        # LOGGER.logger.info("Static Calibration -----> Done")

        gaitFilename="gait1.c3d"

        mfpa = None
        reconstructFilenameLabelled = gaitFilename

        acqGait,error = cgm1.fitting(model,DATA_PATH, reconstructFilenameLabelled,
            None,
            markerDiameter,
            pointSuffix,
            mfpa,
            enums.MomentProjection.Proximal,
            displayCoordinateSystem=True)

        testingUtils.test_point(acqGait,"LPelvisAngles","LPelvisAngles_test",decimal = 3)
        testingUtils.test_point(acqGait,"RPelvisAngles","RPelvisAngles_test",decimal = 3)
        testingUtils.test_point(acqGait,"LHipAngles","LHipAngles_test",decimal = 3)
        testingUtils.test_point(acqGait,"LKneeAngles","LKneeAngles_test",decimal = 2)
        testingUtils.test_point(acqGait,"LAnkleAngles","LAnkleAngles_test",decimal = 2)
        testingUtils.test_point(acqGait,"RHipAngles","RHipAngles_test",decimal = 3)
        testingUtils.test_point(acqGait,"RKneeAngles","RKneeAngles_test",decimal = 2)
        testingUtils.test_point(acqGait,"RAnkleAngles","RAnkleAngles_test",decimal = 2)
        testingUtils.test_point(acqGait,"LFootProgressAngles","LFootProgressAngles_test",decimal = 2)
        testingUtils.test_point(acqGait,"RFootProgressAngles","RFootProgressAngles_test",decimal = 2)

        testingUtils.test_point(acqGait,"LThoraxAngles","LThoraxAngles_test",decimal = 2)
        testingUtils.test_point(acqGait,"RThoraxAngles","RThoraxAngles_test",decimal = 2)
        testingUtils.test_point(acqGait,"LSpineAngles","LSpineAngles_test",decimal = 2)
        testingUtils.test_point(acqGait,"RSpineAngles","RSpineAngles_test",decimal = 2)
        testingUtils.test_point(acqGait,"LShoulderAngles","LShoulderAngles_test",decimal = 2)
        testingUtils.test_point(acqGait,"RShoulderAngles","RShoulderAngles_test",decimal = 2)
        testingUtils.test_point(acqGait,"LElbowAngles","LElbowAngles_test",decimal = 2)
        testingUtils.test_point(acqGait,"RElbowAngles","RElbowAngles_test",decimal = 2)
        testingUtils.test_point(acqGait,"LHeadAngles","LHeadAngles_test",decimal = 3)
        testingUtils.test_point(acqGait,"RHeadAngles","RHeadAngles_test",decimal = 3)
        # testingUtils.test_point(acqGait,"LWristAngles","LWristAngles_test",decimal = 3) fail on z!
        # testingUtils.test_point(acqGait,"RWristAngles","RWristAngles_test",decimal = 3) fail on Z!
        # testingUtils.test_point(acqGait,"CentreOfMass","CentreOfMass_test",decimal = 3)

        btkTools.smartAppendPoint(acqGait,"headCOM_py",model.getSegment("Head").getComTrajectory())
        btkTools.smartAppendPoint(acqGait,"ThoraxCOM_py",model.getSegment("Thorax").getComTrajectory())
        btkTools.smartAppendPoint(acqGait,"LhumCOM_py",model.getSegment("Left UpperArm").getComTrajectory())
        btkTools.smartAppendPoint(acqGait,"LforeCom_py",model.getSegment("Left ForeArm").getComTrajectory())
        btkTools.smartAppendPoint(acqGait,"LhandCom_py",model.getSegment("Left Hand").getComTrajectory())
        btkTools.smartAppendPoint(acqGait,"RhumCOM_py",model.getSegment("Right UpperArm").getComTrajectory())
        btkTools.smartAppendPoint(acqGait,"RforeCom_py",model.getSegment("Right ForeArm").getComTrajectory())
        btkTools.smartAppendPoint(acqGait,"RhandCom_py",model.getSegment("Right Hand").getComTrajectory())
Beispiel #11
0
def main(args):
    DATA_PATH = os.getcwd() + "\\"

    # User Settings
    if os.path.isfile(DATA_PATH + args.userFile):
        userSettings = files.openFile(DATA_PATH, args.userFile)
    else:
        raise Exception("user setting file not found")

    # internal (expert) Settings
    if args.expertFile:
        if os.path.isfile(DATA_PATH + args.expertFile):
            internalSettings = files.openFile(DATA_PATH, args.expertFile)
        else:
            raise Exception("expert setting file not found")
    else:
        internalSettings = None

    # translators
    if os.path.isfile(DATA_PATH + "CGM1.translators"):
        translators = files.openFile(DATA_PATH, "CGM1.translators")
    else:
        translators = None

    if args.vskFile:
        vsk = vskTools.Vsk(str(DATA_PATH + args.vskFile))
    else:
        vsk = None

    # --- Manager ----
    manager = ModelManager.CGM1ConfigManager(
        userSettings,
        localInternalSettings=internalSettings,
        localTranslators=translators,
        vsk=vsk)
    manager.contruct()
    finalSettings = manager.getFinalSettings()
    files.prettyDictPrint(finalSettings)

    logging.info("=============Calibration=============")
    model, finalAcqStatic = cgm1.calibrate(DATA_PATH,
                                           manager.staticTrial,
                                           manager.translators,
                                           manager.requiredMp,
                                           manager.optionalMp,
                                           manager.leftFlatFoot,
                                           manager.rightFlatFoot,
                                           manager.headFlat,
                                           manager.markerDiameter,
                                           manager.pointSuffix,
                                           displayCoordinateSystem=True)

    btkTools.smartWriter(
        finalAcqStatic,
        str(DATA_PATH + finalSettings["Calibration"]["StaticTrial"][:-4] +
            "-pyCGM2modelled.c3d"))
    logging.info("Static Calibration -----> Done")

    manager.updateMp(model)
    #files.prettyDictPrint(manager.finalSettings)

    logging.info("=============Fitting=============")
    for trial in manager.dynamicTrials:
        mfpa = None if trial["Mfpa"] == "Auto" else trial["Mfpa"]
        reconstructFilenameLabelled = trial["File"]

        acqGait = cgm1.fitting(model,
                               DATA_PATH,
                               reconstructFilenameLabelled,
                               manager.translators,
                               manager.markerDiameter,
                               manager.pointSuffix,
                               mfpa,
                               manager.momentProjection,
                               displayCoordinateSystem=True)

        btkTools.smartWriter(
            acqGait,
            str(DATA_PATH + reconstructFilenameLabelled[:-4] +
                "-pyCGM2modelled.c3d"))
        logging.info("---->dynamic trial (%s) processed" %
                     (reconstructFilenameLabelled))

    logging.info("=============Writing of final Settings=============")
    i = 0
    while os.path.exists("CGM1 [%s].completeSettings" % i):
        i += 1
    filename = "CGM1 [" + str(i) + "].completeSettings"
    files.saveJson(DATA_PATH, filename, finalSettings)
    logging.info("---->complete settings (%s) exported" % (filename))
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 foldercd
    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 + "CGM1-pyCGM2.settings"):
        settings = files.openFile(pyCGM2.PYCGM2_APPDATA_PATH,
                                  "CGM1-pyCGM2.settings")
    else:
        settings = files.openFile(pyCGM2.PYCGM2_SETTINGS_FOLDER,
                                  "CGM1-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() + "\\", "CGM1.translators")
    if not translators: translators = settings["Translators"]

    # --------------------------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
    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 = cgm1.calibrate(DATA_PATH, calibrateFilenameLabelled,
                                      translators, required_mp, optional_mp,
                                      leftFlatFoot, rightFlatFoot, headFlat,
                                      markerDiameter, 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

        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 = cgm1.fitting(model, DATA_PATH, reconstructFilenameLabelled,
                               translators, 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")
Beispiel #13
0
def main():

    parser = argparse.ArgumentParser(description='CGM1 Calibration')
    parser.add_argument('-l',
                        '--leftFlatFoot',
                        type=int,
                        help='left flat foot option')
    parser.add_argument('-r',
                        '--rightFlatFoot',
                        type=int,
                        help='right flat foot option')
    parser.add_argument('-hf', '--headFlat', type=int, help='head flat option')
    parser.add_argument('-md',
                        '--markerDiameter',
                        type=float,
                        help='marker diameter')
    parser.add_argument('-ps',
                        '--pointSuffix',
                        type=str,
                        help='suffix of model outputs')
    parser.add_argument('--check',
                        action='store_true',
                        help='force model output suffix')
    parser.add_argument('--resetMP',
                        action='store_true',
                        help='reset optional mass parameters')
    parser.add_argument('-ae',
                        '--anomalyException',
                        action='store_true',
                        help='stop if anomaly detected ')

    args = parser.parse_args()

    NEXUS = ViconNexus.ViconNexus()
    NEXUS_PYTHON_CONNECTED = NEXUS.Client.IsConnected()

    if NEXUS_PYTHON_CONNECTED:  # run Operation

        # --------------------------GLOBAL SETTINGS ------------------------------------
        # global setting ( in user/AppData)
        if os.path.isfile(pyCGM2.PYCGM2_APPDATA_PATH + "CGM1-pyCGM2.settings"):
            settings = files.openFile(pyCGM2.PYCGM2_APPDATA_PATH,
                                      "CGM1-pyCGM2.settings")
        else:
            settings = files.openFile(pyCGM2.PYCGM2_SETTINGS_FOLDER,
                                      "CGM1-pyCGM2.settings")
        # --------------------------CONFIG ------------------------------------
        argsManager = CgmArgsManager.argsManager_cgm1(settings, args)
        leftFlatFoot = argsManager.getLeftFlatFoot()
        rightFlatFoot = argsManager.getRightFlatFoot()
        headFlat = argsManager.getHeadFlat()
        markerDiameter = argsManager.getMarkerDiameter()
        pointSuffix = argsManager.getPointSuffix("cgm1")

        DATA_PATH, calibrateFilenameLabelledNoExt = NEXUS.GetTrialName()

        calibrateFilenameLabelled = calibrateFilenameLabelledNoExt + ".c3d"

        LOGGER.logger.info("data Path: " + DATA_PATH)
        LOGGER.set_file_handler(DATA_PATH + "pyCGM2-Calibration.log")
        LOGGER.logger.info("calibration file: " + calibrateFilenameLabelled)

        # --------------------------SUBJECT ------------------------------------
        subjects = NEXUS.GetSubjectNames()
        subject = nexusTools.getActiveSubject(
            NEXUS)  #checkActivatedSubject(NEXUS,subjects)
        Parameters = NEXUS.GetSubjectParamNames(subject)

        required_mp, optional_mp = nexusUtils.getNexusSubjectMp(
            NEXUS, subject, resetFlag=args.resetMP)

        # -------------------------- INFOS ------------------------------------
        mpInfo, mpFilename = files.getMpFileContent(DATA_PATH, "mp.pyCGM2",
                                                    subject)

        #  translators management
        translators = files.getTranslators(DATA_PATH, "CGM1.translators")
        if not translators: translators = settings["Translators"]

        # btkAcq builder
        nacf = nexusFilters.NexusConstructAcquisitionFilter(
            DATA_PATH, calibrateFilenameLabelledNoExt, subject)
        acq = nacf.build()

        # --------------------------MODELLING PROCESSING -----------------------
        model, acqStatic, detectAnomaly = cgm1.calibrate(
            DATA_PATH,
            calibrateFilenameLabelled,
            translators,
            required_mp,
            optional_mp,
            leftFlatFoot,
            rightFlatFoot,
            headFlat,
            markerDiameter,
            pointSuffix,
            forceBtkAcq=acq,
            anomalyException=args.anomalyException)

        # ----------------------SAVE-------------------------------------------
        #pyCGM2.model
        files.saveModel(model, DATA_PATH, subject)

        # save mp
        files.saveMp(mpInfo, model, DATA_PATH, mpFilename)

        # ----------------------DISPLAY ON VICON-------------------------------
        nexusUtils.updateNexusSubjectMp(NEXUS, model, subject)
        nexusFilters.NexusModelFilter(NEXUS,
                                      model,
                                      acqStatic,
                                      subject,
                                      pointSuffix,
                                      staticProcessing=True).run()
Beispiel #14
0
def main(args):
    NEXUS = ViconNexus.ViconNexus()
    NEXUS_PYTHON_CONNECTED = NEXUS.Client.IsConnected()


    if NEXUS_PYTHON_CONNECTED: # run Operation

        # --------------------------GLOBAL SETTINGS ------------------------------------
        # global setting ( in user/AppData)

        if os.path.isfile(pyCGM2.PYCGM2_APPDATA_PATH + "CGM1-pyCGM2.settings"):
            settings = files.openFile(pyCGM2.PYCGM2_APPDATA_PATH,"CGM1-pyCGM2.settings")
        else:
            settings = files.openFile(pyCGM2.PYCGM2_SETTINGS_FOLDER,"CGM1-pyCGM2.settings")
        # --------------------------CONFIG ------------------------------------
        argsManager = CgmArgsManager.argsManager_cgm1(settings,args)
        leftFlatFoot = argsManager.getLeftFlatFoot()
        rightFlatFoot = argsManager.getRightFlatFoot()
        headFlat = argsManager.getHeadFlat()
        markerDiameter = argsManager.getMarkerDiameter()
        pointSuffix = argsManager.getPointSuffix("cgm1")

        DATA_PATH, calibrateFilenameLabelledNoExt = NEXUS.GetTrialName()

        calibrateFilenameLabelled = calibrateFilenameLabelledNoExt+".c3d"

        logging.info( "data Path: "+ DATA_PATH )
        logging.info( "calibration file: "+ calibrateFilenameLabelled)


        # --------------------------SUBJECT ------------------------------------
        subjects = NEXUS.GetSubjectNames()
        subject = nexusTools.checkActivatedSubject(NEXUS,subjects)
        Parameters = NEXUS.GetSubjectParamNames(subject)

        required_mp,optional_mp = nexusUtils.getNexusSubjectMp(NEXUS,subject,resetFlag=args.resetMP)


        # -------------------------- INFOS ------------------------------------
        mpInfo,mpFilename = files.getMpFileContent(DATA_PATH,"mp.pyCGM2",subject)


        #  translators management
        translators = files.getTranslators(DATA_PATH,"CGM1.translators")
        if not translators:  translators = settings["Translators"]

        # btkAcq builder
        nacf = nexusFilters.NexusConstructAcquisitionFilter(DATA_PATH,calibrateFilenameLabelledNoExt,subject)
        acq = nacf.build()

        # --------------------------MODELLING PROCESSING -----------------------
        model,acqStatic = cgm1.calibrate(DATA_PATH,calibrateFilenameLabelled,translators,
                      required_mp,optional_mp,
                      leftFlatFoot,rightFlatFoot,headFlat,markerDiameter,
                      pointSuffix,forceBtkAcq=acq)


        # ----------------------SAVE-------------------------------------------
        #pyCGM2.model
        files.saveModel(model,DATA_PATH,subject)

        # save mp
        files.saveMp(mpInfo,model,DATA_PATH,mpFilename)

        # ----------------------DISPLAY ON VICON-------------------------------
        nexusUtils.updateNexusSubjectMp(NEXUS,model,subject)
        nexusFilters.NexusModelFilter(NEXUS,
                                      model,acqStatic,subject,
                                      pointSuffix,
                                      staticProcessing=True).run()