@@ -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+
492500void MainWindow::printReplacedFilename () {
493501 ui->locationLabel ->setText (
494502 ui->rootEdit ->text () + ' \n ' + replaceFilename (ui->lineEdit_template ->text ()));
0 commit comments