Install pyCGM2

pyCGM2 is implemented for python 3.9 to python 3.11.
Development and testing are primarily conducted with Python 3.10

You can install pyCGM2 in two different ways, depending on your needs:

  • User mode:
    This option is recommended if you simply want to use pyCGM2 without modifying its source code. The installation is straightforward and uses the official conda channel.

  • Developer mode:
    Choose this option if you plan to contribute to pyCGM2 or need to make changes to the source code. You will download the source code and install pyCGM2 in “editable” mode, so any changes you make are immediately reflected.

Select the option below that best fits your use case and follow

User mode

To install pyCGM2 as a regular user, follow these steps:

  1. Open the Anaconda Prompt (Miniconda)
    You can find it in your Start menu or by searching “Anaconda Prompt”.

  2. Create a Python 3.10 virtual environment
    Type the following command to create a new environment named pycgm310:

    conda create --name pycgm310 python=3.10
    

    This step ensures that pyCGM2 runs in an isolated environment with the correct Python version.

  3. Activate your new environment
    Enable the environment with:

    conda activate pycgm310
    
  4. Install pyCGM2 from the conda channel
    Run:

    conda install -c pycgm2 pycgm2
    

    This command downloads and installs pyCGM2 and its dependencies from the official pyCGM2 conda channel.

After installation, pyCGM2 will be available in your environment.
You can find the installed package in:
PATH_TO_MINICONDA\envs\pycgm310\Lib\site-packages

Tip:
Using a virtual environment helps keep your Python projects organized and avoids conflicts

Developer mode

If you want to contribute to pyCGM2 or make changes to its source code, follow these steps to install pyCGM2 in developer mode:

  1. Download the pyCGM2 source code
    You have two options:

    • Download the latest release and unzip it,
      or
    • Clone the master branch from GitHub using your preferred version control tool (GitHub Desktop, Sourcetree, etc.).
  2. Open the Anaconda Prompt (Miniconda)
    You can find it in your Start menu or by searching “Anaconda Prompt”.

  3. Navigate to the pyCGM2 folder
    Use the cd command to go to the folder where you downloaded or cloned pyCGM2:

    cd path/to/my/pycgm2/folder
    
  4. Create the pre-configured Python environment
    Run:

    conda env create -f environment.yml
    

    This will create a Python 3.10 virtual environment named pycgm310.
    If you want to use a different name, use:

    conda env create -f environment.yml -n newName
    

    This command may require few minutes to check the compatibility of the provided environment

  5. Activate your environment

    conda activate pycgm310
    
  6. Install pyCGM2 in editable mode
    Run:

    pip install -e .
    

    The -e flag (“editable” mode) means any changes you make to the source code will be immediately available in your environment, without needing to reinstall.

If you move or rename the pyCGM2 package folder after installation, it will no longer be found by Python.

For vicon users - install the Nexus packages

If you are a Vicon Nexus User, type the command below to enable interaction with Vicon Nexus

pyCGM2-setup_NexusPackages.exe
pyCGM2-generate_pyCGM2_Nexus.exe
  • The first command installs the Vicon-distributed Python packages into Nexus’s internal SDK folder.
  • The second command creates a ready-to-use CGM2.3 pipeline that can be imported into Nexus. It is configured to activate your pyCGM2 environment using a script located in C:/Users/YourName/AppData/pycgm2.

the first command may require to run in administrator mode the anaconda console

Afterwards, you can import the ready-to-use pyCGM23-{EnvironmentName}-CGM23.Pipeline into Nexus.

  • go to your nexus pipeline panel and select import nexusImport

  • the pre configured pipeline is located in C:\Users\Public\Documents\Vicon\Nexus2.x\Configurations\Pipelines

This pipeline includes pre-configured operations for running CGM2.3, gait event detection algorithms, and gap filling.

nexuspipelines

For QTM users - setup a pyCGM2 project

pyCGM2-QTM interactions leverages from QTM scripting and is only available from pyCGM2 version 4.3-rc3. The implementation may be subject to modifications.

Here is the flowchart to configure pyCGM2 with QTM

flowchart LR id0[download/clone a pycgm2 QTM project] subgraph Configure_QTM id1[add event shortcuts] id2[configure c3d export] id3[enable pycgm2 menu] end id1-->id2-->id3 id0--->Configure_QTM

Download/clone a pycgm2 QTM project

Download or clone a pyCGM2 QTM project

Once install, you need to amend each bat file of the template folder

  • open the downloaded project folder in your file explorer
  • go to the folder Template
  • edit and change CONDA_PATH and ENV_NAME

if you do not know where is CONDA_PATH, open a conda console and type conda info

Configure_QTM

add event shorcuts

  • go to Tools/project options.
  • in the tree view, go to Miscellaneous/Events and add event shorcuts as described in this image

qtmeventShortcuts

configure c3d export

  • go to Tools/project options.
  • in the tree view, go to Processing/C3d export and amend the settings to match those described in this image

qtmc3dexport

enable pycgm2 menu

  • go to Tools/project options.
  • in the tree view, go to Miscellaneous/Scripting , add a script
  • add the script pycgm2-scripting.py located in the folder pyCGM2\Apps\QtmApps\qtm-scripting\
  • tick the script and apply it

qtmpycgm2menu

eventually, the pycgm2 menu will appear in the menu toolbar.