sift:tutorials:openbiomechanics_project:impact_shooting_arm_mechanics_free_throw_accuracy
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
sift:tutorials:openbiomechanics_project:impact_shooting_arm_mechanics_free_throw_accuracy [2025/09/16 13:12] – wikisysop | sift:tutorials:openbiomechanics_project:impact_shooting_arm_mechanics_free_throw_accuracy [2025/09/17 15:02] (current) – wikisysop | ||
---|---|---|---|
Line 282: | Line 282: | ||
* Compute_Model_Based_Data | * Compute_Model_Based_Data | ||
* Compute_Model_Based_Data | * Compute_Model_Based_Data | ||
+ | |||
+ | Splitting the pipeline commands into 3 separate files makes the script easier to follow and simplifies future edits and/or debugging. | ||
====Using Sift for Statistical Analysis and Data Visualization==== | ====Using Sift for Statistical Analysis and Data Visualization==== | ||
Line 292: | Line 294: | ||
In order to properly identify all data groups for this tutorial a total of 27 queries will be needed, this includes makes, left misses, and right misses in the x, y, and z planes for each shooting arm joint. The completed query file can be downloaded here for convenience: | In order to properly identify all data groups for this tutorial a total of 27 queries will be needed, this includes makes, left misses, and right misses in the x, y, and z planes for each shooting arm joint. The completed query file can be downloaded here for convenience: | ||
- | **1.** Navigate to the Explore tab on the left and select the Query Builder{{: | + | **1.** Navigate to the Explore tab on the left and select the Query Builder{{: |
**2.** In the conditions list below your new query add a new condition using the **+**. Name the condition **" | **2.** In the conditions list below your new query add a new condition using the **+**. Name the condition **" | ||
| | ||
Line 342: | Line 344: | ||
===K-Means Clusters=== | ===K-Means Clusters=== | ||
- | Once PCA has been performed on the select groups we can use K-Means testing on the results. K-Means testing | + | Once PCA has been performed on the select groups we can use K-Means testing on the results. K-Means testing uses an unsupervised algorithm to create clusters of data with similar characteristics, |
To perform **K-Means** on our results navigate to the **Outlier Detection Using PCA** button on the top tool bar. Select **K-Means** from the dropdown menu. This will generate a dialogue box, complete it like so for your wrist, shoulder and elbow joints. | To perform **K-Means** on our results navigate to the **Outlier Detection Using PCA** button on the top tool bar. Select **K-Means** from the dropdown menu. This will generate a dialogue box, complete it like so for your wrist, shoulder and elbow joints. | ||
Line 424: | Line 426: | ||
{{: | {{: | ||
- | **To script the SIFT command line process a code editor application and the newest version of Python must be installed.** In this tutorial the code editor **Visual Studio Code** is used. | + | **To script the SIFT command line process a code editor application and the newest version of Python must be installed.** In this tutorial the code editor **Visual Studio Code** is used. Python is just one method of automating processing through the Sift CLI, any other scripting or programming language can be used. |
Below are the steps required to build and execute the SIFT command line script. The final code is rather lengthy, it can be downloaded here if needed[[https:// | Below are the steps required to build and execute the SIFT command line script. The final code is rather lengthy, it can be downloaded here if needed[[https:// | ||
Line 430: | Line 432: | ||
===Required Libraries=== | ===Required Libraries=== | ||
**1.** Import the subprocesses library. This will allow you to run shell commands and manage external processes directly from Python.\\ | **1.** Import the subprocesses library. This will allow you to run shell commands and manage external processes directly from Python.\\ | ||
- | **2.** Import the os library. This will allow you to have access to folders and files within your computer. | + | **2.** Import the os library. This will allow you to have access to folders and files within your computer.\\ |
**3.** Import the tkinter library as well as filedialog from the ktinter import. This is used in prompting the user to select a folder. | **3.** Import the tkinter library as well as filedialog from the ktinter import. This is used in prompting the user to select a folder. | ||
Line 440: | Line 442: | ||
===Selecting and accessing the work folder=== | ===Selecting and accessing the work folder=== | ||
- | **1.**The code will open a file explorer prompt and ask the user to select the folder with all the data. | + | **1.**The code will open a file explorer prompt and ask the user to select the folder with all the data. In the example in the image below, the folder that would be selected is the " |
{{: | {{: | ||
Line 452: | Line 454: | ||
===Navigating through the work folder=== | ===Navigating through the work folder=== | ||
- | **1.**This part of the code goes through your working folder and checks to see if the folders within it contain any .json or .cmz files. | + | **1.**This part of the code goes through your working folder and checks to see if the folders within it contain any .json files to be processed. For this specific project the raw data is in json form, if you are using any other file type be sure to change the .json with that file type. |
- | | + | |
- | | + | |
- | + | ||
- | The logic below checks if a folder has .json files but no .cmz files. This is done as the code will process any folders with .json to create corresponding .cmz files, but if these .cmz files already exist it will skip the folder as to not have to process them again. | + | |
- | + | ||
- | **2.** If a folder contains .json files the code then checks folders within the folder to see if .cmz files are stored in there. An example is if this script was already ran, the folder " | + | |
+ | **2.** If the folder does have a .json file it will first create a variable " | ||
if has_json: | if has_json: | ||
- | | + | |
- | sub_path | + | |
- | cmz_files = [f for f in os.listdir(sub_path) if f.endswith(" | + | |
- | if cmz_files: | + | |
- | has_cmz = True | + | |
- | break | + | |
- | \\ | + | The next step after this is to run the Sift CMD line subprocess. |
- | If the folder contains .json files and no .cmz files, the next step is to create a subfolder to hold all the produced .cmz files. It will check if the folder already has a folder labelled " | + | |
+ | import subprocess | ||
+ | import os | ||
+ | import tkinter as tk | ||
+ | from tkinter import filedialog | ||
+ | from tkinter.filedialog import askdirectory | ||
+ | directory = askdirectory(title =' | ||
+ | os.chdir(directory) | ||
+ | |||
+ | for folder, | ||
+ | has_json = any(file.endswith(" | ||
+ | | ||
+ | if has_json: | ||
+ | fileName = os.path.basename(folder) | ||
+ | #SUBPROCESS STARTS HERE | ||
| | ||
Ensure that the indentation of your code follows the same format as the code above. | Ensure that the indentation of your code follows the same format as the code above. | ||
====Executing Sift CMD line operations==== | ====Executing Sift CMD line operations==== | ||
- | **1.** The following part of the code is run in the command prompt. This cannot be done if the import subprocess was not done at the beginning of the code. First, Sift will be open in the command prompt which will allow for the specific Sift commands to be used. The first Sift command is going to be " | + | **1.** The following part of the code is run in the command prompt. This cannot be done if the import subprocess was not done at the beginning of the code. First, Sift will be open in the command prompt which will allow for the specific Sift commands to be used. The first Sift command is going to be " |
subprocess.run([ | subprocess.run([ | ||
Line 487: | Line 494: | ||
" | " | ||
| | ||
- | *An issue you may run into is Sift without GUI not running. This may be caused do to Sift NoGUI already being open on your device. If you want to rerun Sif NoGUI the other instance has to be exited as Sift does not allow for multiple Sift NoGUI to be run simultaneously. | + | *Note: Only one instance of the Sift command line can be run at once, if you are notified of this error ensure all other command line windows are closed and re-run |
| | ||
**2.**The following line " | **2.**The following line " | ||
Line 504: | Line 511: | ||
; | ; | ||
- | **b)** | + | **b)** |
- | + | ||
- | Set_Pipeline_Parameter_To_Folder_Path | + | |
- | / | + | |
- | / | + | |
- | ! / | + | |
- | ! / | + | |
- | ! / | + | |
- | ! / | + | |
- | ! / | + | |
- | ! / | + | |
- | ; | + | |
File_Save_As | File_Save_As | ||
/ | / | ||
- | /FOLDER=::FOLDERPROCESSED | + | /FOLDER=::FOLDER |
! / | ! / | ||
! / | ! / | ||
! / | ! / | ||
+ | ; | ||
+ | |||
+ | **c) OPTIONAL** If you are not using .json files for your data you will also have to make changes to the pipeline as it is currently hardcoded to specifically process .json files. In the second command of the pipeline, Set_Pipeline_Parameter_To_List_Of_Files, | ||
+ | |||
+ | |||
+ | Set_Pipeline_Parameter_To_List_Of_Files | ||
+ | / | ||
+ | /FOLDER= ::FOLDER | ||
+ | ! / | ||
+ | / | ||
+ | ! / | ||
+ | ! / | ||
+ | ! / | ||
; | ; | ||
Line 528: | Line 537: | ||
" | " | ||
- | " | + | " |
| |
sift/tutorials/openbiomechanics_project/impact_shooting_arm_mechanics_free_throw_accuracy.1758028322.txt.gz · Last modified: 2025/09/16 13:12 by wikisysop