Ejemplo n.º 1
0
    def __init__(self, dataPath, filenameNoExt, subject):
        """
        """
        self.m_dataPath = dataPath
        self.m_filenameNoExt = filenameNoExt
        self.m_subject = subject

        self.m_framerate = NEXUS.GetFrameRate()
        #self.m_frames = NEXUS.GetTrialRange()[1]
        self.m_rangeROI = NEXUS.GetTrialRegionOfInterest()
        self.m_trialRange = NEXUS.GetTrialRange()
        self.m_trialFirstFrame = self.m_trialRange[
            0]  # might be different from 1 if corpped and no x2d

        self.m_firstFrame = self.m_rangeROI[0]
        self.m_lastFrame = self.m_rangeROI[1]
        self.m_frames = self.m_lastFrame - (self.m_firstFrame - 1)

        deviceIDs = NEXUS.GetDeviceIDs()
        self.m_analogFrameRate = NEXUS.GetDeviceDetails(
            deviceIDs[0])[2] if (len(deviceIDs) > 0) else self.m_framerate

        self.m_numberAnalogSamplePerFrame = int(self.m_analogFrameRate /
                                                self.m_framerate)
        self.m_analogFrameNumber = self.m_frames * self.m_numberAnalogSamplePerFrame

        self.m_nexusForcePlates = list()
        self.m_nexusAnalogDevices = list()

        if (len(deviceIDs) > 0):
            for deviceID in deviceIDs:
                if NEXUS.GetDeviceDetails(deviceID)[1] == "ForcePlate":
                    self.m_nexusForcePlates.append(
                        Devices.ForcePlate(deviceID))
                else:
                    self.m_nexusAnalogDevices.append(
                        Devices.AnalogDevice(deviceID))

        self.m_acq = btk.btkAcquisition()
        self.m_acq.Init(0, int(self.m_frames), 0,
                        self.m_numberAnalogSamplePerFrame)
        self.m_acq.SetPointFrequency(self.m_framerate)
        self.m_acq.SetFirstFrame(self.m_firstFrame)
Ejemplo n.º 2
0
    def __init__(self, dataPath, filenameNoExt, subject):
        """
        """
        self.m_dataPath = dataPath
        self.m_filenameNoExt = filenameNoExt
        self.m_subject = subject

        self.m_framerate = NEXUS.GetFrameRate()
        #self.m_frames = NEXUS.GetTrialRange()[1]
        self.m_rangeROI = NEXUS.GetTrialRegionOfInterest()
        self.m_trialRange = NEXUS.GetTrialRange()
        self.m_trialFirstFrame = self.m_trialRange[0]

        self.m_firstFrame = self.m_rangeROI[0]
        self.m_lastFrame = self.m_rangeROI[1]
        self.m_frames = self.m_lastFrame - (self.m_firstFrame - 1)

        deviceIDs = NEXUS.GetDeviceIDs()
        self.m_analogFrameRate = NEXUS.GetDeviceDetails(1)[2] if (
            len(deviceIDs) > 0) else self.m_framerate

        self.m_numberAnalogSamplePerFrame = int(self.m_analogFrameRate /
                                                self.m_framerate)
        self.m_analogFrameNumber = self.m_frames * self.m_numberAnalogSamplePerFrame

        self.m_nexusForcePlates = list()
        self.m_nexusAnalogDevices = list()

        if (len(deviceIDs) > 0):
            for deviceID in deviceIDs:
                if NEXUS.GetDeviceDetails(deviceID)[1] == "ForcePlate":
                    self.m_nexusForcePlates.append(
                        Devices.ForcePlate(deviceID))
                else:
                    self.m_nexusAnalogDevices.append(
                        Devices.AnalogDevice(deviceID))

        self.m_root = ma.Node('root')
        self.m_trial = ma.Trial("NexusTrial", self.m_root)

        self.m_trial.setProperty("POINT:RATE", self.m_framerate)
        self.m_trial.setProperty("ANALOG:RATE", self.m_analogFrameRate)
Ejemplo n.º 3
0
    def test_analogDeviceTest(self):
        NEXUS = ViconNexus.ViconNexus()

        DATA_PATH = pyCGM2.TEST_DATA_PATH + "NexusAPI\\c3d_x2d\\"

        filenameNoExt = "gait_GAP"
        NEXUS.OpenTrial(str(DATA_PATH + filenameNoExt), 30)

        framerate = NEXUS.GetFrameRate()
        frames = NEXUS.GetFrameCount()
        analogFrameRate = NEXUS.GetDeviceDetails(1)[2]

        device = Devices.AnalogDevice(6)
        output = device.getChannels()
Ejemplo n.º 4
0
    def analogDeviceTest(cls):
        NEXUS = ViconNexus.ViconNexus()
        NEXUS_PYTHON_CONNECTED = NEXUS.Client.IsConnected()

        DATA_PATH = "C:\\Users\\HLS501\\Documents\\VICON DATA\\pyCGM2-Data\\operations\\NexusAPI\\c3d_x2d\\"

        filenameNoExt = "gait_GAP"
        NEXUS.OpenTrial(str(DATA_PATH + filenameNoExt), 30)

        framerate = NEXUS.GetFrameRate()
        frames = NEXUS.GetFrameCount()
        analogFrameRate = NEXUS.GetDeviceDetails(1)[2]

        device = Devices.AnalogDevice(6)
        output = device.getChannels()
Ejemplo n.º 5
0
    def test_forcePlateTest(self):
        NEXUS = ViconNexus.ViconNexus()

        DATA_PATH = pyCGM2.TEST_DATA_PATH + "NexusAPI\\c3d_x2d\\"

        filenameNoExt = "gait_GAP"
        NEXUS.OpenTrial(str(DATA_PATH + filenameNoExt), 30)

        #----Btk----
        acq0 = btkTools.smartReader(str(DATA_PATH + filenameNoExt + ".c3d"))

        analogFx = acq0.GetAnalog("Force.Fx1").GetValues()
        analogFy = acq0.GetAnalog("Force.Fy1").GetValues()
        analogFz = acq0.GetAnalog("Force.Fz1").GetValues()
        analogMx = acq0.GetAnalog("Moment.Mx1").GetValues()
        analogMy = acq0.GetAnalog("Moment.My1").GetValues()
        analogMz = acq0.GetAnalog("Moment.Mz1").GetValues()

        pfe = btk.btkForcePlatformsExtractor()
        pfe.SetInput(acq0)
        pfc = pfe.GetOutput()
        pfc.Update()
        btkfp0 = pfc.GetItem(0)
        ch0_Fx = btkfp0.GetChannel(0).GetValues()
        ch1_Fy = btkfp0.GetChannel(1).GetValues()
        ch2_Fz = btkfp0.GetChannel(2).GetValues()
        ch3_Mx = btkfp0.GetChannel(3).GetValues()
        ch4_My = btkfp0.GetChannel(4).GetValues()
        ch5_Mz = btkfp0.GetChannel(5).GetValues()

        # --- ground reaction force wrench ---
        grwf = btk.btkGroundReactionWrenchFilter()
        grwf.SetInput(pfc)
        grwc = grwf.GetOutput()
        grwc.Update()

        grw0_force = grwc.GetItem(0).GetForce().GetValues()

        #----Nexus----
        nexusForcePlate = Devices.ForcePlate(1)
        forceLocal = nexusForcePlate.getLocalReactionForce()
        momentLocal = nexusForcePlate.getLocalReactionMoment()
Ejemplo n.º 6
0
    def forcePlateTest(cls):
        NEXUS = ViconNexus.ViconNexus()
        NEXUS_PYTHON_CONNECTED = NEXUS.Client.IsConnected()

        DATA_PATH = "C:\\Users\\HLS501\\Documents\\VICON DATA\\pyCGM2-Data\\operations\\NexusAPI\\c3d_x2d\\"

        filenameNoExt = "gait_GAP"
        NEXUS.OpenTrial(str(DATA_PATH + filenameNoExt), 30)

        #----Btk----
        acq0 = btkTools.smartReader(str(DATA_PATH + filenameNoExt + ".c3d"))

        analogFx = acq0.GetAnalog("Force.Fx1").GetValues()
        analogFy = acq0.GetAnalog("Force.Fy1").GetValues()
        analogFz = acq0.GetAnalog("Force.Fz1").GetValues()
        analogMx = acq0.GetAnalog("Moment.Mx1").GetValues()
        analogMy = acq0.GetAnalog("Moment.My1").GetValues()
        analogMz = acq0.GetAnalog("Moment.Mz1").GetValues()

        pfe = btk.btkForcePlatformsExtractor()
        pfe.SetInput(acq0)
        pfc = pfe.GetOutput()
        pfc.Update()
        btkfp0 = pfc.GetItem(0)
        ch0_Fx = btkfp0.GetChannel(0).GetValues()
        ch1_Fy = btkfp0.GetChannel(1).GetValues()
        ch2_Fz = btkfp0.GetChannel(2).GetValues()
        ch3_Mx = btkfp0.GetChannel(3).GetValues()
        ch4_My = btkfp0.GetChannel(4).GetValues()
        ch5_Mz = btkfp0.GetChannel(5).GetValues()

        # --- ground reaction force wrench ---
        grwf = btk.btkGroundReactionWrenchFilter()
        grwf.SetInput(pfc)
        grwc = grwf.GetOutput()
        grwc.Update()

        grw0_force = grwc.GetItem(0).GetForce().GetValues()

        # ch3_Mx = btkfp0.GetChannel(3).GetValues()
        # ch4_My = btkfp0.GetChannel(4).GetValues()
        # ch5_Mz = btkfp0.GetChannel(5).GetValues()

        #----Nexus----
        nexusForcePlate = Devices.ForcePlate(1)
        forceLocal = nexusForcePlate.getLocalReactionForce()

        # plt.figure()
        # plt.plot(forceLocal[2310:,0],"-r")
        # plt.plot(ch0_Fx,"or")
        # plt.plot(analogFx,"oc")
        # #plt.plot(grw0_force[:,0],"-g")
        # #plt.plot(forceGlobal[2320:,0],"og")
        #
        #
        # plt.figure()
        # plt.plot(forceLocal[2310:,1],"-r")
        # plt.plot(ch1_Fy,"or")
        # plt.plot(analogFy,"oc")
        #
        #
        # plt.figure()
        # plt.plot(forceLocal[2310:,2],"-r")
        # plt.plot(ch2_Fz,"or")
        # plt.plot(analogFz,"oc")

        # plt.show()

        momentLocal = nexusForcePlate.getLocalReactionMoment()