57 #define FREE_33(x) if ((char *)(x) != NULL) free((char *)(x))
59 #define MALLOC_33(x,t) (t *)malloc((x)*sizeof(t))
65 using namespace Eigen;
66 using namespace FIFFLIB;
67 using namespace MNELIB;
73 MneRawInfo::MneRawInfo()
79 MneRawInfo::~MneRawInfo()
81 this->filename.clear();
97 while (tmp_node->type != FIFFB_MEAS) {
98 if (tmp_node->parent == NULL)
100 tmp_node = tmp_node->parent;
116 while (tmp_node->type != FIFFB_MEAS) {
117 if (tmp_node->parent == NULL)
119 tmp_node = tmp_node->parent;
121 for (
k = 0;
k < tmp_node->nchild();
k++)
122 if (tmp_node->children[
k]->type == FIFFB_MEAS_INFO)
123 return (tmp_node->children[
k]);
135 QList<FiffDirNode::SPtr> temp;
136 temp = node->dir_tree_find(FIFFB_RAW_DATA);
137 if (temp.size() == 0) {
138 temp = node->dir_tree_find(FIFFB_CONTINUOUS_DATA);
153 QList<FiffDirNode::SPtr> temp;
169 QList<FiffChInfo>& chp,
181 QList<FiffChInfo> ch;
186 QList<FiffDirNode::SPtr> hpi;
188 fiff_int_t kind, pos;
198 if (!(meas = find_meas(node))) {
200 printf (
"Meas. block not found!");
205 if (!(node = find_meas_info(node))) {
207 printf (
"Meas. info not found!");
214 if (!meas->id.isEmpty()) {
217 (*id)->version = meas->id.version;
218 (*id)->machid[0] = meas->id.machid[0];
219 (*id)->machid[1] = meas->id.machid[1];
220 (*id)->time = meas->id.time;
227 for (
k = 0;
k < node->nent();
k++) {
228 kind = node->dir[
k]->kind;
229 pos = node->dir[
k]->pos;
236 if (!stream->read_tag(t_pTag,pos))
238 *nchan = *t_pTag->toInt();
240 for (j = 0; j < *nchan; j++) {
244 to_find = to_find + *nchan - 1;
251 if (!stream->read_tag(t_pTag,pos))
253 *sfreq = *t_pTag->toFloat();
261 if (!stream->read_tag(t_pTag,pos))
263 *lowpass = *t_pTag->toFloat();
271 if (!stream->read_tag(t_pTag,pos))
273 *highpass = *t_pTag->toFloat();
281 if (!stream->read_tag(t_pTag,pos))
284 this_ch = t_pTag->toChInfo();
286 qCritical (
"FIFF_CH_INFO : scan # out of range!");
290 ch[this_ch.
scanNo-1] = this_ch;
297 if (!stream->read_tag(t_pTag,pos))
300 FREE_33(*start_time);
302 *start_time = (
fiffTime)t_pTag->data();
310 if (!stream->read_tag(t_pTag,pos))
314 t = FiffCoordTransOld::read_helper( t_pTag );
318 if (t->
from == FIFFV_COORD_DEVICE && t->
to == FIFFV_COORD_HEAD) {
332 hpi = node->dir_tree_find(FIFFB_HPI_RESULT);
336 if (hpi.size() > 0 && *trans == NULL)
337 for (
k = 0;
k < hpi[0]->nent();
k++)
342 if (!stream->read_tag(t_pTag,hpi[0]->dir[
k]->pos))
344 t = FiffCoordTransOld::read_helper( t_pTag );
348 if (t->
from == FIFFV_COORD_DEVICE && t->
to == FIFFV_COORD_HEAD) {
356 *lowpass = *sfreq/2.0;
365 printf (
"Not all essential tags were found!");
380 int MneRawInfo::mne_load_raw_info(
const QString& name,
int allow_maxshield,
MneRawInfo **infop)
391 QList<FiffChInfo> chs;
394 QList<FiffDirEntry::SPtr> rawDir;
404 int maxshield_data = FALSE;
412 raw = find_raw(stream->dirtree());
413 if (raw->isEmpty()) {
414 if (allow_maxshield) {
415 raw = find_maxshield(stream->dirtree());
416 if (raw->isEmpty()) {
417 printf(
"No raw data in this file.");
420 maxshield_data = TRUE;
423 printf(
"No raw data in this file.");
430 if (get_meas_info (stream,
482 for (
k = 0;
k < raw->nent();
k++) {
487 if (raw->dir[
k]->type == FIFFT_DAU_PACK16 || raw->dir[
k]->type == FIFFT_SHORT)
488 info->
buf_size = raw->dir[
k]->size/(nchan*
sizeof(fiff_short_t));
489 else if (raw->dir[
k]->type == FIFFT_FLOAT)
490 info->
buf_size = raw->dir[
k]->size/(nchan*
sizeof(fiff_float_t));
491 else if (raw->dir[
k]->type == FIFFT_INT)
492 info->
buf_size = raw->dir[
k]->size/(nchan*
sizeof(fiff_int_t));
494 printf(
"We are not prepared to handle raw data type: %d",raw->dir[
k]->type);
501 printf(
"No raw data buffers available.");
505 info->
ndir = raw->nent();
510 if (res != FIFF_OK) {