In cartesian_dmp.py, the rotation matrix is converted to quaternion (x, y, z, w) format using R.from_matrix(demo_trajectory[i][:3,:3]).as_quat(), but in quaternion_dmp, the format of quaternion is (w,x,y,z). There is a format mismatch, and I am not sure if you noticed this problem.
In cartesian_dmp.py, the rotation matrix is converted to quaternion (x, y, z, w) format using R.from_matrix(demo_trajectory[i][:3,:3]).as_quat(), but in quaternion_dmp, the format of quaternion is (w,x,y,z). There is a format mismatch, and I am not sure if you noticed this problem.