Skip to content
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

fslmaths z value behavior #8

Closed
neurolabusc opened this issue Dec 14, 2021 · 3 comments
Closed

fslmaths z value behavior #8

neurolabusc opened this issue Dec 14, 2021 · 3 comments

Comments

@neurolabusc
Copy link
Contributor

This demo exhibits that fslmaths -ztop and -ptoz show unexpected behavior. The round trip ends up converting extreme z scores to zero, rather than clamping them. niimath performs nicely for positive values, but extreme negatives become more extreme (as we get to the subnormal range we need to ensure we choose a value that further away from zero).

#!/usr/bin/env python3
# -*- coding: utf-8 -*-

#Test FSLmaths commands
# -ztop    : Convert Z-stat to (uncorrected) P
# -ptoz    : Convert (uncorrected) P to Z
# test image is -12,-11...+12
#
#fslmaths f32_zval -ztop -ptoz fsl32_zval
#niimath f32_zval -ztop -ptoz n32_zval
#fslmaths -dt double f64_zval -ztop -ptoz fsl64_zval -odt double
#niimath -dt double f64_zval -ztop -ptoz n64_zval -odt double
#
#fslmaths float64 results in 0 when z > 8 or z < -8
#fslmaths float32 results in 0 when z > 8 or z < -5

import nibabel as nib
import numpy as np

def makenii():
    data = np.arange(5*5).reshape(5,5,1)
    mid = np.rint(0.5 * (np.amax(data) + 1))
    data = np.subtract(data, mid)
    data32 = data.astype('float32')
    img32 = nib.Nifti1Image(data32, affine=np.eye(4))
    nib.save(img32, 'f32_zval.nii')
    data64 = data.astype('float64')
    img64 = nib.Nifti1Image(data64, affine=np.eye(4))
    nib.save(img64, 'f64_zval.nii')

if __name__ == '__main__':
    makenii()
neurolabusc added a commit that referenced this issue Dec 14, 2021
@neurolabusc
Copy link
Contributor Author

Latest niimath commit has -ztop clamp input voxels to -5.41 (or -8.29 if -dt double). It will also emit a warning if any converted voxels required clamping:

ztop clamped 7 extremely negative z-scores

@neurolabusc
Copy link
Contributor Author

Latest niimath commit has -ztop clamp input voxels to 13.0 regardless of datatype. Will emit clamp warning for both extreme negative and positive input values.

@neurolabusc
Copy link
Contributor Author

Latest commit ensures niimath clamps values. Issue has been reported to fsl developers (@hanayik)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant