Problems with –im (involuntary patient motion correction)

Dear all,

I am having trouble with motion correction reconstruction when using the –im option. When I try to apply motion correction reconstruction I get the error:

Error, the 2th motion trigger timestamp: xxx occurs after the end of the last frame (frame 1, timestop: 0!

This error occurs in the code in the file oDynamicDataManager line 413 and arises incorrectly. When I do –im reconstruction in combination with 1 frame (so no framing), the time stop value of the frame remains 0s, it is not read from the data file. As a result, the time steps of the motion triggers are greater than the time stop value of the frame (line 407) and you will eventually get an error. When I manually adjust this time stop value to the correct value myself, this error message goes away, but I get incorrect reconstructed images. I only get black images after reconstruction where each voxel has NaN as its value. When I apply the same motion correction where I also divide the data into, for example, 2 frames (-frm…), I get correctly reconstructed images.

Does anyone of you know why the option –im gives these weird results, or what I maybe do wrong?
I use list-mode PET data with a total duration of 900 seconds. For the motion correction, I used three motion triggers (and deformations).

Thanks in advance!


Good afternoon Igne

Thank you for your email.

We actually just released a new version of CASToR ( V3.1 ) which fixed some bugs related to the handling of motion timestamps.

Maybe you could try with this version , if it is not too difficult , to check if the behaviour you experience is related to these bugs ?

In the latest version , the oDynamidDataManager will remove all timestamps that occur after the end of the last frame.

Normally the duration of the frame ( even when not specifying framing ) is set by the Start time (s) and Duration (s) entries in the datafile header.

Do you have these entries in your datafile header?

Kind Regards,

Zacharias Chalampalakis

Dear Zacharis,

Thank you for your quick response.

As for oDynamicDataManager, in the datafile header a start time and duration are indeed given, these are 0s and 900s respectively. even though these values are included, the frame time stop remains 0s when I apply motion correction without framing.

I tried the new version of Castor (V3.1), but I have trouble with configuring and building te program. Configuring only creates four projects in the solution (all_build, castor-recon, install and zero_check) instead of seven projects (all_build, castor-recon, install, zero_check, castor-datafileExplorer, castor-imageDynamicTools and castor-scannerLUTExplorer) and this causes problems building the solution.

As far as configuring and building is concerned, I did everything the same as with v_3.0.1. I configured Castor with CMake and tried to build it in Windows Visual Studio.

Do you know if the problem with configuring and building could be with this new version?

Kind regards,


Hi Inge,

The building problem might come from the CMake configuration file, as these projects have been relocated (now you must enable CASToR_BUILD_SAMPLE_UTILITIES in cmake to build them). It should not have caused issues to build the solution though, so I will have a closer look at it.

Could you try to rebuild the 3.1 version with CASToR_BUILD_SAMPLE_UTILITIES enabled ? Alternatively if there are still some issues, you can use the configuration file from the previous version in attachements (to replace the one in the castor directory).

Let me know if this helps

Kind regards,


CMakeLists.txt (17.5 KB)