other:inspect3d:tutorials:perform_principal_component_analysis
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
other:inspect3d:tutorials:perform_principal_component_analysis [2024/07/16 19:22] – created sgranger | other:inspect3d:tutorials:perform_principal_component_analysis [2025/01/17 15:24] (current) – wikisysop | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== | + | ====== |
This tutorial will show you how to use Inspect3D in order to perform [[Sift: | This tutorial will show you how to use Inspect3D in order to perform [[Sift: | ||
Line 13: | Line 13: | ||
As with previous tutorials, we begin by loading the CMO library and defining the queries relevant to our question. | As with previous tutorials, we begin by loading the CMO library and defining the queries relevant to our question. | ||
- | 1. Click {{I3DLoadLibrary.png}} **Load Library** in the [[Other: | + | 1. Click {{:I3DLoadLibrary.png?20}} **Load Library** in the [[Other: |
2. Click **Browse** and select the folder where the data is stored. | 2. Click **Browse** and select the folder where the data is stored. | ||
Line 23: | Line 23: | ||
For this tutorial we will manually create two groups based on tags, one for subjects with osteoarthritis and one for normal control subjects. We begin by defining a query for subjects with the OA tag (indicating osteoarthritis). | For this tutorial we will manually create two groups based on tags, one for subjects with osteoarthritis and one for normal control subjects. We begin by defining a query for subjects with the OA tag (indicating osteoarthritis). | ||
- | 1. Click on the {{I3DGroups.png}} **Query Definitions** icon on the [[Other: | + | 1. Click on the {{:I3DGroups.png?20}} **Query Definitions** icon on the [[Other: |
- | 2. {{ActionAdd48x48.png}} Add a query, name it OA, and click **Save**. | + | 2. {{:ActionAdd48x48.png?20}} Add a query, name it OA, and click **Save**. |
- | 3. {{ActionAdd48x48.png}} Add a condition and name it OA. | + | 3. {{:ActionAdd48x48.png?20}} Add a condition and name it OA. |
3.1. **Signals**: | 3.1. **Signals**: | ||
Line 39: | Line 39: | ||
Next we will define a query for subjects with the NC tag (indicating Normal Control). In this case we can easily modify our previous query rather than starting from scratch. | Next we will define a query for subjects with the NC tag (indicating Normal Control). In this case we can easily modify our previous query rather than starting from scratch. | ||
- | 1. {{ActionAdd48x48.png}} Add a query, name it NC, and click **Save**. | + | 1. {{:ActionAdd48x48.png?20}} Add a query, name it NC, and click **Save**. |
- | 2. {{ActionAdd48x48.png}} Add a condition and name it NC. | + | 2. {{:ActionAdd48x48.png?20}} Add a condition and name it NC. |
3. In the **Refinements** tab, change the selected tag from OA to NC. | 3. In the **Refinements** tab, change the selected tag from OA to NC. | ||
Line 59: | Line 59: | ||
3. Click **Refresh Plot**. | 3. Click **Refresh Plot**. | ||
- | The plot that is produced will not be very informative if the traces are not coloured by group, which is the comparison we are interested in. If this is the case, open the {{I3DShowOptions.png}} **Show Options** dialog from the application tool bar and under **Plotting options** set the **Display Styles from** to " | + | The plot that is produced will not be very informative if the traces are not coloured by group, which is the comparison we are interested in. If this is the case, open the {{:I3DShowOptions.png?20}} **Show Options** dialog from the application tool bar and under **Plotting options** set the **Display Styles from** to " |
- | {{NC_Workspace_Style.png}} | + | {{: |
Once this is done, inspecting the plot shows that although participants from the two groups walk very differently, | Once this is done, inspecting the plot shows that although participants from the two groups walk very differently, | ||
- | {{NC_Group_Style.png}} | + | {{: |
This is one of the motivations behind PCA: by transforming our original data into a coordinate system based on principal components we will end up with a few dimensions that explain most of the variance in the data set. This, in turn, will help us to explain and detect the differences between the groups. | This is one of the motivations behind PCA: by transforming our original data into a coordinate system based on principal components we will end up with a few dimensions that explain most of the variance in the data set. This, in turn, will help us to explain and detect the differences between the groups. | ||
Line 73: | Line 73: | ||
1. Ensure that all groups and workspaces are selected in the **Groups** and **Workspaces** lists. | 1. Ensure that all groups and workspaces are selected in the **Groups** and **Workspaces** lists. | ||
- | 2. Open the {{I3D_PCAOptions2.png}} **PCA Options** dropdown menu on the [[Other: | + | 2. Open the {{:I3D_PCAOptions2.png?20}} **PCA Options** dropdown menu on the [[Other: |
3. Set **Number PCs** to 4. | 3. Set **Number PCs** to 4. | ||
Line 79: | Line 79: | ||
4. Ensure that **Use Workspace Mean** is checked. | 4. Ensure that **Use Workspace Mean** is checked. | ||
- | 5. Click {{I3D_RunPCA.png}} **Run PCA**. | + | 5. Click {{:I3D_RunPCA.png?20}} **Run PCA**. |
- | 6. The results of these calculations will automatically populate the PCA graphs. If these aren't already displayed, click {{I3D_PCAShowGraphs.png}} **Show PCA Graphs** in the {{I3D_PCAOptions2.png}} **PCA Options** dropdown menu. | + | 6. The results of these calculations will automatically populate the PCA graphs. If these aren't already displayed, click {{:I3D_PCAShowGraphs.png?20}} **Show PCA Graphs** in the {{:I3D_PCAOptions2.png?20}} **PCA Options** dropdown menu. |
- | {{NC_PCA_Complete.png}} | + | {{: |
Line 94: | Line 94: | ||
The Variance Explained window, which displays the variance explained by each principal component as well as the cumulative variance for each principal components. It is important to verify that the calculated principal components do explain a significant amount of the data set's variability. A good heuristic to use is that you want enough principal components to explain 95% of the data set's variety, otherwise there will be at least a moderate amount of variation that your analysis has not captured. In this example, our 4 principal components explain 96% of the data set's variability, | The Variance Explained window, which displays the variance explained by each principal component as well as the cumulative variance for each principal components. It is important to verify that the calculated principal components do explain a significant amount of the data set's variability. A good heuristic to use is that you want enough principal components to explain 95% of the data set's variety, otherwise there will be at least a moderate amount of variation that your analysis has not captured. In this example, our 4 principal components explain 96% of the data set's variability, | ||
- | {{NC_Variance_Explained.png}} | + | {{: |
Clicking on a bar will display the exact variance explained by that principal component. In this example, the second principal component explains 17.6% of the variation in the original data set. | Clicking on a bar will display the exact variance explained by that principal component. In this example, the second principal component explains 17.6% of the variation in the original data set. | ||
Line 103: | Line 103: | ||
Next, the Group Scores window helps us to determine if there is a significant differences between the groups for any individual principal component. This is established by looking at each principal component' | Next, the Group Scores window helps us to determine if there is a significant differences between the groups for any individual principal component. This is established by looking at each principal component' | ||
- | {{NC_Group_Scores.png}} | + | {{: |
As with the Variance Explained window, hovering over a point will display a tooltip with precise values for that group score. | As with the Variance Explained window, hovering over a point will display a tooltip with precise values for that group score. | ||
Line 110: | Line 110: | ||
=== Workspace Scores === | === Workspace Scores === | ||
- | {{NC_Workspace_Scores.png}} | + | {{: |
Having identified our principal components of interest, switch to the Workspace Scores window and plot the chosen principal components against one another (i.e., for this tutorial, plot PC1 versus PC2). We are looking to be able to distinguish our groups and in this case there is a pretty clear separation between the groups in this 2D space. Although PC1 may describe more of the data set's variability than PC2, PC2 can discriminate between the groups better (this isn't mathematically shown here, but can be seen if the visual inspection is followed by a cluster analysis). Of course, PC1 and PC2 can discriminate between the groups even better if they are used together instead of separately. | Having identified our principal components of interest, switch to the Workspace Scores window and plot the chosen principal components against one another (i.e., for this tutorial, plot PC1 versus PC2). We are looking to be able to distinguish our groups and in this case there is a pretty clear separation between the groups in this 2D space. Although PC1 may describe more of the data set's variability than PC2, PC2 can discriminate between the groups better (this isn't mathematically shown here, but can be seen if the visual inspection is followed by a cluster analysis). Of course, PC1 and PC2 can discriminate between the groups even better if they are used together instead of separately. | ||
If you want to investigate the original data for a particular workspace, click on the workspace' | If you want to investigate the original data for a particular workspace, click on the workspace' | ||
- | {{NC_Workspace_Scores_Selected.png}} | + | {{: |
Line 124: | Line 124: | ||
For the **Plot Type** drop-down menu, select the Mean and Slider option. Leave the **PC Number** set to 1 and then click **Play**. The mean reconstruction (gray in the figure below) will remain static while the other reconstruction (blue in the figure below) will vary in the range Mean +/- 2 Standard Deviations. Watching this animation demonstrates that PC1 is capturing variability as an offset in the signal. Vertical offsets in gait data can occur for a variety of reasons, including differences in standing calibration posture. Therefore, PC1 may explain a significant amount of variability that is not very helpful for answering our question. | For the **Plot Type** drop-down menu, select the Mean and Slider option. Leave the **PC Number** set to 1 and then click **Play**. The mean reconstruction (gray in the figure below) will remain static while the other reconstruction (blue in the figure below) will vary in the range Mean +/- 2 Standard Deviations. Watching this animation demonstrates that PC1 is capturing variability as an offset in the signal. Vertical offsets in gait data can occur for a variety of reasons, including differences in standing calibration posture. Therefore, PC1 may explain a significant amount of variability that is not very helpful for answering our question. | ||
- | {{NC_Extreme_Plot.png}} | + | {{: |
Now select **PC Number** 2 and click **Play** again. This PC shows a different story, with the largest differences in this animation occurring during late stance and mid-swing. | Now select **PC Number** 2 and click **Play** again. This PC shows a different story, with the largest differences in this animation occurring during late stance and mid-swing. |
other/inspect3d/tutorials/perform_principal_component_analysis.1721157752.txt.gz · Last modified: 2024/07/16 19:22 by sgranger