Closed chihyanghsu0805 closed 7 years ago
I think I need some more details.
Do you have an example image you can share? What is ws
in your example?
ws is an NIFTI object read using the following line.
ws = readNIfTI(filename)
Sorry, but I can't share my images due to confidentiality.
For some of my cases, I also run into the following error
Error in gam(y ~ X - 1, paraPen = list(X = D), method = method, ...) : Model has more coefficients than data
I ma wondering whether it is because of my image registration or bias correction.
After carefully reading the instructions, I found that it was noted that
This method performs white matter mean and standard deviation estimates on data that has been rigidly-registered to the MNI template and uses histogram-based methods.
I have not register to MNI template, I will try it.
Hope this worked. Reopen if not.
Hi,
I have a similar issue. I would like to apply the normalisation to the DWI images from the ISLES 2015 challange (SISS). In addition to their preprocess I have applied rigid registration to register the images to MNI space. I also have strippid the background. I get the following error:
Smoothing Histogram
Error in model.frame.default(formula = y ~ X - 1, drop.unused.levels = TRUE) : invalid type (list) for variable 'X' Timing stopped at: 0 0 0
First, I thought it was a type problem, since the images were stored as single. However, converting to double did not help. No NaNs are present in the image array either.
Applying the normalisation to images from our own center that went through the same pre-process did not raise any issues.
Do you have any suggestion on how to solve this issue?
Thank you.
Can you make a reproducible example? It’ll be great if you can share the data from the challenge. I’ve done the challenge as well so should have access to the data but it’s much easier if you make a reproducible example. Also indicate which identifiers are failing please
On Thu, Mar 11, 2021 at 6:56 AM MLTOL @.***> wrote:
Hi,
I have a similar issue. I would like to apply the normalisation to the DWI images from the ISLES 2015 challange (SISS). In addition to their preprocess I have applied rigid registration to register the images to MNI space. I also have strippid the background. I get the following error:
Smoothing Histogram
Error in model.frame.default(formula = y ~ X - 1, drop.unused.levels = TRUE) : invalid type (list) for variable 'X' Timing stopped at: 0 0 0
First, I thought it was a type problem, since the images were stored as single. However, converting to double did not help. No NaNs are present in the image array either.
Applying the normalisation to images from our own center that went through the same pre-process did not raise any issues.
Do you have any suggestion on how to solve this issue?
Thank you.
— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/muschellij2/WhiteStripe/issues/5#issuecomment-796683903, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAIGPLSIJ337PL4WYDY5KO3TDCVVPANCNFSM4DHKDTQQ .
-- Best, John
Thank you for your quick response.
I have shared one of the images.
as formality: This SICAS Medical Image Repository Data is made available under the Open Database License: http://opendatacommons.org/licenses/odbl/1.0/. Any rights in individual contents of the database are licensed under the Database Contents License: http://opendatacommons.org/licenses/dbcl/1.0/.
Rigid registration and background strip has been applied to the original image using the spm8 toolbox, which has placed the image in MNI space.
For normalisation, I have used the following code:
img=readNIfTI(fname = "rb1000_backgroundstrip.nii.gz" , reorient = FALSE)
ws = whitestripe(img = img, type = "T1", stripped = TRUE) norm = whitestripe_norm(img = img, indices=ws$whitestipe.ind) std = ws$mu.whitestripe-ws$whitestripe[1]
norm_img = (img - ws$mu.whitestripe)/std
datatype(norm_img) <- 64 bitpix(norm_img) <-64
writeNIfTI(norm_img, "normalised_image", gzipped=FALSE)
The image is all zero:
library(WhiteStripe)
library(neurobase)
#> Loading required package: oro.nifti
#> oro.nifti 0.11.0
img=readNIfTI(fname = "~/Downloads/rb1000_backgroundstrip.nii.gz" , reorient = FALSE)
range(img)
#> [1] 0 0
ortho2(img)
Created on 2021-03-11 by the reprex package (v1.0.0)
My apologies, something went wrong during gzipping. This image should work.
So the issue is this https://github.com/muschellij2/WhiteStripe/blob/fd993fad86e3e3b30a7771f36bcecea94375d5f8/R/get.largest.mode.R#L78:
if (remove.tail) {
which.rare <- y < (rare.prop * max(y))
y = y[!which.rare]
x = x[!which.rare]
}
And your data has a HUGE spike around zero. The data you have is not integer, which is interesting given it should likely be a raw-ish image. I would definitely look at rounding issues or rounding the data to some value. Here I show you exactly what I mean and have put a warning in there just in case. There are 2 solutions presented:
library(RNifti)
library(neurobase)
#> Loading required package: oro.nifti
#> oro.nifti 0.11.0
#>
#> Attaching package: 'oro.nifti'
#> The following object is masked from 'package:RNifti':
#>
#> 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 object is masked from 'package:RNifti':
#>
#> origin
library(WhiteStripe)
fname = "~/Downloads/rb1000_backgroundstrip.nii.gz"
img = readNifti(fname)
range(img)
#> [1] -193.8515 2141.6748
img=readNIfTI(fname = fname , reorient = FALSE)
range(img)
#> [1] -193.8515 2141.6748
ortho2(img)
This is likely due to really small (but not zero values)
hist(c(img), breaks = 100)
This is from the whitestripe
code and defaults
breaks = 2000
img.voi <- img[img > 0]
See small values
range(img.voi)
#> [1] 2.283842e-05 2.141675e+03
img.hist = hist(img.voi, breaks = breaks, plot = FALSE)
y.in = img.hist$counts
x.in = img.hist$mids
x.in = x.in[!is.na(y.in)]
y.in = y.in[!is.na(y.in)]
The largest spike is x of 0.5
x.in[which.max(y.in)]
#> [1] 0.5
range(y.in)
#> [1] 0 94659
This causes HUGE SPIKE
plot(img.hist)
get.last.mode
The get.last.mode
uses remove.tail
and the proportion below the max
times rare.prop
is removed
range(x.in)
#> [1] 0.5 2141.5
max(y.in)
#> [1] 94659
max(y.in) * 1/5
#> [1] 18931.8
quantile(y.in, probs = 0.999)
#> 99.9%
#> 6335.542
max(y.in) * 1/5
#> [1] 18931.8
REMEMBER - y.in represents counts from the histogram, not observed values # Fail
ws = whitestripe(img = img, type = "T1", stripped = TRUE)
#> Making Image VOI
#> Making T1 Histogram
#> Warning in whitestripe(img = img, type = "T1", stripped = TRUE): Stripped data has very small, but > 0 values,
#> probably rounding needed, such as img[abs(img) <= 0.1] = 0
#> Getting T1 Modes
#> Smoothing Histogram
#> Error in model.frame.default(formula = y ~ X - 1, drop.unused.levels = TRUE): invalid type (list) for variable 'X'
#> Timing stopped at: 0.008 0 0.008
max(y.in) * 1/100
#> [1] 946.59
quantile(y.in, probs = 0.999) * 1/5
#> 99.9%
#> 1267.108
plot(img.hist)
abline(h = max(y.in) * 1/5, col = "red")
abline(h = max(y.in) * 1/100, col = "blue")
abline(h = quantile(y.in, probs = 0.999) * 1/5, col = "green")
You can change rare.prop, but not a great solution necessarily
ws = whitestripe(img = img, type = "T1", stripped = TRUE, rare.prop = 1/100)
#> Making Image VOI
#> Making T1 Histogram
#> Warning in whitestripe(img = img, type = "T1", stripped = TRUE, rare.prop = 1/100): Stripped data has very small, but > 0 values,
#> probably rounding needed, such as img[abs(img) <= 0.1] = 0
#> Getting T1 Modes
#> Smoothing Histogram
#> Smoothing Derivative
#> Quantile T1 VOI
Or you should likely round your data at zero (recommended)
img[img < 0] = 0
img[ abs(img) < 1]= 0
ws = whitestripe(img = img, type = "T1", stripped = TRUE)
#> Making Image VOI
#> Making T1 Histogram
#> Getting T1 Modes
#> Smoothing Histogram
#> Smoothing Derivative
#> Quantile T1 VOI
Created on 2021-03-11 by the reprex package (v1.0.0)
Great, thank you for pointing out that the images were not integer. I think that is a bit strange also. After rounding the images, the issue was solved. Thank you!
Hi, thank you for the awesome package.
As I was using WhiteStripe to process my data with the following line, wsIndex = whitestripe(img = ws, type = ImageType, stripped = FALSE)
one of my cases raised the following error. Error in model.frame.default(formula = y ~ X - 1, drop.unused.levels = TRUE)
All my images are without skull stripping, but if I used TRUE for the argument stripped, the error-causing case would actually finish.
Therefore, I was wondering how significant does skull-stripping affect the normalization. Thank you for your time.