示例#1
0
/*{{{  get_mfxepoch_exit(transform_info_ptr tinfo)*/
METHODDEF void
get_mfxepoch_exit(transform_info_ptr tinfo) {
 struct get_mfxepoch_storage *local_arg=(struct get_mfxepoch_storage *)tinfo->methods->local_storage;
 mfx_close(local_arg->fileptr);
 local_arg->fileptr=NULL;
 tinfo->methods->init_done=FALSE;
}
示例#2
0
static int ml_mfx_close(lua_State* l) {
	checkargs(0, "mfx.close");

	mfx_close();

	return 0;
}
示例#3
0
文件: write_mfx.c 项目: berndf/avg_q
/*{{{  write_mfx_exit(transform_info_ptr tinfo) {*/
METHODDEF void
write_mfx_exit(transform_info_ptr tinfo) {
 struct write_mfx_storage *local_arg=(struct write_mfx_storage *)tinfo->methods->local_storage;
 mfx_close(local_arg->mfxfile);
 local_arg->mfxfile=NULL;
 tinfo->methods->init_done=FALSE;
}
示例#4
0
文件: write_mfx.c 项目: berndf/avg_q
/*{{{  write_mfx_init(transform_info_ptr tinfo) {*/
METHODDEF void
write_mfx_init(transform_info_ptr tinfo) {
 struct write_mfx_storage *local_arg=(struct write_mfx_storage *)tinfo->methods->local_storage;
 transform_argument *args=tinfo->methods->arguments;
 int NoOfChannels=tinfo->nr_of_channels;
 int channel;

 local_arg->mfxfile=mfx_open(args[ARGS_OFILE].arg.s, "r+b", MFX_DATATYPE);
 if (!args[ARGS_APPEND].is_set || local_arg->mfxfile==NULL) {   /* target does not exist*/
  /*{{{  Create file*/
  if (local_arg->mfxfile!=NULL) mfx_close(local_arg->mfxfile);
  if ((local_arg->mfxfile=mfx_create(args[ARGS_OFILE].arg.s, (args[ARGS_CREATE_TRIGGERCHANNEL].is_set ? NoOfChannels+1 : NoOfChannels), MFX_DATATYPE))==NULL) {
   ERREXIT1(tinfo->emethods, "write_mfx_init: Can't open file >%s<\n", MSGPARM(args[ARGS_OFILE].arg.s));
  }
  if (mfx_describefile(local_arg->mfxfile, tinfo->comment, 1.0/tinfo->sfreq, (args[ARGS_CONTINUOUS].is_set ? 0 : tinfo->nr_of_points), -tinfo->beforetrig/tinfo->sfreq)!=MFX_NOERR) {
   ERREXIT1(tinfo->emethods, "write_mfx_init: mfx_describefile error %s\n", MSGPARM(mfx_errors[mfx_lasterr]));
  }
  for (channel=0; channel<NoOfChannels; channel++) {
   double * const pos_mfx=local_arg->mfxfile->channelheaders[channel].position;
   double * const pos_tinfo=tinfo->probepos+3*channel;
   int i;
   const Bool is_electric=(*tinfo->channelnames[channel]!='M');
   if (mfx_describechannel(local_arg->mfxfile, channel+1, tinfo->channelnames[channel], (is_electric ? "uV" : "fT"),
    (is_electric ? DT_EEGTYPE : DT_MEGTYPE), SHRT_MIN/args[ARGS_CONVFACTOR].arg.d, SHRT_MAX/args[ARGS_CONVFACTOR].arg.d)!=MFX_NOERR) {
    ERREXIT1(tinfo->emethods, "write_mfx_init: mfx_describechannel error %s\n", MSGPARM(mfx_errors[mfx_lasterr]));
   }
   for (i=0; i<3; i++) {
    pos_mfx[i]=pos_tinfo[i];
   }
  }
  if (args[ARGS_CREATE_TRIGGERCHANNEL].is_set) {
   if (mfx_describechannel(local_arg->mfxfile, channel+1, "TRIGGER", "T", DT_TRIGGER, -32768.0, 32767.0)!=MFX_NOERR) {
    ERREXIT1(tinfo->emethods, "write_mfx_init: mfx_describechannel error %s\n", MSGPARM(mfx_errors[mfx_lasterr]));
   }
  }
  /*}}}  */
 } else {
  /*{{{  Append to file*/
  mfx_seek(local_arg->mfxfile, 0L, SEEK_END);
  /*}}}  */
 }
 if ((local_arg->mfxfile->selected_channels=(int *)malloc(NoOfChannels*sizeof(int)))==NULL) {
  ERREXIT(tinfo->emethods, "write_mfx_init: Error allocating selection array\n");
 }
 for (channel=0; channel<NoOfChannels; channel++) {
  local_arg->mfxfile->selected_channels[channel]=channel+1;
 }
 local_arg->mfxfile->nr_of_channels_selected=NoOfChannels;

 tinfo->methods->init_done=TRUE;
}
示例#5
0
void dgreed_close(void) {
    malka_states_end();
    malka_states_close();

    sprsheet_close();

    malka_close();

    mfx_close();
    particles_close();

    keyval_close();

    sound_close();
    video_close();
}
示例#6
0
int main(int argc, char **argv) {
 int i, c, errflag=0, seconds=FALSE;
 enum {
  JUSTPOINTS,
  MFXTRIGFORMAT,
  AVG_Q_FORMAT
 } trigfileformat=JUSTPOINTS;
 double position;

 /*{{{  Process commandline options*/
 while ((c=getopt(argc, argv, "stE"))!=EOF) {
  switch (c) {
   case 's':
    seconds=TRUE;
    break;
   case 't':
    trigfileformat=MFXTRIGFORMAT;
    break;
   case 'E':
    trigfileformat=AVG_Q_FORMAT;
    break;
   case '?':
   default:
    errflag++;
    continue;
  }
 }
 if (argc-optind!=2 || errflag>0) {
  fprintf(stderr, "This is mfxwritetrigs using the mfx library version\n%s\n\n"
        	  "Usage: %s [-s | -t] mfxfile triggerfile\n"
                  " triggerfile format:\n"
                  "  position_trig1 position_trig2 ...\n"
                  "  ... (negative values are blank placeholders)\n\n"
        	  " -s: Trigger positions specified in seconds, not points\n"
                  " -t: Reads mfxtriggers -v output\n"
                  " -E: Reads avg_q's trigger file format\n"
        	  , mfx_version, argv[0]);
  return 1;
 }
 /*}}}  */

 /*{{{  Prepare i/o files*/
 if ((myfile=mfx_open(argv[optind++], "r+b", MFX_SHORTS))==NULL) {
  fprintf(stderr, "mfx_open: %s\n", mfx_errors[mfx_lasterr]);
  return 2;
 }
 if ((trigfile=fopen(argv[optind], "r"))==NULL) {
  fprintf(stderr, "Can't open %s\n", argv[optind]);
  return 2;
 }
 if (mfx_cselect(myfile, "TRIGGER")==0) {
  fprintf(stderr, "mfx_cselect: %s\n", mfx_errors[mfx_lasterr]);
  return 3;
 }
 /*}}}  */

 switch(trigfileformat) {
  case JUSTPOINTS:
   while ((fgets(buffer, LENOFBUFFER, trigfile))!=NULL) {
    /*{{{  Process triggerfile line*/
    /* endnum is set to inbuf if strtod can't form any number from the string */
    for (i=1, inbuf=buffer; position=strtod(inbuf, &endnum), inbuf!=endnum; inbuf=endnum, i++) {
     if (position<0) continue;
     write1trig(position, i, seconds);
    }
    /*}}}  */
   }
   break;
  case MFXTRIGFORMAT:
   while ((fgets(buffer, LENOFBUFFER, trigfile))!=NULL) {
    /*{{{  Process triggerfile line*/
    if (*buffer=='#') continue;	/* Line commented out */
    /*{{{  Read position value*/
    if ((inbuf=strstr(buffer, POS_START))==NULL) continue;
    position=strtod(inbuf+strlen(POS_START), &endnum);
    if (inbuf==endnum) {
     fprintf(stderr, "Can't read position on line:\n%s", buffer);
     continue;
    }
    /*}}}  */
    /*{{{  Read trigcode value*/
    if ((inbuf=strstr(buffer, CODE_START))==NULL) continue;
    i=strtod(inbuf+strlen(CODE_START), &endnum);
    if (inbuf==endnum) {
     fprintf(stderr, "Can't read trigger code on line:\n%s", buffer);
     continue;
    }
    /*}}}  */
    write1trig(position, i, FALSE);
    /*}}}  */
   }
   break;
  case AVG_Q_FORMAT: {
   float const sfreq= 1.0/myfile->fileheader.sample_period;
   long trigpoint;
   while((i=read_trigger_from_trigfile(trigfile, sfreq, &trigpoint))!=0) {
    write1trig((double)trigpoint, i, FALSE);
   }
   }
   break;
 }

 fclose(trigfile);
 mfx_close(myfile);
 return 0;
}