ENHANCE-PET / FALCON

FALCON is a Python-based software application designed to facilitate PET motion correction, both for head and total-body scans. Our program is built around the fast 'greedy' registration toolkit, which serves as the registration engine. With FALCON, users can enjoy a streamlined experience for implementing motion correction.
GNU General Public License v3.0
38 stars 6 forks source link

Bug: FALCON Crashes When Reference Frame Index is 0 and Starting Frame Index is 1 #56

Closed LalithShiyam closed 5 months ago

LalithShiyam commented 5 months ago

Description:

I encountered a crash in the FALCON application when attempting to perform a rigid transformation using the command-line interface. The crash occurs specifically when setting the reference frame index (-rf) to 0 and the starting frame index (-sf) to 1. This issue seems to be related to how the reference frame is handled within the list of moving frames.

Steps to Reproduce:

  1. Execute the FALCON command with the following parameters:

    falconz -d <dir_path> -rf 0 -sf 1 -r rigid -m cruise

    Replace <dir_path> with the path to your directory containing the frames.

  2. Observe the crash with the error output as described below.

Expected Behavior: FALCON should process the specified frames starting from the frame index 1, considering the frame at index 0 as the reference, and apply the rigid transformation without errors.

Actual Behavior: The application crashes with the following error message:

Traceback (most recent call last):
  File "/home/mz/Documents/Projects/Lalith/MACOSX/Codes/falconz_env/bin/falconz", line 8, in <module>
    sys.exit(main())
  File "/home/mz/Documents/Projects/Lalith/MACOSX/Codes/falconz_env/lib/python3.10/site-packages/falconz/falconz.py", line 220, in main
    moving_frames = moving_frames.remove(reference_file)
ValueError: list.remove(x): x not in list

Workaround Found: Replacing the line

moving_frames = moving_frames.remove(reference_file)

with a list comprehension

moving_frames = [frame for frame in moving_frames if frame != reference_file]

resolved the crash. This suggests an issue with how the remove method is used, perhaps due to the reference_file not being in the moving_frames list in some cases.

Suggested Solution: Consider replacing the .remove() usage with the list comprehension approach mentioned above, which safely filters out the reference_file without throwing an error if it's not found in the list.

Environment:

Bug originally reported by Otto Muzik