Skip to content

Commit df0ad99

Browse files
committed
Change default output filename in client.py to be based on the input filename
1 parent 32b2b81 commit df0ad99

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

client.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
'filename': '',
2020
'in_group': '',
2121
'address': 'localhost',
22-
'port': 9002,
23-
'outfile': 'out.h5',
22+
'port': 9002,
23+
'outfile': None,
2424
'out_group': str(datetime.datetime.now()),
2525
'config': 'invertcontrast',
2626
'config_local': '',
@@ -322,6 +322,7 @@ def main(args):
322322
logging.info("Sent %5d acquisitions | Received %5d acquisitions", connection.sentAcqs, recvWaveforms.value)
323323
logging.info("Sent %5d images | Received %5d images", connection.sentImages, recvImages.value)
324324
logging.info("Sent %5d waveforms | Received %5d waveforms", connection.sentWaveforms, recvWaveforms.value)
325+
logging.info("Results written to %s", args.outfile)
325326
logging.info("Session complete")
326327

327328
return
@@ -340,7 +341,7 @@ def main(args):
340341
parser.add_argument('-C', '--config-local', help='Local configuration file')
341342
parser.add_argument('-w', '--send-waveforms', action='store_true', help='Send waveform (physio) data')
342343
parser.add_argument('-v', '--verbose', action='store_true', help='Verbose mode')
343-
parser.add_argument('-l', '--logfile', type=str, help='Path to log file')
344+
parser.add_argument('-l', '--logfile', type=str, help='Path to log file')
344345
parser.add_argument( '--ignore-json-config', action='store_true', help='Ignore config specified in JSON')
345346

346347
parser.set_defaults(**defaults)
@@ -360,6 +361,11 @@ def main(args):
360361
else:
361362
logging.root.setLevel(logging.INFO)
362363

364+
if args.outfile is None:
365+
base, ext = os.path.splitext(args.filename)
366+
args.outfile = base + '_results' + ext
367+
logging.info("Output file not specified -- writing results to %s", args.outfile)
368+
363369
# If a config is specified via the command line arguments, then set ignore_json_config to True
364370
if ('-c' in sys.argv) or ('--config' in sys.argv):
365371
args.ignore_json_config = True

0 commit comments

Comments
 (0)