ANTsX / ANTsR

R interface to the ANTs biomedical image processing library
https://antsx.github.io/ANTsR
Apache License 2.0
127 stars 35 forks source link

multiChannelPCA is failing in R 4.3.1 #405

Closed muratmaga closed 3 weeks ago

muratmaga commented 4 weeks ago

Describe the bug Example code for multichannelPCA works in R 4.2.1 but fails in R 4.3.1

To Reproduce

  resampleImage( c(4,4) )
img2 = antsImageRead( getANTsRData( "r64" ) ) %>%
  resampleImage( c(4,4) )
img3 = antsImageRead( getANTsRData( "r27" ) ) %>%
  resampleImage( c(4,4) )
img4 = antsImageRead( getANTsRData( "r30" ) ) %>%
  resampleImage( c(4,4) )
reg1 = antsRegistration( img1, img2, 'SyN' )
reg2 = antsRegistration( img1, img3, 'SyN' )
reg3 = antsRegistration( img1, img4, 'SyN' )
w1 = antsImageRead( reg1$fwdtransforms[1] )
w2 = antsImageRead( reg2$fwdtransforms[1] )
w3 = antsImageRead( reg3$fwdtransforms[1] )
mask = getMask( img1 )
x = list( w1, w2, w3 )
dpca = multichannelPCA( x, mask )

creates this error:

Error in sum(mask >= 1) : invalid 'type' (S4) of argument.

This must be an R change but not sure what causing the error, since if I run the sum(mask>=1) by itself, I get the count of 1109 without an error.

ntustison commented 4 weeks ago

I'm running 4.3.3 and don't get any error. I remember seeing this type of error recently with some ANTsRNet development but @ncullen93 's relatively recent overhaul removed those errors.

muratmaga commented 3 weeks ago

Rebuild everything from updated source, and error is now gone. Thanks @ntustison and @ncullen93