.. _scil_volume_math: scil_volume_math ================ :: usage: __main__.py [-h] [--data_type DATA_TYPE] [--exclude_background] [-v [{DEBUG,INFO,WARNING,ERROR}]] [-f] {lower_threshold,upper_threshold,lower_threshold_eq,upper_threshold_eq,lower_threshold_otsu,upper_threshold_otsu,lower_clip,upper_clip,absolute_value,round,ceil,floor,normalize_sum,normalize_max,log_10,log_e,convert,invert,addition,subtraction,multiplication,division,maximum,mean,std,correlation,union,intersection,difference,concatenate,dilation,erosion,closing,opening,blur} in_args [in_args ...] out_image Performs an operation on a list of images. The supported operations are listed below. This script is loading all images in memory, will often crash after a few hundred images. Some operations such as multiplication or addition accept float value as parameters instead of images. > scil_volume_math multiplication img.nii.gz 10 mult_10.nii.gz lower_threshold: IMG THRESHOLD All values below the threshold will be set to zero. All values above the threshold will be set to one. upper_threshold: IMG THRESHOLD All values below the threshold will be set to one. All values above the threshold will be set to zero. Equivalent to lower_threshold followed by an inversion. lower_threshold_eq: IMG THRESHOLD All values below the threshold will be set to zero. All values above or equal the threshold will be set to one. upper_threshold_eq: IMG THRESHOLD All values below or equal the threshold will be set to one. All values above the threshold will be set to zero. Equivalent to lower_threshold followed by an inversion. lower_threshold_otsu: IMG All values below or equal to the Otsu threshold will be set to zero. All values above the Otsu threshold will be set to one. (Otsu's method is an algorithm to perform automatic image thresholding of the background.) upper_threshold_otsu: IMG All values below the Otsu threshold will be set to one. All values above or equal to the Otsu threshold will be set to zero. Equivalent to lower_threshold_otsu followed by an inversion. lower_clip: IMG THRESHOLD All values below the threshold will be set to threshold. upper_clip: IMG THRESHOLD All values above the threshold will be set to threshold. absolute_value: IMG All negative values will become positive. round: IMG Round all decimal values to the closest integer. ceil: IMG Ceil all decimal values to the next integer. floor: IMG Floor all decimal values to the previous integer. normalize_sum: IMG Normalize the image so the sum of all values is one. normalize_max: IMG Normalize the image so the maximum value is one. log_10: IMG Apply a log (base 10) to all non zeros values of an image. log_e: IMG Apply a natural log to all non zeros values of an image. convert: IMG Perform no operation, but simply change the data type. invert: IMG Operation on binary image to interchange 0s and 1s in a binary mask. addition: IMGs Add multiple images together. subtraction: IMG_1 IMG_2 Subtract first image by the second (IMG_1 - IMG_2). multiplication: IMGs Multiply multiple images together (danger of underflow and overflow) division: IMG_1 IMG_2 Divide first image by the second (danger of underflow and overflow) Ignore zeros values, excluded from the operation. maximum: IMGs Compute the voxel-wise maximum across images. mean: IMGs Compute the mean of images. If a single 4D image is provided, average along the last dimension. std: IMGs Compute the standard deviation average of multiple images. If a single 4D image is provided, compute the STD along the last dimension. correlation: IMGs Computes the correlation of the 3x3x3 neighborhood of each voxel, for all pair of input images. The final image is the average correlation (through all pairs). For a given pair of images - Background is considered as 0. May lead to very high correlations close to the border of the background regions, or very poor ones if the background in both images differ. - Images are zero-padded. For the same reason as higher, may lead to very high correlations if you have data close to the border of the image. - NaN values (if a voxel's neighborhood is entirely uniform; std 0) are replaced by - 0 if at least one neighborhood was entirely containing background. - 1 if the voxel's neighborhoods are uniform in both images - 0 if the voxel's neighborhoods is uniform in one image, but not the other. UPDATE AS OF VERSION 2.0: Random noise was previously added in the process to help avoid NaN values. Now replaced by either 0 or 1 as explained above. union: IMGs Operation on binary image to keep voxels, that are non-zero, in at least one file. intersection: IMGs Operation on binary image to keep the voxels, that are non-zero, are present in all files. difference: IMG_1 IMG_2 Operation on binary image to keep voxels from the first file that are not in the second file (non-zeros). concatenate: IMGs Concatenate a list of 3D and 4D images into a single 4D image. dilation: IMG, VALUE Binary morphological operation to spatially extend the values of an image to their neighbors. VALUE is in voxels: an integer > 0. erosion: IMG, VALUE Binary morphological operation to spatially shrink the volume contained in a binary image. VALUE is in voxels: an integer > 0. closing: IMG, VALUE Binary morphological operation, dilation followed by an erosion. opening: IMG, VALUE Binary morphological operation, erosion followed by a dilation. blur: IMG, VALUE Apply a gaussian blur to a single image. VALUE is sigma, the standard deviation of the Gaussian kernel. positional arguments: {lower_threshold,upper_threshold,lower_threshold_eq,upper_threshold_eq,lower_threshold_otsu,upper_threshold_otsu,lower_clip,upper_clip,absolute_value,round,ceil,floor,normalize_sum,normalize_max,log_10,log_e,convert,invert,addition,subtraction,multiplication,division,maximum,mean,std,correlation,union,intersection,difference,concatenate,dilation,erosion,closing,opening,blur} The type of operation to be performed on the images. in_args The list of image files or parameters. Refer to each operation's documentation of the expected arguments. out_image Output image path. options: -h, --help show this help message and exit --data_type DATA_TYPE Data type of the output image. Use the format: uint8, int16, int/float32, int/float64. --exclude_background Does not affect the background of the original images. -v [{DEBUG,INFO,WARNING,ERROR}] Produces verbose output depending on the provided level. Default level is warning, default when using -v is info. -f Force overwriting of the output files. 2.2.2