/* * $Id: spm_resels_vol.c 4453 2011-09-02 10:47:25Z guillaume $ * John Ashburner */ /* See Worsley et al. (1996), Human Brain Mapping 4:58-73 for a description of what it does. */ #include #include "mex.h" #include "spm_mapping.h" static void resel_fun(int *curr, int *prev, /* current and previous planes */ int m, int n, /* image dimensions */ int *P, /* # points */ int E[3], /* # edges */ int F[4], /* # faces */ int *C) /* # cubes */ { int p=0,ex=0,ey=0,ez=0,fxy=0,fxz=0,fyz=0,c=0; int i, j; for(i=1; i 1) { mexErrMsgTxt("Incorrect usage."); } map = get_maps(prhs[0], &nn); if (nn!=1) { free_maps(map, nn); mexErrMsgTxt("Bad image handle dimensions."); } if (!mxIsNumeric(prhs[1]) || mxIsComplex(prhs[1]) || !mxIsDouble(prhs[1])) { free_maps(map, 1); mexErrMsgTxt("Second argument must be numeric, real, full and double."); } if (mxGetM(prhs[1])*mxGetN(prhs[1]) != 3) { free_maps(map, nn); mexErrMsgTxt("Second argument must contain three elements."); } r[0] = 1.0/mxGetPr(prhs[1])[0]; r[1] = 1.0/mxGetPr(prhs[1])[1]; r[2] = 1.0/mxGetPr(prhs[1])[2]; plhs[0] = mxCreateDoubleMatrix(4,1,mxREAL); R = mxGetPr(plhs[0]); m = map->dim[0]; n = map->dim[1]; k = map->dim[2]; curr = (int *)mxCalloc((m+1)*(n+1),sizeof(int)); /* current plane */ prev = (int *)mxCalloc((m+1)*(n+1),sizeof(int)); /* previous plane */ img = (double *)mxCalloc((m+1)*(n+1),sizeof(double)); P = C = E[0] = E[1] = E[2] = F[0] = F[1] = F[2] = 0; for(i=0; i