Feat: Falcon now automatically identifies start frame for performing motion correction
LalithShiyam opened this issue ยท 6 comments
It would be great to objectively determine from which frame the motion correction needs to be performed. By doing so, the user doesn't need to mention a start frame based on heuristics.
Using 37 Zubal phantom frames without imposed motion, acquired MI over all frames can be seen in the graph below:
Two approaches I came up with for now to determine the starting frame:
[1]: get the frame where the change in MI reduces by 75% (e.g.: frame 4 as in the figure above) as starting frame
[2]: calculate the MI of the reference frame itself and base a threshold on this value to determine starting frame
Awesome! This would be my suggested approach. We know that the last four frames are very similar to each other (34-37) in terms of structure and intensity (kind-of). I would take the average (median/mean) of the MI of the last four frames (original resolution), say "avg_ref_mi". And the rule for finding the start frame would be the following: If the downsampled (1/8th org resolution) MI ("low_res_mi" is greater than the "avg_ref_mi", we should consider this as the start frame. @Keyn34 do you feel this makes sense?
It makes perfect sense to me... Working on it now!
I also quickly stitched together the first 25 frames, resampled vs original, for comparison:
Resampled_vs_Original_ZUBAL.odt
@Keyn34 Great! would be nice to show the frame 37 (original and downsampled version as well). Because we need to see how they match up. Also use a screenshot, no .odt.
The result of implementation is spot on with what you proposed @LalithShiyam:
Computing threshold between file vol34.nii and vol37.nii
MI threshold: -0.06680289264331131
Threshold: Starting frame found at index 2, file vol03.nii
Included frame 37. I will see how I can extract a nice screenshot from the odt, it's just for arranging the files for now.
@LalithShiyam, I pushed the function I implemented for this issue in the corresponding issue branch in FALCON. I will wait for a pull request once we have decided where to put the function and tested it. Is this ok?