muschellij2 / fslr

FSL-R Interface package
41 stars 11 forks source link

error in fslr function #27

Open troywty opened 3 years ago

troywty commented 3 years ago

Hello John, I am working on a project to do defacing, for which your library is being used in my script. We have used your library without any error for several months since we installed it. However, a following error suddenly recently appears when I run functions such as fslsmooth and CT_Skull_Strip_robust in fslr, even if fslr is sucessfully loaded in R.

smooth = fslsmooth(thresh.img, sigma = 0.5, retimg=TRUE)#sigma value to control to be soother

fslmaths "/tmp/Rtmpz4mcgw/file3897145cb153.nii.gz" -s 0.5 "/tmp/Rtmpz4mcgw/file389710b12b8f";

Error in (function (fname, onefile = TRUE, gzipped = TRUE, verbose = FALSE, : Not all data was read in: should be length 34078720 but only 32156 was read in!

Do you know why this error occurs and how should I fix it? Are there any requirements for installing particular versions of associated R packages to avoid this error in fslr? Any advice will be great help! Thanks, Tingyu

muschellij2 commented 3 years ago

If you have a question, please provide a MCVE: https://stackoverflow.com/help/mcve. In any example, I recommend using a reproducible example using the reprex package (https://github.com/tidyverse/reprex). Also, please include a sessioninfo::session_info() output.

troywty commented 3 years ago

Hi, thank you for replying so quickly. Here is an example of fslr that addresses the same error. The session info is attached as a txt.

library(fslr) if (have.fsl()){ system.time({ dims = c(50, 50, 20) x = array(rnorm(prod(dims)), dim = dims) img = nifti(x, dim= dims, datatype = convert.datatype()$FLOAT32, cal.min = min(x), cal.max = max(x), pixdim = rep(1, 4)) s.img = fslsmooth(img, retimg=TRUE) }) } fslmaths "/tmp/RtmpLA9Qtd/file3acd1a3e0df9.nii.gz" -s 10 "/tmp/RtmpLA9Qtd/file3acd7935f068"; Error in (function (fname, onefile = TRUE, gzipped = TRUE, verbose = FALSE, : Not all data was read in: should be length 50000 but only 2213 was read in! Timing stopped at: 0.233 0.034 0.264

sessionInfo.txt

muschellij2 commented 3 years ago

Sorry, but I can't reproduce that error. That error is coming from oro.nifti::readNIfTI I think. Can you try to run the command fslsmooth(img, retimg = FALSE, outfile = "myfile.nii.gz") and then run readniii("myfile.nii.gz")? Also, can you view myfile.nii.gz in FSL? Please see the reprex package for future reproducible examples.

troywty commented 3 years ago

Hello John, I tried what you suggested, but here is the similar error again.

image

We tried to view the input image generated by the example code in fslr, here is the capture of the image. image

Because of the error in the reading of the nifty image, fslview("myfile.nii.gz") does not display anything.

Thanks for your timely help! Do you have any suggestions to resolve this issue?

muschellij2 commented 3 years ago

And when you load it into FSL?

On Thu, Jun 24, 2021 at 5:50 PM troywty @.***> wrote:

Hello John, I tried what you suggested, but here is the similar error again.

[image: image] https://user-images.githubusercontent.com/23205820/123337005-a210bc00-d514-11eb-9bce-b854cdc82f5e.png

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/muschellij2/fslr/issues/27#issuecomment-867974476, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAIGPLXDGLLUGYH4BD2SF23TUOSCRANCNFSM47IAI4DA .

-- Best, John