# dipy_math

## Synopsis

Perform mathematical operations on volume input files.

This workflow allows the user to perform mathematical operations on multiple input files. e.g. to add two volumes together, subtract one: `dipy_math "vol1 + vol2 - vol3" t1.nii.gz t1_a.nii.gz t1_b.nii.gz` The input files must be in Nifti format and have the same shape.

## Usage

    dipy_math [OPTIONS] operation input_files

## Input Parameters

- `operation`

  Mathematical operation to perform. supported operators are:

    - Bitwise operators (and, or, not, xor): `&, |, ~, ^`

    - Comparison operators: `<, <=, ==, !=, >=, >`

    - Unary arithmetic operators: `-`

    - Binary arithmetic operators: `+, -, *, /, **, <<, >>`

  Supported functions are:

    - `where(bool, number1, number2) -> number`: number1 if the bool condition is true, number2 otherwise.

    - `{sin,cos,tan}(float|complex) -> float|complex`: trigonometric sine, cosine or tangent.

    - `{arcsin,arccos,arctan}(float|complex) -> float|complex`: trigonometric inverse sine, cosine or tangent.

    - `arctan2(float1, float2) -> float`: trigonometric inverse tangent of float1/float2.

    - `{sinh,cosh,tanh}(float|complex) -> float|complex`: hyperbolic sine, cosine or tangent.

    - `{arcsinh,arccosh,arctanh}(float|complex) -> float|complex`: hyperbolic inverse sine, cosine or tangent.

    - `{log,log10,log1p}(float|complex) -> float|complex`: natural, base-10 and log(1+x) logarithms.

    - `{exp,expm1}(float|complex) -> float|complex`: exponential and exponential minus one.

    - `sqrt(float|complex) -> float|complex`: square root.

    - `abs(float|complex) -> float|complex`: absolute value.

    - `conj(complex) -> complex`: conjugate value.

    - `{real,imag}(complex) -> float`: real or imaginary part of complex.

    - `complex(float, float) -> complex`: complex from real and imaginary parts.

    - `contains(np.str, np.str) -> bool`: returns True for every string in op1 that contains op2.

- `input_files`

  Any number of Nifti1 files

## General Options

- `--dtype`

  Data type of the resulting file. (default: None)

## Output Options

- `--out_dir`

  Output directory (default: current directory)

- `--out_file`

  Name of the resulting file to be saved. (default: math_out.nii.gz)

## References

Garyfallidis, E., M. Brett, B. Amirbekian, A. Rokem, S. Van Der Walt, M. Descoteaux, and I. Nimmo-Smith. Dipy, a library for the analysis of diffusion MRI data. Frontiers in Neuroinformatics, 1-18, 2014.