uncbiag / uniGradICON

The official website for uniGradICON: A Foundation Model for Medical Image Registration
Apache License 2.0
64 stars 3 forks source link

Discrepancy between ITK wrapper and pure pytorch implementation #7

Closed neel-dey closed 4 months ago

neel-dey commented 5 months ago

Hi again,

I was using unigradicon-register on the L2R-CTMRI dataset (used in the paper) to warp the MR to the CT and there seems to be a bug somewhere in the ITK-based processing. See the intrasubject sample result from subject 0001 below (top left: moving, top right: fixed, bottom: moved):

image

However, the same subject pair works qualitatively fine (/similar to the result in the paper) in the Colab demo which uses the same set of weights and stays in pytorch the entire time.

I'm guessing that there's an issue introduced in going back and forth between pytorch and ITK? I'd offer to help track it down but ITK deformation conventions always trip me up :) Thanks!

neel-dey commented 5 months ago

I haven't tested whether this fixes the wrapper as I have to run to a meeting, but I think I found the issue. The preprocessing function is different.

The colab demo and paper do (x - x.min()) / (x.max() - x.min()) whereas i think that function only does x/ 0.9*x.max() which doesn't rescale to [0, 1] as in the paper when your inputs have negative numbers (as in CT).

HastingsGreer commented 5 months ago

Thank you for finding this! This is my fault and I will fix it asap