84#define VEC_COPY_16(to,from) {\
85 (to)[X_16] = (from)[X_16];\
86 (to)[Y_16] = (from)[Y_16];\
87 (to)[Z_16] = (from)[Z_16];\
90#define MALLOC_16(x,t) (t *)malloc((x)*sizeof(t))
92#define REALLOC_16(x,y,t) (t *)((x == NULL) ? malloc((y)*sizeof(t)) : realloc((x),(y)*sizeof(t)))
94#define ALLOC_CMATRIX_16(x,y) mne_cmatrix_16((x),(y))
96static void matrix_error_16(
int kind,
int nr,
int nc)
100 printf(
"Failed to allocate memory pointers for a %d x %d matrix\n",nr,nc);
102 printf(
"Failed to allocate memory for a %d x %d matrix\n",nr,nc);
104 printf(
"Allocation error for a %d x %d matrix\n",nr,nc);
105 if (
sizeof(
void *) == 4) {
106 printf(
"This is probably because you seem to be using a computer with 32-bit architecture.\n");
107 printf(
"Please consider moving to a 64-bit platform.");
109 printf(
"Cannot continue. Sorry.\n");
121 if (!m) matrix_error_16(1,nr,nc);
123 if (!whole) matrix_error_16(2,nr,nc);
130#define FREE_16(x) if ((char *)(x) != NULL) free((char *)(x))
131#define FREE_CMATRIX_16(m) mne_free_cmatrix_16((m))
143 for (
int i = 0; i < m; ++i)
144 for (
int j = 0; j < n; ++j)
145 to_mat[i][j] = from_mat(i,j);
156 for (
int i = 0; i < m; ++i)
157 for (
int j = 0; j < n; ++j)
158 to_mat[i][j] = from_mat(i,j);
189 float guessrad = 0.080;
190 std::unique_ptr<MNESourceSpace> guesses;
193 if (!guessname.isEmpty()) {
197 std::vector<std::unique_ptr<MNESourceSpace>> sp;
200 if (
static_cast<int>(sp.size()) != 1) {
201 printf(
"Incorrect number of source spaces in guess file");
204 printf(
"Read guesses from %s\n",guessname.toUtf8().constData());
205 guesses = std::move(sp[0]);
209 int free_inner_skull =
FALSE;
216 printf(
"Using inner skull surface from the BEM (%s)...\n",f->
bemname.toUtf8().constData());
220 else if (!guess_surfname.isEmpty()) {
221 printf(
"Reading inner skull surface from %s...\n",guess_surfname.toUtf8().data());
224 free_inner_skull =
TRUE;
229 if (free_inner_skull)
233 std::vector<std::unique_ptr<MNESourceSpace>> guesses_vec;
234 guesses_vec.push_back(std::move(guesses));
237 guesses = std::move(guesses_vec[0]);
241 this->
nguess = guesses->nuse;
243 for (k = 0, p = 0; k < guesses->np; k++)
244 if (guesses->inuse[k]) {
250 printf(
"Go through all guess source locations...");
252 for (k = 0; k < this->
nguess; k++)
263 for (k = 0; k < this->nguess; k++) {
268 printf(
"%f %f %f\n",sing[0],sing[1],sing[2]);
273 printf(
"[done %d sources]\n",p);
289 float guessrad = 0.080f;
290 std::unique_ptr<MNESourceSpace> guesses;
292 if (!guessname.isEmpty()) {
296 std::vector<std::unique_ptr<MNESourceSpace>> sp;
299 if (
static_cast<int>(sp.size()) != 1) {
300 qCritical(
"Incorrect number of source spaces in guess file");
303 printf(
"Read guesses from %s\n",guessname.toUtf8().constData());
304 guesses = std::move(sp[0]);
308 int free_inner_skull =
FALSE;
315 printf(
"Using inner skull surface from the BEM (%s)...\n",f->
bemname.toUtf8().constData());
319 else if (!guess_surfname.isEmpty()) {
320 printf(
"Reading inner skull surface from %s...\n",guess_surfname.toUtf8().data());
323 free_inner_skull =
TRUE;
328 if (free_inner_skull)
334 if (guesses->nuse == 0) {
335 qCritical(
"No active guess locations remaining.");
338 if (guess_save_name) {
339 printf(
"###################DEBUG writing source spaces not yet implemented.");
348 std::vector<std::unique_ptr<MNESourceSpace>> guesses_vec;
349 guesses_vec.push_back(std::move(guesses));
352 guesses = std::move(guesses_vec[0]);
356 this->
nguess = guesses->nuse;
358 for (k = 0, p = 0; k < guesses->np; k++)
359 if (guesses->inuse[k]) {
366 for (k = 0; k < this->
nguess; k++)
387 for (
int k = 0; k <
nguess; k++)
401 qCritical(
"Data missing in compute_guess_fields");
405 qCritical(
"Noise covariance missing in compute_guess_fields");
408 printf(
"Go through all guess source locations...");
414 for (
int k = 0; k < this->
nguess; k++) {
422 printf(
"%f %f %f\n",sing[0],sing[1],sing[2]);
426 printf(
"[done %d sources]\n",this->nguess);
FiffTag class declaration, which provides fiff tag I/O and processing methods.
FiffStream class declaration.
#define FIFFV_BEM_SURF_ID_BRAIN
MNESurface class declaration.
MNESourceSpace class declaration.
GuessData class declaration.
DipoleForward class declaration.
Dipole Fit Data class declaration.
#define VEC_COPY_16(to, from)
#define ALLOC_CMATRIX_16(x, y)
void fromFloatEigenMatrix_16(const Eigen::MatrixXf &from_mat, float **&to_mat, const int m, const int n)
void fromIntEigenMatrix_16(const Eigen::MatrixXi &from_mat, int **&to_mat, const int m, const int n)
float ** mne_cmatrix_16(int nr, int nc)
#define FREE_CMATRIX_16(m)
void mne_free_cmatrix_16(float **m)
Core MNE data structures (source spaces, source estimates, hemispheres).
FIFF file I/O and data structures (raw, epochs, evoked, covariance, forward).
Inverse source estimation (MNE, dSPM, sLORETA, dipole fitting).
Forward modelling (BEM, MEG/EEG lead fields).
static MNELIB::MNESurface * make_guesses(MNELIB::MNESurface *guess_surf, float guessrad, float *guess_r0, float grid, float exclude, float mindist)
Forward field computation function pointers and client data for MEG and EEG dipole fitting.
Dipole Fit Data implementation.
std::unique_ptr< FWDLIB::FwdBemModel > bem_model
dipoleFitFuncs mag_dipole_funcs
std::unique_ptr< MNELIB::MNECovMatrix > noise
dipoleFitFuncs sphere_funcs
std::unique_ptr< FIFFLIB::FiffCoordTrans > mri_head_t
static DipoleForward * dipole_forward_one(DipoleFitData *d, float *rd, DipoleForward *old)
Stores forward field matrices and source space data for magnetic dipole fitting.
bool compute_guess_fields(DipoleFitData *f)
DipoleForward ** guess_fwd
This defines a source space.
static int read_source_spaces(const QString &name, std::vector< std::unique_ptr< MNESourceSpace > > &spaces)
static int transform_source_spaces_to(int coord_frame, const FIFFLIB::FiffCoordTrans &t, std::vector< std::unique_ptr< MNESourceSpace > > &spaces)
static MNESurface * read_bem_surface(const QString &name, int which, int add_geometry, float *sigmap)
Eigen::MatrixX3f apply_inverse_trans(const Eigen::MatrixX3f &rr, bool do_move=true) const
static QString frame_name(int frame)