annotate spyboat_cli.py @ 8:10ae027ab022 draft default tip

planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 4b95b96461684de086fe7e8086af9385f3ed7930
author iuc
date Wed, 20 Dec 2023 18:03:23 +0000
parents 639d2031d998
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
1 #!/usr/bin/env python
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
2
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
3 # Gets interfaced by Galaxy or can be used for bash scripting
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
4 import argparse
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
5 import logging
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
6 import os
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
7 import sys
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
8
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
9 import output_report
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
10 import spyboat
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
11 from numpy import float32
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
12 from skimage import io
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
13
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
14 logging.basicConfig(level=logging.INFO, stream=sys.stdout, force=True)
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
15 logger = logging.getLogger('spyboat-cli')
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
16
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
17 # ----------command line parameters ---------------
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
18
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
19 parser = argparse.ArgumentParser(description='Process some arguments.')
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
20
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
21 # I/O
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
22 parser.add_argument('--input_path', help="Input movie location", required=True)
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
23 parser.add_argument('--phase_out', help='Phase output file name', required=False)
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
24 parser.add_argument('--period_out', help='Period output file name', required=False)
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
25 parser.add_argument('--power_out', help='Power output file name', required=False)
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
26 parser.add_argument('--amplitude_out', help='Amplitude output file name', required=False)
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
27 parser.add_argument('--preprocessed_out', help="Preprocessed-input output file name", required=False)
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
28
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
29 # (Optional) Multiprocessing
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
30
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
31 parser.add_argument('--ncpu', help='Number of processors to use',
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
32 required=False, type=int, default=1)
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
33
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
34 # Optional spatial downsampling
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
35 parser.add_argument('--rescale_factor', help='Rescale the image by a factor given in %%, None means no rescaling',
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
36 required=False, type=int)
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
37 # Optional Gaussian smoothing
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
38 parser.add_argument('--gauss_sigma', help='Gaussian smoothing parameter, None means no smoothing', required=False,
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
39 type=float)
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
40
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
41 # Wavelet Analysis Parameters
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
42 parser.add_argument('--dt', help='Sampling interval', required=True, type=float)
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
43 parser.add_argument('--Tmin', help='Smallest period', required=True, type=float)
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
44 parser.add_argument('--Tmax', help='Biggest period', required=True, type=float)
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
45 parser.add_argument('--nT', help='Number of periods to scan for', required=True, type=int)
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
46
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
47 parser.add_argument('--Tcutoff', help='Sinc cut-off period, disables detrending if not set', required=False, type=float)
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
48 parser.add_argument('--win_size', help='Sliding window size for amplitude normalization, None means no normalization',
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
49 required=False, type=float)
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
50
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
51 # Optional masking
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
52 parser.add_argument('--masking', help="Set to either 'dynamic', 'static' or 'None' which is the default",
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
53 default='None', required=False, type=str)
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
54
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
55 parser.add_argument('--mask_frame',
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
56 help="The frame of the input movie to create a static mask from, needs masking set to 'static'",
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
57 required=False, type=int)
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
58
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
59 parser.add_argument('--mask_thresh',
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
60 help='The threshold of the mask, all pixels with less than this value get masked (if masking enabled).',
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
61 required=False, type=float,
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
62 default=0)
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
63
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
64 # output html report/snapshots
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
65 parser.add_argument('--html_fname', help="Name of the html report.",
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
66 default='OutputReport.html', required=False, type=str)
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
67
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
68 parser.add_argument('--report_img_path', help="For the html report, to be set in Galaxy. Without galaxy leave at cwd!",
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
69 default='.', required=False, type=str)
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
70
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
71 parser.add_argument('--version', action='version', version='0.1.0')
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
72
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
73 arguments = parser.parse_args()
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
74
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
75 logger.info("Received following arguments:")
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
76 for arg in vars(arguments):
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
77 logger.info(f'{arg} -> {getattr(arguments, arg)}')
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
78
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
79 # ------------Read the input----------------------------------------
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
80 try:
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
81 movie = spyboat.open_tif(arguments.input_path)
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
82 except FileNotFoundError:
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
83 logger.critical(f"Couldn't open {arguments.input_path}, check movie storage directory!")
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
84 sys.exit(1)
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
85 # problems get logged in 'open_tif'
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
86 if movie is None:
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
87 sys.exit(1)
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
88 # -------- Do (optional) spatial downsampling ---------------------------
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
89
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
90 scale_factor = arguments.rescale_factor
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
91
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
92 # defaults to None
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
93 if not scale_factor:
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
94 logger.info('No downsampling requested..')
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
95
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
96 elif 0 < scale_factor < 100:
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
97 logger.info(f'Downsampling the movie to {scale_factor:d}% of its original size..')
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
98 movie = spyboat.down_sample(movie, scale_factor / 100)
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
99 else:
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
100 raise ValueError('Scale factor must be between 0 and 100!')
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
101
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
102 # -------- Do (optional) pre-smoothing -------------------------
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
103 # note that downsampling already is a smoothing operation..
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
104
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
105 # check if pre-smoothing requested
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
106 if not arguments.gauss_sigma:
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
107 logger.info('No pre-smoothing requested..')
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
108 else:
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
109 logger.info(f'Pre-smoothing the movie with Gaussians, sigma = {arguments.gauss_sigma:.2f}..')
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
110
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
111 movie = spyboat.gaussian_blur(movie, arguments.gauss_sigma)
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
112
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
113 # ----- Set up Masking before processing ----
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
114
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
115 mask = None
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
116 if arguments.masking == 'static':
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
117 if not arguments.mask_frame:
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
118 logger.critical("Frame number for static masking is missing!")
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
119 sys.exit(1)
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
120
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
121 if (arguments.mask_frame > movie.shape[0]) or (arguments.mask_frame < 0):
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
122 logger.critical(f'Requested frame does not exist, input only has {movie.shape[0]} frames.. exiting')
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
123 sys.exit(1)
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
124
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
125 else:
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
126 logger.info(f'Creating static mask from frame {arguments.mask_frame} with threshold {arguments.mask_thresh}')
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
127 mask = spyboat.create_static_mask(movie, arguments.mask_frame,
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
128 arguments.mask_thresh)
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
129 elif arguments.masking == 'dynamic':
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
130 logger.info(f'Creating dynamic mask with threshold {arguments.mask_thresh}')
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
131 mask = spyboat.create_dynamic_mask(movie, arguments.mask_thresh)
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
132
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
133 else:
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
134 logger.info('No masking requested..')
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
135
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
136 # ------ Retrieve wavelet parameters ---------------------------
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
137
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
138 Wkwargs = {'dt': arguments.dt,
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
139 'Tmin': arguments.Tmin,
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
140 'Tmax': arguments.Tmax,
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
141 'nT': arguments.nT,
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
142 'T_c': arguments.Tcutoff, # defaults to None
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
143 'win_size': arguments.win_size # defaults to None
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
144 }
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
145
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
146 # --- start parallel processing ---
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
147
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
148 results = spyboat.run_parallel(movie, arguments.ncpu, **Wkwargs)
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
149
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
150 # --- masking? ---
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
151
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
152 if mask is not None:
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
153 # mask all output movies (in place!)
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
154 for key in results:
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
155 logger.info(f'Masking {key}')
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
156 spyboat.apply_mask(results[key], mask, fill_value=-1)
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
157
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
158 # --- Produce Output HTML Report Figures/png's ---
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
159
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
160 # create the directory, yes we have to do that ourselves :)
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
161 # galaxy then magically renders the html from that directory
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
162 try:
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
163
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
164 if arguments.report_img_path != '.':
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
165 logger.info(f'Creating report directory {arguments.report_img_path}')
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
166 os.mkdir(arguments.report_img_path)
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
167
1
639d2031d998 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 88e9d9a220d160f55e0472719bb463143a4eefa5"
iuc
parents: 0
diff changeset
168 # 4 figures per snapshot
639d2031d998 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 88e9d9a220d160f55e0472719bb463143a4eefa5"
iuc
parents: 0
diff changeset
169 Nsnap = 8
0
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
170 NFrames = movie.shape[0]
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
171 # show only frames at least one Tmin
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
172 # away from the edge (-effects)
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
173 start_frame = int(Wkwargs['Tmin'] / Wkwargs['dt'])
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
174
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
175 if (start_frame > NFrames // 2):
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
176 logger.warning("Smallest period already is larger than half the observation time!")
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
177 # set to 0 in this case
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
178 start_frame = 0
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
179
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
180 frame_increment = int((NFrames - 2 * start_frame) / Nsnap)
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
181 snapshot_frames = range(start_frame, NFrames - start_frame, frame_increment)
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
182
1
639d2031d998 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 88e9d9a220d160f55e0472719bb463143a4eefa5"
iuc
parents: 0
diff changeset
183 # get all relevant parameters
639d2031d998 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 88e9d9a220d160f55e0472719bb463143a4eefa5"
iuc
parents: 0
diff changeset
184 par_str = ''
639d2031d998 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 88e9d9a220d160f55e0472719bb463143a4eefa5"
iuc
parents: 0
diff changeset
185 for arg in vars(arguments):
639d2031d998 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 88e9d9a220d160f55e0472719bb463143a4eefa5"
iuc
parents: 0
diff changeset
186 if 'out' in arg or 'path' in arg or 'html' in arg:
639d2031d998 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 88e9d9a220d160f55e0472719bb463143a4eefa5"
iuc
parents: 0
diff changeset
187 continue
639d2031d998 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 88e9d9a220d160f55e0472719bb463143a4eefa5"
iuc
parents: 0
diff changeset
188 par_str += f'{arg} -> {getattr(arguments, arg)}\n'
639d2031d998 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 88e9d9a220d160f55e0472719bb463143a4eefa5"
iuc
parents: 0
diff changeset
189
0
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
190 for snapshot_frame in snapshot_frames:
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
191 output_report.produce_snapshots(movie, results, snapshot_frame, Wkwargs, img_path=arguments.report_img_path)
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
192
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
193 output_report.produce_distr_plots(results, Wkwargs, img_path=arguments.report_img_path)
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
194
1
639d2031d998 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 88e9d9a220d160f55e0472719bb463143a4eefa5"
iuc
parents: 0
diff changeset
195 output_report.create_html(snapshot_frames, par_str, arguments.html_fname)
0
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
196
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
197 except FileExistsError as e:
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
198 logger.critical(f"Could not create html report directory: {repr(e)}")
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
199
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
200 # --- save out result movies ---
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
201
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
202 # None means output is filtered from galaxy settings
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
203 if arguments.phase_out is not None:
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
204 # save phase movie
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
205 io.imsave(arguments.phase_out, results['phase'], plugin="tifffile")
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
206 logger.info(f'Written phase to {arguments.phase_out}')
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
207 if arguments.period_out is not None:
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
208 # save period movie
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
209 io.imsave(arguments.period_out, results['period'], plugin="tifffile")
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
210 logger.info(f'Written period to {arguments.period_out}')
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
211 if arguments.power_out is not None:
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
212 # save power movie
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
213 io.imsave(arguments.power_out, results['power'], plugin="tifffile")
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
214 logger.info(f'Written power to {arguments.power_out}')
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
215 if arguments.amplitude_out is not None:
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
216 # save amplitude movie
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
217 io.imsave(arguments.amplitude_out, results['amplitude'], plugin="tifffile")
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
218 logger.info(f'Written amplitude to {arguments.amplitude_out}')
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
219
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
220 # save out the probably pre-processed (scaled and blurred) input movie for
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
221 # direct comparison to results and coordinate mapping etc.
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
222 if arguments.preprocessed_out is not None:
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
223 io.imsave(arguments.preprocessed_out, movie.astype(float32), plugin='tifffile')
76733d05d8ef "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/packages/spyboat commit 5c60a414c785246371beac23ce52d8bbab3602d1"
iuc
parents:
diff changeset
224 logger.info(f'Written preprocessed to {arguments.preprocessed_out}')