User Tools

Site Tools


visual3d:documentation:pipeline:metric_commands:metric_compute_power_from_dft_coefficients

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
visual3d:documentation:pipeline:metric_commands:metric_compute_power_from_dft_coefficients [2024/07/16 16:59] – removed sgrangervisual3d:documentation:pipeline:metric_commands:metric_compute_power_from_dft_coefficients [2025/09/23 17:31] (current) wikisysop
Line 1: Line 1:
 +====== Metric Compute Power From DFT Coefficients ======
  
 +The power in a signal can be computed from the [[Visual3D:Documentation:Pipeline:Metric_Commands:Metric_Compute_DFT_Coefficients|DFT coefficients]].
 +
 +The form of the DFT is as follows:
 +
 +p(t)= p0 + p1 sin(**w** t) + p2 cos(**w** t) + p3 sin(2**w** t) + p4 cos(2 **w** t) + ....
 +
 +where **w** = 2 * PI * Base_Frequency
 +
 +the power at a given frequency is given as the sum of the squares of the coefficients.
 +
 +For example, the power at the Base_Frequency is given by (p1^2 + p2^2) the power at 2 * Base_Frequency is given by (p3^2 + p3^2)
 +
 +This can be useful when looking at muscle related signals like EMGs. 
 +
 +====Pipeline Command====
 +
 +The command below is as seen on the Visual3D application, it can be found in the **Pipeline Workshop** within the **Metric** folder.
 +
 +<code>
 +Metric_Compute_Power_From_DFT_Coefficients
 +/SIGNAL_TYPES=
 +! /SIGNAL_FOLDER=DFT
 +! /SIGNAL_NAMES=
 +! /RESULT_FOLDER=DFT
 +! /RESULT_SUFFIX=_POWER
 +;
 +</code>
 +
 +Additionally (starting in Visual3D Version 5) the Mean and Median Frequency are computed.
 +
 +These two metrics are commonly used to describe changes related to muscle fatigue.
 +
 +====Command Parameters====
 +- Table with parameters and descriptions (include link to parameter wiki pages if they are available)
 +
 +The following table shows the command parameters and descriptions:
 +
 +|**SIGNAL_TYPES**|**Specify Signal Types**|
 +|**SIGNAL_FOLDER**|**Specify folder containing signals**|
 +|**SIGNAL_NAMES**|**Specify names of signals to be processed**|
 +|**RESULT_FOLDER**|**Specify destination folder for results**|
 +|**RESULT_SUFFIX**|**Specify suffix attached to resulting signals**|
 +
 +====Notes====
 +
 +=== Signal Components ===
 +
 +The resulting Metric signal has two components.
 +
 +The first component is the frequency.
 +The second component is the power at the associated frequency.
 +=== Median Frequency ===
 +
 +The Median Frequency is the Frequency at which the Integral of the Power Spectrum to that Frequency equals half the Integral of the Total Power Spectrum (e.g. divides the power spectrum in two)
 +
 +{{:MedianFrequency.jpg}} where MF = Median Frequency
 +
 +=== Mean Frequency ===
 +
 +The Mean Frequency is the Ratio of the Integral of the Frequency*Power over the Integral of the Power.
 +
 +{{:MeanFrequency.jpg}}
 +
 +=== _STATS ===
 +
 +An additional result signal appended with _STATS is also created.
 +
 +This signal contains the median frequency (component 1) and mean frequency (component 2)
 +
 +====Examples====
 +
 +===Simple example===
 +Here we will look at a basic example of computing power from DFT coefficients calculated for EMG signals during the right stance phase. For more information on computing DFT coefficients go to [[visual3d:documentation:pipeline:metric_commands:metric_compute_dft_coefficients|]].
 +
 +First we must create a group of EMG signals from the analog folder. This can be done using the **Set Pipeline Parameter to List of Signal Names** command, like so:
 +
 +<code>
 +Set_Pipeline_Parameter_To_List_Of_Signal_Names
 +/PARAMETER_NAME=EMG_Signals
 +/SIGNAL_TYPES=ANALOG
 +/SIGNAL_FOLDER=ORIGINAL
 +/SIGNAL_MASK=EMG*
 +;
 +</code>
 +
 +Now that our EMGs have been grouped we can compute the DFT coefficients for each signal. 
 +
 +<code>
 +Metric_Compute_DFT_Coefficients
 +/SIGNAL_TYPES=ANALOG
 +/SIGNAL_FOLDER=ORIGINAL
 +/SIGNAL_NAMES=&::EMG_Signals
 +! /SIGNAL_COMPONENTS=ALL_COMPONENTS
 +! /RESULT_FOLDER=DFT
 +! /RESULT_SUFFIX=_DFT
 +/EVENT_SEQUENCE=RON+ROFF
 +! /EXCLUDE_EVENTS=
 +! /START_FRAME=
 +! /END_FRAME=
 +! /BASE_FREQUENCY=
 +! /NUM_FREQUENCIES=4
 +;
 +</code>
 +
 +Now, use the **Metric Compute Power From DFT Coefficients** command to find the power from the DFT coefficients that were just created. We'll create a new folder within the METRIC folder called **DFT_Power** for this data.
 +
 +<code>
 +Metric_Compute_Power_From_DFT_Coefficients
 +/SIGNAL_TYPES=METRIC
 +/SIGNAL_FOLDER=DFT
 +! /SIGNAL_NAMES=
 +/RESULT_FOLDER=DFT_Power
 +! /RESULT_SUFFIX=_POWER
 +;
 +</code>
 +
 +Once the pipeline has been executed two new folders should be located within the METRIC folder, one called **DFT** and one called **DFT_Power** containing the DFT coefficients and the power associated with them.
 +
 +===Complex example==
 +In real world applications it is often necessary to apply filters to data before analysis can be conducted. Here, similar to above, we will compute the DFT coefficients and power for EMG signals, but only after applying a filter to the raw EMG data. 
 +
 +First we will assemble the same list of EMG signals as above using **Set Pipeline Parameter to List of Signal Names**.
 +
 +<code>
 +Set_Pipeline_Parameter_To_List_Of_Signal_Names
 +/PARAMETER_NAME=EMG_Signals
 +/SIGNAL_TYPES=ANALOG
 +/SIGNAL_FOLDER=ORIGINAL
 +/SIGNAL_MASK=EMG*
 +;
 +</code>
 +
 +Next, before computing DFT coefficients we will apply a bandpass filter to the EMG signals using a combination of a highpass and lowpass filter. The pipeline commands for each filter are below.
 +
 +<code>
 +Highpass_Filter
 +/SIGNAL_TYPES=ANALOG
 +/SIGNAL_FOLDER=ORIGINAL
 +/SIGNAL_NAMES=&::EMG_Signals
 +/RESULT_FOLDER=PROCESSED_EMG
 +! /RESULT_SUFFIX=
 +! /FILTER_CLASS=BUTTERWORTH
 +! /FREQUENCY_CUTOFF=6.0
 +! /NUM_REFLECTED=6
 +! /NUM_EXTRAPOLATED=0
 +! /TOTAL_BUFFER_SIZE=6
 +! /NUM_BIDIRECTIONAL_PASSES=1
 +;
 +</code>
 +
 +<code>
 +Lowpass_Filter
 +/SIGNAL_TYPES=ANALOG
 +/SIGNAL_FOLDER=ORIGINAL
 +/SIGNAL_NAMES=&::EMG_Signals
 +/RESULT_FOLDER=PROCESSED_EMG
 +! /RESULT_SUFFIX=
 +! /FILTER_CLASS=BUTTERWORTH
 +! /FREQUENCY_CUTOFF=6.0
 +! /NUM_REFLECTED=6
 +! /NUM_EXTRAPOLATED=0
 +! /TOTAL_BUFFER_SIZE=6
 +! /NUM_BIDIRECTIONAL_PASSES=1
 +;
 +</code>
 +
 +Now that our EMG signals have been appropriately filtered we can compute DFT coefficients and find the associated signal power, using the same commands as the previous example.
 +
 +**Metric Compute DFT Coefficients**
 +<code>
 +Metric_Compute_DFT_Coefficients
 +/SIGNAL_TYPES=ANALOG
 +/SIGNAL_FOLDER=PROCESSED_EMG
 +/SIGNAL_NAMES=
 +! /SIGNAL_COMPONENTS=ALL_COMPONENTS
 +! /RESULT_FOLDER=DFT
 +! /RESULT_SUFFIX=_DFT
 +/EVENT_SEQUENCE=RON+ROFF
 +! /EXCLUDE_EVENTS=
 +! /START_FRAME=
 +! /END_FRAME=
 +! /BASE_FREQUENCY=
 +! /NUM_FREQUENCIES=4
 +;
 +</code>
 +
 +**Metric Compute Power from DFT Coefficients**
 +<code>
 +Metric_Compute_Power_From_DFT_Coefficients
 +/SIGNAL_TYPES=METRIC
 +/SIGNAL_FOLDER=DFT
 +! /SIGNAL_NAMES=
 +/RESULT_FOLDER=DFT_Power
 +! /RESULT_SUFFIX=_POWER
 +;
 +</code>
 +
 +You should now see two new folders in the METRIC folder, one for the DFT coefficients and another for the signal power. 
 +
 +Using these results we can create a report showing the power spectrum of an EMG signal. Navigate to the **Reports** tab and create a new page. Add a 2d graph and table using the contents shown below.
 +
 +{{:visual3d:documentation:pipeline:metric_commands:power_graph.png?550|}}
 +
 +{{:visual3d:documentation:pipeline:metric_commands:power_table.png?550|}}
 +
 +You should now see a graph and table showing you the filtered EMG signal data similar to below.
 +
 +{{:visual3d:documentation:pipeline:metric_commands:emg_graph.png?550|}}
visual3d/documentation/pipeline/metric_commands/metric_compute_power_from_dft_coefficients.1721149145.txt.gz · Last modified: 2024/07/16 16:59 by sgranger