./PaxHeaders.7921/edfbrowser_157_source 0000644 0000000 0000000 00000000132 12646460742 014746 x ustar 00 30 mtime=1452958178.269246659
30 atime=1452958178.221246821
30 ctime=1452958178.269246659
edfbrowser_157_source/ 0000755 0001750 0000144 00000000000 12646460742 015227 5 ustar 00guv users 0000000 0000000 edfbrowser_157_source/PaxHeaders.7921/z_ratio_filter.cpp 0000644 0000000 0000000 00000000132 12646460742 020406 x ustar 00 30 mtime=1452958178.249246726
30 atime=1452958178.249246726
30 ctime=1452958178.249246726
edfbrowser_157_source/z_ratio_filter.cpp 0000644 0001750 0000144 00000013634 12646460742 020756 0 ustar 00guv users 0000000 0000000 /*
***************************************************************************
*
* Author: Teunis van Beelen
*
* Copyright (C) 2012, 2013, 2014, 2015, 2016 Teunis van Beelen
*
* Email: teuniz@gmail.com
*
***************************************************************************
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
***************************************************************************
*/
#include "z_ratio_filter.h"
#define ZRATIO_EPOCH_LEN 2
#define ZRATIO_F1 3.0
#define ZRATIO_F3 12.0
#define ZRATIO_F4 25.0
struct zratio_filter_settings * create_zratio_filter(int smp_per_record, long long long_data_record_duration, double crossoverf, double bitval)
{
struct zratio_filter_settings * settings;
settings = (struct zratio_filter_settings *)calloc(1, sizeof(struct zratio_filter_settings));
if(settings == NULL)
{
return(NULL);
}
settings->crossoverfreq = crossoverf;
settings->bitvalue = bitval;
settings->dftblocksize = ((long long)smp_per_record * (ZRATIO_EPOCH_LEN * TIME_DIMENSION)) / long_data_record_duration;
if(settings->dftblocksize < (ZRATIO_EPOCH_LEN * 100))
{
free(settings);
return(NULL);
}
settings->samplefreq = (double)smp_per_record / ((double)long_data_record_duration / TIME_DIMENSION);
if(settings->samplefreq < 99.9999999)
{
free(settings);
return(NULL);
}
settings->fft_outputbufsize = settings->dftblocksize / 2;
settings->freqstep = settings->samplefreq / (double)settings->dftblocksize;
if(settings->freqstep > 1.0001)
{
free(settings);
return(NULL);
}
settings->f2 = settings->crossoverfreq / settings->freqstep;
settings->f1 = ZRATIO_F1 / settings->freqstep;
settings->f3 = ZRATIO_F3 / settings->freqstep;
settings->f4 = ZRATIO_F4 / settings->freqstep;
settings->fft_inputbuf = (double *)malloc(sizeof(double) * settings->dftblocksize);
if(settings->fft_inputbuf == NULL)
{
free(settings);
return(NULL);
}
settings->fft_inputbuf_bu = (double *)malloc(sizeof(double) * settings->dftblocksize);
if(settings->fft_inputbuf_bu == NULL)
{
free(settings->fft_inputbuf);
free(settings);
return(NULL);
}
settings->fft_outputbuf = (double *)calloc(1, sizeof(double) * settings->fft_outputbufsize);
if(settings->fft_outputbuf == NULL)
{
free(settings->fft_inputbuf);
free(settings->fft_inputbuf_bu);
free(settings);
return(NULL);
}
settings->kiss_fftbuf = (kiss_fft_cpx *)malloc((settings->fft_outputbufsize + 1) * sizeof(kiss_fft_cpx));
if(settings->kiss_fftbuf == NULL)
{
free(settings->fft_inputbuf);
free(settings->fft_inputbuf_bu);
free(settings->fft_outputbuf);
free(settings);
return(NULL);
}
settings->cfg = kiss_fftr_alloc(settings->dftblocksize, 0, NULL, NULL);
settings->smpls_in_inputbuf = 0;
settings->zratio_value = 0.0;
return(settings);
}
double run_zratio_filter(double new_sample, struct zratio_filter_settings *settings)
{
int i;
double power_delta,
power_theta,
power_alpha,
power_beta,
power_total;
settings->fft_inputbuf[settings->smpls_in_inputbuf++] = new_sample;
if(settings->smpls_in_inputbuf >= settings->dftblocksize)
{
settings->smpls_in_inputbuf = 0;
kiss_fftr(settings->cfg, settings->fft_inputbuf, settings->kiss_fftbuf);
power_delta = 0.0;
power_theta = 0.0;
power_alpha = 0.0;
power_beta = 0.0;
power_total = 0.0;
for(i=0; ifft_outputbufsize; i++)
{
settings->fft_outputbuf[i] = (((settings->kiss_fftbuf[i].r * settings->kiss_fftbuf[i].r) + (settings->kiss_fftbuf[i].i * settings->kiss_fftbuf[i].i)) / settings->fft_outputbufsize);
if((i > 0) && (i < settings->f1))
{
power_delta += settings->fft_outputbuf[i];
}
if((i >= settings->f1) && (i < settings->f2))
{
power_theta += settings->fft_outputbuf[i];
}
if((i >= settings->f2) && (i < settings->f3))
{
power_alpha += settings->fft_outputbuf[i];
}
if((i >= settings->f3) && (i <= settings->f4))
{
power_beta += settings->fft_outputbuf[i];
}
power_total += settings->fft_outputbuf[i];
}
if(power_total <= 0.0)
{
settings->zratio_value = 0.0;
}
else
{
settings->zratio_value = ((power_delta + power_theta) - (power_alpha + power_beta)) / power_total;
}
}
return(settings->zratio_value / settings->bitvalue);
}
void zratio_filter_save_buf(struct zratio_filter_settings *settings)
{
settings->smpls_in_inputbuf_bu = settings->smpls_in_inputbuf;
settings->zratio_value_bu = settings->zratio_value;
memcpy(settings->fft_inputbuf_bu, settings->fft_inputbuf, settings->dftblocksize);
}
void zratio_filter_restore_buf(struct zratio_filter_settings *settings)
{
settings->smpls_in_inputbuf = settings->smpls_in_inputbuf_bu;
settings->zratio_value = settings->zratio_value_bu;
memcpy(settings->fft_inputbuf, settings->fft_inputbuf_bu, settings->dftblocksize);
}
void free_zratio_filter(struct zratio_filter_settings *settings)
{
free(settings->fft_inputbuf);
free(settings->fft_inputbuf_bu);
free(settings->fft_outputbuf);
free(settings->kiss_fftbuf);
free(settings->cfg);
free(settings);
}
void reset_zratio_filter(struct zratio_filter_settings *settings)
{
settings->smpls_in_inputbuf = 0;
settings->zratio_value = 0.0;
}
edfbrowser_157_source/PaxHeaders.7921/signal_chooser.h 0000644 0000000 0000000 00000000132 12646460742 020036 x ustar 00 30 mtime=1452958178.240246757
30 atime=1452958178.240246757
30 ctime=1452958178.240246757
edfbrowser_157_source/signal_chooser.h 0000644 0001750 0000144 00000004150 12646460742 020377 0 ustar 00guv users 0000000 0000000 /*
***************************************************************************
*
* Author: Teunis van Beelen
*
* Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016 Teunis van Beelen
*
* Email: teuniz@gmail.com
*
***************************************************************************
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
***************************************************************************
*/
#ifndef SIGNAL_CHOOSERFORM1_H
#define SIGNAL_CHOOSERFORM1_H
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include "global.h"
#include "mainwindow.h"
#include "viewcurve.h"
#include "adjustfiltersettings.h"
#include "ecg_filter.h"
#include "utils.h"
class UI_Mainwindow;
class ViewCurve;
class UI_SignalChooser : public QObject
{
Q_OBJECT
public:
UI_SignalChooser(QWidget *, int, int *sgnl_nr = NULL);
UI_Mainwindow *mainwindow;
private:
QDialog *signalchooser_dialog;
QPushButton *CloseButton,
*UpButton,
*DownButton,
*DeleteButton,
*InvertButton;
QListWidget *list;
int task,
*signal_nr;
void strip_types_from_label(char *);
void load_signalcomps(void);
int get_selectionlist(int *);
private slots:
void call_sidemenu(QListWidgetItem *);
void signalUp();
void signalDown();
void signalDelete();
void signalInvert();
};
#endif // SIGNAL_CHOOSERFORM1_H
edfbrowser_157_source/PaxHeaders.7921/biox2edf.h 0000644 0000000 0000000 00000000132 12646460742 016541 x ustar 00 30 mtime=1452958178.238246763
30 atime=1452958178.238246763
30 ctime=1452958178.238246763
edfbrowser_157_source/biox2edf.h 0000644 0001750 0000144 00000003532 12646460742 017105 0 ustar 00guv users 0000000 0000000 /*
***************************************************************************
*
* Author: Teunis van Beelen
*
* Copyright (C) 2015, 2016 Teunis van Beelen
*
* Email: teuniz@gmail.com
*
***************************************************************************
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
***************************************************************************
*/
#ifndef UI_BIOX2EDFFORM_H
#define UI_BIOX2EDFFORM_H
#include
#include
#include
#include
#include
#include
#include
#include
#include
#if QT_VERSION < 0x050000
#include
#include
#endif
#include
#include
#include
#include
#include
#include
#include "global.h"
#include "utils.h"
#include "edflib.h"
#include "utc_date_time.h"
class UI_BIOX2EDFwindow : public QObject
{
Q_OBJECT
public:
UI_BIOX2EDFwindow(char *recent_dir=NULL, char *save_dir=NULL);
private:
QPushButton *pushButton1,
*pushButton2;
QTextEdit *textEdit1;
QDialog *myobjectDialog;
char *recent_opendir,
*recent_savedir;
private slots:
void SelectFileButton();
};
#endif
edfbrowser_157_source/PaxHeaders.7921/edflib.h 0000644 0000000 0000000 00000000132 12646460742 016264 x ustar 00 30 mtime=1452958178.238246763
30 atime=1452958178.238246763
30 ctime=1452958178.238246763
edfbrowser_157_source/edflib.h 0000644 0001750 0000144 00000076437 12646460742 016646 0 ustar 00guv users 0000000 0000000 /*
*****************************************************************************
*
* Copyright (c) 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016 Teunis van Beelen
* All rights reserved.
*
* email: teuniz@gmail.com
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY Teunis van Beelen ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL Teunis van Beelen BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*****************************************************************************
*/
/* compile with options "-D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE" */
#ifndef EDFLIB_INCLUDED
#define EDFLIB_INCLUDED
#include
#include
#include
#include
#define EDFLIB_TIME_DIMENSION (10000000LL)
#define EDFLIB_MAXSIGNALS 512
#define EDFLIB_MAX_ANNOTATION_LEN 512
#define EDFSEEK_SET 0
#define EDFSEEK_CUR 1
#define EDFSEEK_END 2
/* the following defines are used in the member "filetype" of the edf_hdr_struct */
/* and as return value for the function edfopen_file_readonly() */
#define EDFLIB_FILETYPE_EDF 0
#define EDFLIB_FILETYPE_EDFPLUS 1
#define EDFLIB_FILETYPE_BDF 2
#define EDFLIB_FILETYPE_BDFPLUS 3
#define EDFLIB_MALLOC_ERROR -1
#define EDFLIB_NO_SUCH_FILE_OR_DIRECTORY -2
#define EDFLIB_FILE_CONTAINS_FORMAT_ERRORS -3
#define EDFLIB_MAXFILES_REACHED -4
#define EDFLIB_FILE_READ_ERROR -5
#define EDFLIB_FILE_ALREADY_OPENED -6
#define EDFLIB_FILETYPE_ERROR -7
#define EDFLIB_FILE_WRITE_ERROR -8
#define EDFLIB_NUMBER_OF_SIGNALS_INVALID -9
#define EDFLIB_FILE_IS_DISCONTINUOUS -10
#define EDFLIB_INVALID_READ_ANNOTS_VALUE -11
/* values for annotations */
#define EDFLIB_DO_NOT_READ_ANNOTATIONS 0
#define EDFLIB_READ_ANNOTATIONS 1
#define EDFLIB_READ_ALL_ANNOTATIONS 2
/* the following defines are possible errors returned by edfopen_file_writeonly() */
#define EDFLIB_NO_SIGNALS -20
#define EDFLIB_TOO_MANY_SIGNALS -21
#define EDFLIB_NO_SAMPLES_IN_RECORD -22
#define EDFLIB_DIGMIN_IS_DIGMAX -23
#define EDFLIB_DIGMAX_LOWER_THAN_DIGMIN -24
#define EDFLIB_PHYSMIN_IS_PHYSMAX -25
#ifdef __cplusplus
extern "C" {
#endif
/* For more info about the EDF and EDF+ format, visit: http://edfplus.info/specs/ */
/* For more info about the BDF and BDF+ format, visit: http://www.teuniz.net/edfbrowser/bdfplus%20format%20description.html */
struct edf_param_struct{ /* this structure contains all the relevant EDF-signal parameters of one signal */
char label[17]; /* label (name) of the signal, null-terminated string */
long long smp_in_file; /* number of samples of this signal in the file */
double phys_max; /* physical maximum, usually the maximum input of the ADC */
double phys_min; /* physical minimum, usually the minimum input of the ADC */
int dig_max; /* digital maximum, usually the maximum output of the ADC, can not not be higher than 32767 for EDF or 8388607 for BDF */
int dig_min; /* digital minimum, usually the minimum output of the ADC, can not not be lower than -32768 for EDF or -8388608 for BDF */
int smp_in_datarecord; /* number of samples of this signal in a datarecord */
char physdimension[9]; /* physical dimension (uV, bpm, mA, etc.), null-terminated string */
char prefilter[81]; /* null-terminated string */
char transducer[81]; /* null-terminated string */
};
struct edf_annotation_struct{ /* this structure is used for annotations */
long long onset; /* onset time of the event, expressed in units of 100 nanoSeconds and relative to the starttime in the header */
char duration[16]; /* duration time, this is a null-terminated ASCII text-string */
char annotation[EDFLIB_MAX_ANNOTATION_LEN + 1]; /* description of the event in UTF-8, this is a null terminated string */
};
struct edf_hdr_struct{ /* this structure contains all the relevant EDF header info and will be filled when calling the function edf_open_file_readonly() */
int handle; /* a handle (identifier) used to distinguish the different files */
int filetype; /* 0: EDF, 1: EDFplus, 2: BDF, 3: BDFplus, a negative number means an error */
int edfsignals; /* number of EDF signals in the file, annotation channels are NOT included */
long long file_duration; /* duration of the file expressed in units of 100 nanoSeconds */
int startdate_day;
int startdate_month;
int startdate_year;
long long starttime_subsecond; /* starttime offset expressed in units of 100 nanoSeconds. Is always less than 10000000 (one second). Only used by EDFplus and BDFplus */
int starttime_second;
int starttime_minute;
int starttime_hour;
char patient[81]; /* null-terminated string, contains patientfield of header, is always empty when filetype is EDFPLUS or BDFPLUS */
char recording[81]; /* null-terminated string, contains recordingfield of header, is always empty when filetype is EDFPLUS or BDFPLUS */
char patientcode[81]; /* null-terminated string, is always empty when filetype is EDF or BDF */
char gender[16]; /* null-terminated string, is always empty when filetype is EDF or BDF */
char birthdate[16]; /* null-terminated string, is always empty when filetype is EDF or BDF */
char patient_name[81]; /* null-terminated string, is always empty when filetype is EDF or BDF */
char patient_additional[81]; /* null-terminated string, is always empty when filetype is EDF or BDF */
char admincode[81]; /* null-terminated string, is always empty when filetype is EDF or BDF */
char technician[81]; /* null-terminated string, is always empty when filetype is EDF or BDF */
char equipment[81]; /* null-terminated string, is always empty when filetype is EDF or BDF */
char recording_additional[81]; /* null-terminated string, is always empty when filetype is EDF or BDF */
long long datarecord_duration; /* duration of a datarecord expressed in units of 100 nanoSeconds */
long long datarecords_in_file; /* number of datarecords in the file */
long long annotations_in_file; /* number of annotations in the file */
struct edf_param_struct signalparam[EDFLIB_MAXSIGNALS]; /* array of structs which contain the relevant signal parameters */
};
/***************** the following functions are used to read files **************************/
int edfopen_file_readonly(const char *path, struct edf_hdr_struct *edfhdr, int read_annotations);
/* opens an existing file for reading */
/* path is a null-terminated string containing the path to the file */
/* hdr is a pointer to an edf_hdr_struct, all fields in this struct will be overwritten */
/* the edf_hdr_struct will be filled with all the relevant header- and signalinfo/parameters */
/* read_annotations must have one of the following values: */
/* EDFLIB_DO_NOT_READ_ANNOTATIONS annotations will not be read (this saves time when opening a very large EDFplus or BDFplus file */
/* EDFLIB_READ_ANNOTATIONS annotations will be read immediately, stops when an annotation has */
/* been found which contains the description "Recording ends" */
/* EDFLIB_READ_ALL_ANNOTATIONS all annotations will be read immediately */
/* returns 0 on success, in case of an error it returns -1 and an errorcode will be set in the member "filetype" of struct edf_hdr_struct */
/* This function is required if you want to read a file */
int edfread_physical_samples(int handle, int edfsignal, int n, double *buf);
/* reads n samples from edfsignal, starting from the current sample position indicator, into buf (edfsignal starts at 0) */
/* the values are converted to their physical values e.g. microVolts, beats per minute, etc. */
/* bufsize should be equal to or bigger than sizeof(double[n]) */
/* the sample position indicator will be increased with the amount of samples read */
/* returns the amount of samples read (this can be less than n or zero!) */
/* or -1 in case of an error */
int edfread_digital_samples(int handle, int edfsignal, int n, int *buf);
/* reads n samples from edfsignal, starting from the current sample position indicator, into buf (edfsignal starts at 0) */
/* the values are the "raw" digital values */
/* bufsize should be equal to or bigger than sizeof(int[n]) */
/* the sample position indicator will be increased with the amount of samples read */
/* returns the amount of samples read (this can be less than n or zero!) */
/* or -1 in case of an error */
long long edfseek(int handle, int edfsignal, long long offset, int whence);
/* The edfseek() function sets the sample position indicator for the edfsignal pointed to by edfsignal. */
/* The new position, measured in samples, is obtained by adding offset samples to the position specified by whence. */
/* If whence is set to EDFSEEK_SET, EDFSEEK_CUR, or EDFSEEK_END, the offset is relative to the start of the file, */
/* the current position indicator, or end-of-file, respectively. */
/* Returns the current offset. Otherwise, -1 is returned. */
/* note that every signal has it's own independent sample position indicator and edfseek() affects only one of them */
long long edftell(int handle, int edfsignal);
/* The edftell() function obtains the current value of the sample position indicator for the edfsignal pointed to by edfsignal. */
/* Returns the current offset. Otherwise, -1 is returned */
/* note that every signal has it's own independent sample position indicator and edftell() affects only one of them */
void edfrewind(int handle, int edfsignal);
/* The edfrewind() function sets the sample position indicator for the edfsignal pointed to by edfsignal to the beginning of the file. */
/* It is equivalent to: (void) edfseek(int handle, int edfsignal, 0LL, EDFSEEK_SET) */
/* note that every signal has it's own independent sample position indicator and edfrewind() affects only one of them */
int edf_get_annotation(int handle, int n, struct edf_annotation_struct *annot);
/* Fills the edf_annotation_struct with the annotation n, returns 0 on success, otherwise -1 */
/* The string that describes the annotation/event is encoded in UTF-8 */
/* To obtain the number of annotations in a file, check edf_hdr_struct -> annotations_in_file. */
/*
Notes:
Annotationsignals
EDFplus and BDFplus store the annotations in one or more signals (in order to be backwards compatibel with EDF and BDF).
The counting of the signals in the file starts at 0. Signals used for annotations are skipped by EDFlib.
This means that the annotationsignal(s) in the file are hided.
Use the function edf_get_annotation() to get the annotations.
So, when a file contains 5 signals and the third signal is used to store the annotations, the library will
report that there are only 4 signals in the file.
The library will "map" the signalnumbers as follows: 0->0, 1->1, 2->3, 3->4.
This way you don't need to worry about which signals are annotationsignals. The library will do it for you.
How the library stores time-values
To avoid rounding errors, the library stores some timevalues in variables of type long long int.
In order not to loose the subsecond precision, all timevalues have been multiplied by 10000000.
This will limit the timeresolution to 100 nanoSeconds. To calculate the amount of seconds, divide
the timevalue by 10000000 or use the macro EDFLIB_TIME_DIMENSION which is declared in edflib.h.
The following variables do use this when you open a file in read mode: "file_duration", "starttime_subsecond" and "onset".
*/
/***************** the following functions are used to read or write files **************************/
int edfclose_file(int handle);
/* closes (and in case of writing, finalizes) the file */
/* returns -1 in case of an error, 0 on success */
/* this function MUST be called when you are finished reading or writing */
/* This function is required after reading or writing. Failing to do so will cause */
/* unnessecary memory usage and in case of writing it will cause a corrupted and incomplete file */
int edflib_version(void);
/* Returns the version number of this library, multiplied by hundred. if version is "1.00" than it will return 100 */
int edflib_is_file_used(const char *path);
/* returns 1 if the file is used, either for reading or writing */
/* otherwise returns 0 */
int edflib_get_number_of_open_files(void);
/* returns the number of open files, either for reading or writing */
int edflib_get_handle(int file_number);
/* returns the handle of an opened file, either for reading or writing */
/* file_number starts with 0 */
/* returns -1 if the file is not opened */
/***************** the following functions are used to write files **************************/
int edfopen_file_writeonly(const char *path, int filetype, int number_of_signals);
/* opens an new file for writing. warning, an already existing file with the same name will be silently overwritten without advance warning!! */
/* path is a null-terminated string containing the path and name of the file */
/* filetype must be EDFLIB_FILETYPE_EDFPLUS or EDFLIB_FILETYPE_BDFPLUS */
/* returns a handle on success, you need this handle for the other functions */
/* in case of an error it returns a negative number corresponding to one of the following values: */
/* EDFLIB_MALLOC_ERROR */
/* EDFLIB_NO_SUCH_FILE_OR_DIRECTORY */
/* EDFLIB_MAXFILES_REACHED */
/* EDFLIB_FILE_ALREADY_OPENED */
/* EDFLIB_NUMBER_OF_SIGNALS_INVALID */
/* This function is required if you want to write a file */
int edf_set_samplefrequency(int handle, int edfsignal, int samplefrequency);
/* Sets the samplefrequency of signal edfsignal. */
/* Returns 0 on success, otherwise -1 */
/* This function is required for every signal and can be called only after opening a */
/* file in writemode and before the first sample write action */
int edf_set_physical_maximum(int handle, int edfsignal, double phys_max);
/* Sets the maximum physical value of signal edfsignal. (the value of the input of the ADC when the output equals the value of "digital maximum") */
/* Returns 0 on success, otherwise -1 */
/* This function is required for every signal and can be called only after opening a */
/* file in writemode and before the first sample write action */
int edf_set_physical_minimum(int handle, int edfsignal, double phys_min);
/* Sets the minimum physical value of signal edfsignal. (the value of the input of the ADC when the output equals the value of "digital minimum") */
/* Usually this will be (-(phys_max)) */
/* Returns 0 on success, otherwise -1 */
/* This function is required for every signal and can be called only after opening a */
/* file in writemode and before the first sample write action */
int edf_set_digital_maximum(int handle, int edfsignal, int dig_max);
/* Sets the maximum digital value of signal edfsignal. The maximum value is 32767 for EDF+ and 8388607 for BDF+ */
/* Usually it's the extreme output of the ADC */
/* Returns 0 on success, otherwise -1 */
/* This function is required for every signal and can be called only after opening a file in writemode */
/* and before the first sample write action */
int edf_set_digital_minimum(int handle, int edfsignal, int dig_min);
/* Sets the minimum digital value of signal edfsignal. The minimum value is -32768 for EDF+ and -8388608 for BDF+ */
/* Usually it's the extreme output of the ADC */
/* Usually this will be (-(dig_max + 1)) */
/* Returns 0 on success, otherwise -1 */
/* This function is required for every signal and can be called only after opening a file in writemode */
/* and before the first sample write action */
int edf_set_label(int handle, int edfsignal, const char *label);
/* Sets the label (name) of signal edfsignal. ("FP1", "SaO2", etc.) */
/* label is a pointer to a NULL-terminated ASCII-string containing the label (name) of the signal edfsignal */
/* Returns 0 on success, otherwise -1 */
/* This function is recommended for every signal when you want to write a file */
/* and can be called only after opening a file in writemode and before the first sample write action */
int edf_set_prefilter(int handle, int edfsignal, const char *prefilter);
/* Sets the prefilter of signal edfsignal ("HP:0.1Hz", "LP:75Hz N:50Hz", etc.). */
/* prefilter is a pointer to a NULL-terminated ASCII-string containing the prefilter text of the signal edfsignal */
/* Returns 0 on success, otherwise -1 */
/* This function is optional and can be called only after opening a file in writemode and before */
/* the first sample write action */
int edf_set_transducer(int handle, int edfsignal, const char *transducer);
/* Sets the transducer of signal edfsignal ("AgAgCl cup electrodes", etc.). */
/* transducer is a pointer to a NULL-terminated ASCII-string containing the transducer text of the signal edfsignal */
/* Returns 0 on success, otherwise -1 */
/* This function is optional and can be called only after opening a file in writemode and before */
/* the first sample write action */
int edf_set_physical_dimension(int handle, int edfsignal, const char *phys_dim);
/* Sets the physical dimension of signal edfsignal. ("uV", "BPM", "mA", "Degr.", etc.) */
/* phys_dim is a pointer to a NULL-terminated ASCII-string containing the physical dimension of the signal edfsignal */
/* Returns 0 on success, otherwise -1 */
/* This function is recommanded for every signal when you want to write a file */
/* and can be called only after opening a file in writemode and before the first sample write action */
int edf_set_startdatetime(int handle, int startdate_year, int startdate_month, int startdate_day,
int starttime_hour, int starttime_minute, int starttime_second);
/* Sets the startdate and starttime. */
/* year: 1970 - 3000, month: 1 - 12, day: 1 - 31 */
/* hour: 0 - 23, minute: 0 - 59, second: 0 - 59 */
/* If not called, the library will use the system date and time at runtime */
/* Returns 0 on success, otherwise -1 */
/* This function is optional and can be called only after opening a file in writemode */
/* and before the first sample write action */
int edf_set_patientname(int handle, const char *patientname);
/* Sets the patientname. patientname is a pointer to a null-terminated ASCII-string. */
/* Returns 0 on success, otherwise -1 */
/* This function is optional and can be called only after opening a file in writemode */
/* and before the first sample write action */
int edf_set_patientcode(int handle, const char *patientcode);
/* Sets the patientcode. patientcode is a pointer to a null-terminated ASCII-string. */
/* Returns 0 on success, otherwise -1 */
/* This function is optional and can be called only after opening a file in writemode */
/* and before the first sample write action */
int edf_set_gender(int handle, int gender);
/* Sets the gender. 1 is male, 0 is female. */
/* Returns 0 on success, otherwise -1 */
/* This function is optional and can be called only after opening a file in writemode */
/* and before the first sample write action */
int edf_set_birthdate(int handle, int birthdate_year, int birthdate_month, int birthdate_day);
/* Sets the birthdate. */
/* year: 1800 - 3000, month: 1 - 12, day: 1 - 31 */
/* This function is optional */
/* Returns 0 on success, otherwise -1 */
/* This function is optional and can be called only after opening a file in writemode */
/* and before the first sample write action */
int edf_set_patient_additional(int handle, const char *patient_additional);
/* Sets the additional patientinfo. patient_additional is a pointer to a null-terminated ASCII-string. */
/* Returns 0 on success, otherwise -1 */
/* This function is optional and can be called only after opening a file in writemode */
/* and before the first sample write action */
int edf_set_admincode(int handle, const char *admincode);
/* Sets the admincode. admincode is a pointer to a null-terminated ASCII-string. */
/* Returns 0 on success, otherwise -1 */
/* This function is optional and can be called only after opening a file in writemode */
/* and before the first sample write action */
int edf_set_technician(int handle, const char *technician);
/* Sets the technicians name. technician is a pointer to a null-terminated ASCII-string. */
/* Returns 0 on success, otherwise -1 */
/* This function is optional and can be called only after opening a file in writemode */
/* and before the first sample write action */
int edf_set_equipment(int handle, const char *equipment);
/* Sets the name of the equipment used during the aquisition. equipment is a pointer to a null-terminated ASCII-string. */
/* Returns 0 on success, otherwise -1 */
/* This function is optional and can be called only after opening a file in writemode */
/* and before the first sample write action */
int edf_set_recording_additional(int handle, const char *recording_additional);
/* Sets the additional recordinginfo. recording_additional is a pointer to a null-terminated ASCII-string. */
/* Returns 0 on success, otherwise -1 */
/* This function is optional and can be called only after opening a file in writemode */
/* and before the first sample write action */
int edfwrite_physical_samples(int handle, double *buf);
/* Writes n physical samples (uV, mA, Ohm) from *buf belonging to one signal */
/* where n is the samplefrequency of that signal. */
/* The physical samples will be converted to digital samples using the */
/* values of physical maximum, physical minimum, digital maximum and digital minimum */
/* The number of samples written is equal to the samplefrequency of the signal */
/* Size of buf should be equal to or bigger than sizeof(double[samplefrequency]) */
/* Call this function for every signal in the file. The order is important! */
/* When there are 4 signals in the file, the order of calling this function */
/* must be: signal 0, signal 1, signal 2, signal 3, signal 0, signal 1, signal 2, etc. */
/* Returns 0 on success, otherwise -1 */
int edf_blockwrite_physical_samples(int handle, double *buf);
/* Writes physical samples (uV, mA, Ohm) from *buf */
/* buf must be filled with samples from all signals, starting with n samples of signal 0, n samples of signal 1, n samples of signal 2, etc. */
/* where n is the samplefrequency of that signal. */
/* buf must be filled with samples from all signals, starting with signal 0, 1, 2, etc. */
/* one block equals one second */
/* The physical samples will be converted to digital samples using the */
/* values of physical maximum, physical minimum, digital maximum and digital minimum */
/* The number of samples written is equal to the sum of the samplefrequencies of all signals */
/* Size of buf should be equal to or bigger than sizeof(double) multiplied by the sum of the samplefrequencies of all signals */
/* Returns 0 on success, otherwise -1 */
int edfwrite_digital_short_samples(int handle, short *buf);
/* Writes n "raw" digital samples from *buf belonging to one signal */
/* where n is the samplefrequency of that signal. */
/* The samples will be written to the file without any conversion. */
/* Because the size of a short is 16-bit, do not use this function with BDF (24-bit) */
/* The number of samples written is equal to the samplefrequency of the signal */
/* Size of buf should be equal to or bigger than sizeof(short[samplefrequency]) */
/* Call this function for every signal in the file. The order is important! */
/* When there are 4 signals in the file, the order of calling this function */
/* must be: signal 0, signal 1, signal 2, signal 3, signal 0, signal 1, signal 2, etc. */
/* Returns 0 on success, otherwise -1 */
int edfwrite_digital_samples(int handle, int *buf);
/* Writes n "raw" digital samples from *buf belonging to one signal */
/* where n is the samplefrequency of that signal. */
/* The 16 (or 24 in case of BDF) least significant bits of the sample will be written to the */
/* file without any conversion. */
/* The number of samples written is equal to the samplefrequency of the signal */
/* Size of buf should be equal to or bigger than sizeof(int[samplefrequency]) */
/* Call this function for every signal in the file. The order is important! */
/* When there are 4 signals in the file, the order of calling this function */
/* must be: signal 0, signal 1, signal 2, signal 3, signal 0, signal 1, signal 2, etc. */
/* Returns 0 on success, otherwise -1 */
int edf_blockwrite_digital_3byte_samples(int handle, void *buf);
/* Writes "raw" digital samples from *buf. */
/* buf must be filled with samples from all signals, starting with n samples of signal 0, n samples of signal 1, n samples of signal 2, etc. */
/* where n is the samplefrequency of that signal. */
/* One block equals one second. One sample equals 3 bytes, order is little endian (least significant byte first) */
/* Encoding is second's complement, most significant bit of most significant byte is the sign-bit */
/* The samples will be written to the file without any conversion. */
/* Because the size of a 3-byte sample is 24-bit, this function can only be used when writing a BDF file */
/* The number of samples written is equal to the sum of the samplefrequencies of all signals. */
/* Size of buf should be equal to or bigger than: the sum of the samplefrequencies of all signals x 3 bytes */
/* Returns 0 on success, otherwise -1 */
int edf_blockwrite_digital_short_samples(int handle, short *buf);
/* Writes "raw" digital samples from *buf. */
/* buf must be filled with samples from all signals, starting with n samples of signal 0, n samples of signal 1, n samples of signal 2, etc. */
/* where n is the samplefrequency of that signal. */
/* One block equals one second. */
/* The samples will be written to the file without any conversion. */
/* Because the size of a short is 16-bit, do not use this function with BDF (24-bit) */
/* The number of samples written is equal to the sum of the samplefrequencies of all signals. */
/* Size of buf should be equal to or bigger than sizeof(short) multiplied by the sum of the samplefrequencies of all signals */
/* Returns 0 on success, otherwise -1 */
int edf_blockwrite_digital_samples(int handle, int *buf);
/* Writes "raw" digital samples from *buf. */
/* buf must be filled with samples from all signals, starting with n samples of signal 0, n samples of signal 1, n samples of signal 2, etc. */
/* where n is the samplefrequency of that signal. */
/* One block equals one second. */
/* The 16 (or 24 in case of BDF) least significant bits of the sample will be written to the */
/* file without any conversion. */
/* The number of samples written is equal to the sum of the samplefrequencies of all signals. */
/* Size of buf should be equal to or bigger than sizeof(int) multiplied by the sum of the samplefrequencies of all signals */
/* Returns 0 on success, otherwise -1 */
int edfwrite_annotation_utf8(int handle, long long onset, long long duration, const char *description);
/* writes an annotation/event to the file */
/* onset is relative to the starttime and startdate of the file */
/* onset and duration are in units of 100 microSeconds! resolution is 0.0001 second! */
/* for example: 34.071 seconds must be written as 340710 */
/* if duration is unknown or not applicable: set a negative number (-1) */
/* description is a null-terminated UTF8-string containing the text that describes the event */
/* This function is optional and can be called only after opening a file in writemode */
/* and before closing the file */
int edfwrite_annotation_latin1(int handle, long long onset, long long duration, const char *description);
/* writes an annotation/event to the file */
/* onset is relative to the starttime and startdate of the file */
/* onset and duration are in units of 100 microSeconds! resolution is 0.0001 second! */
/* for example: 34.071 seconds must be written as 340710 */
/* if duration is unknown or not applicable: set a negative number (-1) */
/* description is a null-terminated Latin1-string containing the text that describes the event */
/* This function is optional and can be called only after opening a file in writemode */
/* and before closing the file */
int edf_set_datarecord_duration(int handle, int duration);
/* Sets the datarecord duration. The default value is 1 second. */
/* ATTENTION: the argument "duration" is expressed in units of 10 microSeconds! */
/* So, if you want to set the datarecord duration to 0.1 second, you must give */
/* the argument "duration" a value of "10000". */
/* This function is optional, normally you don't need to change the default value. */
/* The datarecord duration must be in the range 0.001 to 60 seconds. */
/* Returns 0 on success, otherwise -1 */
/* This function is NOT REQUIRED but can be called after opening a */
/* file in writemode and before the first sample write action. */
/* This function can be used when you want to use a samplerate */
/* which is not an integer. For example, if you want to use a samplerate of 0.5 Hz, */
/* set the samplefrequency to 5 Hz and the datarecord duration to 10 seconds, */
/* or set the samplefrequency to 1 Hz and the datarecord duration to 2 seconds. */
/* Do not use this function, except when absolutely necessary! */
int edf_set_number_of_annotation_signals(int handle, int annot_signals);
/* Sets the number of annotation signals. The default value is 1 */
/* This function is optional and can be called only after opening a file in writemode */
/* and before the first sample write action */
/* Normally you don't need to change the default value. Only when the number of annotations */
/* you want to write is more than the number of seconds of the duration of the recording, you can use */
/* this function to increase the storage space for annotations */
/* Minimum is 1, maximum is 64 */
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif
edfbrowser_157_source/PaxHeaders.7921/ascii2edf.h 0000644 0000000 0000000 00000000132 12646460742 016670 x ustar 00 30 mtime=1452958178.238246763
30 atime=1452958178.238246763
30 ctime=1452958178.238246763
edfbrowser_157_source/ascii2edf.h 0000644 0001750 0000144 00000006351 12646460742 017236 0 ustar 00guv users 0000000 0000000 /*
***************************************************************************
*
* Author: Teunis van Beelen
*
* Copyright (C) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016 Teunis van Beelen
*
* Email: teuniz@gmail.com
*
***************************************************************************
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
***************************************************************************
*/
#ifndef UI_ASCII2EDFFORM_H
#define UI_ASCII2EDFFORM_H
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include "global.h"
#include "xml.h"
#include "utils.h"
#define ASCII_MAX_EDF_SIGNALS 512
#define ASCII_MAX_LINE_LEN 2048
class UI_ASCII2EDFapp : public QObject
{
Q_OBJECT
public:
UI_ASCII2EDFapp(char *recent_dir=NULL, char *save_dir=NULL);
private:
QDialog *ascii2edfDialog;
QLabel *SeparatorLabel,
*NumsignalsLabel,
*DatastartLabel,
*SamplefreqLabel,
*PatientnameLabel,
*RecordingLabel,
*DatetimeLabel,
*SignalsLabel,
*autoPhysicalMaximumLabel;
QRadioButton *edfButton,
*bdfButton;
QGroupBox *groupbox1;
QVBoxLayout *vbox1;
QLineEdit *SeparatorLineEdit,
*PatientnameLineEdit,
*RecordingLineEdit;
QSpinBox *NumcolumnsSpinbox,
*DatastartSpinbox;
QDoubleSpinBox *SamplefreqSpinbox;
QDateTimeEdit *StartDatetimeedit;
QCheckBox *autoPhysicalMaximumCheckbox;
QTableWidget *SignalsTablewidget;
QPushButton *GoButton,
*CloseButton,
*SaveButton,
*LoadButton;
char separator,
*recent_opendir,
*recent_savedir;
int edfsignals,
startline,
columns,
column_enabled[ASCII_MAX_EDF_SIGNALS],
autoPhysicalMaximum,
edf_format;
double samplefrequency,
datrecduration,
sensitivity[ASCII_MAX_EDF_SIGNALS],
value[ASCII_MAX_EDF_SIGNALS],
physmax[ASCII_MAX_EDF_SIGNALS];
int check_input(void);
private slots:
void numofcolumnschanged(int);
void gobuttonpressed();
void savebuttonpressed();
void loadbuttonpressed();
void autoPhysicalMaximumCheckboxChanged(int);
};
#endif
edfbrowser_157_source/PaxHeaders.7921/videoplayer.cpp 0000644 0000000 0000000 00000000132 12646460742 017715 x ustar 00 30 mtime=1452958178.249246726
30 atime=1452958178.249246726
30 ctime=1452958178.249246726
edfbrowser_157_source/videoplayer.cpp 0000644 0001750 0000144 00000026743 12646460742 020272 0 ustar 00guv users 0000000 0000000 /*
***************************************************************************
*
* Author: Teunis van Beelen
*
* Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016 Teunis van Beelen
*
* Email: teuniz@gmail.com
*
***************************************************************************
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
***************************************************************************
*/
#include "mainwindow.h"
// #define DEBUG_VIDEOPLAYER
#ifdef DEBUG_VIDEOPLAYER
FILE *debug_vpr;
#endif
// Next parts of code are tested with VLC media player 2.1.2 and later with 2.1.5 Rincewind on Linux.
// On windows it's disabled because the console interface of VLC on windows is broken.
// Once they (videolan.org) has fixed this, we can test it and hopefully enable it on windows too.
void UI_Mainwindow::start_stop_video()
{
if(video_player->status != VIDEO_STATUS_STOPPED)
{
stop_video_generic();
return;
}
if(playback_realtime_active)
{
return;
}
if(live_stream_active)
{
QMessageBox messagewindow(QMessageBox::Critical, "Error", "Can not open a video during a live stream.");
messagewindow.exec();
return;
}
if(video_player->status != VIDEO_STATUS_STOPPED)
{
QMessageBox messagewindow(QMessageBox::Critical, "Error", "There is already a video running.");
messagewindow.exec();
return;
}
if(signalcomps < 1)
{
QMessageBox messagewindow(QMessageBox::Critical, "Error", "Put some signals on the screen first.");
messagewindow.exec();
return;
}
if(annot_editor_active)
{
QMessageBox messagewindow(QMessageBox::Critical, "Error", "Close the annotation editor first.");
messagewindow.exec();
return;
}
strcpy(videopath, QFileDialog::getOpenFileName(this, "Select video", QString::fromLocal8Bit(recent_opendir),
"Video files (*.ogv *.OGV *.ogg *.OGG *.mkv *.MKV *.avi *.AVI"
" *.mp4 *.MP4 *.mpeg *.MPEG *.mpg *.MPG *.wmv *.WMV)").toLocal8Bit().data());
if(!strcmp(videopath, ""))
{
return;
}
get_directory_from_path(recent_opendir, videopath, MAX_PATH_LENGTH);
video_player->utc_starttime = parse_date_time_stamp(videopath);
if(video_player->utc_starttime < 0LL)
{
QMessageBox messagewindow(QMessageBox::Warning, "Warning", "Unable to get startdate and starttime from video filename.\n"
" \nAssume video starttime equals EDF/BDF starttime?\n ");
messagewindow.setStandardButtons(QMessageBox::Yes | QMessageBox::Cancel);
messagewindow.setDefaultButton(QMessageBox::Yes);
if(messagewindow.exec() == QMessageBox::Cancel) return;
video_player->utc_starttime = edfheaderlist[sel_viewtime]->utc_starttime;
}
video_player->stop_det_counter = 0;
video_player->fpos = 0;
video_player->starttime_diff = (int)(edfheaderlist[sel_viewtime]->utc_starttime - video_player->utc_starttime);
if((edfheaderlist[sel_viewtime]->utc_starttime + edfheaderlist[sel_viewtime]->recording_len_sec) < video_player->utc_starttime)
{
QMessageBox messagewindow(QMessageBox::Critical, "Error", "The video registration and the EDF/BDF registration do not overlap (in time)!");
messagewindow.exec();
return;
}
if((video_player->utc_starttime + 259200LL) < edfheaderlist[sel_viewtime]->utc_starttime)
{
QMessageBox messagewindow(QMessageBox::Critical, "Error", "The video registration and the EDF/BDF registration do not overlap (in time)!");
messagewindow.exec();
return;
}
video_process = new QProcess(this);
#ifdef Q_OS_WIN32
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
env.insert("PATH", env.value("PATH") + ";C:\\Program Files\\VideoLAN\\VLC");
video_process->setProcessEnvironment(env);
#endif
connect(video_process, SIGNAL(error(QProcess::ProcessError)), this, SLOT(video_process_error(QProcess::ProcessError)));
QStringList arguments;
arguments << "--video-on-top" << "-I" << "rc";
video_process->start("vlc", arguments);
if(video_process->waitForStarted(5000) == false)
{
QMessageBox messagewindow(QMessageBox::Critical, "Error", "Unable to start VLC mediaplayer.\n"
"Check your installation of VLC.\n"
"Also, check if VLC is present in the PATH evironment variable.");
messagewindow.exec();
return;
}
#ifdef DEBUG_VIDEOPLAYER
debug_vpr = fopen("debug_vpr.txt", "wb");
#endif
video_player->status = VIDEO_STATUS_STARTUP_1;
video_player->poll_timer = 100;
video_player->cntdwn_timer = 5000;
video_poll_timer->start(video_player->poll_timer);
video_act->setText("Stop video");
}
void UI_Mainwindow::video_poll_timer_func()
{
int i, err, len, vpos=0;
char buf[4096];
if(video_player->status == VIDEO_STATUS_STOPPED) return;
if(video_player->status != VIDEO_STATUS_PAUSED)
{
video_player->cntdwn_timer -= video_player->poll_timer;
}
if(video_player->cntdwn_timer <= 0)
{
stop_video_generic();
QMessageBox messagewindow(QMessageBox::Critical, "Error", "Videoplayer: time-out.");
messagewindow.exec();
return;
}
len = mpr_read(buf, 4095);
if(len < 1)
{
video_poll_timer->start(video_player->poll_timer);
return;
}
if(video_player->status == VIDEO_STATUS_STARTUP_1)
{
if(!strncmp(buf, "Command Line Interface initialized.", 35))
{
video_player->status = VIDEO_STATUS_STARTUP_2;
}
}
if(video_player->status < VIDEO_STATUS_PLAYING)
{
if(!strncmp(buf, "> ", 2))
{
if(video_player->status == VIDEO_STATUS_STARTUP_2)
{
mpr_write("clear\n");
video_process->waitForBytesWritten(1000);
video_player->status = VIDEO_STATUS_STARTUP_3;
video_player->cntdwn_timer = 5000;
}
else if(video_player->status == VIDEO_STATUS_STARTUP_3)
{
strcpy(buf, "add ");
strcat(buf, videopath);
strcat(buf, "\n");
mpr_write(buf);
video_process->waitForBytesWritten(1000);
video_player->status = VIDEO_STATUS_STARTUP_4;
video_player->cntdwn_timer = 5000;
}
else if(video_player->status == VIDEO_STATUS_STARTUP_4)
{
mpr_write("volume 255\n");
video_process->waitForBytesWritten(1000);
video_player->status = VIDEO_STATUS_PLAYING;
video_pause_act->setText("Pause");
video_pause_act->setToolTip("Pause video");
video_player->cntdwn_timer = 5000;
}
}
video_poll_timer->start(video_player->poll_timer);
return;
}
if(video_player->status == VIDEO_STATUS_PLAYING)
{
if(!strncmp(buf, "> ", 2))
{
if((len > 4) && (buf[len-1] == '\n'))
{
err = 0;
for(i=2; i<(len-1); i++)
{
if((buf[i] < '0') || (buf[i] > '9'))
err = 1;
break;
}
if(!err)
{
vpos = atoi(buf + 2);
if(video_player->fpos != vpos)
{
jump_to_time_millisec(video_player->utc_starttime - edfheaderlist[sel_viewtime]->utc_starttime + (vpos * 1000LL));
video_player->fpos = vpos;
video_player->stop_det_counter = 0;
}
video_player->cntdwn_timer = 5000;
}
}
else if(buf[2] == '\r')
{
video_player->stop_det_counter += video_player->poll_timer;
if(video_player->stop_det_counter > 1500)
{
stop_video_generic();
QMessageBox messagewindow(QMessageBox::NoIcon, "Stopped", " \nVideo has reached the end \n");
messagewindow.exec();
return;
}
}
}
mpr_write("get_time\n");
video_process->waitForBytesWritten(1000);
}
if(!strncmp(buf, "( state stopped )", 17))
{
stop_video_generic();
return;
}
video_poll_timer->start(video_player->poll_timer);
}
void UI_Mainwindow::video_player_seek(int sec)
{
char str[512];
if((video_player->status != VIDEO_STATUS_PLAYING) && (video_player->status != VIDEO_STATUS_PAUSED)) return;
sec += video_player->starttime_diff;
if(sec < 0) sec = 0;
sprintf(str, "seek %i\n", sec);
mpr_write(str);
video_process->waitForBytesWritten(1000);
video_player->cntdwn_timer = 5000;
}
void UI_Mainwindow::video_player_toggle_pause()
{
if(video_player->status == VIDEO_STATUS_STOPPED)
{
start_stop_video();
return;
}
if((video_player->status != VIDEO_STATUS_PLAYING) && (video_player->status != VIDEO_STATUS_PAUSED))
{
return;
}
mpr_write("pause\n");
if(video_player->status == VIDEO_STATUS_PLAYING)
{
video_player->status = VIDEO_STATUS_PAUSED;
video_pause_act->setText("Play");
video_pause_act->setToolTip("Play video");
video_player->cntdwn_timer = 5000;
}
else
{
video_player->status = VIDEO_STATUS_PLAYING;
video_pause_act->setText("Pause");
video_pause_act->setToolTip("Pause video");
}
}
void UI_Mainwindow::stop_video_generic()
{
video_poll_timer->stop();
if(video_player->status == VIDEO_STATUS_STOPPED) return;
video_player->status = VIDEO_STATUS_STOPPED;
disconnect(video_process, SIGNAL(error(QProcess::ProcessError)), this, SLOT(video_process_error(QProcess::ProcessError)));
mpr_write("quit\n");
video_process->waitForFinished(1000);
video_process->kill();
delete video_process;
video_act->setText("Start video");
video_pause_act->setText("Play");
#ifdef DEBUG_VIDEOPLAYER
fclose(debug_vpr);
#endif
}
void UI_Mainwindow::video_process_error(QProcess::ProcessError err)
{
char str[1024];
if(video_player->status == VIDEO_STATUS_STOPPED) return;
stop_video_generic();
strcpy(str, "The process that runs the mediaplayer reported an error:\n");
if(err == QProcess::FailedToStart)
{
strcat(str, "\nFailed to start.");
}
if(err == QProcess::Crashed)
{
strcat(str, "\nCrashed.");
}
if(err == QProcess::Timedout)
{
strcat(str, "\nTimed out.");
}
if(err == QProcess::WriteError)
{
strcat(str, "\nWrite error.");
}
if(err == QProcess::ReadError)
{
strcat(str, "\nRead error.");
}
if(err == QProcess::UnknownError)
{
strcat(str, "\nUnknown error.");
}
QMessageBox messagewindow(QMessageBox::Critical, "Error", str);
messagewindow.exec();
}
inline void UI_Mainwindow::mpr_write(const char *cmd_str)
{
#ifdef DEBUG_VIDEOPLAYER
fprintf(debug_vpr, "edfbr: %s", cmd_str);
#endif
video_process->write(cmd_str);
}
inline int UI_Mainwindow::mpr_read(char *buf, int sz)
{
#ifdef DEBUG_VIDEOPLAYER
int n;
n = video_process->readLine(buf, sz);
if(n > 0)
{
fprintf(debug_vpr, "vlc: %s ", buf);
for(int i=0; ireadLine(buf, sz);
#endif
}
edfbrowser_157_source/PaxHeaders.7921/about_dialog.h 0000644 0000000 0000000 00000000132 12646460742 017470 x ustar 00 30 mtime=1452958178.237246767
30 atime=1452958178.237246767
30 ctime=1452958178.237246767
edfbrowser_157_source/about_dialog.h 0000644 0001750 0000144 00000003040 12646460742 020026 0 ustar 00guv users 0000000 0000000 /*
***************************************************************************
*
* Author: Teunis van Beelen
*
* Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016 Teunis van Beelen
*
* Email: teuniz@gmail.com
*
***************************************************************************
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
***************************************************************************
*/
#ifndef ABOUT_FORM1_H
#define ABOUT_FORM1_H
#include
#include
#include
#include
#include
#include
#include
#include
#include "global.h"
#include "mainwindow.h"
class UI_Aboutwindow : public QObject
{
Q_OBJECT
public:
UI_Aboutwindow(UI_Mainwindow *);
private:
QDialog *AboutDialog;
QPushButton *pushButton1;
QTextEdit *textedit1;
QHBoxLayout *hlayout1;
QVBoxLayout *vlayout1;
};
#endif // ABOUT_FORM1_H
edfbrowser_157_source/PaxHeaders.7921/adjustfiltersettings.h 0000644 0000000 0000000 00000000132 12646460742 021320 x ustar 00 30 mtime=1452958178.237246767
30 atime=1452958178.237246767
30 ctime=1452958178.237246767
edfbrowser_157_source/adjustfiltersettings.h 0000644 0001750 0000144 00000004607 12646460742 021670 0 ustar 00guv users 0000000 0000000 /*
***************************************************************************
*
* Author: Teunis van Beelen
*
* Copyright (C) 2010, 2011, 2012, 2013, 2014, 2015, 2016 Teunis van Beelen
*
* Email: teuniz@gmail.com
*
***************************************************************************
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
***************************************************************************
*/
#ifndef ADJUSTFILTERSETTINGS_H
#define ADJUSTFILTERSETTINGS_H
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include "global.h"
#include "mainwindow.h"
#include "viewcurve.h"
#include "ravg_filter.h"
#include "utils.h"
#include "third_party/fidlib/fidlib.h"
class UI_Mainwindow;
class ViewCurve;
class AdjustFilterSettings : public QObject
{
Q_OBJECT
public:
AdjustFilterSettings(struct signalcompblock *, QWidget *);
private:
int filter_nr,
filter_cnt,
type,
model,
order,
size,
brand[MAXFILTERS];
double frequency1,
frequency2,
ripple;
struct signalcompblock * signalcomp;
UI_Mainwindow *mainwindow;
ViewCurve *maincurve;
QDialog *filtersettings_dialog;
QLabel *label[5];
QComboBox *filterbox,
*stepsizebox;
QSpinBox *orderbox;
QDoubleSpinBox *freq1box,
*freq2box;
QPushButton *CloseButton,
*RemoveButton;
void update_filter(void);
void loadFilterSettings(void);
private slots:
void freqbox1valuechanged(double);
void freqbox2valuechanged(double);
void orderboxvaluechanged(int);
void stepsizeboxchanged(int);
void filterboxchanged(int);
void removeButtonClicked();
};
#endif // ADJUSTFILTERSETTINGS_H
edfbrowser_157_source/PaxHeaders.7921/date_time_stamp_parser.h 0000644 0000000 0000000 00000000132 12646460742 021552 x ustar 00 30 mtime=1452958178.238246763
30 atime=1452958178.238246763
30 ctime=1452958178.238246763
edfbrowser_157_source/date_time_stamp_parser.h 0000644 0001750 0000144 00000002301 12646460742 022107 0 ustar 00guv users 0000000 0000000 /*
***************************************************************************
*
* Author: Teunis van Beelen
*
* Copyright (C) 2014, 2015, 2016 Teunis van Beelen
*
* Email: teuniz@gmail.com
*
***************************************************************************
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
***************************************************************************
*/
#ifndef DATE_TIME_STAMP_PARSER_INCLUDED
#define DATE_TIME_STAMP_PARSER_INCLUDED
#ifdef __cplusplus
extern "C" {
#endif
long long parse_date_time_stamp(const char *);
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif
edfbrowser_157_source/PaxHeaders.7921/save_annots.h 0000644 0000000 0000000 00000000132 12646460742 017357 x ustar 00 30 mtime=1452958178.240246757
30 atime=1452958178.240246757
30 ctime=1452958178.240246757
edfbrowser_157_source/save_annots.h 0000644 0001750 0000144 00000002605 12646460742 017723 0 ustar 00guv users 0000000 0000000 /*
***************************************************************************
*
* Author: Teunis van Beelen
*
* Copyright (C) 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016 Teunis van Beelen
*
* Email: teuniz@gmail.com
*
***************************************************************************
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
***************************************************************************
*/
#ifndef SAVE_ANNOTATIONS_H
#define SAVE_ANNOTATIONS_H
#include
#include
#include
#include
#include
#include
#include "global.h"
#include "mainwindow.h"
#include "utils.h"
#include "edf_annot_list.h"
int save_annotations(UI_Mainwindow *, FILE *, struct edfhdrblock *, struct annotationblock *);
#endif
edfbrowser_157_source/PaxHeaders.7921/averager_curve_wnd.cpp 0000644 0000000 0000000 00000000132 12646460742 021242 x ustar 00 30 mtime=1452958178.246246736
30 atime=1452958178.246246736
30 ctime=1452958178.246246736
edfbrowser_157_source/averager_curve_wnd.cpp 0000644 0001750 0000144 00000041534 12646460742 021612 0 ustar 00guv users 0000000 0000000 /*
***************************************************************************
*
* Author: Teunis van Beelen
*
* Copyright (C) 2011, 2012, 2013, 2014, 2015, 2016 Teunis van Beelen
*
* Email: teuniz@gmail.com
*
***************************************************************************
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
***************************************************************************
*/
#include "averager_curve_wnd.h"
UI_AverageCurveWindow::UI_AverageCurveWindow(struct signalcompblock *signal_comp, QWidget *w_parent, int number,
double *abuf,
double maxvalue,
double minvalue,
long long apagetime,
long long samples_on_screen,
int acnt,
int trigger_position,
char *annotation,
double avg__period)
{
char str[1024];
averager_curve_dialog_is_destroyed = 0;
class_is_deleted = 0;
mainwindow = (UI_Mainwindow *)w_parent;
signalcomp = signal_comp;
averagecurvedialognumber = number;
pagetime = apagetime;
pagetime /= TIME_DIMENSION;
avgbuf = abuf;
avg_max_value = maxvalue;
avg_min_value = minvalue;
avg_samples_on_screen = samples_on_screen;
avg_cnt = acnt;
avg_trigger_position_ratio = trigger_position;
avg_period = avg__period;
strcpy(avg_annotation, annotation);
flywheel_value = 1000;
averager_curve_dialog = new QDialog;
averager_curve_dialog->setAttribute(Qt::WA_DeleteOnClose, true);
averager_curve_dialog->setMinimumSize(650, 480);
averager_curve_dialog->setSizeGripEnabled(true);
averager_curve_dialog->setModal(false);
averager_curve_dialog->setWindowFlags(Qt::Window | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint);
averager_curve_dialog->setWindowIcon(QIcon(":/images/edf.png"));
strcpy(str, "Averaging ");
strcat(str, signalcomp->signallabel);
averager_curve_dialog->setWindowTitle(str);
curve1 = new SignalCurve;
curve1->setSignalColor(Qt::green);
curve1->setBackgroundColor(Qt::black);
curve1->setRasterColor(Qt::gray);
curve1->setCrosshairColor(Qt::red);
curve1->setTraceWidth(0);
curve1->setH_label("sec");
curve1->setLowerLabel("Time");
curve1->setV_label(signalcomp->physdimension);
curve1->setDashBoardEnabled(false);
curve1->setMarker1Color(Qt::yellow);
curve1->create_button("to EDF/BDF");
sprintf(str, "Averaging %i triggers \"%s\"", avg_cnt, avg_annotation);
curve1->setUpperLabel1(str);
flywheel1 = new UI_Flywheel;
flywheel1->setMinimumSize(20, 85);
amplitudeSlider = new QSlider;
amplitudeSlider->setOrientation(Qt::Vertical);
amplitudeSlider->setMinimum(1);
amplitudeSlider->setMaximum(2000);
amplitudeSlider->setValue(1100);
amplitudeSlider->setInvertedAppearance(true);
amplitudeSlider->setMinimumSize(15, 280);
amplitudeLabel = new QLabel;
amplitudeLabel->setText("Amplitude");
amplitudeLabel->setMinimumSize(100, 15);
amplitudeLabel->setAlignment(Qt::AlignHCenter);
inversionCheckBox = new QCheckBox("Invert");
inversionCheckBox->setMinimumSize(70, 25);
inversionCheckBox->setTristate(false);
if(mainwindow->average_upsidedown == 1)
{
inversionCheckBox->setCheckState(Qt::Checked);
}
else
{
inversionCheckBox->setCheckState(Qt::Unchecked);
}
BWCheckBox = new QCheckBox("B/W");
BWCheckBox->setMinimumSize(70, 25);
BWCheckBox->setTristate(false);
if(mainwindow->average_bw == 1)
{
BWCheckBox->setCheckState(Qt::Checked);
}
else
{
BWCheckBox->setCheckState(Qt::Unchecked);
}
vlayout3 = new QVBoxLayout;
vlayout3->addStretch(100);
vlayout3->addWidget(flywheel1, 100);
vlayout3->addStretch(100);
hlayout4 = new QHBoxLayout;
hlayout4->addStretch(100);
hlayout4->addLayout(vlayout3, 100);
hlayout4->addStretch(100);
hlayout4->addWidget(amplitudeSlider, 300);
vlayout2 = new QVBoxLayout;
vlayout2->setSpacing(20);
vlayout2->addStretch(100);
vlayout2->addWidget(amplitudeLabel, 0, Qt::AlignHCenter);
vlayout2->addLayout(hlayout4, 200);
vlayout2->addWidget(inversionCheckBox);
vlayout2->addWidget(BWCheckBox);
spanSlider = new QSlider;
spanSlider->setOrientation(Qt::Horizontal);
spanSlider->setMinimum(10);
spanSlider->setMaximum(1000);
spanSlider->setValue(1000);
spanSlider->setMinimumSize(500, 15);
spanLabel = new QLabel;
spanLabel->setText("Span");
spanLabel->setMinimumSize(110, 15);
spanLabel->setAlignment(Qt::AlignHCenter);
centerSlider = new QSlider;
centerSlider->setOrientation(Qt::Horizontal);
centerSlider->setMinimum(0);
centerSlider->setMaximum(1000);
centerSlider->setValue(250);
centerSlider->setMinimumSize(500, 15);
centerLabel = new QLabel;
centerLabel->setText("Center");
centerLabel->setMinimumSize(110, 15);
centerLabel->setAlignment(Qt::AlignHCenter);
hlayout1 = new QHBoxLayout;
hlayout1->setSpacing(20);
hlayout1->addLayout(vlayout2);
hlayout1->addWidget(curve1, 100);
hlayout2 = new QHBoxLayout;
hlayout2->setSpacing(20);
hlayout2->addWidget(spanLabel);
hlayout2->addWidget(spanSlider);
hlayout2->addStretch(100);
hlayout3 = new QHBoxLayout;
hlayout3->setSpacing(20);
hlayout3->addWidget(centerLabel);
hlayout3->addWidget(centerSlider);
hlayout3->addStretch(100);
vlayout1 = new QVBoxLayout;
vlayout1->setSpacing(20);
vlayout1->addLayout(hlayout1);
vlayout1->addLayout(hlayout2);
vlayout1->addLayout(hlayout3);
averager_curve_dialog->setLayout(vlayout1);
QObject::connect(amplitudeSlider, SIGNAL(valueChanged(int)), this, SLOT(sliderMoved(int)));
QObject::connect(inversionCheckBox, SIGNAL(stateChanged(int)), this, SLOT(sliderMoved(int)));
QObject::connect(BWCheckBox, SIGNAL(stateChanged(int)), this, SLOT(sliderMoved(int)));
QObject::connect(spanSlider, SIGNAL(valueChanged(int)), this, SLOT(sliderMoved(int)));
QObject::connect(centerSlider, SIGNAL(valueChanged(int)), this, SLOT(sliderMoved(int)));
QObject::connect(averager_curve_dialog, SIGNAL(destroyed(QObject *)), this, SLOT(averager_curve_dialogDestroyed(QObject *)));
QObject::connect(curve1, SIGNAL(extra_button_clicked()), this, SLOT(export_edf()));
QObject::connect(flywheel1, SIGNAL(dialMoved(int)), this, SLOT(update_flywheel(int)));
sliderMoved(0);
averager_curve_dialog->show();
}
void UI_AverageCurveWindow::export_edf(void)
{
int i, j, k, p,
type,
edf_hdl,
smp_per_record,
datarecords,
smpls_left;
char path[MAX_PATH_LENGTH],
str[512];
double *buf,
frequency,
frequency2;
smp_per_record = signalcomp->edfhdr->edfparam[signalcomp->edfsignal[0]].smp_per_record;
datarecords = avg_samples_on_screen / smp_per_record;
smpls_left = avg_samples_on_screen % smp_per_record;
path[0] = 0;
if(mainwindow->recent_savedir[0]!=0)
{
strcpy(path, mainwindow->recent_savedir);
strcat(path, "/");
}
get_filename_from_path(path + strlen(path), signalcomp->edfhdr->filename, 512);
remove_extension_from_filename(path);
sprintf(path + strlen(path), " averaging %s %i triggers [%s]",
signalcomp->signallabel,
avg_cnt,
avg_annotation);
if(signalcomp->edfhdr->edf)
{
strcat(path, ".edf");
strcpy(path, QFileDialog::getSaveFileName(0, "Save as EDF", QString::fromLocal8Bit(path), "EDF files (*.edf *.EDF)").toLocal8Bit().data());
}
else
{
strcat(path, ".bdf");
strcpy(path, QFileDialog::getSaveFileName(0, "Save as BDF", QString::fromLocal8Bit(path), "BDF files (*.bdf *.BDF)").toLocal8Bit().data());
}
if(!strcmp(path, ""))
{
return;
}
get_directory_from_path(mainwindow->recent_savedir, path, MAX_PATH_LENGTH);
if(signalcomp->edfhdr->edf)
{
edf_hdl = edfopen_file_writeonly(path, EDFLIB_FILETYPE_EDFPLUS, 1);
}
else
{
edf_hdl = edfopen_file_writeonly(path, EDFLIB_FILETYPE_BDFPLUS, 1);
}
if(edf_hdl < 0)
{
QMessageBox messagewindow(QMessageBox::Critical, "Error", "Can not open output file for writing.");
messagewindow.exec();
return;
}
edf_set_samplefrequency(edf_hdl, 0, smp_per_record);
if(edf_set_datarecord_duration(edf_hdl, signalcomp->edfhdr->long_data_record_duration / 100LL))
{
QMessageBox messagewindow(QMessageBox::Critical, "Error", "Datarecordduration out of range.");
messagewindow.exec();
return;
}
if(signalcomp->edfhdr->edf)
{
edf_set_digital_maximum(edf_hdl, 0, 32767);
edf_set_digital_minimum(edf_hdl, 0, -32768);
}
else
{
edf_set_digital_maximum(edf_hdl, 0, 8388607);
edf_set_digital_minimum(edf_hdl, 0, -8388608);
}
edf_set_physical_maximum(edf_hdl, 0, avg_max_value);
edf_set_physical_minimum(edf_hdl, 0, avg_min_value);
edf_set_label(edf_hdl, 0, signalcomp->signallabel);
edf_set_physical_dimension(edf_hdl, 0, signalcomp->physdimension);
p = 0;
for(j=0; jfidfilter_cnt; j++)
{
type = signalcomp->fidfilter_type[j];
frequency = signalcomp->fidfilter_freq[j];
frequency2 = signalcomp->fidfilter_freq2[j];
if(type == 0)
{
p += sprintf(str + p, "HP:%f", frequency);
}
if(type == 1)
{
p += sprintf(str + p, "LP:%f", frequency);
}
if(type == 2)
{
p += sprintf(str + p, "N:%f", frequency);
}
if(type == 3)
{
p += sprintf(str + p, "BP:%f", frequency);
}
if(type == 4)
{
p += sprintf(str + p, "BS:%f", frequency);
}
for(k=(p-1); k>0; k--)
{
if(str[k]!='0') break;
}
if(str[k]=='.') str[k] = 0;
else str[k+1] = 0;
p = strlen(str);
if((type == 3) || (type == 4))
{
p += sprintf(str + p, "-%f", frequency2);
for(k=(p-1); k>0; k--)
{
if(str[k]!='0') break;
}
if(str[k]=='.') str[k] = 0;
else str[k+1] = 0;
}
strcat(str, "Hz ");
p = strlen(str);
if(p>80) break;
}
for(j=0; jravg_filter_cnt; j++)
{
if(signalcomp->ravg_filter_type[j] == 0)
{
p += sprintf(str + p, "HP:%iSmpls ", signalcomp->ravg_filter[j]->size);
}
if(signalcomp->ravg_filter_type[j] == 1)
{
p += sprintf(str + p, "LP:%iSmpls ", signalcomp->ravg_filter[j]->size);
}
p = strlen(str);
if(p>80) break;
}
strcat(str, signalcomp->edfhdr->edfparam[signalcomp->edfsignal[0]].prefilter);
edf_set_prefilter(edf_hdl, 0, str);
edf_set_transducer(edf_hdl, 0, signalcomp->edfhdr->edfparam[signalcomp->edfsignal[0]].transducer);
if((signalcomp->edfhdr->edfplus) || (signalcomp->edfhdr->bdfplus))
{
edf_set_patientname(edf_hdl, signalcomp->edfhdr->plus_patient_name);
sprintf(str, "%i triggers \"%s\" averaged. %s", avg_cnt, avg_annotation, signalcomp->edfhdr->plus_recording_additional);
edf_set_recording_additional(edf_hdl, str);
edf_set_patientcode(edf_hdl, signalcomp->edfhdr->plus_patientcode);
if(signalcomp->edfhdr->plus_gender[0] == 'M')
{
edf_set_gender(edf_hdl, 1);
}
if(signalcomp->edfhdr->plus_gender[0] == 'F')
{
edf_set_gender(edf_hdl, 0);
}
edf_set_patient_additional(edf_hdl, signalcomp->edfhdr->plus_patient_additional);
edf_set_admincode(edf_hdl, signalcomp->edfhdr->plus_admincode);
edf_set_technician(edf_hdl, signalcomp->edfhdr->plus_technician);
edf_set_equipment(edf_hdl, signalcomp->edfhdr->plus_equipment);
}
else
{
edf_set_patientname(edf_hdl, signalcomp->edfhdr->patient);
sprintf(str, "%i triggers \"%s\" averaged. %s", avg_cnt, avg_annotation, signalcomp->edfhdr->recording);
edf_set_recording_additional(edf_hdl, str);
}
for(i=0; ivalue() * steps / 1000;
startstep = centerSlider->value() * (steps - spanstep) / 1000;
stopstep = startstep + spanstep;
avg_mid_value = (avg_max_value + avg_min_value) / 2.0;
avg_peak_value = (avg_max_value - avg_min_value) / 2.0;
avg_peak_value = (avg_peak_value * (double)amplitudeSlider->value() / 1000.0) * ((double)flywheel_value / 1000.0);
dtmp1 = avg_mid_value + avg_peak_value;
dtmp2 = avg_mid_value - avg_peak_value;
if(inversionCheckBox->isChecked() == true)
{
curve1->setUpsidedownEnabled(true);
mainwindow->average_upsidedown = 1;
}
else
{
curve1->setUpsidedownEnabled(false);
mainwindow->average_upsidedown = 0;
}
if(BWCheckBox->isChecked() == true)
{
curve1->setSignalColor(Qt::black);
curve1->setBackgroundColor(Qt::white);
curve1->setRasterColor(Qt::black);
curve1->setMarker1Color(Qt::black);
curve1->setBorderColor(Qt::white);
curve1->setTextColor(Qt::black);
curve1->setCrosshairColor(Qt::black);
mainwindow->average_bw = 1;
}
else
{
curve1->setSignalColor(Qt::green);
curve1->setBackgroundColor(Qt::black);
curve1->setRasterColor(Qt::gray);
curve1->setMarker1Color(Qt::yellow);
curve1->setBorderColor(Qt::lightGray);
curve1->setTextColor(Qt::black);
curve1->setCrosshairColor(Qt::red);
mainwindow->average_bw = 0;
}
curve1->drawCurve(avgbuf + startstep, stopstep - startstep, dtmp1, dtmp2);
max_sec = pagetime * stopstep / steps - (pagetime * (1.0 / avg_trigger_position_ratio));
precision = 0;
if(max_sec < 100.0)
{
precision = 1;
}
if(max_sec < 10.0)
{
precision = 2;
}
if(max_sec < 1.0)
{
precision = 3;
}
if(max_sec < 0.1)
{
precision = 4;
}
start_sec = pagetime * startstep / steps - (pagetime * (1.0 / avg_trigger_position_ratio));
curve1->setH_RulerValues(start_sec, max_sec);
centerLabel->setText(QString::number(start_sec + ((max_sec - start_sec) / 2.0), 'f', precision).append(" sec").prepend("Center "));
spanLabel->setText(QString::number(max_sec - start_sec, 'f', precision).append(" sec").prepend("Span "));
if(avg_trigger_position_ratio > 0)
{
markerstep = steps / avg_trigger_position_ratio;
if((markerstep > startstep) && (markerstep < stopstep))
{
curve1->setMarker1Enabled(true);
curve1->setMarker1Position((((double)steps / (double)avg_trigger_position_ratio) - (double)startstep) / (double)spanstep);
}
else
{
curve1->setMarker1Enabled(false);
}
}
else
{
curve1->setMarker1Enabled(false);
}
}
void UI_AverageCurveWindow::averager_curve_dialogDestroyed(QObject *)
{
averager_curve_dialog_is_destroyed = 1;
mainwindow->averagecurvedialog[averagecurvedialognumber] = NULL;
if(!class_is_deleted)
{
delete this;
}
}
UI_AverageCurveWindow::~UI_AverageCurveWindow()
{
int i;
class_is_deleted = 1;
if(!averager_curve_dialog_is_destroyed)
{
averager_curve_dialog->close();
}
if(avgbuf != NULL)
{
free(avgbuf);
}
mainwindow->averagecurvedialog[averagecurvedialognumber] = NULL;
for(i=0; iavg_dialog[i] == (averagecurvedialognumber + 1))
{
signalcomp->avg_dialog[i] = 0;
}
}
}
void UI_AverageCurveWindow::update_flywheel(int new_value)
{
flywheel_value += new_value;
if(flywheel_value < 10)
{
flywheel_value = 10;
}
if(flywheel_value > 100000)
{
flywheel_value = 100000;
}
sliderMoved(0);
}
edfbrowser_157_source/PaxHeaders.7921/utc_date_time.h 0000644 0000000 0000000 00000000132 12646460742 017645 x ustar 00 30 mtime=1452958178.240246757
30 atime=1452958178.240246757
30 ctime=1452958178.240246757
edfbrowser_157_source/utc_date_time.h 0000644 0001750 0000144 00000002755 12646460742 020217 0 ustar 00guv users 0000000 0000000 /*
***************************************************************************
*
* Author: Teunis van Beelen
*
* Copyright (C) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016 Teunis van Beelen
*
* Email: teuniz@gmail.com
*
***************************************************************************
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
***************************************************************************
*/
#ifndef UTC_DATE_TIME_INCLUDED
#define UTC_DATE_TIME_INCLUDED
#include
#ifdef __cplusplus
extern "C" {
#endif
struct date_time_struct{
int year;
int month;
int day;
int hour;
int minute;
int second;
char month_str[4];
};
void utc_to_date_time(long long, struct date_time_struct *);
void date_time_to_utc(long long *, struct date_time_struct);
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif
edfbrowser_157_source/PaxHeaders.7921/edfbrowser.pro 0000644 0000000 0000000 00000000132 12646460742 017552 x ustar 00 30 mtime=1452958178.253246713
30 atime=1452958178.253246713
30 ctime=1452958178.253246713
edfbrowser_157_source/edfbrowser.pro 0000644 0001750 0000144 00000015147 12646460742 020123 0 ustar 00guv users 0000000 0000000
contains(QT_MAJOR_VERSION, 4) {
LIST = 0 1 2 3 4 5 6
for(a, LIST):contains(QT_MINOR_VERSION, $$a):error("This project needs Qt4 version >= 4.7.1 or Qt5 version >= 5.5.1")
contains(QT_MINOR_VERSION, 7) {
LIST = 0
for(a, LIST):contains(QT_PATCH_VERSION, $$a):error("This project needs Qt4 version >= 4.7.1 or Qt5 version >= 5.5.1")
}
}
contains(QT_MAJOR_VERSION, 5) {
LIST = 0 1 2 3 4
for(a, LIST):contains(QT_MINOR_VERSION, $$a):error("This project needs Qt4 version >= 4.7.1 or Qt5 version >= 5.5.1")
contains(QT_MINOR_VERSION, 5) {
LIST = 0
for(a, LIST):contains(QT_PATCH_VERSION, $$a):error("This project needs Qt4 version >= 4.7.1 or Qt5 version >= 5.5.1")
}
}
TEMPLATE = app
TARGET = edfbrowser
DEPENDPATH += .
INCLUDEPATH += .
CONFIG += qt
CONFIG += warn_on
CONFIG += release
CONFIG += static
CONFIG += largefile
QT += network
contains(QT_MAJOR_VERSION, 5) {
QT += widgets
QT += printsupport
win32 {
QTPLUGIN += windowsprintersupport
} else:mac {
QTPLUGIN += cocoaprintersupport
} else {
QTPLUGIN += cupsprintersupport
}
}
OBJECTS_DIR = ./objects
MOC_DIR = ./moc
HEADERS += global.h
HEADERS += mainwindow.h
HEADERS += viewcurve.h
HEADERS += check_edf_file.h
HEADERS += show_edf_hdr.h
HEADERS += signals_dialog.h
HEADERS += signal_chooser.h
HEADERS += ascii_export.h
HEADERS += edf_compat.h
HEADERS += colordialog.h
HEADERS += filter.h
HEADERS += filter_dialog.h
HEADERS += jump_dialog.h
HEADERS += about_dialog.h
HEADERS += edf_annotations.h
HEADERS += annotations_dock.h
HEADERS += options_dialog.h
HEADERS += nk2edf.h
HEADERS += xml.h
HEADERS += save_montage_dialog.h
HEADERS += load_montage_dialog.h
HEADERS += view_montage_dialog.h
HEADERS += show_actual_montage_dialog.h
HEADERS += print_to_edf.h
HEADERS += pagetime_dialog.h
HEADERS += print_to_bdf.h
HEADERS += ascii2edf.h
HEADERS += fino2edf.h
HEADERS += nexfin2edf.h
HEADERS += edfplusd_cnv.h
HEADERS += utc_date_time.h
HEADERS += emsa2edf.h
HEADERS += special_button.h
HEADERS += bdf2edf.h
HEADERS += edit_annotation_dock.h
HEADERS += popup_save_cancelwindow.h
HEADERS += save_annots.h
HEADERS += filtercurve.h
HEADERS += utils.h
HEADERS += signalcurve.h
HEADERS += spectrumanalyzer.h
HEADERS += bi9800.h
HEADERS += edflib.h
HEADERS += export_annotations.h
HEADERS += edit_predefined_mtg.h
HEADERS += spectrum_dock.h
HEADERS += edf_annot_list.h
HEADERS += reduce_signals.h
HEADERS += active_file_chooser.h
HEADERS += header_editor.h
HEADERS += biosemi2bdfplus.h
HEADERS += bdf_triggers.h
HEADERS += adjustfiltersettings.h
HEADERS += import_annotations.h
HEADERS += ravg_filter.h
HEADERS += wav2edf.h
HEADERS += fma_ecg2edf.h
HEADERS += averager_dialog.h
HEADERS += averager_curve_wnd.h
HEADERS += ecg_filter.h
HEADERS += ecg_export.h
HEADERS += statistics_dialog.h
HEADERS += filteredblockread.h
HEADERS += flywheel.h
HEADERS += z_score_dialog.h
HEADERS += z_ratio_filter.h
HEADERS += raw2edf.h
HEADERS += check_for_updates.h
HEADERS += manscan2edf.h
HEADERS += scp_ecg2edf.h
HEADERS += unisens2edf.h
HEADERS += date_time_stamp_parser.h
HEADERS += spike_filter.h
HEADERS += spike_filter_dialog.h
HEADERS += mit2edf.h
HEADERS += biox2edf.h
HEADERS += third_party/fidlib/fidlib.h
HEADERS += third_party/fidlib/fidmkf.h
HEADERS += third_party/fidlib/fidrf_cmdlist.h
HEADERS += third_party/kiss_fft/kiss_fft.h
HEADERS += third_party/kiss_fft/_kiss_fft_guts.h
HEADERS += third_party/kiss_fft/kiss_fftr.h
SOURCES += main.cpp
SOURCES += mainwindow_constr.cpp
SOURCES += mainwindow.cpp
SOURCES += viewbuf.cpp
SOURCES += videoplayer.cpp
SOURCES += read_write_settings.cpp
SOURCES += viewcurve.cpp
SOURCES += check_edf_file.cpp
SOURCES += show_edf_hdr.cpp
SOURCES += signals_dialog.cpp
SOURCES += signal_chooser.cpp
SOURCES += ascii_export.cpp
SOURCES += edf_compat.cpp
SOURCES += colordialog.cpp
SOURCES += filter.cpp
SOURCES += filter_dialog.cpp
SOURCES += jump_dialog.cpp
SOURCES += about_dialog.cpp
SOURCES += edf_annotations.cpp
SOURCES += annotations_dock.cpp
SOURCES += options_dialog.cpp
SOURCES += nk2edf.cpp
SOURCES += xml.cpp
SOURCES += save_montage_dialog.cpp
SOURCES += load_montage_dialog.cpp
SOURCES += view_montage_dialog.cpp
SOURCES += show_actual_montage_dialog.cpp
SOURCES += print_to_edf.cpp
SOURCES += pagetime_dialog.cpp
SOURCES += print_to_bdf.cpp
SOURCES += ascii2edf.cpp
SOURCES += fino2edf.cpp
SOURCES += nexfin2edf.cpp
SOURCES += edfplusd_cnv.cpp
SOURCES += utc_date_time.c
SOURCES += emsa2edf.cpp
SOURCES += special_button.cpp
SOURCES += bdf2edf.cpp
SOURCES += edit_annotation_dock.cpp
SOURCES += popup_save_cancelwindow.cpp
SOURCES += save_annots.cpp
SOURCES += filtercurve.cpp
SOURCES += utils.c
SOURCES += signalcurve.cpp
SOURCES += spectrumanalyzer.cpp
SOURCES += bi9800.cpp
SOURCES += edflib.c
SOURCES += export_annotations.cpp
SOURCES += edit_predefined_mtg.cpp
SOURCES += spectrum_dock.cpp
SOURCES += edf_annot_list.c
SOURCES += reduce_signals.cpp
SOURCES += active_file_chooser.cpp
SOURCES += header_editor.cpp
SOURCES += biosemi2bdfplus.cpp
SOURCES += bdf_triggers.cpp
SOURCES += adjustfiltersettings.cpp
SOURCES += import_annotations.cpp
SOURCES += ravg_filter.cpp
SOURCES += wav2edf.cpp
SOURCES += fma_ecg2edf.cpp
SOURCES += averager_dialog.cpp
SOURCES += averager_curve_wnd.cpp
SOURCES += ecg_filter.cpp
SOURCES += ecg_export.cpp
SOURCES += statistics_dialog.cpp
SOURCES += filteredblockread.cpp
SOURCES += flywheel.cpp
SOURCES += z_score_dialog.cpp
SOURCES += z_ratio_filter.cpp
SOURCES += raw2edf.cpp
SOURCES += check_for_updates.cpp
SOURCES += manscan2edf.cpp
SOURCES += scp_ecg2edf.cpp
SOURCES += unisens2edf.cpp
SOURCES += date_time_stamp_parser.c
SOURCES += spike_filter.cpp
SOURCES += spike_filter_dialog.cpp
SOURCES += mit2edf.cpp
SOURCES += biox2edf.cpp
SOURCES += third_party/fidlib/fidlib.c
SOURCES += third_party/kiss_fft/kiss_fft.c
SOURCES += third_party/kiss_fft/kiss_fftr.c
RESOURCES = images.qrc
win32 {
RC_FILE = edfbrowser.rc
}
QMAKE_CXXFLAGS += -Wextra -Wshadow -Wformat-nonliteral -Wformat-security -Wtype-limits -Wfatal-errors
unix {
target.path = /usr/bin
target.files = edfbrowser
INSTALLS += target
documentation.path = /usr/share/doc/edfbrowser
documentation.files = doc/*
INSTALLS += documentation
icon_a.path = /usr/share/icons
icon_a.files = images/edf.png
INSTALLS += icon_a
icon_b.path += /usr/share/pixmaps
icon_b.files = images/edf.png
INSTALLS += icon_b
icon_c.path += /usr/share/icons/hicolor/48x48/apps
icon_c.files = images/edf.png
INSTALLS += icon_c
icon_d.path += /usr/share/icons/hicolor/48x48/mimetypes
icon_d.files = images/edf.png
INSTALLS += icon_d
desktop_link.path += /usr/share/applications
desktop_link.files += install/edfbrowser.desktop
INSTALLS += desktop_link
mime.path += /usr/share/mime/packages
mime.files += install/edfbrowser.xml
INSTALLS += mime
}
edfbrowser_157_source/PaxHeaders.7921/biosemi2bdfplus.cpp 0000644 0000000 0000000 00000000132 12646460742 020463 x ustar 00 30 mtime=1452958178.246246736
30 atime=1452958178.246246736
30 ctime=1452958178.246246736
edfbrowser_157_source/biosemi2bdfplus.cpp 0000644 0001750 0000144 00000056662 12646460742 021043 0 ustar 00guv users 0000000 0000000 /*
***************************************************************************
*
* Author: Teunis van Beelen
*
* Copyright (C) 2010, 2011, 2012, 2013, 2014, 2015, 2016 Teunis van Beelen
*
* Email: teuniz@gmail.com
*
***************************************************************************
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
***************************************************************************
*/
#include "biosemi2bdfplus.h"
UI_BIOSEMI2BDFPLUSwindow::UI_BIOSEMI2BDFPLUSwindow(QWidget *w_parent)
{
int i;
char str[128];
mainwindow = (UI_Mainwindow *)w_parent;
recent_opendir = mainwindow->recent_opendir;
recent_savedir = mainwindow->recent_savedir;
myobjectDialog = new QDialog;
myobjectDialog->setMinimumSize(600, 630);
myobjectDialog->setMaximumSize(600, 630);
myobjectDialog->setWindowTitle("Biosemi to BDF+ converter");
myobjectDialog->setModal(true);
myobjectDialog->setAttribute(Qt::WA_DeleteOnClose, true);
label2 = new QLabel(myobjectDialog);
label2->setGeometry(20, 20, 200, 25);
label2->setText("Trigger Input descriptions:");
label3 = new QLabel(myobjectDialog);
label3->setGeometry(290, 350, 200, 25);
label3->setText("Annotations will be generated at");
label4 = new QLabel(myobjectDialog);
label4->setGeometry(290, 440, 200, 25);
label4->setText("of trigger input.");
for(i=0; i<16; i++)
{
label1[i] = new QLabel(myobjectDialog);
label1[i]->setGeometry(20, 50 + (i * 30), 20, 25);
sprintf(str, "%i", i + 1);
label1[i]->setText(str);
lineEdit1[i] = new QLineEdit(myobjectDialog);
lineEdit1[i]->setGeometry(70, 50 + (i * 30), 120, 25);
sprintf(str, "Trigger Input %i", i + 1);
lineEdit1[i]->setText(str);
lineEdit1[i]->setMaxLength(16);
}
radioButton1 = new QRadioButton(myobjectDialog);
radioButton1->setGeometry(290, 385, 150, 20);
radioButton1->setText("rising edge");
radioButton1->setChecked(true);
radioButton2 = new QRadioButton(myobjectDialog);
radioButton2->setGeometry(290, 415, 150, 20);
radioButton2->setText("falling edge");
checkBox1 = new QCheckBox(myobjectDialog);
checkBox1->setGeometry(290, 500, 200, 20);
checkBox1->setText("measure event duration");
checkBox1->setTristate(false);
checkBox1->setChecked(false);
selectButton = new QPushButton(myobjectDialog);
selectButton->setGeometry(20, 584, 100, 25);
selectButton->setText("Select File");
closeButton = new QPushButton(myobjectDialog);
closeButton->setGeometry(480, 584, 100, 25);
closeButton->setText("Close");
QObject::connect(selectButton, SIGNAL(clicked()), this, SLOT(SelectFileButton()));
QObject::connect(closeButton, SIGNAL(clicked()), myobjectDialog, SLOT(close()));
inputpath[0] = 0;
outputpath[0] = 0;
myobjectDialog->exec();
}
void UI_BIOSEMI2BDFPLUSwindow::SelectFileButton()
{
int i, j, k,
error,
hdl_in,
hdl_out,
edfsignals,
status_signal=0,
status_samples_in_datarecord=0,
rising_edge,
set_duration,
status[24],
totalSamplesInDatarecord,
*buf,
buf_offset[EDFLIB_MAXSIGNALS],
sf,
new_sf,
samplerate_divider;
char str[2048],
triggerlabel[24][64],
outputfilename[MAX_PATH_LENGTH];
long long datarecords,
status_sample_duration,
trigger_cnt,
progress_steps;
struct edf_hdr_struct hdr;
struct annotationblock *annotlist=NULL;
struct annotationblock *annotation;
for(i=0; i<16; i++)
{
if(!lineEdit1[i]->text().length())
{
sprintf(str, "Trigger Input label %i is empty!", i + 1);
QMessageBox messagewindow(QMessageBox::Critical, "Error", str);
messagewindow.exec();
return;
}
}
for(i=0; i<16; i++)
{
for(j=0; j<16; j++)
{
if(i != j)
{
if(!strcmp(lineEdit1[i]->text().toLocal8Bit().data(), lineEdit1[j]->text().toLocal8Bit().data()))
{
sprintf(str, "Trigger Input labels %i and %i are the same!", i + 1, j + 1);
QMessageBox messagewindow(QMessageBox::Critical, "Error", str);
messagewindow.exec();
return;
}
}
}
}
str[0] = 0;
strcpy(inputpath, QFileDialog::getOpenFileName(0, "Select inputfile", QString::fromLocal8Bit(recent_opendir), "BDF files (*.bdf *.BDF)").toLocal8Bit().data());
if(!strcmp(inputpath, ""))
{
return;
}
get_directory_from_path(recent_opendir, inputpath, MAX_PATH_LENGTH);
error = edfopen_file_readonly(inputpath, &hdr, EDFLIB_DO_NOT_READ_ANNOTATIONS);
if(error < 0)
{
error = hdr.filetype;
switch(error)
{
case EDFLIB_MALLOC_ERROR : strcpy(str, "EDFlib: malloc error.");
break;
case EDFLIB_NO_SUCH_FILE_OR_DIRECTORY : strcpy(str, "EDFlib: no such file or directory.");
break;
case EDFLIB_FILE_CONTAINS_FORMAT_ERRORS : strcpy(str, "EDFlib: file contains format errors.\nOpen the file in EDFbrowser to get more info.");
break;
case EDFLIB_MAXFILES_REACHED : strcpy(str, "EDFlib: maximum amount of files reached.");
break;
case EDFLIB_FILE_READ_ERROR : strcpy(str, "EDFlib: a file read error occurred.");
break;
case EDFLIB_FILE_ALREADY_OPENED : strcpy(str, "EDFlib: file is already opened.");
break;
case EDFLIB_FILETYPE_ERROR : strcpy(str, "EDFlib: filetype error.");
break;
case EDFLIB_FILE_WRITE_ERROR : strcpy(str, "EDFlib: file write error.");
break;
case EDFLIB_NUMBER_OF_SIGNALS_INVALID : strcpy(str, "EDFlib: invalid number of signals.");
break;
case EDFLIB_FILE_IS_DISCONTINUOUS : strcpy(str, "EDFlib: file is discontinuous.");
break;
case EDFLIB_INVALID_READ_ANNOTS_VALUE : strcpy(str, "EDFlib: invalid read annotations argument.");
break;
default : strcpy(str, "EDFlib: unknown error.");
}
QMessageBox messagewindow(QMessageBox::Critical, "Error", str);
messagewindow.exec();
return;
}
hdl_in = hdr.handle;
/////////////////// check file /////////////////////////////////////////////
if(hdr.filetype == EDFLIB_FILETYPE_BDFPLUS)
{
QMessageBox messagewindow(QMessageBox::Critical, "Error", "Selected file is already a BDF-plus file.");
messagewindow.exec();
edfclose_file(hdl_in);
return;
}
if(hdr.filetype != EDFLIB_FILETYPE_BDF)
{
QMessageBox messagewindow(QMessageBox::Critical, "Error", "Selected file is not a BDF file.");
messagewindow.exec();
edfclose_file(hdl_in);
return;
}
if(hdr.datarecord_duration != EDFLIB_TIME_DIMENSION)
{
QMessageBox messagewindow(QMessageBox::Critical, "Error", "Datarecord duration of inputfile must be 1 second.");
messagewindow.exec();
edfclose_file(hdl_in);
return;
}
edfsignals = hdr.edfsignals;
if(edfsignals < 1)
{
QMessageBox messagewindow(QMessageBox::Critical, "Error", "There are no signals in the selected file.");
messagewindow.exec();
edfclose_file(hdl_in);
return;
}
sf = hdr.signalparam[0].smp_in_datarecord;
for(i=1; itext().toUtf8().data());
triggerlabel[i][16] = 0;
}
strcpy(&triggerlabel[16][0], "new epoch");
if(radioButton1->isChecked() == true)
{
rising_edge = 1;
for(i=0; i<16; i++)
{
status[i] = 1;
}
}
else
{
rising_edge = 0;
for(i=0; i<16; i++)
{
status[i] = 0;
}
}
if(checkBox1->isChecked() == true)
{
set_duration = 1;
}
else
{
set_duration = 0;
}
for(i=16; i<24; i++)
{
status[i] = 1;
}
strcpy(outputfilename, inputpath);
remove_extension_from_filename(outputfilename);
strcat(outputfilename, "_+.bdf");
outputpath[0] = 0;
if(recent_savedir[0]!=0)
{
strcpy(outputpath, recent_savedir);
strcat(outputpath, "/");
}
strcat(outputpath, outputfilename);
strcpy(outputpath, QFileDialog::getSaveFileName(0, "Output file", QString::fromLocal8Bit(outputpath), "BDF files (*.bdf *.BDF)").toLocal8Bit().data());
if(!strcmp(outputpath, ""))
{
edfclose_file(hdl_in);
return;
}
get_directory_from_path(recent_savedir, outputpath, MAX_PATH_LENGTH);
if(mainwindow->file_is_opened(outputpath))
{
QMessageBox messagewindow(QMessageBox::Critical, "Error", "Outputfile is already opened in EDFbrowser.\nClose the file and try again.");
messagewindow.exec();
edfclose_file(hdl_in);
return;
}
if(!(strcmp(inputpath, outputpath)))
{
QMessageBox messagewindow(QMessageBox::Critical, "Error", "Inputfile and outputfile are the same.");
messagewindow.exec();
edfclose_file(hdl_in);
return;
}
hdl_out = edfopen_file_writeonly(outputpath, EDFLIB_FILETYPE_BDFPLUS, edfsignals);
if(hdl_out < 0)
{
switch(hdl_out)
{
case EDFLIB_MALLOC_ERROR : strcpy(str, "EDFlib: malloc error.");
break;
case EDFLIB_NO_SUCH_FILE_OR_DIRECTORY : strcpy(str, "EDFlib: no such file or directory.");
break;
case EDFLIB_MAXFILES_REACHED : strcpy(str, "EDFlib: maximum amount of files reached.");
break;
case EDFLIB_FILE_READ_ERROR : strcpy(str, "EDFlib: a file read error occurred.");
break;
case EDFLIB_FILE_ALREADY_OPENED : strcpy(str, "EDFlib: file is already opened.");
break;
case EDFLIB_FILETYPE_ERROR : strcpy(str, "EDFlib: filetype error.");
break;
case EDFLIB_FILE_WRITE_ERROR : strcpy(str, "EDFlib: file write error.");
break;
case EDFLIB_NUMBER_OF_SIGNALS_INVALID : strcpy(str, "EDFlib: invalid number of signals.");
break;
default : strcpy(str, "EDFlib: unknown error.");
}
QMessageBox messagewindow(QMessageBox::Critical, "Error", str);
messagewindow.exec();
edfclose_file(hdl_in);
return;
}
/////////////////// copy header /////////////////////////////////////////////
for(i=0; i= ((hdr.datarecords_in_file * 32) - 2))
{
break;
}
if(trigger_cnt >= 100000)
{
break;
}
if(!(datarecords % progress_steps))
{
progress.setValue((int)datarecords);
qApp->processEvents();
if(progress.wasCanceled())
{
edfclose_file(hdl_in);
edfclose_file(hdl_out);
free(buf);
edfplus_annotation_delete_list(&annotlist);
return;
}
}
if(edfread_digital_samples(hdl_in, status_signal, status_samples_in_datarecord, buf) < 0)
{
progress.reset();
QMessageBox messagewindow(QMessageBox::Critical, "Error", "A read error occurred during the collection of triggers.");
messagewindow.exec();
edfclose_file(hdl_in);
edfclose_file(hdl_out);
free(buf);
edfplus_annotation_delete_list(&annotlist);
return;
}
for(i=0; ionset = (datarecords * EDFLIB_TIME_DIMENSION) + ((long long)i * status_sample_duration);
annotation->onset += hdr.starttime_subsecond;
strcpy(annotation->annotation, triggerlabel[j]);
edfplus_annotation_add_item(&annotlist, annotation);
trigger_cnt++;
}
else
{
if(set_duration)
{
k = edfplus_annotation_count(&annotlist);
for(; k>0; k--)
{
annotation = edfplus_annotation_item(&annotlist, k - 1);
if(annotation == NULL)
{
break;
}
if(!strcmp(annotation->annotation, triggerlabel[j]))
{
sprintf(str, "%.4f", (double)((datarecords * EDFLIB_TIME_DIMENSION) + ((long long)i * status_sample_duration) - annotation->onset) / (double)EDFLIB_TIME_DIMENSION);
str[15] = 0;
strcpy(annotation->duration, str);
break;
}
}
}
}
status[j] = 0;
}
else // rising edge detected
{
if(rising_edge || (j == 16))
{
annotation = (struct annotationblock *)calloc(1, sizeof(struct annotationblock));
if(annotation == NULL)
{
progress.reset();
QMessageBox messagewindow(QMessageBox::Critical, "Error", "Malloc error (annotation).");
messagewindow.exec();
edfclose_file(hdl_in);
edfclose_file(hdl_out);
free(buf);
edfplus_annotation_delete_list(&annotlist);
return;
}
annotation->onset = (datarecords * EDFLIB_TIME_DIMENSION) + ((long long)i * status_sample_duration);
annotation->onset += hdr.starttime_subsecond;
strcpy(annotation->annotation, triggerlabel[j]);
edfplus_annotation_add_item(&annotlist, annotation);
trigger_cnt++;
}
else
{
if(set_duration)
{
k = edfplus_annotation_count(&annotlist);
for(; k>0; k--)
{
annotation = edfplus_annotation_item(&annotlist, k - 1);
if(annotation == NULL)
{
break;
}
if(!strcmp(annotation->annotation, triggerlabel[j]))
{
sprintf(str, "%.4f", (double)((datarecords * EDFLIB_TIME_DIMENSION) + ((long long)i * status_sample_duration) - annotation->onset) / (double)EDFLIB_TIME_DIMENSION);
str[15] = 0;
strcpy(annotation->duration, str);
break;
}
}
}
}
status[j] = 1;
}
}
}
}
}
edfwrite_annotation_latin1(hdl_out, 0LL, -1LL, "Recording starts");
j = edfplus_annotation_count(&annotlist);
for(i=0; iduration[0] == 0)
{
edfwrite_annotation_utf8(hdl_out, annotation->onset / 1000LL, -1LL, annotation->annotation);
}
else
{
edfwrite_annotation_utf8(hdl_out, annotation->onset / 1000LL, (long long)(atof(annotation->duration) * 10000.0), annotation->annotation);
}
}
free(buf);
edfwrite_annotation_latin1(hdl_out, hdr.datarecords_in_file * 10000LL, -1LL, "Recording ends");
/////////////////// choose datarecord duration /////////////////////////////////////////////
samplerate_divider = 1;
i = edfplus_annotation_count(&annotlist);
edfplus_annotation_delete_list(&annotlist);
annotlist = NULL;
if(i % 2)
{
i++;
}
i += 2;
while(i > hdr.datarecords_in_file)
{
samplerate_divider *= 2;
i /= 2;
if(samplerate_divider == 32)
{
break;
}
}
if(samplerate_divider > 1)
{
for(i=0; iprocessEvents();
if(progress.wasCanceled())
{
edfclose_file(hdl_in);
edfclose_file(hdl_out);
free(buf);
return;
}
}
for(i=0; i