sct-pipeline / spine-park

Pipeline for multicontrast analysis in PD patients
MIT License
0 stars 0 forks source link

Cropped edges in registration to the template #33

Closed jcohenadad closed 5 months ago

jcohenadad commented 6 months ago

When working on #31 I noticed cropped edges in the registered template:

ezgif-3-c9f1467a0f

I suspect this is caused by improper straightening (too large curvature?). I'll investigate

jcohenadad commented 6 months ago

The segmentation goes to the last bottom slice: image

And the straightening looks OK: image

The NURBS-based fitting looks OK: fig_centerline_240514-085522686883_nurbs

jcohenadad commented 6 months ago

The straight2curve warping field applied to the straightened image does not result in the same original image (notice the discs move a lot, and the cord seems slightly larger on the registered image):

ezgif-3-56e1998e68

Although I don't think this explains the multiple slices that are missing on the edges, this is highly concerning and an issue should be opened on SCT

EDIT 20240514_094659: Issue opened: https://github.com/spinalcordtoolbox/spinalcordtoolbox/issues/4477

jcohenadad commented 5 months ago

@Kaonashi22 now that https://github.com/spinalcordtoolbox/spinalcordtoolbox/issues/4477 is solved, I'm rerunning processing on 14 subjects to see if this issue is resolved on your data. I'll report results here.

Kaonashi22 commented 5 months ago

Thanks @jcohenadad!

jcohenadad commented 5 months ago

OK, in general, the fix improves results a lot. However, some issues still remain, that I'm investigating now. For example, with subject sub-DEV169Sujet03, the fix still produced cropped edges.

Before fix: ezgif-7-2aa1afd53a

After fix: ezgif-7-58c0bfa6e5

jcohenadad commented 5 months ago

Comparing the input image and the input-straight-curved shows highly similar content overall (thanks to https://github.com/spinalcordtoolbox/spinalcordtoolbox/pull/4514), except at the top/bottom edge:

ezgif-7-3b1fbed23d

Maybe this is the cause of the problem?

It is surprising, given that many slices are affected at the bottom (about 30), even though the warping field at the bottom seems only affected over a few slices, and the segmentation is fine towards the bottom:

image

jcohenadad commented 5 months ago

The first landmark-based rigid registration did not work: getRigidTransformFromLandmarks_plot

Leading to a strong cropping of the straightened image: image

jcohenadad commented 5 months ago

Going into debug mode...

The input label files to step=0 are properly positioned and oriented:

image

jcohenadad commented 5 months ago

Checking on another subject where this cropping is not/less apparent: sub-BB277

Ah! Still not working properly: image

jcohenadad commented 5 months ago

Has this issue been introduced by https://github.com/spinalcordtoolbox/spinalcordtoolbox/pull/4514? Let's re-run SCT before the fix...

nope! Same problem before the fix: image

jcohenadad commented 5 months ago

@Kaonashi22 good news, the issue has been identified and fixed in https://github.com/spinalcordtoolbox/spinalcordtoolbox/pull/4533. Once @joshuacwnewton reviews it we will merge it and you can resume your experiments.

Kaonashi22 commented 5 months ago

Thanks everyone!!!

jcohenadad commented 5 months ago

@Kaonashi22 to be 100% sure I'm also re-running the processing on the 14 subjects you shared with me. I'll share the QC report once done.

EDIT 20240618_142034:

Two crashes:

joshuacwnewton commented 5 months ago

Sorry for the delay! The PR has been merged. Feel free to update your local copies of SCT and retry.

jcohenadad commented 5 months ago

@Kaonashi22 you need to do the following:

cd $SCT_DIR
git pull

And then you can re-run the processing on all subjects. For every new issue you experience, please open a specific issue. I'm closing this issue now.