-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathch-plot-intensity-file
executable file
·43 lines (34 loc) · 1.39 KB
/
ch-plot-intensity-file
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
#!/usr/bin/env python
import os
import sys
import argparse
class HelpfulParser(argparse.ArgumentParser):
def error(self, message):
self.print_help(sys.stderr)
sys.stderr.write('error: %s\n' % message)
sys.exit(2)
parser = HelpfulParser()
parser.add_argument('filename')
parser.add_argument('-d', action='store_true', help='detrend using simple_detrender')
args = parser.parse_args()
input_filename = args.filename
input_basename = os.path.basename(input_filename)
input_dirname = os.path.dirname(input_filename)
output_basename = ('detrended_' if args.d else 'raw_')
for suffix in [ '.h5', '.hdf5' ]:
if input_basename.endswith(suffix):
output_basename += input_basename[:-len(suffix)]
output_stem = os.path.join(input_dirname, output_basename)
break
else:
print >>sys.stderr, "ch-plot-intensity-file: expected filename '%s' to end with either .h5 or .hdf5" % input_filename
sys.exit(1)
try:
import rf_pipelines
except ImportError:
print >>sys.stderr, "ch-plot-intensity-file: Couldn't import rf_pipelines. Maybe you need to install it? (https://github.com/kmsmith137/rf_pipelines)"
sys.exit(1)
s = rf_pipelines.chime_stream_from_filename(input_filename)
t = rf_pipelines.plotter_transform(output_stem, img_nfreq=512, img_nt=1536, downsample_nt=16)
tlist = [ rf_pipelines.simple_detrender(1024), t ] if args.d else [ t ]
s.run(tlist)