-
Notifications
You must be signed in to change notification settings - Fork 4
/
grab_image_from_scanner.py
executable file
·65 lines (55 loc) · 1.84 KB
/
grab_image_from_scanner.py
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
#! /usr/bin/env python
"""Retrieve an image from a specific series in the current exam."""
from __future__ import print_function
import sys
import optparse
import textwrap
# Change this path to point to where the rtfmri code lives
try:
sys.path.insert(0, "/home/cniuser/rt/rtfmri")
except:
pass
from rtfmri.fetcher import SessionFetcher
def main(arglist):
args = parse_args(arglist)
client = SessionFetcher(hostname=args.hostname, username=args.username,
password=args.password, port=args.port,
base_dir=args.image_dir, outfile=args.output)
def parse_args(arglist):
usage = """\
usage: grab_image_from_scanner.py [options]
-u / --username must be specified
-p / --password must be specified
-o / --output must be specified
"""
parser = optparse.OptionParser(usage=textwrap.dedent(usage))
parser.add_option(
'-u', '--username', default='',
help='login username USERNAME '
)
parser.add_option(
'-p', '--password', default='',
help='login PASSWORD'
)
parser.add_option(
'-o', '--output',
help='create new nii file OUTPUT [required]'
)
parser.add_option(
'--host', dest='hostname', default='cnimr',
help='find scanner at HOST [default: %default]')
parser.add_option(
'--port', dest='port', type='int', default=22,
help='connect via PORT [default: %default]'
)
parser.add_option(
'--image-dir', dest = 'image_dir', default='/export/home1/sdc_image_pool/images',
help='directory containing patients/exams/sessions [default: %default]'
)
options, args = parser.parse_args()
if options.output is None:
parser.print_help()
sys.exit(-1)
return options
if __name__ == "__main__":
main(sys.argv[1:])