unravel.image_tools.smooth module#

Use img_smooth (smooth) from UNRAVEL to smooth an image.nii.gz and save it.

Note

  • Sigma is the Gaussian standard deviation.

  • By default, sigma is interpreted in voxels (scipy.ndimage.gaussian_filter).

  • With –mm, sigma is interpreted in millimeters (FSL fslmaths -s).

  • This matches conventions used elsewhere in UNRAVEL (e.g., reg: voxels; vstats: mm).

  • Smoothing is performed in 3D.

Inputs:
  • path/img.nii.gz or glob pattern(s)

Outputs:
  • path/img_s<sigma><mm|vx>.nii.gz

Usage:#

img_smooth [-i path/img.nii.gz or glob pattern(s)] [-s sigma] [-m] [-v]

unravel.image_tools.smooth.parse_args()[source]#
unravel.image_tools.smooth.smooth_w_sigma_in_mm(img_path, sigma_mm, output_path)[source]#

Smooth an image with a Gaussian kernel using FSL’s fslmaths -s, which expects sigma in millimeters.

Parameters:#

img_pathstr or Path

Path to the input image (e.g., .nii.gz).

sigma_mmfloat

Standard deviation of the Gaussian kernel in millimeters.

output_pathstr or Path

Path to save the smoothed image (e.g., .nii.gz).

unravel.image_tools.smooth.smooth_w_sigma_in_voxels(img_path, sigma_vx, output_path)[source]#

Smooth an image with a Gaussian kernel using scipy.ndimage.gaussian_filter, which expects sigma in voxels.

Parameters:#

img_pathstr or Path

Path to the input image (e.g., .nii.gz).

sigma_vxfloat

Standard deviation of the Gaussian kernel in voxels.

output_pathstr or Path

Path to save the smoothed image (e.g., .nii.gz).

unravel.image_tools.smooth.smooth_image(img_path, sigma, mm=False)[source]#

Smooth an image with a Gaussian kernel, interpreting sigma in either millimeters or voxels.

Parameters:#

img_pathstr or Path

Path to the input image (e.g., .nii.gz).

sigmafloat

Standard deviation of the Gaussian kernel.

mmbool, optional

If True, interpret sigma in millimeters and use FSL’s fslmaths -s. If False, interpret sigma in voxels and use scipy.ndimage.gaussian_filter. Default is False.

unravel.image_tools.smooth.main()[source]#