unravel.image_io.io_nii module#

Use io_nii from UNRAVEL to convert the data type of a .nii.gz image and optionally scale the data.

Inputs:
  • .nii.gz image

Outputs:
  • .nii.gz image with the specified data type and scaling.

Possible numpy data types:
  • Unsigned Integer: uint8, uint16, uint32, uint64

  • Signed Integer: int8, int16, int32, int64

  • Floating Point: float32, float64

Note

  • With –scale, the min intensity becomes dtype min and max intensity becomes dtype max. Every other intensity is scaled accordingly.

  • With –binary, the image is binarized (0 or 1).

  • With –zscore, the range of z-scored data from -3 to 3 is converted to 0 to 255.

  • With –fixed_scale, the data is scaled using the provided min and max values.

Usage:#

io_nii -i path/img.nii.gz -d float32 [-o path/new_img.nii.gz] [-f min,max | -s | -b | -z] [-v]

unravel.image_io.io_nii.parse_args()[source]#
unravel.image_io.io_nii.convert_dtype(ndarray, data_type, scale_mode='none', fixed_scale_range=None, zscore_range=(-3, 3), target_range=(0, 255))[source]#

Convert the data type of an ndarray and optionally scale the data.

Parameters: - ndarray: Input ndarray. - data_type: Target data type. - scale_mode: ‘none’, ‘standard’, or ‘zscore’. Determines the scaling approach. - fixed_scale_range: Tuple indicating the fixed range for scaling if scale_mode is ‘fixed’. - zscore_range: Tuple indicating the z-score range for scaling if scale_mode is ‘zscore’. - target_range: Tuple indicating the target range for the data type conversion.

Returns: - Converted ndarray with the specified data type and scaling.

unravel.image_io.io_nii.main()[source]#