-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
131 lines (117 loc) · 5.82 KB
/
main.cpp
File metadata and controls
131 lines (117 loc) · 5.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
/*
*****************************************************************************
*
* Cuculus is command line application for converting EEG *.SIG files (Schwarzer BrainLab) to *.EDF
* Copyright (C) 2022 Adam Kalina
* email: adam.kalina89@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 <https://www.gnu.org/licenses/>.
*
*****************************************************************************
*/
#include <QCoreApplication>
#include <QDebug>
#include <QString>
#include <QCommandLineParser>
#include <QElapsedTimer>
#include "wrapper.h"
QString EdfPath;
int main(int argc, char *argv[])
{
setlocale(LC_ALL, "czech");
QCoreApplication a(argc, argv);
QCoreApplication::setApplicationName("Cuculus - .SIG to .EDF converter");
QCoreApplication::setApplicationVersion("0.3");
QCommandLineParser parser;
parser.setApplicationDescription(
" :.\n"
" ~?7.\n"
" .~J5?:\n"
" .::::. .~J55?.\n"
" .~7?77!77?!: ~J55Y!.\n"
" :~!7YJ: .7^ :!?777!~^. ~J5557.\n"
" .^??: . ..:^!7??7^^J555?:\n"
" 7Y. :~7J555!\n"
" .Y7 .:. :!J7:\n"
" :Y! .:~~~^:.... .~??~. . :^\n"
" :7J?77!^ ^Y7. .^~!7??????????7~ .7?!!7\n"
" :7?!^..^7?!^. .7J!: ..::.. .^7?7:...^7J?7.\n"
" .^!77!~~!7?7!^. :7JJ7!~^^^^^~~~^:..:~!??7~^~!777!~:.\n"
" ^~~~!!7?JYYJ7!^::^!7????7!~~^~!?JYYJ?77!!~^. :.\n"
" ^77!~^::.:^^~!!!7?JYYYYYYYJ?7!~~^::.YYJ?7!.^!7?7^..\n"
" :::^!?JJ?!~^^~~!!7??7!~~!77!!!!777?????7?JYYJ?777\n"
" !!!!!777!!7?JJ??7!!~~~~~~!!77????7!~^:....\n"
"\n"
"Cuculus is .SIG (Brainlab) to .EDF converter based of EDFlib by Teuniz and sigtoedf by Frederik-D-Weber.\n"
"Cuculus Copyright (C) 2022 Adam Kalina\n"
"This program comes with ABSOLUTELY NO WARRANTY\n"
"This is free software, and you are welcome to redistribute it\n");
parser.addHelpOption();
parser.addVersionOption();
QCommandLineOption anonymizeOption("a", QCoreApplication::translate("main", "Anonymize output"));
parser.addOption(anonymizeOption);
QCommandLineOption shortenOption("s", QCoreApplication::translate("main", "Shorten events labels"));
parser.addOption(shortenOption);
QCommandLineOption systemEventsOption("y", QCoreApplication::translate("main", "Export recorder system events in annotations"));
parser.addOption(systemEventsOption);
parser.addPositionalArgument("input", QCoreApplication::translate("main", "Source *.SIG file"));
parser.addPositionalArgument("output", QCoreApplication::translate("main", "Target *.EDF file - optional"));
// Process the actual command line arguments given by the user
parser.process(a);
const QStringList args = parser.positionalArguments();
// source is args.at(0), destination is args.at(1)
bool anonymize = parser.isSet(anonymizeOption); // disable adding patients info in the header
bool shorten = parser.isSet(shortenOption); // use shortened labels for events, e.g. ZO/OO
bool exportSystemEvents = parser.isSet(systemEventsOption);
// qDebug() << "anonymize is " << anonymize;
// qDebug() << "shorten is " << shorten;
// qDebug() << args;
if(args.size()==0){
parser.showHelp();
}
else{
QFileInfo infoSig(args.at(0));
if(args.size() == 2){ // two arguments provided
EdfPath = args.at(1);
}else{ // only one (or more than two) arguments provided
EdfPath = infoSig.path() + "/" + infoSig.completeBaseName() + ".EDF";
//qDebug() << "Exporting to the same folder";
std::cout << "Exporting to the same folder" << std::endl;
}
QFileInfo infoEdf(EdfPath);
if(infoEdf.completeSuffix() != "EDF"){ //must be EDF file
//qDebug() << "The path to output does not end with .EDF - exiting";
std::cout << "The path to output does not end with .EDF - exiting" << std::endl;
return 1;
}
if(infoSig.completeSuffix().toLower() == "sig" && infoSig.exists()){ // check if input is .sig or .SIG file
// call the wrapper class here
wrapper Wrapper;
if (Wrapper.readAndSaveFileChunks(infoSig, infoEdf, anonymize, shorten, exportSystemEvents)){
std::cout << "error processing the file" << std::endl;
return 1;
}
else{
std::cout << "Finished successfully!" << std::endl;
return 0;
}
}
else{
//qDebug() << "The input file does not exist or it is not a .SIG file - exiting";
std::cout << "The input file does not exist or it is not a .SIG file - exiting" << std::endl;
return 1;
}
}
//return a.exec();
}