-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
N4 Segfault with unsigned char/float #109
Comments
This works however: library(ANTsRCore)
dims = c(50, 50)
img<-makeImage(imagesize = dims, rnorm(prod(dims)) )
n4img<-n4BiasFieldCorrection(img)
n4img<-n4BiasFieldCorrection(img, mask = img > 0) |
library(ANTsRCore)
#>
#> Attaching package: 'ANTsRCore'
#> The following objects are masked from 'package:stats':
#>
#> sd, var
#> The following objects are masked from 'package:base':
#>
#> all, any, apply, max, min, prod, range, sum
fname = getANTsRData("r16")
in_img = antsImageRead(fname)
n4 = n4BiasFieldCorrection(in_img)
plot(n4)
Created on 2019-12-05 by the reprex package (v0.3.0.9000) Session infosessioninfo::session_info()
#> ─ Session info ──────────────────────────────────────────────────────────
#> setting value
#> version R version 3.6.0 (2019-04-26)
#> os macOS Mojave 10.14.6
#> system x86_64, darwin15.6.0
#> ui X11
#> language (EN)
#> collate en_US.UTF-8
#> ctype en_US.UTF-8
#> tz America/New_York
#> date 2019-12-05
#>
#> ─ Packages ──────────────────────────────────────────────────────────────
#> package * version date lib source
#> ANTsRCore * 0.7.3 2019-11-26 [1] local
#> assertthat 0.2.1 2019-03-21 [1] CRAN (R 3.6.0)
#> cli 1.1.0 2019-03-19 [1] CRAN (R 3.6.0)
#> crayon 1.3.4 2017-09-16 [1] CRAN (R 3.6.0)
#> curl 4.2 2019-09-24 [1] CRAN (R 3.6.0)
#> digest 0.6.23 2019-11-23 [1] CRAN (R 3.6.0)
#> evaluate 0.14 2019-05-28 [1] CRAN (R 3.6.0)
#> highr 0.8 2019-03-20 [1] CRAN (R 3.6.0)
#> htmltools 0.4.0 2019-10-04 [1] CRAN (R 3.6.0)
#> httr 1.4.1 2019-08-05 [1] CRAN (R 3.6.0)
#> ITKR 0.5.2 2019-11-05 [1] Github (stnava/ITKR@fe97efa)
#> knitr 1.24.3 2019-08-28 [1] Github (muschellij2/knitr@abcea3d)
#> lattice 0.20-38 2018-11-04 [1] CRAN (R 3.6.0)
#> magrittr 1.5 2014-11-22 [1] CRAN (R 3.6.0)
#> Matrix 1.2-17 2019-03-22 [1] CRAN (R 3.6.0)
#> mime 0.7 2019-06-11 [1] CRAN (R 3.6.0)
#> misc3d * 0.8-4 2013-01-25 [1] CRAN (R 3.6.0)
#> pixmap * 0.4-11 2011-07-19 [1] CRAN (R 3.6.0)
#> R6 2.4.1 2019-11-12 [1] CRAN (R 3.6.0)
#> Rcpp 1.0.3 2019-11-08 [1] CRAN (R 3.6.0)
#> RcppEigen 0.3.3.5.0 2018-11-24 [1] CRAN (R 3.6.0)
#> rlang 0.4.2 2019-11-23 [1] CRAN (R 3.6.0)
#> rmarkdown 1.16 2019-10-01 [1] CRAN (R 3.6.0)
#> sessioninfo 1.1.1 2018-11-05 [1] CRAN (R 3.6.0)
#> stringi 1.4.3 2019-03-12 [1] CRAN (R 3.6.0)
#> stringr 1.4.0 2019-02-10 [1] CRAN (R 3.6.0)
#> withr 2.1.2 2018-03-15 [1] CRAN (R 3.6.0)
#> xfun 0.11 2019-11-12 [1] CRAN (R 3.6.0)
#> xml2 1.2.2 2019-08-09 [1] CRAN (R 3.6.0)
#> yaml 2.2.0 2018-07-25 [1] CRAN (R 3.6.0)
#>
#> [1] /Library/Frameworks/R.framework/Versions/3.6/Resources/library |
Also weirdly it may be due to dimensions!? No segfault: library(ANTsRCore)
for (i in 1:5) {
print(i)
dims = c(50, 50)
img <-makeImage(imagesize = dims, rnorm(prod(dims)) )
n4img<-n4BiasFieldCorrection(img)
n4img<-n4BiasFieldCorrection(img, mask = img > 0)
} Will segfault for (i in 1:5) {
print(i)
dims = c(256, 256)
img <-makeImage(imagesize = dims, rnorm(prod(dims)) )
n4img<-n4BiasFieldCorrection(img)
# segfault
sum(img > 0)
n4img<-n4BiasFieldCorrection(img, mask = img > 0)
n4img
} |
Reinstalling to see if this goes away. |
yes. I suspect something is out of sync.
brian
…On Thu, Dec 5, 2019 at 3:26 PM John Muschelli ***@***.***> wrote:
Reinstalling to see if this goes away.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#109?email_source=notifications&email_token=AACPE7VSQ5ZHQKTEZRXYNTTQXFPXTA5CNFSM4JV7SL6KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEGCBAJA#issuecomment-562303012>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AACPE7WG4VHCWXCGUBSQ6GDQXFPXTANCNFSM4JV7SL6A>
.
|
Still getting same error after installing locally. GitHub install may be different - but something is off. |
tested on OS X and ubuntu 18.04 with recent full stack installs - no issues.
but perhaps I have something out of date. not sure.
brian
…On Thu, Dec 5, 2019 at 4:55 PM John Muschelli ***@***.***> wrote:
Still getting same error after installing locally. GitHub install may be
different - but something is off.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#109?email_source=notifications&email_token=AACPE7XFURNC37KMATAHFYDQXF2FRA5CNFSM4JV7SL6KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEGCJDRY#issuecomment-562336199>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AACPE7VBXKEFREI6DJIB7ZLQXF2FRANCNFSM4JV7SL6A>
.
|
Still failingwith
Can you send your session info? Having problems in 3D with |
I suspect this was fixed by @ntustison just yesterday ( in ANTs ) ... |
That's great news! Either way, here should be a reproducible example: library(ANTsRCore)
#>
#> Attaching package: 'ANTsRCore'
#> The following objects are masked from 'package:stats':
#>
#> sd, var
#> The following objects are masked from 'package:base':
#>
#> all, any, apply, max, min, prod, range, sum
library(neurobase)
#> Loading required package: oro.nifti
#> oro.nifti 0.10.1
#>
#> Attaching package: 'oro.nifti'
#> The following objects are masked from 'package:ANTsRCore':
#>
#> origin, origin<-
library(extrantsr)
#>
#> Attaching package: 'extrantsr'
#> The following object is masked from 'package:neurobase':
#>
#> zero_pad
#> The following objects are masked from 'package:oro.nifti':
#>
#> origin, origin<-
#> The following objects are masked from 'package:ANTsRCore':
#>
#> origin, origin<-
destfile = tempfile(fileext = ".zip")
download.file("https://github.com/ANTsX/ANTsRCore/files/4073596/Archive.zip",
destfile = destfile)
unzip(destfile, exdir = tempdir())
files = "IXI002-Guys-0828-T1_bias_correct.nii.gz"
files = file.path(tempdir(), files)
img = antsImageRead(files)
maskfile = "IXI002-Guys-0828-T1_brain_mask.nii.gz"
maskfile = file.path(tempdir(), maskfile)
mask = antsImageRead(maskfile)
img
#> antsImage
#> Pixel Type : float
#> Components Per Pixel: 1
#> Dimensions : 150x256x202
#> Voxel Spacing : 1.19999694824219x0.9375x0.9375
#> Origin : -90.15966 120.7078 -82.64942
#> Direction : 1 3.756096e-08 2.323527e-09 3.756096e-08 -0.9923758 -0.1232487 2.323527e-09 -0.1232487 0.9923758
#> Filename : /var/folders/1s/wrtqcpxn685_zk570bnx9_rr0000gr/T//RtmpJ141o8/IXI002-Guys-0828-T1_bias_correct.nii.gz
mask
#> antsImage
#> Pixel Type : float
#> Components Per Pixel: 1
#> Dimensions : 150x256x202
#> Voxel Spacing : 1.19999694824219x0.9375x0.9375
#> Origin : -90.15966 120.7078 -82.64942
#> Direction : 1 3.756095e-08 2.323527e-09 3.756095e-08 -0.9923758 -0.1232487 2.323527e-09 -0.1232487 0.9923758
#> Filename : /var/folders/1s/wrtqcpxn685_zk570bnx9_rr0000gr/T//RtmpJ141o8/IXI002-Guys-0828-T1_brain_mask.nii.gz
range(img)
#> [1] 0.0000 988.2431
range(mask)
#> [1] 0 1
unique(c(as.array(mask)))
#> [1] 0 1
ortho2(img) ortho2(mask) outfiles = tempfile(fileext = ".nii.gz")
bc = n4BiasFieldCorrection(img, verbose = TRUE)
antsImageWrite(bc, outfiles)
range(bc)
#> [1] 0.00 2161.69
ortho2(bc, mask) masked_image = maskImage(bc, mask)
range(masked_image)
#> [1] 0.000 1163.379
ortho2(masked_image) ofile1 = outfiles
f = outfiles[1]
fslr::fslmask(file = f, mask = maskfile,
outfile = f,
retimg = FALSE)
#> Warning in get.fsl(): Setting fsl.path to /usr/local/fsl
#> Warning in get.fsloutput(): Can't find FSLOUTPUTTYPE, setting to NIFTI_GZ
#> FSLDIR='/usr/local/fsl'; PATH=${FSLDIR}/bin:${PATH};export PATH FSLDIR; sh "${FSLDIR}/etc/fslconf/fsl.sh"; FSLOUTPUTTYPE=NIFTI_GZ; export FSLOUTPUTTYPE; ${FSLDIR}/bin/fslmaths "/private/var/folders/1s/wrtqcpxn685_zk570bnx9_rr0000gr/T/RtmpJ141o8/file597b5872170e.nii.gz" -mas "/private/var/folders/1s/wrtqcpxn685_zk570bnx9_rr0000gr/T/RtmpJ141o8/IXI002-Guys-0828-T1_brain_mask.nii.gz" "/var/folders/1s/wrtqcpxn685_zk570bnx9_rr0000gr/T//RtmpJ141o8/file597b5872170e"
#> [1] 0
fsl_masked_image = antsImageRead(f)
ortho2(fsl_masked_image)
range(fsl_masked_image)
#> [1] 0.000 1163.379
all.equal(as.array(fsl_masked_image), as.array(masked_image))
#> [1] TRUE Here is the segfaultbc2 = n4BiasFieldCorrection(masked_image, mask = mask, verbose = TRUE)
Created on 2020-01-16 by the reprex package (v0.3.0.9001) Session infosessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#> setting value
#> version R version 3.6.0 (2019-04-26)
#> os macOS Mojave 10.14.6
#> system x86_64, darwin15.6.0
#> ui X11
#> language (EN)
#> collate en_US.UTF-8
#> ctype en_US.UTF-8
#> tz America/New_York
#> date 2020-01-16
#>
#> ─ Packages ───────────────────────────────────────────────────────────────────
#> package * version date lib source
#> abind 1.4-5 2016-07-21 [1] CRAN (R 3.6.0)
#> ANTsR 0.5.4.2 2019-11-14 [1] local
#> ANTsRCore * 0.7.3 2019-12-11 [1] Github (ANTsX/ANTsRCore@416d8f1)
#> assertthat 0.2.1 2019-03-21 [1] CRAN (R 3.6.0)
#> backports 1.1.5 2019-10-02 [1] CRAN (R 3.6.0)
#> bitops 1.0-6 2013-08-17 [1] CRAN (R 3.6.0)
#> cli 2.0.0 2019-12-09 [1] CRAN (R 3.6.0)
#> colorout * 1.2-1 2019-06-19 [1] Github (jalvesaq/colorout@7ea9440)
#> crayon 1.3.4 2017-09-16 [1] CRAN (R 3.6.0)
#> curl 4.3 2019-12-02 [1] CRAN (R 3.6.0)
#> digest 0.6.23 2019-11-23 [1] CRAN (R 3.6.0)
#> evaluate 0.14 2019-05-28 [1] CRAN (R 3.6.0)
#> extrantsr * 3.9.12.1 2020-01-03 [1] local
#> fansi 0.4.0 2018-10-05 [1] CRAN (R 3.6.0)
#> fs 1.3.1 2019-05-06 [1] CRAN (R 3.6.0)
#> fslr 2.24.4 2019-12-03 [1] local
#> glue 1.3.1 2019-03-12 [1] CRAN (R 3.6.0)
#> highr 0.8 2019-03-20 [1] CRAN (R 3.6.0)
#> htmltools 0.4.0 2019-10-04 [1] CRAN (R 3.6.0)
#> httr 1.4.1 2019-08-05 [1] CRAN (R 3.6.0)
#> ITKR 0.5.2 2019-11-05 [1] Github (stnava/ITKR@fe97efa)
#> knitr 1.26.1 2020-01-05 [1] Github (muschellij2/knitr@f5af631)
#> lattice 0.20-38 2018-11-04 [1] CRAN (R 3.6.0)
#> magrittr 1.5 2014-11-22 [1] CRAN (R 3.6.0)
#> Matrix 1.2-17 2019-03-22 [1] CRAN (R 3.6.0)
#> matrixStats 0.55.0 2019-09-07 [1] CRAN (R 3.6.0)
#> mgcv 1.8-28 2019-03-21 [1] CRAN (R 3.6.0)
#> mime 0.8 2019-12-19 [1] CRAN (R 3.6.0)
#> neurobase * 1.29.1 2020-01-14 [1] local
#> nlme 3.1-141 2019-08-01 [1] CRAN (R 3.6.0)
#> oro.nifti * 0.10.1 2019-12-14 [1] local
#> pillar 1.4.3 2019-12-20 [1] CRAN (R 3.6.0)
#> pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 3.6.0)
#> plyr 1.8.5 2019-12-10 [1] CRAN (R 3.6.0)
#> purrr 0.3.3 2019-10-18 [1] CRAN (R 3.6.0)
#> R.matlab 3.6.2 2018-09-27 [1] CRAN (R 3.6.0)
#> R.methodsS3 1.7.1 2016-02-16 [1] CRAN (R 3.6.0)
#> R.oo 1.23.0 2019-11-03 [1] CRAN (R 3.6.0)
#> R.utils 2.9.0 2019-06-13 [1] CRAN (R 3.6.0)
#> R6 2.4.1 2019-11-12 [1] CRAN (R 3.6.0)
#> Rcpp 1.0.3 2019-11-08 [1] CRAN (R 3.6.0)
#> RcppEigen 0.3.3.7.0 2019-11-16 [1] CRAN (R 3.6.0)
#> reprex 0.3.0.9001 2020-01-05 [1] Github (tidyverse/reprex@5ae0b29)
#> rlang 0.4.2 2019-11-23 [1] CRAN (R 3.6.0)
#> rmarkdown 2.0 2019-12-12 [1] CRAN (R 3.6.0)
#> RNifti 1.0.1 2019-11-27 [1] CRAN (R 3.6.0)
#> rstudioapi 0.10.0-9003 2020-01-05 [1] Github (rstudio/rstudioapi@abe596d)
#> sessioninfo 1.1.1 2018-11-05 [1] CRAN (R 3.6.0)
#> stapler 0.7.0.1 2020-01-03 [1] local
#> stringi 1.4.3 2019-03-12 [1] CRAN (R 3.6.0)
#> stringr 1.4.0 2019-02-10 [1] CRAN (R 3.6.0)
#> styler 1.1.1 2019-05-06 [1] CRAN (R 3.6.0)
#> tibble 2.1.3 2019-06-06 [1] CRAN (R 3.6.0)
#> WhiteStripe 2.3.2 2019-10-01 [1] local
#> withr 2.1.2 2018-03-15 [1] CRAN (R 3.6.0)
#> xfun 0.11 2019-11-12 [1] CRAN (R 3.6.0)
#> xml2 1.2.2 2019-08-09 [1] CRAN (R 3.6.0)
#> yaml 2.2.0 2018-07-25 [1] CRAN (R 3.6.0)
#>
#> [1] /Library/Frameworks/R.framework/Versions/3.6/Resources/library |
Still getting N4 fails with 3D: https://travis-ci.org/muschellij2/ANTsRCore/jobs/645574697#L4437 |
yes - I saw this recently as well. it's a familiar error and occurs at the
end of the pipeline, after n4 runs.
brian
…On Mon, Feb 3, 2020 at 2:11 PM John Muschelli ***@***.***> wrote:
Still getting N4 fails with 3D:
https://travis-ci.org/muschellij2/ANTsRCore/jobs/645574697#L4437
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#109?email_source=notifications&email_token=AACPE7S3M4R72RSZCRJMRFTRBBT6DA5CNFSM4JV7SL6KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEKVAZWI#issuecomment-581569753>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AACPE7QQLWCIPG35VFMYICDRBBT6DANCNFSM4JV7SL6A>
.
|
Looking at this now. I wonder if our previous attempt at eliminating a similar ANTsPy occurrence is now causing this. |
yes possible - would float type be more general?
brian
…On Tue, Feb 4, 2020 at 11:41 AM Nick Tustison ***@***.***> wrote:
Looking at this now. I wonder if our previous attempt
<ANTsX/ANTs@4528978>
at eliminating a similar ANTsPy occurrence is now causing this.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#109?email_source=notifications&email_token=AACPE7UTAM3YKOJWGSLYFW3RBGLCDA5CNFSM4JV7SL6KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEKYJ6AA#issuecomment-582000384>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AACPE7UUNTBF5UFANI64X5LRBGLCDANCNFSM4JV7SL6A>
.
|
Yeah, that's the next thing I was going to try as soon as I can reproduce it on the dgx. Apparently my ANTsRCore was older so I wasn't able to reproduce. |
hmm .... well let me know if you can't reproduce and I will clean
everything out and start again
brian
…On Tue, Feb 4, 2020 at 12:13 PM Nick Tustison ***@***.***> wrote:
Yeah, that's the next thing I was going to try as soon as I can reproduce
it on the dgx. Apparently my ANTsRCore was older so I wasn't able to
reproduce.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#109?email_source=notifications&email_token=AACPE7WMA6PIZI2ERLMJJBLRBGO2TA5CNFSM4JV7SL6KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEKYN4EI#issuecomment-582016529>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AACPE7RZX6LTCAWWRYRF4O3RBGO2TANCNFSM4JV7SL6A>
.
|
Is this resolved? I am still getting segfaults (which is a pretty strong fail - are there possibilities to make this robust in R to fail but not segfault?). I'm reinstalling everything from scratch today (ITKR and ANTsRCore), and retry |
@muschellij2 --- can you try the small change I recommended to Brian in the comment previous to yours? My guess is that this change should fix it but I'm unable to reproduce the segfault on my end. |
@ntustison - I tried that change but still got issues .... however, I would like to know if anyone else can reproduce. my finding was that the error only occurred (on my example data) if I both used a mask and downsampling >2. the error occurs after the filter completes (judging by verbose mode). |
Awesome. Thanks. Too bad it didn't work, though. There's not an insignificant amount of processing that takes place after the verbose output which is why I really need to be able to reproduce before I can debug. I'll take a look at this again today and see if somehow things are different this time around. |
library(ANTsRCore)
#>
#> Attaching package: 'ANTsRCore'
#> The following objects are masked from 'package:stats':
#>
#> sd, var
#> The following objects are masked from 'package:base':
#>
#> all, any, apply, max, min, prod, range, sum
dims = c(50, 50)
img<-makeImage(imagesize = dims, rnorm(prod(dims)) )
n4img<-n4BiasFieldCorrection(img)
n4img<-n4BiasFieldCorrection(img, mask = img > 0)
testthat::expect_error(n4BiasFieldCorrection(img, weight_mask = "somepath"))
testthat::expect_error(n4BiasFieldCorrection(img, splineParam = rep(200, 3)))
n4img<-n4BiasFieldCorrection(img, splineParam = c(200, 20))
rm(img); gc()
#> used (Mb) gc trigger (Mb) limit (Mb) max used (Mb)
#> Ncells 1860508 99.4 3551941 189.7 NA 2702461 144.4
#> Vcells 3323055 25.4 8388608 64.0 16384 5520418 42.2
rm(n4img); gc()
#> used (Mb) gc trigger (Mb) limit (Mb) max used (Mb)
#> Ncells 1860765 99.4 3551941 189.7 NA 2702461 144.4
#> Vcells 3323714 25.4 8388608 64.0 16384 5520418 42.2
fname = getANTsRData("r16")
in_img = antsImageRead(fname)
n4 = n4BiasFieldCorrection(in_img)
rm(n4); gc()
#> used (Mb) gc trigger (Mb) limit (Mb) max used (Mb)
#> Ncells 1863010 99.5 3551941 189.7 NA 2702461 144.4
#> Vcells 3329119 25.4 8388608 64.0 16384 5520418 42.2
mask = in_img > 0
mask2 = antsImageClone(mask, out_pixeltype = "float")
# fails Created on 2020-02-20 by the reprex package (v0.3.0.9001) Session infosessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#> setting value
#> version R version 3.6.2 (2019-12-12)
#> os macOS Mojave 10.14.6
#> system x86_64, darwin15.6.0
#> ui X11
#> language (EN)
#> collate en_US.UTF-8
#> ctype en_US.UTF-8
#> tz America/New_York
#> date 2020-02-20
#>
#> ─ Packages ───────────────────────────────────────────────────────────────────
#> package * version date lib source
#> ANTsRCore * 0.7.3 2020-02-20 [1] Github (ANTsX/ANTsRCore@6f7e9aa)
#> assertthat 0.2.1 2019-03-21 [1] CRAN (R 3.6.0)
#> backports 1.1.5 2019-10-02 [1] CRAN (R 3.6.0)
#> cli 2.0.1 2020-01-08 [1] CRAN (R 3.6.0)
#> crayon 1.3.4 2017-09-16 [1] CRAN (R 3.6.0)
#> digest 0.6.23 2019-11-23 [1] CRAN (R 3.6.0)
#> ellipsis 0.3.0 2019-09-20 [1] CRAN (R 3.6.0)
#> evaluate 0.14 2019-05-28 [1] CRAN (R 3.6.0)
#> fansi 0.4.1 2020-01-08 [1] CRAN (R 3.6.0)
#> fs 1.3.1 2019-05-06 [1] CRAN (R 3.6.0)
#> glue 1.3.1 2019-03-12 [1] CRAN (R 3.6.0)
#> highr 0.8 2019-03-20 [1] CRAN (R 3.6.0)
#> htmltools 0.4.0 2019-10-04 [1] CRAN (R 3.6.0)
#> ITKR 0.5.2 2020-02-20 [1] Github (stnava/ITKR@fe97efa)
#> knitr 1.26.1 2020-01-05 [1] Github (muschellij2/knitr@f5af631)
#> lattice 0.20-38 2018-11-04 [1] CRAN (R 3.6.2)
#> magrittr 1.5 2014-11-22 [1] CRAN (R 3.6.0)
#> Matrix 1.2-18 2019-11-27 [1] CRAN (R 3.6.2)
#> pillar 1.4.3 2019-12-20 [1] CRAN (R 3.6.0)
#> pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 3.6.0)
#> purrr 0.3.3 2019-10-18 [1] CRAN (R 3.6.0)
#> R6 2.4.1 2019-11-12 [1] CRAN (R 3.6.0)
#> Rcpp 1.0.3 2019-11-08 [1] CRAN (R 3.6.2)
#> RcppEigen 0.3.3.7.0 2019-11-16 [1] CRAN (R 3.6.0)
#> reprex 0.3.0.9001 2020-01-05 [1] Github (tidyverse/reprex@5ae0b29)
#> rlang 0.4.4 2020-01-28 [1] CRAN (R 3.6.0)
#> rmarkdown 2.0.7 2020-01-17 [1] Github (rstudio/rmarkdown@2faf16a)
#> rstudioapi 0.11.0-9000 2020-02-19 [1] Github (rstudio/rstudioapi@deb9c47)
#> sessioninfo 1.1.1 2018-11-05 [1] CRAN (R 3.6.0)
#> stringi 1.4.5 2020-01-11 [1] CRAN (R 3.6.0)
#> stringr 1.4.0 2019-02-10 [1] CRAN (R 3.6.0)
#> styler 1.1.1 2019-05-06 [1] CRAN (R 3.6.0)
#> testthat 2.3.0 2019-11-05 [1] CRAN (R 3.6.0)
#> tibble 2.1.3 2019-06-06 [1] CRAN (R 3.6.0)
#> withr 2.1.2 2018-03-15 [1] CRAN (R 3.6.0)
#> xfun 0.11 2019-11-12 [1] CRAN (R 3.6.0)
#> yaml 2.2.0 2018-07-25 [1] CRAN (R 3.6.0)
#>
#> [1] /Library/Frameworks/R.framework/Versions/3.6/Resources/library > n4 = n4BiasFieldCorrection(in_img, mask = mask, verbose = TRUE) This seems to fail even before N4 starts:
|
this example works fine for me on both OSX (Catalina) and on Ubuntu 18.04
@ntustison - still fails on dgx with data I sent previously ... am using
/usr/bin/R
with ~/R/x86_64-pc-linux-gnu-library/
example is ~/code/n4biasfieldsegfault/run.R
…On Thu, Feb 20, 2020 at 1:00 PM John Muschelli ***@***.***> wrote:
library(ANTsRCore)
#>
#> Attaching package: 'ANTsRCore'
#> The following objects are masked from 'package:stats':
#>
#> sd, var
#> The following objects are masked from 'package:base':
#>
#> all, any, apply, max, min, prod, range, sum
dims = c(50, 50)
img<-makeImage(imagesize = dims, rnorm(prod(dims)) )
n4img<-n4BiasFieldCorrection(img)
n4img<-n4BiasFieldCorrection(img, mask = img > 0)
testthat::expect_error(n4BiasFieldCorrection(img, weight_mask = "somepath"))
testthat::expect_error(n4BiasFieldCorrection(img, splineParam = rep(200, 3)))
n4img<-n4BiasFieldCorrection(img, splineParam = c(200, 20))
rm(img); gc()
#> used (Mb) gc trigger (Mb) limit (Mb) max used (Mb)
#> Ncells 1860508 99.4 3551941 189.7 NA 2702461 144.4
#> Vcells 3323055 25.4 8388608 64.0 16384 5520418 42.2
rm(n4img); gc()
#> used (Mb) gc trigger (Mb) limit (Mb) max used (Mb)
#> Ncells 1860765 99.4 3551941 189.7 NA 2702461 144.4
#> Vcells 3323714 25.4 8388608 64.0 16384 5520418 42.2
fname = getANTsRData("r16")
in_img = antsImageRead(fname)
n4 = n4BiasFieldCorrection(in_img)
rm(n4); gc()
#> used (Mb) gc trigger (Mb) limit (Mb) max used (Mb)
#> Ncells 1863010 99.5 3551941 189.7 NA 2702461 144.4
#> Vcells 3329119 25.4 8388608 64.0 16384 5520418 42.2
mask = in_img > 0
mask2 = antsImageClone(mask, out_pixeltype = "float")
# fails
Created on 2020-02-20 by the reprex package <https://reprex.tidyverse.org>
(v0.3.0.9001)
Session info
sessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#> setting value
#> version R version 3.6.2 (2019-12-12)
#> os macOS Mojave 10.14.6
#> system x86_64, darwin15.6.0
#> ui X11
#> language (EN)
#> collate en_US.UTF-8
#> ctype en_US.UTF-8
#> tz America/New_York
#> date 2020-02-20
#>
#> ─ Packages ───────────────────────────────────────────────────────────────────
#> package * version date lib source
#> ANTsRCore * 0.7.3 2020-02-20 [1] Github ***@***.***)
#> assertthat 0.2.1 2019-03-21 [1] CRAN (R 3.6.0)
#> backports 1.1.5 2019-10-02 [1] CRAN (R 3.6.0)
#> cli 2.0.1 2020-01-08 [1] CRAN (R 3.6.0)
#> crayon 1.3.4 2017-09-16 [1] CRAN (R 3.6.0)
#> digest 0.6.23 2019-11-23 [1] CRAN (R 3.6.0)
#> ellipsis 0.3.0 2019-09-20 [1] CRAN (R 3.6.0)
#> evaluate 0.14 2019-05-28 [1] CRAN (R 3.6.0)
#> fansi 0.4.1 2020-01-08 [1] CRAN (R 3.6.0)
#> fs 1.3.1 2019-05-06 [1] CRAN (R 3.6.0)
#> glue 1.3.1 2019-03-12 [1] CRAN (R 3.6.0)
#> highr 0.8 2019-03-20 [1] CRAN (R 3.6.0)
#> htmltools 0.4.0 2019-10-04 [1] CRAN (R 3.6.0)
#> ITKR 0.5.2 2020-02-20 [1] Github ***@***.***)
#> knitr 1.26.1 2020-01-05 [1] Github ***@***.***)
#> lattice 0.20-38 2018-11-04 [1] CRAN (R 3.6.2)
#> magrittr 1.5 2014-11-22 [1] CRAN (R 3.6.0)
#> Matrix 1.2-18 2019-11-27 [1] CRAN (R 3.6.2)
#> pillar 1.4.3 2019-12-20 [1] CRAN (R 3.6.0)
#> pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 3.6.0)
#> purrr 0.3.3 2019-10-18 [1] CRAN (R 3.6.0)
#> R6 2.4.1 2019-11-12 [1] CRAN (R 3.6.0)
#> Rcpp 1.0.3 2019-11-08 [1] CRAN (R 3.6.2)
#> RcppEigen 0.3.3.7.0 2019-11-16 [1] CRAN (R 3.6.0)
#> reprex 0.3.0.9001 2020-01-05 [1] Github ***@***.***)
#> rlang 0.4.4 2020-01-28 [1] CRAN (R 3.6.0)
#> rmarkdown 2.0.7 2020-01-17 [1] Github ***@***.***)
#> rstudioapi 0.11.0-9000 2020-02-19 [1] Github ***@***.***)
#> sessioninfo 1.1.1 2018-11-05 [1] CRAN (R 3.6.0)
#> stringi 1.4.5 2020-01-11 [1] CRAN (R 3.6.0)
#> stringr 1.4.0 2019-02-10 [1] CRAN (R 3.6.0)
#> styler 1.1.1 2019-05-06 [1] CRAN (R 3.6.0)
#> testthat 2.3.0 2019-11-05 [1] CRAN (R 3.6.0)
#> tibble 2.1.3 2019-06-06 [1] CRAN (R 3.6.0)
#> withr 2.1.2 2018-03-15 [1] CRAN (R 3.6.0)
#> xfun 0.11 2019-11-12 [1] CRAN (R 3.6.0)
#> yaml 2.2.0 2018-07-25 [1] CRAN (R 3.6.0)
#>
#> [1] /Library/Frameworks/R.framework/Versions/3.6/Resources/library
> n4 = n4BiasFieldCorrection(in_img, mask = mask, verbose = TRUE)
Running N4 for 2-dimensional images.
*** caught segfault ***
*** caught segfault ***
address 0x109bc1000, cause 'memory not mapped'
address 0x109bc5000, cause 'memory not mapped'
Traceback:
Traceback:
1: 1: .helpn4BiasFieldCorrection(args).helpn4BiasFieldCorrection(args)
2: 2: n4BiasFieldCorrection(in_img, mask = mask, verbose = TRUE)n4BiasFieldCorrection(in_img, mask = mask, verbose = TRUE)
Possible actions:
1: abort (with core dump, if enabled)
2: normal R exit
3: exit R without saving workspace
4: exit R saving workspace
Possible actions:
1: abort (with core dump, if enabled)
2: normal R exit
3: exit R without saving workspace
4: exit R saving workspace
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#109?email_source=notifications&email_token=AACPE7WWYTKSBQZJK6ODAVDRD3ALNA5CNFSM4JV7SL6KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEMPOJCY#issuecomment-589227147>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AACPE7SLGJX5IOD4OD75O6DRD3ALNANCNFSM4JV7SL6A>
.
|
Yeah, that example works for me, too. @stnava --- it looks I don't have permission to access that example. Can you open up the permissions? |
Done
On Thu, Feb 20, 2020 at 2:29 PM Nick Tustison ***@***.***> wrote:
Yeah, that example works for me, too. @stnava <https://github.com/stnava>
--- it looks I don't have permission to access that example. Can you open
up the permissions?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#109?email_source=notifications&email_token=AACPE7WEJ4OTQFSWL5ANMC3RD3K27A5CNFSM4JV7SL6KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEMPYCMI#issuecomment-589267249>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AACPE7X2HOBM67HGQS6RNXTRD3K27ANCNFSM4JV7SL6A>
.
--
brian
|
Thanks @stnava . This ("/usr/bin/R") was particularly useful. I installed a different version of R on the DGX which is why I haven't been able to reproduce. So, in summary, for me
I assume both you and @muschellij2 are using 3.6.1, correct? |
yes
brian
…On Thu, Feb 20, 2020 at 4:11 PM Nick Tustison ***@***.***> wrote:
Thanks @stnava <https://github.com/stnava> . This ("/usr/bin/R") was
particularly useful. I installed a different version of R on the DGX which
is why I haven't been able to reproduce. So, in summary, for me
- R --version = 3.5.1 ---> passes
- /usr/bin/R --version = 3.6.1 ---> segfaults
I assume both you and @muschellij2 <https://github.com/muschellij2> are
using 3.6.1, correct?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#109?email_source=notifications&email_token=AACPE7VP5ATVFWT7MNGPV2DRD3WXFA5CNFSM4JV7SL6KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEMQFBDI#issuecomment-589320333>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AACPE7XUXKK3WAS6CI7B65LRD3WXFANCNFSM4JV7SL6A>
.
|
Using 3.6.2
Best,
John
…On Thu, Feb 20, 2020 at 4:49 PM stnava ***@***.***> wrote:
yes
brian
On Thu, Feb 20, 2020 at 4:11 PM Nick Tustison ***@***.***>
wrote:
> Thanks @stnava <https://github.com/stnava> . This ("/usr/bin/R") was
> particularly useful. I installed a different version of R on the DGX
which
> is why I haven't been able to reproduce. So, in summary, for me
>
> - R --version = 3.5.1 ---> passes
> - /usr/bin/R --version = 3.6.1 ---> segfaults
>
> I assume both you and @muschellij2 <https://github.com/muschellij2> are
> using 3.6.1, correct?
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <
#109?email_source=notifications&email_token=AACPE7VP5ATVFWT7MNGPV2DRD3WXFA5CNFSM4JV7SL6KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEMQFBDI#issuecomment-589320333
>,
> or unsubscribe
> <
https://github.com/notifications/unsubscribe-auth/AACPE7XUXKK3WAS6CI7B65LRD3WXFANCNFSM4JV7SL6A
>
> .
>
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#109?email_source=notifications&email_token=AAIGPLRERVKGMHU6B3MZEIDRD33INA5CNFSM4JV7SL6KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEMQI7GI#issuecomment-589336473>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAIGPLQ5A2S3EGY7DJGJ7ETRD33INANCNFSM4JV7SL6A>
.
|
Same behavior - still failing if both sets of code are run, but not failing if first set of code is not run.
|
That's unfortunate. I was able to reproduce the issue on my laptop if I went the |
OK - I'll remove all and reload all the packages today.
Best,
John
…On Mon, Mar 23, 2020 at 12:20 PM Nick Tustison ***@***.***> wrote:
That's unfortunate. I was able to reproduce the issue on my laptop if I
went the git clone ..; R CMD INSTALL ANTsRCore installation route vs.
devtools::install_github(). And what I corrected seemed to fit this
bizarre behavior and it certainly fixed it on my laptop. At this point, I
don't know what else to do.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#109 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAIGPLSJFVFT6TDQQCBT3LLRI6D3HANCNFSM4JV7SL6A>
.
|
Okay, if that doesn't work, one thing we can do is some simplistic, yet effective, debugging by placing |
Still failing - It's a bit complicated to change what is being used, need to change ANTs tag, then make sure ANTs tag really matches up with ITKR ITK tag. So if that can be merged after testing, it may be easier to set this. |
Not sure what to do here? |
I'm sorry but I don't either at this point. Originally, there was an obvious memory problem with one of the image iterators which definitely needed to be fixed. After fixing that, there was an additional memory issue (or, I would say, idiosyncrasy with specific platforms) that I was able to reproduce on only one of my machines through a specific build process. After modifying that, I can no longer reproduce the issue on any machine to which I have access. Are you able to reproduce this on more than one machine? And, if so, can you isolate the section of code through the use of |
I don't have another mac to use, and didn't want to fiddle around with the
xcode installs (to try to make a similar machine on Travis). TL;DR - I
need my PR ANTsX/ANTs#978 accepted before I can
debug using std::cout
The impossibility of "adding std::cout" statements is because N4 is really
called from ANTs, not ANTsRCore code, so you have to send a PR to ANTs, not
ANTsRCore, which I've done here: ANTsX/ANTs#978,
but need some review and then integration. **Then**, I need to make sure
that I update the configure git tag to point to that ANTs installation, but
also double check that the external ITK tag in the cmake builds hasn't
changed because it then hasn't been checked against that ITK build and
ensure that ITK tag is the same one with ITKR.
Sorry - bit of a rant, but also a useful pointer in the future to people
who want to debug/make additions. Small recap
So it's ITK tag → ITKR, is also referenced in CMake of ANTs, which is what
ANTsRCore will pull and reference against. So the ANTs Tag needs ot refer
to the ITKR ITK tag (for consistency) and then the ANTsRCore tag needs to
be updated to the ANTs Tag. Then building with ANTsRCore
will refer to a specific ANTs tag, which references a specific ITK tag,
which should be the same ITK tag in stnava/ITKR.
Best,
John
…On Mon, Mar 30, 2020 at 4:41 PM Nick Tustison ***@***.***> wrote:
I'm sorry but I don't either at this point. Originally, there was an
obvious memory problem with one of the image iterators which definitely
needed to be fixed. After fixing that, there was an additional memory issue
(or, I would say, idiosyncrasy with specific platforms) that I was able to
reproduce on only one of my machines through a specific build process.
After modifying that, I can no longer reproduce the issue on any machine to
which I have access.
Are you able to reproduce this on more than one machine? And, if so, can
you isolate the section of code through the use of std::cout statements
so I have some idea where this memory issue is surfacing?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#109 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAIGPLVE7IBNXICWF3C5PSDRKD7YHANCNFSM4JV7SL6A>
.
|
Oddly, all the fails for that PR are Xcode 10: https://travis-ci.org/github/ANTsX/ANTs/builds/665998685?utm_source=github_status&utm_medium=notification |
Why do you need to modify
|
But, I agree, it's a burden. However, I don't what else to tell you as I can't reproduce it. It would be nice if there were another machine that could verify that this isn't an isolated issue. |
OK - added the lines and seems to segfault at: https://github.com/muschellij2/ANTs/blob/master/Examples/N4BiasFieldCorrection.cxx#L147
|
Interesting. So it seems there's something going on that the reader doesn't like in this particular spot of this particular program. Not surprising as there's a bit of pointer stuff going on there. Before we dive into that, perhaps you should try replacing the
|
Seems to have broken all the code: library(ANTsRCore)
#>
#> Attaching package: 'ANTsRCore'
#> The following objects are masked from 'package:stats':
#>
#> sd, var
#> The following objects are masked from 'package:base':
#>
#> all, any, apply, max, min, prod, range, sum
dims = c(50, 50)
img<-makeImage(imagesize = dims, rnorm(prod(dims)) )
n4img<-n4BiasFieldCorrection(img)
n4img<-n4BiasFieldCorrection(img, mask = img > 0)
#> /Library/Frameworks/R.framework/Versions/3.6/Resources/library/ITKR/libs/include/ITK-5.1/itkImageFileReader.hxx:133:
#> Could not create IO object for reading file 0x7f88c286b610
#> The file doesn't exist.
#> Filename = 0x7f88c286b610
testthat::expect_error(n4BiasFieldCorrection(img, weight_mask = "somepath"))
testthat::expect_error(n4BiasFieldCorrection(img, splineParam = rep(200, 3)))
n4img<-n4BiasFieldCorrection(img, splineParam = c(200, 20))
rm(img); gc()
#> used (Mb) gc trigger (Mb) limit (Mb) max used (Mb)
#> Ncells 1893705 101.2 3797505 202.9 NA 2451542 131.0
#> Vcells 3381342 25.8 8388608 64.0 16384 4749362 36.3
rm(n4img); gc()
#> used (Mb) gc trigger (Mb) limit (Mb) max used (Mb)
#> Ncells 1893944 101.2 3797505 202.9 NA 2451542 131.0
#> Vcells 3381972 25.9 8388608 64.0 16384 4749362 36.3
fname = getANTsRData("r16")
in_img = antsImageRead(fname)
n4 = n4BiasFieldCorrection(in_img)
rm(n4); gc()
#> used (Mb) gc trigger (Mb) limit (Mb) max used (Mb)
#> Ncells 1897591 101.4 3797505 202.9 NA 2451542 131.0
#> Vcells 3390396 25.9 8388608 64.0 16384 4749362 36.3
mask = in_img > 0
mask2 = antsImageClone(mask, out_pixeltype = "float")
# fails
mask
#> antsImage
#> Pixel Type : unsigned char
#> Components Per Pixel: 1
#> Dimensions : 256x256
#> Voxel Spacing : 1x1
#> Origin : 0 0
#> Direction : 1 0 0 1
sum(mask)
#> [1] 19278
n4 = n4BiasFieldCorrection(in_img, mask = mask, verbose = TRUE)
#> /Library/Frameworks/R.framework/Versions/3.6/Resources/library/ITKR/libs/include/ITK-5.1/itkImageFileReader.hxx:133:
#> Could not create IO object for reading file 0x7f88bde1f0f0
#> The file doesn't exist.
#> Filename = 0x7f88bde1f0f0
# fails Created on 2020-03-30 by the reprex package (v0.3.0.9001) |
Sorry, my bad---I forgot that all the R overhead was added to the ANTs Read/Write functionality. So I don't know what to do at this point. As far as I can tell, it doesn't look to be anything specific to the N4 program. If I could reproduce the error, then I would see where it's segfaulting in the reader or switch the order of reading in the input image vs. the mask. But all this would be just trial-and-error and certainly not something that can be done in a GitHub repo thread. |
FYI - we're trying using GitHub actions to compile/test the packages and found that this still is lurking: https://github.com/muschellij2/ANTsRCore/runs/832316950?check_suite_focus=true#step:9:185 |
Thanks @muschellij2 . I would assume the seg faulting is the same as before in that it occurs when the mask is read using the |
Describe the bug
Segfault when mask is 2D unsigned char.
To Reproduce
Created on 2019-12-05 by the reprex package (v0.3.0.9000)
Session info
The text was updated successfully, but these errors were encountered: