sollan / alma

Fully automated (rodent) limb motion analysis toolbox for behavioral analysis with bodypart coordinate data, building upon markerless pose estimation.
GNU General Public License v3.0
13 stars 5 forks source link

How to extract the variables/parameters associated with each principal component? #33

Closed SIM0N-WU closed 1 year ago

SIM0N-WU commented 1 year ago

In the paper, it Is mentioned that you could calculate the "factor loadings" (Fig. 2), or extract the "key parameters clustering with PC1" (Fig. 5). I was wondering if this function was included in the toolbox? If not, would it be possible if you could provide a brief tutorial on how one could approach this? I am grateful for this toolbox as it has allowed me to easier access to machine learning analysis techniques like PCA and Random forest classification, tools that I could not use before.

sollan commented 1 year ago

Hi, sorry for the late reply!

Not sure if you've found the solution yet, but we have actually included the PCA analysis function in the GUI (check out the Wiki page or source code). As you can see the GUI option is based on scikit-learn and simply uses default values. But won't be hard to implement your own PCA with sklearn to try out different parameters, e.g. number of components. Feel free to use the source code from Alma as a starting point (especially if you're using output from the automated kinematic analysis, then the data preprocessing code from Alma can be reused to parse the input for the sklearn functions).

You can find some sklearn tutorials for PCA here: https://scikit-learn.org/stable/modules/generated/sklearn.decomposition.PCA.html

SIM0N-WU commented 1 year ago

Hi Sollan,

Thank you for the guidance. The sklearn tutorial link was helpful. I am now* able to view the weighting the goes into each principal component! I think in the future, it would be useful to other researchers if a .csv file containing the parameter weights for each PC would automatically be exported as well!

Thanks a lot, Simon