do { \
int idx_x1y1z1, idx_x2y1z1, idx_x1y2z1, idx_x2y2z1; \
int idx_x1y1z2, idx_x2y1z2, idx_x1y2z2, idx_x2y2z2; \
float m_x1y1z1, m_x2y1z1, m_x1y2z1, m_x2y2z1; \
float m_x1y1z2, m_x2y1z2, m_x1y2z2, m_x2y2z2; \
\
idx_x1y1z1 = mvf; \
idx_x2y1z1 = mvf+1; \
idx_x1y2z1 = mvf+moving->dim[0]; \
idx_x2y2z1 = mvf+moving->dim[0+1]; \
idx_x1y1z2 = mvf+moving->dim[1]*moving->dim[0]; \
idx_x2y1z2 = mvf+moving->dim[1]*moving->dim[0]+1; \
idx_x1y2z2 = mvf+moving->dim[1]*moving->dim[0]+moving->dim[0]; \
idx_x2y2z2 = mvf+moving->dim[1]*moving->dim[0]+moving->dim[0]+1; \
\
m_x1y1z1 = fx1 * fy1 * fz1 * m_img[idx_x1y1z1]; \
m_x2y1z1 = fx2 * fy1 * fz1 * m_img[idx_x2y1z1]; \
m_x1y2z1 = fx1 * fy2 * fz1 * m_img[idx_x1y2z1]; \
m_x2y2z1 = fx2 * fy2 * fz1 * m_img[idx_x2y2z1]; \
m_x1y1z2 = fx1 * fy1 * fz2 * m_img[idx_x1y1z2]; \
m_x2y1z2 = fx2 * fy1 * fz2 * m_img[idx_x2y1z2]; \
m_x1y2z2 = fx1 * fy2 * fz2 * m_img[idx_x1y2z2]; \
m_x2y2z2 = fx2 * fy2 * fz2 * m_img[idx_x2y2z2]; \
m_val = m_x1y1z1 + m_x2y1z1 + m_x1y2z1 + m_x2y2z1 \
+ m_x1y1z2 + m_x2y1z2 + m_x1y2z2 + m_x2y2z2; \
} while (0)