1
- import glob , subprocess , sys
1
+ import glob
2
+ import subprocess
3
+ import sys
4
+
2
5
3
6
def query_yes_no (question , default = "yes" ):
4
7
"""Ask a yes/no question via raw_input() and return their answer.
@@ -10,8 +13,8 @@ def query_yes_no(question, default="yes"):
10
13
11
14
The "answer" return value is one of "yes" or "no".
12
15
"""
13
- valid = {"yes" :False , "y" :False , "ye" :False ,
14
- "no" :True , "n" :True }
16
+ valid = {"yes" : False , "y" : False , "ye" : False ,
17
+ "no" : True , "n" : True }
15
18
if default == None :
16
19
prompt = " [y/n] "
17
20
elif default == "yes" :
@@ -29,21 +32,22 @@ def query_yes_no(question, default="yes"):
29
32
elif choice in valid :
30
33
return valid [choice ]
31
34
else :
32
- sys .stdout .write ("Please respond with 'yes' or 'no' " \
35
+ sys .stdout .write ("Please respond with 'yes' or 'no' "
33
36
"(or 'y' or 'n').\n " )
34
37
35
38
36
39
if (len (sys .argv ) < 4 ):
37
- print 'e.g. python nrrd2wlzDom.py DomainPrefix templateFile WoolzDir FijiExec Zsize XYsize'
38
- print 'Error: missing arguments - using defaults:'
39
- print 'e.g. python nrrd2wlzDom.py TAGdomain flyVNCtemplate20xDaS_th.wlz /disk/data/VFBTools/Woolz2013Full/bin/ /disk/data/VFBTools/Fiji.145/fiji-linux64'
40
+ print ( 'e.g. python nrrd2wlzDom.py DomainPrefix templateFile WoolzDir FijiExec Zsize XYsize' )
41
+ print ( 'Error: missing arguments - using defaults:' )
42
+ print ( 'e.g. python nrrd2wlzDom.py TAGdomain flyVNCtemplate20xDaS_th.wlz /disk/data/VFBTools/Woolz2013Full/bin/ /disk/data/VFBTools/Fiji.145/fiji-linux64' )
40
43
wlzdir = '/disk/data/VFBTools/Woolz2013Full/bin/'
41
44
Tfile = 'flyVNCtemplate20xDaS_th.wlz'
42
45
Fpre = 'TAGdomain'
43
46
Lfiji = '/disk/data/VFBTools/Fiji.145/fiji-linux64'
44
47
Zsize = str (1 )
45
48
Vsize = str (1 )
46
- if query_yes_no ('Do you want to run with the defaults?' , default = 'no' ): sys .exit (0 )
49
+ if query_yes_no ('Do you want to run with the defaults?' , default = 'no' ):
50
+ sys .exit (0 )
47
51
else :
48
52
Lfiji = str (sys .argv [4 ])
49
53
wlzdir = str (sys .argv [3 ])
@@ -53,32 +57,37 @@ def query_yes_no(question, default="yes"):
53
57
Vsize = str (sys .argv [6 ])
54
58
55
59
for infile in glob .glob (Fpre + "0*.nrrd" ):
56
- print 'Converting %s to %s...' % (infile , infile .replace ('.nrrd' ,'.tif' ))
57
- subprocess .call ('nice xvfb-run %s -macro nrrd2tif.ijm %s -batch' % (Lfiji , infile ), shell = True )
60
+ print ('Converting %s to %s...' % (infile , infile .replace ('.nrrd' , '.tif' )))
61
+ subprocess .call ('nice xvfb-run %s -macro nrrd2tif.ijm %s -batch' %
62
+ (Lfiji , infile ), shell = True )
58
63
59
- for i in xrange (1 ,250 ):
64
+ for i in xrange (1 , 250 ):
60
65
outfile = Fpre + str (i ).zfill (4 ) + '_dom.wlz'
61
- print 'Creating blank %s...' % outfile
62
- subprocess .call ('nice %sWlzMakeEmpty -o%s' % (wlzdir , outfile ), shell = True )
66
+ print ( 'Creating blank %s...' % outfile )
67
+ subprocess .call ('nice %sWlzMakeEmpty -o%s' % (wlzdir , outfile ), shell = True )
63
68
64
69
65
70
for infile in glob .glob (Fpre + "0*.tif" ):
66
- outfile = infile .replace ('.tif' ,'_dom.wlz' )
67
- print 'Converting %s to %s...' % (infile , outfile )
68
- subprocess .call ('nice %sWlzExtFFConvert -ftif -Fwlz %s | %sWlzThreshold -v1 |%sWlzDomain |%sWlzSetVoxelSize -x%s -y%s -z%s >%s' % (wlzdir , infile , wlzdir , wlzdir , wlzdir , Vsize , Vsize , Zsize , outfile ), shell = True )
69
- comfile = infile .replace ('.tif' ,'.txt' )
70
- print 'Calculating centre for %s and saving to %s...' % (outfile , comfile )
71
- subprocess .call ('nice %sWlzCentreOfMass -o %s %s' % (wlzdir , comfile , outfile ), shell = True )
71
+ outfile = infile .replace ('.tif' , '_dom.wlz' )
72
+ print ('Converting %s to %s...' % (infile , outfile ))
73
+ subprocess .call ('nice %sWlzExtFFConvert -ftif -Fwlz %s | %sWlzThreshold -v1 |%sWlzDomain |%sWlzSetVoxelSize -x%s -y%s -z%s >%s' %
74
+ (wlzdir , infile , wlzdir , wlzdir , wlzdir , Vsize , Vsize , Zsize , outfile ), shell = True )
75
+ comfile = infile .replace ('.tif' , '.txt' )
76
+ print ('Calculating centre for %s and saving to %s...' % (outfile , comfile ))
77
+ subprocess .call ('nice %sWlzCentreOfMass -o %s %s' %
78
+ (wlzdir , comfile , outfile ), shell = True )
72
79
73
- #print '%sWlzExtFFConvert -ftif -Fwlz %s | %sWlzDomain >%s' % (wlzdir, infile, wlzdir, outfile)
80
+ # print( '%sWlzExtFFConvert -ftif -Fwlz %s | %sWlzDomain >%s' % (wlzdir, infile, wlzdir, outfile)
74
81
75
82
76
- print 'Compiling...'
83
+ print ( 'Compiling...' )
77
84
78
- subprocess .call ('%sWlzSetVoxelSize -x%s -y%s -z%s %s >%s' % (wlzdir , Vsize , Vsize , Zsize , Tfile , Tfile .replace ('.wlz' ,'_E.wlz' )), shell = True )
85
+ subprocess .call ('%sWlzSetVoxelSize -x%s -y%s -z%s %s >%s' % (wlzdir , Vsize ,
86
+ Vsize , Zsize , Tfile , Tfile .replace ('.wlz' , '_E.wlz' )), shell = True )
79
87
80
88
#subprocess.call('find %s0*_dom.wlz -size -2b | xargs rm -f'% (Fpre), shell=True)
81
89
82
- subprocess .call ('cat %s %s0*_dom.wlz | %sWlzCompound >out.wlz' % (Tfile .replace ('.wlz' ,'_E.wlz' ), Fpre , wlzdir ), shell = True )
90
+ subprocess .call ('cat %s %s0*_dom.wlz | %sWlzCompound >out.wlz' %
91
+ (Tfile .replace ('.wlz' , '_E.wlz' ), Fpre , wlzdir ), shell = True )
83
92
84
- print 'Result saved to out.wlz'
93
+ print ( 'Result saved to out.wlz' )
0 commit comments