python_c_extension/_disptools.c
/*!
 * Method to compute the Jacobian of a given displacement field.
 */
Method to compute the Jacobian of a given displacement field.
Method to compute the Jacobian of a given displacement field .
static PyObject *method_jacobian(PyObject *self, PyObject *args)
{
    FLOATING spacing[3];
    PyArrayObject *field = NULL, *jacobian = NULL;
    PyObject *spacing_tuple = NULL;
    (void) self;
    if (!PyArg_ParseTuple(args, PY_FMT_JACOBIAN, &spacing_tuple, &field, &jacobian)) {
        return NULL;
    }
    if (!field || !jacobian || !spacing_tuple) {
        return NULL;
    }
    if (read_triplet(spacing_tuple, spacing, 3, "spacing")) {
        return NULL;
    }
    const int nz = PyArray_DIM(jacobian, 0);
    const int ny = PyArray_DIM(jacobian, 1);
    const int nx = PyArray_DIM(jacobian, 2);
    FLOATING *field_data = (FLOATING*) PyArray_DATA(field);
    FLOATING *jacobian_data = (FLOATING*) PyArray_DATA(jacobian);
    jacobian_dynamic(nx, ny, nz, spacing[0], spacing[1], spacing[2], field_data, jacobian_data);
    return Py_None;
}
static PyObject * method_jacobian ( PyObject * self , PyObject * args ) { FLOATING spacing [ 3 ] ; PyArrayObject * field = NULL , * jacobian = NULL ; PyObject * spacing_tuple = NULL ; ( void ) self ; if ( ! PyArg_ParseTuple ( args , PY_FMT_JACOBIAN , & spacing_tuple , & field , & jacobian ) ) { return NULL ; } if ( ! field || ! jacobian || ! spacing_tuple ) { return NULL ; } if ( read_triplet ( spacing_tuple , spacing , 3 , " " ) ) { return NULL ; } const int nz = PyArray_DIM ( jacobian , 0 ) ; const int ny = PyArray_DIM ( jacobian , 1 ) ; const int nx = PyArray_DIM ( jacobian , 2 ) ; FLOATING * field_data = ( FLOATING * ) PyArray_DATA ( field ) ; FLOATING * jacobian_data = ( FLOATING * ) PyArray_DATA ( jacobian ) ; jacobian_dynamic ( nx , ny , nz , spacing [ 0 ] , spacing [ 1 ] , spacing [ 2 ] , field_data , jacobian_data ) ; return Py_None ; }
Method to compute the Jacobian of a given displacement field.
Method to compute the Jacobian of a given displacement field .
/* Parse arguments */ /* Error check */ /* Get the spacing */ /* Get the shape (the ITK index order is zyx)*/ /* Get the data pointers */ /* Call the library function to compute the Jacobian */