You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Looks like a type issue. Not sure if there's anything NIfTI.jl could do about it.
Is it worth mentioning in the readme? Or is this a common footgun/julia knowledge?
# naive attempt, no care about types. loop matches much faster Statistics::mean
sum=0; for x in ni; sum=sum+x; end;
print(sum, "\n", sum/prod(size(ni)),"\n")
# 1.5604549e10
# 836.1491
# make sure accumulator is a BigInt, get the expected value.
sum=BigInt(0); for x in ni; sum=sum+x; end; print(sum, "\n", sum/prod(size(ni)),"\n")
# 1.5642943107e+10
# 838.2063993377057613168724279835390946502057613168724279835390946502057613168706
# force each element to bigint before meaning also works (and is slow)
mean(BigInt,ni)
# 838.2063
# scaling input before mean also works and is much faster than the other methods above
mean(ni/1000)*1000
# 838.2065f0
A lot of images store in Int16 so this comes up. You also are looking at the mean of the entire array instead of just the brain unless you average only masked regions explicitly
Thanks for this package! I'm excited to be able to use Julia in my analysis.
I'm sanity checking and measuring performance here, with this nifti.
The mean of that 3d dataset is
838.206399
(according to fsl and AFNI tools), butmean(niread('mynii.nii.gz'))
reports836.1491
.I'm not sure how to narrow down where the discrepancy is coming from.
The text was updated successfully, but these errors were encountered: