-
Notifications
You must be signed in to change notification settings - Fork 5
/
BayesMex.c
46 lines (35 loc) · 1.26 KB
/
BayesMex.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/* ______________________________________________________________________
*
* Christian Gaser, Robert Dahnke
* Structural Brain Mapping Group (https://neuro-jena.github.io)
* Departments of Neurology and Psychiatry
* Jena University Hospital
* ______________________________________________________________________
* $Id$
*/
#include "mex.h"
#include "math.h"
#include "stdio.h"
void mexFunction( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] )
{
unsigned char *label, *priors, *prob;
double *src, *separations;
const int *dims;
int niters, niters_nu;
if (nrhs!=4)
mexErrMsgTxt("4 inputs required.");
else if (nlhs>2)
mexErrMsgTxt("Too many output arguments.");
if (!mxIsUint8(prhs[1]))
mexErrMsgTxt("Second argument must be uint8.");
src = (double*)mxGetPr(prhs[0]);
priors = (unsigned char*)mxGetPr(prhs[1]);
separations = (double*)mxGetPr(prhs[2]);
niters_nu = (int)mxGetScalar(prhs[3]);
dims = mxGetDimensions(prhs[1]);
plhs[0] = mxCreateNumericArray(3,dims,mxUINT8_CLASS,mxREAL);
label = (unsigned char *)mxGetPr(plhs[0]);
plhs[1] = mxCreateNumericArray(4,dims,mxUINT8_CLASS,mxREAL);
prob = (unsigned char *)mxGetPr(plhs[1]);
Bayes(src, label, priors, prob, separations, dims, niters_nu);
}