diff --git a/Pose2Sim/Utilities/c3d_to_trc.py b/Pose2Sim/Utilities/c3d_to_trc.py index ea166bc..8d0f512 100644 --- a/Pose2Sim/Utilities/c3d_to_trc.py +++ b/Pose2Sim/Utilities/c3d_to_trc.py @@ -115,6 +115,9 @@ def c3d_to_trc_func(*args): c3d_line_markers = c3d_line[index_data_markers] trc_line = '{i}\t{t}\t'.format(i=i, t=trc_time[n]) + '\t'.join(map(str,c3d_line_markers)) trc_o.write(trc_line+'\n') + + print(f'Converted c3d file to {trc_path}') + if __name__ == '__main__': parser = argparse.ArgumentParser() diff --git a/Pose2Sim/Utilities/trc_to_c3d.py b/Pose2Sim/Utilities/trc_to_c3d.py index 32bedb5..a1f67ed 100644 --- a/Pose2Sim/Utilities/trc_to_c3d.py +++ b/Pose2Sim/Utilities/trc_to_c3d.py @@ -34,7 +34,7 @@ __status__ = "Development" ## FUNCTIONS -def extract_marker_data(trc_path): +def extract_trc_data(trc_path): ''' Extract marker names and coordinates from a trc file. @@ -78,6 +78,7 @@ def create_c3d_file(c3d_path, marker_names, trc_data_np): # write c3d file writer = c3d.Writer(point_rate=frame_rate, analog_rate=0, point_scale=1.0, point_units='mm', gen_scale=-1.0) writer.set_point_labels(marker_names) + writer.set_screen_axis(X='+Z', Y='+Y') for frame in trc_data_np: residuals = np.full((len(marker_names), 1), 0.0) @@ -113,9 +114,11 @@ def trc_to_c3d_func(*args): trc_path = args[0] # invoked as a function c3d_path = trc_path.replace('.trc', '.c3d') - marker_names, trc_data_np = extract_marker_data(trc_path) + marker_names, trc_data_np = extract_trc_data(trc_path) create_c3d_file(c3d_path, marker_names, trc_data_np) + print(f'Converted trc file to {c3d_path}') + if __name__ == '__main__': parser = argparse.ArgumentParser(description='Convert TRC files to C3D files.') diff --git a/Pose2Sim/common.py b/Pose2Sim/common.py index 492eea7..a0be4eb 100644 --- a/Pose2Sim/common.py +++ b/Pose2Sim/common.py @@ -428,6 +428,7 @@ def create_c3d_file(c3d_path, marker_names, trc_data_np): # write c3d file writer = c3d.Writer(point_rate=frame_rate, analog_rate=0, point_scale=1.0, point_units='mm', gen_scale=-1.0) writer.set_point_labels(marker_names) + writer.set_screen_axis(X='+Z', Y='+Y') for frame in trc_data_np: residuals = np.full((len(marker_names), 1), 0.0)