balbasty / nitorch

Neuroimaging in PyTorch
Other
83 stars 14 forks source link

Use double data type for the SPM atlas affine #64

Closed brudfors closed 2 years ago

brudfors commented 2 years ago

@balbasty, UniSeg errored for me because the input affine I gave was torch32. think it is best to use double data type for the SPM atlas affine matrix because it is what is returned by default when reading with io.map().affine, plus it is better for numerical precision without much memory overhead.

balbasty commented 2 years ago

What kind of error did you get?

If we go with this change, can you make it aff = aff.to(torch.float64, dat.device) instead?

brudfors commented 2 years ago

Here is the error:

image

balbasty commented 2 years ago

OK. I'd rather add aff = aff.to(X.dtype) at line 311 of _fit.py, so that we work with a single datatype. And if we see numerical problems, we can always switch to double. But I find that it's a pain to works with mixed types in PyTorch (since so many operations are not implemented)

brudfors commented 2 years ago

@balbasty, okay, done. Please merge if happy!

balbasty commented 2 years ago

Thanks :)