Hi all,
I have some NaNs and -nan(ind) values in my grf data and having an issue with running inverse dynamics. I've used matlab to convert C3D into trc and mot files. I've looked at the old post from someone having the same problem and she said replace all nans with 0.
Can I also simply replace all -nan(ind) values with 0 just like nans?
Thank you,
Replacing NaN values
- Ayman Habib
- Posts: 2248
- Joined: Fri Apr 01, 2005 12:24 pm
Re: Replacing NaN values
Hi Jaeho,
Generally speaking, replacing NaN (undefined) with zero (well defined and possible correct value) is not recommended as it pollutes the data you have. I'd suggest you step back to figure out why there are NaNs in the data, maybe COP when there's no contact or other missing frames in which case dropping the frame or interpolating may make more sense. That said, if you're convinced that replacing NaNs with 0s is a valid assumption then replacing -nan is not any different.
Hope this helps,
-Ayman
Generally speaking, replacing NaN (undefined) with zero (well defined and possible correct value) is not recommended as it pollutes the data you have. I'd suggest you step back to figure out why there are NaNs in the data, maybe COP when there's no contact or other missing frames in which case dropping the frame or interpolating may make more sense. That said, if you're convinced that replacing NaNs with 0s is a valid assumption then replacing -nan is not any different.
Hope this helps,
-Ayman
- Yan Junlan
- Posts: 11
- Joined: Tue Dec 01, 2020 7:13 am
Re: Replacing NaN values
Hi Ayman,
I also encountered the same problem. The torque in the mot file is -nan(ind),and the cop is nan.It appeared nan when the volunteer did not step on the force platform, and when the first force platform was stepped on, the second and third blocks had no data.Only the force platform stepped on has the appropriate data.
When I perform RRA, the model always disappears and the new mass is always very low, about 0.01kg, and the Fy is also very large. I am not sure if this is due to the influence of the mot file.
Therefore,I would like to know is there any way to solve this problem. I have been troubled for a long time, so I look forward to your reply.
Yan
I also encountered the same problem. The torque in the mot file is -nan(ind),and the cop is nan.It appeared nan when the volunteer did not step on the force platform, and when the first force platform was stepped on, the second and third blocks had no data.Only the force platform stepped on has the appropriate data.
When I perform RRA, the model always disappears and the new mass is always very low, about 0.01kg, and the Fy is also very large. I am not sure if this is due to the influence of the mot file.
Therefore,I would like to know is there any way to solve this problem. I have been troubled for a long time, so I look forward to your reply.
Yan
- Ayman Habib
- Posts: 2248
- Joined: Fri Apr 01, 2005 12:24 pm
Re: Replacing NaN values
Hi Yan,
We do not process/modify Force values before applying to the model, as such if you have code that combines forces from multiple force plates your code needs to handle/combine these NaNs. I would suggest you check the data files in our gait examples included with the distribution (e.g. Gait2354_Simbody) to see how the forces are represented before being applied to the model. If you're reading data from C3D or other file formats to create mot files then you'll need to handle the conversion to the expected format before performing the simulation.
Hope this helps,
-Ayman
We do not process/modify Force values before applying to the model, as such if you have code that combines forces from multiple force plates your code needs to handle/combine these NaNs. I would suggest you check the data files in our gait examples included with the distribution (e.g. Gait2354_Simbody) to see how the forces are represented before being applied to the model. If you're reading data from C3D or other file formats to create mot files then you'll need to handle the conversion to the expected format before performing the simulation.
Hope this helps,
-Ayman
- Yan Junlan
- Posts: 11
- Joined: Tue Dec 01, 2020 7:13 am
Re: Replacing NaN values
Hi Ayman,
Thanks for your reply.
I implemented the examples in the opensim tutorial and my own,and checked the message window. I found that when applying GRF,there was a difference.
The following is in the tutorial:
Storage::read data file =subject01_walk1_grf.mot (nr=1501 nc=19)
ExternalForce::right
Data source being set to subject01_walk1_grf.mot
ExternalForce::left
Data source being set to subject01_walk1_grf.mot
Computing average residuals between 0.744 and 1.24
Storage: read data file =subject01_walk1_grf.mot (nr=1501 nc=19)
ExternalForce::right
Data source being set to subject01_walk1_grf.mot
ExternalForce::left
Data source being set to subject01_walk1_grf.mot
The following is my example:
ExternalForce::GRF_1
Data source being set to
ExternalForce::GRF_2
Data source being set to
ExternalForce::GRF_3
Data source being set to
Computing average residuals between 6.7 and 7.5
ExternalForce::GRF_1
Data source being set to
ExternalForce::GRF_2
Data source being set to
ExternalForce::GRF_3
Data source being set to
In addition, a file of RRAExternalLoads_2 is generated, and the settings inside are as follows:
<?xml version="1.0" encoding="UTF-8"?>
-<OpenSimDocument Version="40000">
-<ExternalLoads name="Ex1">
<objects/>
<groups/>
<!--Storage file (.sto) containing (3) components of force and/or torque and point of application.Note: this file overrides the data source specified by the individual external forces if specified.-->
<datafile/>
<!--The option is deprecated and unnecessary to apply external loads.A motion file (.mot) or storage file (.sto) containing the model kinematics used to transform a point expressed in ground to the body of force application.If the point is not expressed in ground,the point is not transformed-->
<external_loads_model_kinematics_file/>
<!--Optional low-pass cut-off frequency for filtering the model kinematics corresponding used to transform the point of application. A negative value results in no filtering.The default value is -1.0,so no filtering.-->
<lowpass_cutoff_frequency_for_load_kinematics>-1</lowpass_cutoff_frequency_for_load_kinematics>
</ExternalLoads>
</OpenSimDocument>
Therefore, I think it is because GRF is not properly applied. However, I don't know how to adjust to add GRF properly, my operation is the same as in the tutorial. Do you know where the problem is and how to solve it?
Thanks
Yan
Thanks for your reply.
I implemented the examples in the opensim tutorial and my own,and checked the message window. I found that when applying GRF,there was a difference.
The following is in the tutorial:
Storage::read data file =subject01_walk1_grf.mot (nr=1501 nc=19)
ExternalForce::right
Data source being set to subject01_walk1_grf.mot
ExternalForce::left
Data source being set to subject01_walk1_grf.mot
Computing average residuals between 0.744 and 1.24
Storage: read data file =subject01_walk1_grf.mot (nr=1501 nc=19)
ExternalForce::right
Data source being set to subject01_walk1_grf.mot
ExternalForce::left
Data source being set to subject01_walk1_grf.mot
The following is my example:
ExternalForce::GRF_1
Data source being set to
ExternalForce::GRF_2
Data source being set to
ExternalForce::GRF_3
Data source being set to
Computing average residuals between 6.7 and 7.5
ExternalForce::GRF_1
Data source being set to
ExternalForce::GRF_2
Data source being set to
ExternalForce::GRF_3
Data source being set to
In addition, a file of RRAExternalLoads_2 is generated, and the settings inside are as follows:
<?xml version="1.0" encoding="UTF-8"?>
-<OpenSimDocument Version="40000">
-<ExternalLoads name="Ex1">
<objects/>
<groups/>
<!--Storage file (.sto) containing (3) components of force and/or torque and point of application.Note: this file overrides the data source specified by the individual external forces if specified.-->
<datafile/>
<!--The option is deprecated and unnecessary to apply external loads.A motion file (.mot) or storage file (.sto) containing the model kinematics used to transform a point expressed in ground to the body of force application.If the point is not expressed in ground,the point is not transformed-->
<external_loads_model_kinematics_file/>
<!--Optional low-pass cut-off frequency for filtering the model kinematics corresponding used to transform the point of application. A negative value results in no filtering.The default value is -1.0,so no filtering.-->
<lowpass_cutoff_frequency_for_load_kinematics>-1</lowpass_cutoff_frequency_for_load_kinematics>
</ExternalLoads>
</OpenSimDocument>
Therefore, I think it is because GRF is not properly applied. However, I don't know how to adjust to add GRF properly, my operation is the same as in the tutorial. Do you know where the problem is and how to solve it?
Thanks
Yan