Ejemplo n.º 1
0
def zeni(acqGait, footStrikeOffset=0, footOffOffset=0):
    """
    Detect gait event according Zeni's algorithm (Coordinate only method)

    :param acqGait [Btk.Acquisition]: gait acquisition

    **optional**
    :param footStrikeOffset [int]:  systematic offset to add to foot strike
    :param footOffOffset [int]: systematic oofset to add to foot off

    **Return**
    :param AcqGait [Btk.Acquisition]:  gait acquisition updated with events


    :example:

    >>>
    """
    acqGait.ClearEvents()
    # ----------------------EVENT DETECTOR-------------------------------
    evp = events.ZeniProcedure()
    evp.setFootStrikeOffset(footStrikeOffset)
    evp.setFootOffOffset(footOffOffset)

    # event filter
    evf = events.EventFilter(evp, acqGait)
    evf.detect()

    return acqGait
Ejemplo n.º 2
0
def main(args):
    DATA_PATH = os.getcwd() + "\\"

    file = args.file[0]
    if not os.path.isfile(file):
        raise Exception("the file (%s) doesn t exist" % (file))

    modelledTrials = [file]

    for trial in modelledTrials:
        logging.info("[pyCGM2]: Zeni Event Detection on trial %s" %
                     (str(trial)))
        acqGait = btkTools.smartReader(str(DATA_PATH + trial))

        acqGait.ClearEvents()
        # ----------------------EVENT DETECTOR-------------------------------
        evp = events.ZeniProcedure()
        evp.setFootStrikeOffset(args.footStrikeOffset)
        evp.setFootOffOffset(args.footOffOffset)

        # event filter
        evf = events.EventFilter(evp, acqGait)
        evf.detect()

        btkTools.smartWriter(acqGait, str(DATA_PATH + trial))

        logging.info("[pyCGM2]: Zeni Event Detection on trial %s ----> Done" %
                     (str(trial)))

        if args.MokkaCheck:
            cmd = "Mokka.exe \"%s\"" % (str(DATA_PATH + trial))
            os.system(cmd)
Ejemplo n.º 3
0
def main():

    parser = argparse.ArgumentParser(description='ZeniDetector')
    parser.add_argument('-fso','--footStrikeOffset', type=int, help='systenatic foot strike offset on both side')
    parser.add_argument('-foo','--footOffOffset', type=int, help='systenatic foot off offset on both side')
    args = parser.parse_args()


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


    if NEXUS_PYTHON_CONNECTED: # run Operation

        # ----------------------INPUTS-------------------------------------------
        # --- acquisition file and path----
        DATA_PATH, reconstructFilenameLabelledNoExt = NEXUS.GetTrialName()

        reconstructFilenameLabelled = reconstructFilenameLabelledNoExt+".c3d"

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

        #acqGait = btkTools.smartReader(str(DATA_PATH + reconstructFilenameLabelled))

        # --------------------------SUBJECT -----------------------------------

        # Notice : Work with ONE subject by session
        subjects = NEXUS.GetSubjectNames()
        subject = nexusTools.checkActivatedSubject(NEXUS,subjects)
        logging.info(  "Subject name : " + subject  )

        # --- btk acquisition ----
        nacf = nexusFilters.NexusConstructAcquisitionFilter(DATA_PATH,reconstructFilenameLabelledNoExt,subject)
        acqGait = nacf.build()


        # ----------------------EVENT DETECTOR-------------------------------
        evp = events.ZeniProcedure()
        if args.footStrikeOffset is not None:
            evp.setFootStrikeOffset(args.footStrikeOffset)
        if args.footOffOffset is not None:
            evp.setFootOffOffset(args.footOffOffset)


        evf = events.EventFilter(evp,acqGait)
        evf.detect()
        state = evf.getState()

        # ----------------------DISPLAY ON VICON-------------------------------
        nexusTools.createEvents(NEXUS,subject,acqGait,["Foot Strike","Foot Off"])
        # ========END of the nexus OPERATION if run from Nexus  =========



    else:
        raise Exception("NO Nexus connection. Turn on Nexus")
Ejemplo n.º 4
0
    def detection(cls):

        MAIN_PATH = pyCGM2.TEST_DATA_PATH + "operations\\event detection\\events\\"

        # --- Motion 1
        gaitFilename = "gait-noEvents.c3d"
        acq = btkTools.smartReader(str(MAIN_PATH + gaitFilename))

        evp = events.ZeniProcedure()

        evf = events.EventFilter(evp, acq)
        evf.detect()

        btkTools.smartWriter("testEvent0.c3d", acq)
Ejemplo n.º 5
0
def zeni(acqGait, footStrikeOffset=0, footOffOffset=0, **kwargs):
    """
    Detect gait event according Zeni's algorithm (Coordinate only method)

    :param acqGait [Btk.Acquisition]: gait acquisition

    **optional**
    :param footStrikeOffset [int]:  systematic offset to add to foot strike
    :param footOffOffset [int]: systematic oofset to add to foot off

    **Return**
    :param AcqGait [Btk.Acquisition]:  gait acquisition updated with events


    :example:

    >>>
    """
    acqGait.ClearEvents()

    if "fc_lowPass_marker" in kwargs.keys(
    ) and kwargs["fc_lowPass_marker"] != 0:
        fc = kwargs["fc_lowPass_marker"]
        order = 4
        if "order_lowPass_marker" in kwargs.keys():
            order = kwargs["order_lowPass_marker"]
        signal_processing.markerFiltering(
            acqGait, ["LPSI", "RPSI", "LHEE", "LTOE", "RHEE", "RTOE"],
            order=order,
            fc=fc)

    # ----------------------EVENT DETECTOR-------------------------------
    evp = events.ZeniProcedure()
    evp.setFootStrikeOffset(footStrikeOffset)
    evp.setFootOffOffset(footOffOffset)

    # event filter
    evf = events.EventFilter(evp, acqGait)
    evf.detect()
    state = evf.getState()
    return acqGait, state
Ejemplo n.º 6
0
            raise Exception("[pyCGM2] Your Trial c3d was saved with two activate subject. Re-save it with only one before pyCGM2 calculation")

        # --------------------------SUBJECT -----------------------------------

        # Notice : Work with ONE subject by session
        subjects = NEXUS.GetSubjectNames()
        subject = nexusTools.checkActivatedSubject(NEXUS,subjects)
        logging.info(  "Subject name : " + subject  )

        # ----------------------EVENT DETECTOR-------------------------------
        evp = events.ZeniProcedure()
        if args.footStrikeOffset is not None:
            evp.setFootStrikeOffset(args.footStrikeOffset)
        if args.footOffOffset is not None:
            evp.setFootOffOffset(args.footOffOffset)


        evf = events.EventFilter(evp,acqGait)
        evf.detect()

        # ----------------------DISPLAY ON VICON-------------------------------
        nexusTools.createEvents(NEXUS,subject,acqGait,["Foot Strike","Foot Off"])
        # ========END of the nexus OPERATION if run from Nexus  =========

        if DEBUG:
            NEXUS.SaveTrial(30)


    else:
        raise Exception("NO Nexus connection. Turn on Nexus")