Skip to content

Commit 243513d

Browse files
committed
Display correct label for spin counter in BIDS/non-BIDS-mode
1 parent 25e3bee commit 243513d

3 files changed

Lines changed: 22 additions & 14 deletions

File tree

mainwindow.cpp

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ MainWindow::MainWindow(QWidget *parent, const char *config_file)
4545
connect(
4646
ui->lineEdit_template, &QLineEdit::textChanged, this, &MainWindow::printReplacedFilename);
4747
auto spinchanged = static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged);
48-
connect(ui->experimentNumberSpin, spinchanged, this, &MainWindow::printReplacedFilename);
48+
connect(ui->spin_counter, spinchanged, this, &MainWindow::printReplacedFilename);
4949

5050
// Signals for builder-related edits -> buildFilename
5151
connect(ui->rootBrowseButton, &QPushButton::clicked, [this]() {
@@ -66,8 +66,10 @@ MainWindow::MainWindow(QWidget *parent, const char *config_file)
6666
legacyTemplate = box.text();
6767
box.setText(
6868
QStringLiteral("sub-%p/ses-%s/eeg/sub-%p_ses-%s_task-%b[_acq-%a]_run-%r_eeg.xdf"));
69+
ui->label_counter->setText("Run (%r)");
6970
} else {
7071
box.setText(legacyTemplate);
72+
ui->label_counter->setText("Exp num (%n)");
7173
}
7274
});
7375

@@ -209,9 +211,9 @@ void MainWindow::load_config(QString filename) {
209211
// We only do this on settings-load because manual spin changes might indicate purposeful overwriting.
210212
QString recFilename = ui->lineEdit_template->text();
211213
// Spin Number
212-
if (recFilename.contains(QStringLiteral("%n"))) {
214+
if (recFilename.contains(counterPlaceholder())) {
213215
for (int i = 1; i < 1001; i++) {
214-
ui->experimentNumberSpin->setValue(i);
216+
ui->spin_counter->setValue(i);
215217
if (!QFileInfo::exists(replaceFilename(recFilename))) break;
216218
}
217219
}
@@ -419,9 +421,9 @@ void MainWindow::buildFilename() {
419421
QString tpl = ui->lineEdit_template->text();
420422

421423
// Auto-increment Spin/Run Number if necessary.
422-
if (tpl.contains("%n") || tpl.contains("%r")) {
424+
if (tpl.contains(counterPlaceholder())) {
423425
for (int i = 1; i < 1001; i++) {
424-
ui->experimentNumberSpin->setValue(i);
426+
ui->spin_counter->setValue(i);
425427
if (!QFileInfo::exists(replaceFilename(tpl))) break;
426428
}
427429
}
@@ -435,10 +437,8 @@ QString MainWindow::replaceFilename(QString fullfile) const {
435437
// There are two different wildcard formats: legacy, BIDS
436438

437439
// Legacy takes the form path/to/study/exp%n/%b.xdf
438-
// Where %n will be replaced by the contents of the experimentNumberSpin widget
440+
// Where %n will be replaced by the contents of the spin_counter widget
439441
// and %b will be replaced by the contents of the blockList widget.
440-
QString run = QString("%1").arg(ui->experimentNumberSpin->value(), 3, 10, QChar('0'));
441-
fullfile.replace("%n", run);
442442
fullfile.replace("%b", ui->input_blocktask->currentText());
443443

444444
// BIDS
@@ -449,7 +449,10 @@ QString MainWindow::replaceFilename(QString fullfile) const {
449449
fullfile.replace("%p", ui->lineEdit_participant->text());
450450
fullfile.replace("%s", ui->lineEdit_session->text());
451451
fullfile.replace("%a", ui->lineEdit_acq->text());
452-
fullfile.replace("%r", run);
452+
453+
// Replace either %r or %n with the counter
454+
QString run = QString("%1").arg(ui->spin_counter->value(), 3, 10, QChar('0'));
455+
fullfile.replace(counterPlaceholder(), run);
453456

454457
return fullfile;
455458
}
@@ -489,6 +492,11 @@ QString MainWindow::find_config_file(const char *filename) {
489492
return "";
490493
}
491494

495+
QString MainWindow::counterPlaceholder() const
496+
{
497+
return ui->check_bids->isChecked() ? "%r" : "%n";
498+
}
499+
492500
void MainWindow::printReplacedFilename() {
493501
ui->locationLabel->setText(
494502
ui->rootEdit->text() + '\n' + replaceFilename(ui->lineEdit_template->text()));

mainwindow.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ private slots:
5050
QString replaceFilename(QString fullfile) const;
5151
// function for loading / saving the config file
5252
QString find_config_file(const char *filename);
53+
QString counterPlaceholder() const;
5354
void load_config(QString filename);
5455
void save_config(QString filename);
5556

mainwindow.ui

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,9 @@
111111
</property>
112112
<layout class="QGridLayout" name="gridLayout_2">
113113
<item row="3" column="0">
114-
<widget class="QLabel" name="label_expNum">
114+
<widget class="QLabel" name="label_counter">
115115
<property name="text">
116-
<string>Exp num (%n)
117-
Run (%r)</string>
116+
<string>Counter</string>
118117
</property>
119118
</widget>
120119
</item>
@@ -209,7 +208,7 @@ Run (%r)</string>
209208
</spacer>
210209
</item>
211210
<item row="3" column="1">
212-
<widget class="QSpinBox" name="experimentNumberSpin">
211+
<widget class="QSpinBox" name="spin_counter">
213212
<property name="minimum">
214213
<number>1</number>
215214
</property>
@@ -300,7 +299,7 @@ Run (%r)</string>
300299
<tabstop>lineEdit_template</tabstop>
301300
<tabstop>check_bids</tabstop>
302301
<tabstop>input_blocktask</tabstop>
303-
<tabstop>experimentNumberSpin</tabstop>
302+
<tabstop>spin_counter</tabstop>
304303
<tabstop>lineEdit_participant</tabstop>
305304
<tabstop>lineEdit_session</tabstop>
306305
<tabstop>lineEdit_acq</tabstop>

0 commit comments

Comments
 (0)