Mercurial > repos > gregor.m > spyboat
changeset 5:d5a4180410c4 draft default tip
"planemo upload commit 7bc843096b70fe1c8fc149e69d8f87fceac4eb3b"
author | gregor.m |
---|---|
date | Sat, 28 Nov 2020 18:50:09 +0000 |
parents | a4c6fcf2c456 |
children | |
files | OutputReport.html SpyBOAT.xml __pycache__/output_report.cpython-38.pyc output_report.py period_out.tif phase_out.tif run_tests.sh spyboat.xml spyboat_cli.py test-data/output1.html test-data/phase_out.tif |
diffstat | 11 files changed, 881 insertions(+), 455 deletions(-) [+] |
line wrap: on
line diff
--- a/OutputReport.html Thu Nov 26 16:40:47 2020 +0000 +++ b/OutputReport.html Sat Nov 28 18:50:09 2020 +0000 @@ -22,7 +22,7 @@ text-align: center; /* border: 1px dashed rgba(4, 4, 4, 0.35); */ grid-template-columns: repeat(3,1fr); - grid-template-rows: 20vw; + grid-template-rows: 20vw; grid-gap: 0px; column-gap: 0px } @@ -56,7 +56,7 @@ </head> <body> <h1 style="text-align:center; color:#363333">SpyBOAT Results Report</h1> - <hr style="width:50%"> + <hr style="width:50%"> <h1 class="subheader"> Distribution Dynamics </h1> <div class="distr_gallery"> <figure class=”distr_gallery__item distr_gallery__item--1"> @@ -83,163 +83,226 @@ <!-- defines all elements of the "FrameSlides" class ---> - <div class="FrameSlides"> - <h3 style="text-align:center; color=#363333"> Frame Nr. 20 </h3> + <div class="FrameSlides"> + <h3 style="text-align:center; color=#363333"> + Frame Nr. 20 </h3> <div class="snapshot_gallery"> - <figure class=”snapshot_gallery__item snapshot_gallery__item--1"> - <img src="input_frame20.png" alt="The Input" class="snapshot_gallery__img"> + <figure class=”snapshot_gallery__item + snapshot_gallery__item--1"> + <img src="input_frame20.png" alt="The Input" + class="snapshot_gallery__img"> </figure> - <figure class=”snapshot_gallery__item snapshot_gallery__item--2"> - <img src="phase_frame20.png" alt="Phase" class="snapshot_gallery__img"> + <figure class=”snapshot_gallery__item + snapshot_gallery__item--2"> + <img src="phase_frame20.png" alt="Phase" + class="snapshot_gallery__img"> </figure> - <figure class=”snapshot_gallery__item snapshot_gallery__item--3"> - <img src="period_frame20.png" alt="Period" class="snapshot_gallery__img"> + <figure class=”snapshot_gallery__item + snapshot_gallery__item--3"> + <img src="period_frame20.png" + alt="Period" class="snapshot_gallery__img"> </figure> - <figure class=”snapshot_gallery__item snapshot_gallery__item--4"> - <img src="amplitude_frame20.png" alt="Amplitude" class="snapshot_gallery__img"> + <figure class=”snapshot_gallery__item + snapshot_gallery__item--4"> + <img src="amplitude_frame20.png" + alt="Amplitude" class="snapshot_gallery__img"> </figure> </div> </div> - <div class="FrameSlides"> - <h3 style="text-align:center; color=#363333"> Frame Nr. 29 </h3> + <div class="FrameSlides"> + <h3 style="text-align:center; color=#363333"> + Frame Nr. 28 </h3> <div class="snapshot_gallery"> - <figure class=”snapshot_gallery__item snapshot_gallery__item--1"> - <img src="input_frame29.png" alt="The Input" class="snapshot_gallery__img"> + <figure class=”snapshot_gallery__item + snapshot_gallery__item--1"> + <img src="input_frame28.png" alt="The Input" + class="snapshot_gallery__img"> </figure> - <figure class=”snapshot_gallery__item snapshot_gallery__item--2"> - <img src="phase_frame29.png" alt="Phase" class="snapshot_gallery__img"> + <figure class=”snapshot_gallery__item + snapshot_gallery__item--2"> + <img src="phase_frame28.png" alt="Phase" + class="snapshot_gallery__img"> </figure> - <figure class=”snapshot_gallery__item snapshot_gallery__item--3"> - <img src="period_frame29.png" alt="Period" class="snapshot_gallery__img"> + <figure class=”snapshot_gallery__item + snapshot_gallery__item--3"> + <img src="period_frame28.png" + alt="Period" class="snapshot_gallery__img"> </figure> - <figure class=”snapshot_gallery__item snapshot_gallery__item--4"> - <img src="amplitude_frame29.png" alt="Amplitude" class="snapshot_gallery__img"> + <figure class=”snapshot_gallery__item + snapshot_gallery__item--4"> + <img src="amplitude_frame28.png" + alt="Amplitude" class="snapshot_gallery__img"> </figure> </div> </div> - <div class="FrameSlides"> - <h3 style="text-align:center; color=#363333"> Frame Nr. 38 </h3> + <div class="FrameSlides"> + <h3 style="text-align:center; color=#363333"> + Frame Nr. 36 </h3> <div class="snapshot_gallery"> - <figure class=”snapshot_gallery__item snapshot_gallery__item--1"> - <img src="input_frame38.png" alt="The Input" class="snapshot_gallery__img"> + <figure class=”snapshot_gallery__item + snapshot_gallery__item--1"> + <img src="input_frame36.png" alt="The Input" + class="snapshot_gallery__img"> </figure> - <figure class=”snapshot_gallery__item snapshot_gallery__item--2"> - <img src="phase_frame38.png" alt="Phase" class="snapshot_gallery__img"> + <figure class=”snapshot_gallery__item + snapshot_gallery__item--2"> + <img src="phase_frame36.png" alt="Phase" + class="snapshot_gallery__img"> </figure> - <figure class=”snapshot_gallery__item snapshot_gallery__item--3"> - <img src="period_frame38.png" alt="Period" class="snapshot_gallery__img"> + <figure class=”snapshot_gallery__item + snapshot_gallery__item--3"> + <img src="period_frame36.png" + alt="Period" class="snapshot_gallery__img"> </figure> - <figure class=”snapshot_gallery__item snapshot_gallery__item--4"> - <img src="amplitude_frame38.png" alt="Amplitude" class="snapshot_gallery__img"> + <figure class=”snapshot_gallery__item + snapshot_gallery__item--4"> + <img src="amplitude_frame36.png" + alt="Amplitude" class="snapshot_gallery__img"> </figure> </div> </div> - <div class="FrameSlides"> - <h3 style="text-align:center; color=#363333"> Frame Nr. 47 </h3> + <div class="FrameSlides"> + <h3 style="text-align:center; color=#363333"> + Frame Nr. 44 </h3> <div class="snapshot_gallery"> - <figure class=”snapshot_gallery__item snapshot_gallery__item--1"> - <img src="input_frame47.png" alt="The Input" class="snapshot_gallery__img"> + <figure class=”snapshot_gallery__item + snapshot_gallery__item--1"> + <img src="input_frame44.png" alt="The Input" + class="snapshot_gallery__img"> </figure> - <figure class=”snapshot_gallery__item snapshot_gallery__item--2"> - <img src="phase_frame47.png" alt="Phase" class="snapshot_gallery__img"> + <figure class=”snapshot_gallery__item + snapshot_gallery__item--2"> + <img src="phase_frame44.png" alt="Phase" + class="snapshot_gallery__img"> </figure> - <figure class=”snapshot_gallery__item snapshot_gallery__item--3"> - <img src="period_frame47.png" alt="Period" class="snapshot_gallery__img"> + <figure class=”snapshot_gallery__item + snapshot_gallery__item--3"> + <img src="period_frame44.png" + alt="Period" class="snapshot_gallery__img"> </figure> - <figure class=”snapshot_gallery__item snapshot_gallery__item--4"> - <img src="amplitude_frame47.png" alt="Amplitude" class="snapshot_gallery__img"> + <figure class=”snapshot_gallery__item + snapshot_gallery__item--4"> + <img src="amplitude_frame44.png" + alt="Amplitude" class="snapshot_gallery__img"> </figure> </div> </div> - <div class="FrameSlides"> - <h3 style="text-align:center; color=#363333"> Frame Nr. 56 </h3> + <div class="FrameSlides"> + <h3 style="text-align:center; color=#363333"> + Frame Nr. 52 </h3> <div class="snapshot_gallery"> - <figure class=”snapshot_gallery__item snapshot_gallery__item--1"> - <img src="input_frame56.png" alt="The Input" class="snapshot_gallery__img"> + <figure class=”snapshot_gallery__item + snapshot_gallery__item--1"> + <img src="input_frame52.png" alt="The Input" + class="snapshot_gallery__img"> </figure> - <figure class=”snapshot_gallery__item snapshot_gallery__item--2"> - <img src="phase_frame56.png" alt="Phase" class="snapshot_gallery__img"> + <figure class=”snapshot_gallery__item + snapshot_gallery__item--2"> + <img src="phase_frame52.png" alt="Phase" + class="snapshot_gallery__img"> </figure> - <figure class=”snapshot_gallery__item snapshot_gallery__item--3"> - <img src="period_frame56.png" alt="Period" class="snapshot_gallery__img"> + <figure class=”snapshot_gallery__item + snapshot_gallery__item--3"> + <img src="period_frame52.png" + alt="Period" class="snapshot_gallery__img"> </figure> - <figure class=”snapshot_gallery__item snapshot_gallery__item--4"> - <img src="amplitude_frame56.png" alt="Amplitude" class="snapshot_gallery__img"> + <figure class=”snapshot_gallery__item + snapshot_gallery__item--4"> + <img src="amplitude_frame52.png" + alt="Amplitude" class="snapshot_gallery__img"> </figure> </div> </div> - <div class="FrameSlides"> - <h3 style="text-align:center; color=#363333"> Frame Nr. 65 </h3> + <div class="FrameSlides"> + <h3 style="text-align:center; color=#363333"> + Frame Nr. 60 </h3> <div class="snapshot_gallery"> - <figure class=”snapshot_gallery__item snapshot_gallery__item--1"> - <img src="input_frame65.png" alt="The Input" class="snapshot_gallery__img"> + <figure class=”snapshot_gallery__item + snapshot_gallery__item--1"> + <img src="input_frame60.png" alt="The Input" + class="snapshot_gallery__img"> </figure> - <figure class=”snapshot_gallery__item snapshot_gallery__item--2"> - <img src="phase_frame65.png" alt="Phase" class="snapshot_gallery__img"> + <figure class=”snapshot_gallery__item + snapshot_gallery__item--2"> + <img src="phase_frame60.png" alt="Phase" + class="snapshot_gallery__img"> </figure> - <figure class=”snapshot_gallery__item snapshot_gallery__item--3"> - <img src="period_frame65.png" alt="Period" class="snapshot_gallery__img"> + <figure class=”snapshot_gallery__item + snapshot_gallery__item--3"> + <img src="period_frame60.png" + alt="Period" class="snapshot_gallery__img"> </figure> - <figure class=”snapshot_gallery__item snapshot_gallery__item--4"> - <img src="amplitude_frame65.png" alt="Amplitude" class="snapshot_gallery__img"> + <figure class=”snapshot_gallery__item + snapshot_gallery__item--4"> + <img src="amplitude_frame60.png" + alt="Amplitude" class="snapshot_gallery__img"> </figure> </div> </div> - <div class="FrameSlides"> - <h3 style="text-align:center; color=#363333"> Frame Nr. 74 </h3> + <div class="FrameSlides"> + <h3 style="text-align:center; color=#363333"> + Frame Nr. 68 </h3> <div class="snapshot_gallery"> - <figure class=”snapshot_gallery__item snapshot_gallery__item--1"> - <img src="input_frame74.png" alt="The Input" class="snapshot_gallery__img"> + <figure class=”snapshot_gallery__item + snapshot_gallery__item--1"> + <img src="input_frame68.png" alt="The Input" + class="snapshot_gallery__img"> </figure> - <figure class=”snapshot_gallery__item snapshot_gallery__item--2"> - <img src="phase_frame74.png" alt="Phase" class="snapshot_gallery__img"> + <figure class=”snapshot_gallery__item + snapshot_gallery__item--2"> + <img src="phase_frame68.png" alt="Phase" + class="snapshot_gallery__img"> </figure> - <figure class=”snapshot_gallery__item snapshot_gallery__item--3"> - <img src="period_frame74.png" alt="Period" class="snapshot_gallery__img"> + <figure class=”snapshot_gallery__item + snapshot_gallery__item--3"> + <img src="period_frame68.png" + alt="Period" class="snapshot_gallery__img"> </figure> - <figure class=”snapshot_gallery__item snapshot_gallery__item--4"> - <img src="amplitude_frame74.png" alt="Amplitude" class="snapshot_gallery__img"> + <figure class=”snapshot_gallery__item + snapshot_gallery__item--4"> + <img src="amplitude_frame68.png" + alt="Amplitude" class="snapshot_gallery__img"> </figure> </div> </div>
--- a/SpyBOAT.xml Thu Nov 26 16:40:47 2020 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,248 +0,0 @@ -<tool id="spyboat" name="SpyBOAT" version="@TOOL_VERSION@"> -<description>wavelet transforms image stacks</description> - <macros> - <token name="@TOOL_VERSION@">0.1.1</token> - </macros> - - <requirements> - <requirement type="package" version="@TOOL_VERSION@">spyboat</requirement> - </requirements> - <version_command>python $__tool_directory__/spyboat_cli.py --version</version_command> - <command detect_errors="exit_code"><![CDATA[ - python $__tool_directory__/spyboat_cli.py - --input_path '$movie' - #if $gauss_sigma: - --gauss_sigma $gauss_sigma - #end if - #if $rescale_factor: - --rescale $rescale_factor - #end if - - #if $masking.selection_mode == "create_static_mask": - --masking static - --mask_frame $masking.mask_frame - --mask_thresh $masking.mask_thresh - #else if $masking.selection_mode == "create_dynamic_mask": - --masking dynamic - --mask_thresh $masking.mask_thresh - #end if - - --dt $dt - --Tmin $tmin - --Tmax $tmax - --nT $nt - #if $tcutoff - --Tcutoff $tcutoff - #end if - #if $win_size: - --win_size $win_size - #end if - - --phase_out $phase_out - --period_out $period_out - --power_out $power_out - --amplitude_out $amplitude_out - #if $preprocessed_out: - --preprocessed_out $preprocessed_out - #end if - - --html_fname $html_out - --report_img_path '$html_out.extra_files_path' - - --ncpu "\${GALAXY_SLOTS:-8}" - > $log - - ]]></command> - <!-- "\${GALAXY_SLOTS:-8}" --> - <inputs> - <param name="movie" type="data" format="tiff" label="Movie to analyze" - help="Select a movie to wavelet analyze"/> - - <!-- - The following Wavelet parameters must have the same numerical type as defined in the - argparse parser in spyboat_cli.py - --> - - <param name="gauss_sigma" type="float" label="Sigma" - help="Width of the Gaussian smoothing kernel, leave blank if no pre-smoothing desired." optional="true"> - <validator type="in_range" min="0" max="9999999"/> - </param> - - <param name="rescale_factor" type="integer" value="" label="Rescale factor" - help="Downsamples the input movie by this factor given in %, leave blank to disable downsampling" - optional="true"> - <validator type="in_range" min="0" max="99"/> - </param> - - <conditional name="masking"> - <param label="Masking the output" name="selection_mode" type="select" help="Create a mask from the (blurred/rescaled) input to mask out regions without oscillations/signal in the output"> - <option selected="true" value="no_masking">No masking</option> - <option value="create_static_mask">Create a static mask</option> - <option value="create_dynamic_mask">Create a dynamic mask</option> - </param> - <when value="no_masking"> - </when> - <when value="create_static_mask"> - <param name="mask_frame" type="integer" value="1" label="Create mask from frame" - help="Creates a static mask from the chosen frame of the input movie."> - <validator type="in_range" min="1" max="99999"/> - </param> - <param name="mask_thresh" type="float" value="0" label="Threshold" - help="All pixels below this threshold will be masked in the output."> - <validator type="in_range" min="0" max="999999"/> - </param> - </when> - <when value="create_dynamic_mask"> - <param name="mask_thresh" type="float" value="0" label="Threshold" - help="For each frame of the input, all pixels below this threshold will be masked in the output."> - <validator type="in_range" min="0" max="999999"/> - </param> - </when> - </conditional> - - <param name="dt" type="float" value="1" label="Sampling interval" help="Time span between two frames"> - <validator type="in_range" min="0" max="9999999"/> - </param> - <param name="tmin" type="float" value="20" label="Smallest period" help="Lowest period for the wavelet transform"> - <validator type="in_range" min="0" max="9999999"/> - </param> - - <param name="tmax" type="float" value="30" label="Largest period" - help="Largest period for the wavelet transform"> - <validator type="in_range" min="0" max="9999999"/> - </param> - - <param name="nt" type="integer" value="150" label="Number of periods to scan for" - help="Determines period resolution of the Wavelet power spectra"> - <validator type="in_range" min="0" max="9999999"/> - </param> - - <param name="tcutoff" type="float" value="40" label="Tcutoff" - help="Cut-off-period for sinc filter detrending, a blank field disables detrending" optional="true"> - <validator type="in_range" min="0" max="9999999"/> - </param> - - <param name="win_size" type="float" value="" label="Sliding window size" - help="Window size for amplitude envelope estimation, leave blank to disable normalization " - optional="true"> - <validator type="in_range" min="0" max="9999999"/> - </param> - - <conditional name="save_preprocessed"> - <param label="Save preprocessed input" name="selection" type="select" help="Save the blurred/rescaled input to history? "> - <option selected="true" value="No">No</option> - <option value="Yes">Yes</option> - </param> - <!-- there is an output filter picking up the choice --> - <when value="No"> - </when> - <when value="Yes"> - </when> - </conditional> - </inputs> - - <outputs> - <data name="phase_out" format="tiff" label="${movie.name[:-4]}_phase"/> - <data name="period_out" format="tiff" label="${movie.name[:-4]}_period"/> - <data name="power_out" format="tiff" label="${movie.name[:-4]}_power"/> - <data name="amplitude_out" format="tiff" label="${movie.name[:-4]}_amplitude"/> - <data name="preprocessed_out" format="tiff" label="${movie.namee[:-4]}_preproc"> - <filter>save_preprocessed['selection'] == 'Yes'</filter> - </data> - - <data name="log" format="txt" label="log ${movie.name[:-4]}.txt"/> - <data format="html" name="html_out" label="Report ${movie.name[:-4]}"/> - - </outputs> - - <tests> - <test> - <param name="movie" value="test-movie.tif" ftype="tiff"/> - <output name="phase_out" file="phase_out.tif" ftype="tiff" compare="sim_size"/> - <output name="period_out" file="period_out.tif" ftype="tiff" compare="sim_size"/> - <output name="power_out" file="power_out.tif" ftype="tiff" compare="sim_size"/> - <output name="amplitude_out" file="amplitude_out.tif" ftype="tiff" compare="sim_size"/> - </test> - </tests> - <help><![CDATA[ - **What it does** - - Wavelet transforms a 3d-image stack (time,Y,X) pixel by pixel along the time axis and extracts/evaluates the wavelet ridge. Removal of low-frequency trends is provided via sinc filtering. - There are four output movies generated (phase, period, amplitude and power). They have exactly the same dimensions (time,Y,X) as the (rescaled) input. - - Pre-smoothing of the data with Gaussian kernels is supported and often recommendable. - - To limit the number of Wavelet transformations (computing time), downscaling of the input movie resolution is recommended. - Trimming away parts of the movie with no relevant data (e.g. outer dark edges) also speeds up the processing. - - If multiple channels are present in your data, extract the channel of interest beforehand (e.g. with Fiji). - - **Author**: Gregor Mönke (gregor.moenke@embl.de). - - **Wrapper by**: Jelle Scholtalbers (jelle.scholtalbers@embl.de). - - **Know what you are doing** - - .. class:: warningmark - - You will want to have understood the basics of time-frequency analysis with Wavelets, find more information about the analysis strategy employed at https://github.com/tensionhead/pyBOAT - - **Parameter List** - - - Sigma: - - The Kernel bandwidth (in pixels) for the Gaussian kernels to use for pre-smoothing the input data. The default value of zero means that no pre-smoothing is done. Set this number to a desired kernel width to turn on pre-smoothing. - - - Rescale factor: - - Given in %, downsamples the spatial resolution of the input movie. This speeds - up the whole analysis by a lot. - - - Masking: - SpyBOAT offers 'static' and 'dynamic' masking. 'static' means that a single mask is created by thresholding from a user selected frame. 'dynamic' creates a mask for each frame by thresholding, works better for moving/expanding/shrinking oscillatory fields. - - Sampling interval: - - Time passed between consecutive measurements, e.g 'an image every 10 minutes'. - - - Smallest Period: - - The minimal period to scan for, this is the higher (in frequency) end of the spectrum. A warning will be given during processing if the chosen value deceeds the Nyquist limit (2 times the sampling interval). - - - Largest period: - - The maximal period to scan for, this is the lower (in frequency) end of the spectrum. The inbuild Sinc filter will remove any periods larger than this form the data. Due to the 'roll off' of the filter, this value should be chosen generously. A warning will be given during processing if the chosen value exceeds the length of the time series. - - - Number of periods to scan for: - - This is the the number of convolutions computed per pixel. - - Spectral resolution = ( biggest period - smallest period ) / number of periods - - - Tcutoff: - - The cut-off period for the sinc filter, periods larger than this one will - be removed from the signal before the transform. If no value is given, - no detrending is performed. At least a gracious cut-off of around ~3 times - the largest period to be expected is recommended. - - - Sliding window size - - Length (in time units, e.g. hours) of the sliding window to estimate - an amplitude envelope. The signal then gets normalized by this envelope, - meaning that all amplitudes will be around ~1 after the transform. The - advantage is that signal with strong amplitude trends will have more - meaningful Wavelet powers after normalization. - - ]]></help> - <citations> - - <citation type="bibtex"> @article{monke2020optimal, - title={Optimal time frequency analysis for biological data-pyBOAT}, - author={M{\"o}nke, Gregor and Sorgenfrei, Frieda A and Schmal, Christoph and Granada, Adri{\'a}n E}, - journal={bioRxiv}, - year={2020}, - publisher={Cold Spring Harbor Laboratory} -} - </citation> - </citations> -</tool>
--- a/output_report.py Thu Nov 26 16:40:47 2020 +0000 +++ b/output_report.py Sat Nov 28 18:50:09 2020 +0000 @@ -1,28 +1,24 @@ -''' Produces plots and a summary html 'headless' ''' +""" Produces plots and a summary html 'headless' """ +import logging +import os -import os import matplotlib -# headless plotting and disable latex -matplotlib.use('Agg') -matplotlib.rcParams['text.usetex'] = False import matplotlib.pyplot as ppl - -import logging - import spyboat.plotting as spyplot +ppl.switch_backend('Agg') +matplotlib.rcParams["text.usetex"] = False logger = logging.getLogger(__name__) # figure resolution -DPI=250 +DPI = 250 -def produce_snapshots(input_movie, results, frame, Wkwargs, - img_path='.'): - ''' - Takes the *input_movie* and the - *results* dictionary from spyboat.processing.run_parallel - and produces phase, period and amplitude snapshot png's. +def produce_snapshots(input_movie, results, frame, Wkwargs, img_path="."): + """ + Takes the *input_movie* and the *results* dictionary + from spyboat.processing.run_parallel and produces phase, + period and amplitude snapshot png's. For the period snapshot also the period range is needed, hence the analysis dictionary 'Wkwargs' also gets passed. @@ -32,103 +28,111 @@ and the storage location in *img_path*. These get picked up by 'create_html' - ''' - + """ spyplot.input_snapshot(input_movie[frame]) fig = ppl.gcf() - out_path = os.path.join(img_path, f'input_frame{frame}.png') + out_path = os.path.join(img_path, f"input_frame{frame}.png") + fig.savefig(out_path, dpi=DPI) + ppl.close(fig) + + spyplot.phase_snapshot(results["phase"][frame]) + fig = ppl.gcf() + out_path = os.path.join(img_path, f"phase_frame{frame}.png") fig.savefig(out_path, dpi=DPI) ppl.close(fig) - - spyplot.phase_snapshot(results['phase'][frame]) + + spyplot.period_snapshot( + results["period"][frame], Wkwargs["Tmin"], + Wkwargs["Tmax"], time_unit="a.u." + ) + fig = ppl.gcf() - out_path = os.path.join(img_path, f'phase_frame{frame}.png') + out_path = os.path.join(img_path, f"period_frame{frame}.png") + fig.savefig(out_path, dpi=DPI) + ppl.close(fig) + + spyplot.amplitude_snapshot(results["amplitude"][frame]) + fig = ppl.gcf() + out_path = os.path.join(img_path, f"amplitude_frame{frame}.png") fig.savefig(out_path, dpi=DPI) ppl.close(fig) - spyplot.period_snapshot(results['period'][frame], - Wkwargs['Tmin'],Wkwargs['Tmax'], - time_unit = 'a.u.') - - fig = ppl.gcf() - out_path = os.path.join(img_path, f'period_frame{frame}.png') - fig.savefig(out_path, dpi=DPI) - ppl.close(fig) - - spyplot.amplitude_snapshot(results['amplitude'][frame]) - fig = ppl.gcf() - out_path = os.path.join(img_path, f'amplitude_frame{frame}.png') - fig.savefig(out_path, dpi=DPI) - ppl.close(fig) - - logger.info(f'Produced 4 snapshots for frame {frame}..') + logger.info(f"Produced 4 snapshots for frame {frame}..") + + +def produce_distr_plots(results, Wkwargs, img_path="."): + """ + Output file names are: -def produce_distr_plots(results, Wkwargs, img_path='.'): - - ''' - Output file names are: - - period_distr.png, power_distr.png and phase_distr.png - ''' + period_distr.png, power_distr.png and phase_distr.png + """ - spyplot.period_distr_dynamics(results['period'], Wkwargs) + spyplot.period_distr_dynamics(results["period"], Wkwargs) fig = ppl.gcf() - out_path = os.path.join(img_path, f'period_distr.png') + out_path = os.path.join(img_path, "period_distr.png") fig.savefig(out_path, dpi=DPI) - - spyplot.power_distr_dynamics(results['power'], Wkwargs) + + spyplot.power_distr_dynamics(results["power"], Wkwargs) fig = ppl.gcf() - out_path = os.path.join(img_path, f'power_distr.png') + out_path = os.path.join(img_path, "power_distr.png") fig.savefig(out_path, dpi=DPI) - spyplot.phase_coherence_dynamics(results['phase'], Wkwargs) + spyplot.phase_coherence_dynamics(results["phase"], Wkwargs) fig = ppl.gcf() - out_path = os.path.join(img_path, f'phase_distr.png') + out_path = os.path.join(img_path, "phase_distr.png") fig.savefig(out_path, dpi=DPI) - - logger.info(f'Produced 3 distribution plots..') + + logger.info("Produced 3 distribution plots..") + - -def create_html(frame_nums, html_fname='OutputReport.html'): - - ''' - The html generated assumes the respective png's +def create_html(frame_nums, html_fname="OutputReport.html"): + """ + The html generated assumes the respective png's have been created with 'produce_snapshots' and 'produce_distr_plots' and can be found at the cwd (that's how Galaxy works..) - ''' + """ # -- create a gallery for every frame in frame_nums -- - - galleries = '' + + galleries = "" for frame_num in frame_nums: - new_gal =f''' - <div class="FrameSlides"> - <h3 style="text-align:center; color=#363333"> Frame Nr. {frame_num} </h3> + new_gal = f""" + <div class="FrameSlides"> + <h3 style="text-align:center; color=#363333"> + Frame Nr. {frame_num} </h3> <div class="snapshot_gallery"> - <figure class=”snapshot_gallery__item snapshot_gallery__item--1"> - <img src="input_frame{frame_num}.png" alt="The Input" class="snapshot_gallery__img"> + <figure class=”snapshot_gallery__item + snapshot_gallery__item--1"> + <img src="input_frame{frame_num}.png" alt="The Input" + class="snapshot_gallery__img"> </figure> - <figure class=”snapshot_gallery__item snapshot_gallery__item--2"> - <img src="phase_frame{frame_num}.png" alt="Phase" class="snapshot_gallery__img"> + <figure class=”snapshot_gallery__item + snapshot_gallery__item--2"> + <img src="phase_frame{frame_num}.png" alt="Phase" + class="snapshot_gallery__img"> </figure> - <figure class=”snapshot_gallery__item snapshot_gallery__item--3"> - <img src="period_frame{frame_num}.png" alt="Period" class="snapshot_gallery__img"> + <figure class=”snapshot_gallery__item + snapshot_gallery__item--3"> + <img src="period_frame{frame_num}.png" + alt="Period" class="snapshot_gallery__img"> </figure> - <figure class=”snapshot_gallery__item snapshot_gallery__item--4"> - <img src="amplitude_frame{frame_num}.png" alt="Amplitude" class="snapshot_gallery__img"> + <figure class=”snapshot_gallery__item + snapshot_gallery__item--4"> + <img src="amplitude_frame{frame_num}.png" + alt="Amplitude" class="snapshot_gallery__img"> </figure> </div> </div> - ''' + """ galleries += new_gal - - html_string =f''' + + html_string = f""" <html> <!-- this file got automatically created by 'output_report.py' --> <title>SpyBOAT Output Report</title> @@ -152,7 +156,7 @@ text-align: center; /* border: 1px dashed rgba(4, 4, 4, 0.35); */ grid-template-columns: repeat(3,1fr); - grid-template-rows: 20vw; + grid-template-rows: 20vw; grid-gap: 0px; column-gap: 0px }} @@ -186,7 +190,7 @@ </head> <body> <h1 style="text-align:center; color:#363333">SpyBOAT Results Report</h1> - <hr style="width:50%"> + <hr style="width:50%"> <h1 class="subheader"> Distribution Dynamics </h1> <div class="distr_gallery"> <figure class=”distr_gallery__item distr_gallery__item--1"> @@ -237,13 +241,12 @@ </script> </body> </html> - ''' + """ - with open(html_fname, 'w') as OUT: - + with open(html_fname, "w") as OUT: OUT.write(html_string) - logger.info(f'Created html report') + logger.info("Created html report") return html_string # for local testing
--- a/run_tests.sh Thu Nov 26 16:40:47 2020 +0000 +++ b/run_tests.sh Sat Nov 28 18:50:09 2020 +0000 @@ -4,7 +4,11 @@ INPUT_PATH='./test-data/test-movie.tif' SCRIPT_PATH='.' -python3 $SCRIPT_PATH/spyboat_cli.py --input_path $INPUT_PATH --phase_out phase_test-movie.tif --period_out period_test-movie.tif --power_out power_test-movie.tif --amplitude_out amplitude_test-movie.tif --dt 1 --Tmin 20 --Tmax 30 --nT 200 --ncpu 6 --masking dynamic --preprocessed_out preproc_two_sines.tif --gauss_sigma 2 --rescale 80 --Tcutoff 40 --masking static --mask_frame 10 --mask_thresh 300 +# set to galaxy defaults!! +python3 $SCRIPT_PATH/spyboat_cli.py --input_path $INPUT_PATH --phase_out phase_out.tif --period_out period_out.tif --dt 1 --Tmin 20 --Tmax 30 --nT 150 --ncpu 6 --Tcutoff 40 + +# additional paramters +#--masking static --mask_frame 10 --mask_thresh 300 --rescale 80 --gauss_sigma 1 printf "\n" # printf "\nError examples:\n"
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/spyboat.xml Sat Nov 28 18:50:09 2020 +0000 @@ -0,0 +1,264 @@ +<tool id="spyboat" name="SpyBOAT" version="@TOOL_VERSION@" profile="20.01" license="GPL-3.0-or-later"> +<description>wavelet transforms image stacks</description> + <macros> + <token name="@TOOL_VERSION@">0.1.1</token> + </macros> + <requirements> + <requirement type="package" version="@TOOL_VERSION@">spyboat</requirement> + </requirements> + <version_command>python '$__tool_directory__/spyboat_cli.py' --version</version_command> + <command detect_errors="exit_code"><![CDATA[ + ## needed for pulsar combat + cat '$__tool_directory__/output_report.py' > /dev/null && + ## run tool + python '$__tool_directory__/spyboat_cli.py' + --input_path '$movie' + #if str($PreProc.gauss_sigma): + --gauss_sigma $PreProc.gauss_sigma + #end if + #if str($PreProc.rescale_factor): + --rescale $PreProc.rescale_factor + #end if + + #if $masking.selection_mode == "create_static_mask": + --masking static + --mask_frame $masking.mask_frame + --mask_thresh $masking.mask_thresh + #else if $masking.selection_mode == "create_dynamic_mask": + --masking dynamic + --mask_thresh $masking.mask_thresh + #end if + + --dt $wavana.dt + --Tmin $wavana.tmin + --Tmax $wavana.tmax + --nT $wavana.nt + #if str($wavana.tcutoff) + --Tcutoff $wavana.tcutoff + #end if + #if str($wavana.win_size): + --win_size $wavana.win_size + #end if + + #if 'save_phase' in $outputs: + --phase_out '$phase_out' + #end if + + #if 'save_period' in $outputs: + --period_out '$period_out' + #end if + + #if 'save_power' in $outputs: + --power_out '$power_out' + #end if + + #if 'save_amplitude' in $outputs: + --amplitude_out '$amplitude_out' + #end if + + #if 'save_preprocessed' in $outputs: + --preprocessed_out '$preprocessed_out' + #end if + + --html_fname '$html_out' + --report_img_path '$html_out.extra_files_path' + + --ncpu "\${GALAXY_SLOTS:-8}" + + + ]]></command> + <inputs> + <param name="movie" type="data" format="tiff" label="Movie to analyze" help="Select a movie to wavelet analyze"/> + + <!-- + The following Wavelet parameters must have the same numerical type as defined in the + argparse parser in spyboat_cli.py + --> + <section name="PreProc" title="Preprocessing" expanded="true"> + <param argument="gauss_sigma" type="float" min="0" max="9999999" optional="true" label="Sigma" + help="Width of the Gaussian smoothing kernel, leave blank if no pre-smoothing desired" /> + <param argument="rescale_factor" type="integer" value="" min="0" max="99" optional="true" label="Rescale factor" + help="Downsamples the input movie by this factor given in %, leave blank to disable downsampling" /> + </section> + <section name="wavana" title="Wavelet Analysis" expanded="true"> + <param name="dt" type="float" value="1" min="0" max="9999999" label="Sampling interval" help="Time span between two frames" /> + <param name="tmin" type="float" value="20" min="0" max="9999999" label="Smallest period" help="Lowest period for the wavelet transform" /> + <param name="tmax" type="float" value="30" min="0" max="9999999" label="Largest period" + help="Largest period for the wavelet transform" /> + <param name="nt" type="integer" value="150" min="0" max="9999999" label="Number of periods to scan for" + help="Determines period resolution of the Wavelet power spectra" /> + <param name="tcutoff" type="float" value="40" min="0" max="9999999" label="T cutoff" + help="Cut-off-period for sinc filter detrending, a blank field disables detrending" optional="true" /> + <param name="win_size" type="float" value="" min="0" max="9999999" optional="true" label="Sliding window size" + help="Window size for amplitude envelope estimation, leave blank to disable normalization" /> + </section> + <conditional name="masking"> + <param name="selection_mode" type="select" label="Masking the output" help="Create a mask from the (blurred/rescaled) input to mask out regions without oscillations/signal in the output"> + <option selected="true" value="no_masking">No masking</option> + <option value="create_static_mask">Create a static mask</option> + <option value="create_dynamic_mask">Create a dynamic mask</option> + </param> + <when value="no_masking" /> + <when value="create_static_mask"> + <param name="mask_frame" type="integer" value="1" min="1" max="99999" label="Create mask from frame" + help="Creates a static mask from the chosen frame of the input movie." /> + <param name="mask_thresh" type="float" value="0" min="0" max="999999" label="Threshold" + help="All pixels below this threshold will be masked in the output." /> + </when> + <when value="create_dynamic_mask"> + <param name="mask_thresh" type="float" value="0" min="0" max="999999" label="Threshold" + help="For each frame of the input, all pixels below this threshold will be masked in the output." /> + </when> + </conditional> + <param name="outputs" type="select" optional="true" multiple="true" label="Select optional outputs" help=""> + <option value="save_phase">Phase Movie</option> + <option value="save_period">Period Movie</option> + <option value="save_amplitude">Amplitude Movie</option> + <option value="save_power">Power Movie</option> + <option value="save_preprocessed">Preprocessed Movie</option> + </param> + </inputs> + + <outputs> + <data name="phase_out" format="tiff" label="${movie.name[:-4]}_phase"> + <filter>'save_phase' in ouputs</filter> + </data> + <data name="period_out" format="tiff" label="${movie.name[:-4]}_period"> + <filter>'save_period' in outputs</filter> + </data> + <data name="power_out" format="tiff" label="${movie.name[:-4]}_power"> + <filter>'save_power' in outputs</filter> + </data> + <data name="amplitude_out" format="tiff" label="${movie.name[:-4]}_amplitude"> + <filter>'save_amplitude' in outputs</filter> + </data> + <data name="preprocessed_out" format="tiff" label="${movie.name[:-4]}_preproc"> + <filter>'save_preprocessed' in outputs</filter> + </data> + <data name="html_out" format="html" label="Report ${movie.name[:-4]}" /> + </outputs> + + <tests> + <test expect_num_outputs="2"> + <param name="movie" value="test-movie.tif" ftype="tiff"/> + <param name="outputs" value="save_phase"/> + <conditional name="masking"> + <param name="selection_mode" value="no_masking" /> + </conditional> + <output name="phase_out" ftype="tiff"> + <assert_contents> + <has_size value="1764430" delta="100" /> + </assert_contents> + </output> + <output name="html_out" file="output1.html" ftype="html"/> + </test> + <test expect_num_outputs="4"> + <section name="wavana"> + <param name="tmin" value="20"/> + <param name="nt" value="150"/> + <param name="tcutoff" value="40"/> + </section> + <conditional name="masking"> + <param name="selection_mode" value="create_static_mask" /> + </conditional> + <param name="movie" value="test-movie.tif" ftype="tiff"/> + <param name="outputs" value="save_phase,save_preprocessed,save_power"/> + <output name="phase_out" ftype="tiff"> + <assert_contents> + <has_size value="1764430" delta="100" /> + </assert_contents> + </output> + <output name="html_out" file="output1.html" ftype="html"/> + </test> + <test expect_num_outputs="4"> + <section name="wavana"> + <param name="tmin" value="20"/> + <param name="nt" value="150"/> + <param name="tcutoff" value="40"/> + </section> + <conditional name="masking"> + <param name="selection_mode" value="create_dynamic_mask" /> + </conditional> + <param name="movie" value="test-movie.tif" ftype="tiff"/> + <param name="outputs" value="save_phase,save_preprocessed,save_power"/> + <output name="phase_out" ftype="tiff"> + <assert_contents> + <has_size value="1764430" delta="100" /> + </assert_contents> + </output> + <output name="html_out" file="output1.html" ftype="html"/> + </test> + </tests> + <help><![CDATA[ +.. class:: infomark + +**What it does** + +------------------- + + Wavelet transforms a 3d-image stack (time,Y,X) pixel by pixel along the time axis and extracts/evaluates the wavelet ridge. Removal of low-frequency trends is provided via sinc filtering. + There are four output movies generated (phase, period, amplitude and power). They have exactly the same dimensions (time,Y,X) as the (rescaled) input. + + Pre-smoothing of the data with Gaussian kernels is supported and often recommendable. + + To limit the number of Wavelet transformations (computing time), downscaling of the input movie resolution is recommended. + Trimming away parts of the movie with no relevant data (e.g. outer dark edges) also speeds up the processing. + + If multiple channels are present in your data, extract the channel of interest beforehand (e.g. with Fiji). + + **Author**: Gregor Mönke (gregor.moenke@embl.de). + + **Wrapper by**: Jelle Scholtalbers (jelle.scholtalbers@embl.de). + + **Know what you are doing** + + .. class:: warningmark + + You need to have a basic understanding of time-frequency analysis with Wavelets, find more information about the analysis strategy employed at https://github.com/tensionhead/pyBOAT or the publication cited below. + +------------------- + +**Parameter List** + + - Sigma: + The Kernel bandwidth (in pixels) for the Gaussian kernels to use for pre-smoothing the input data. The default value of zero means that no pre-smoothing is done. Set this number to a desired kernel width to turn on pre-smoothing. + + - Rescale factor: + Given in %, downsamples the spatial resolution of the input movie. This speeds up the whole analysis by a lot. + + - Masking: + SpyBOAT offers 'static' and 'dynamic' masking. 'static' means that a single mask is created by thresholding from a user selected frame. 'dynamic' creates a mask for each frame by thresholding, works better for moving/expanding/shrinking oscillatory fields. + + - Sampling interval: + Time passed between consecutive measurements, e.g 'an image every 10 minutes'. + + - Smallest Period: + The minimal period to scan for, this is the higher (in frequency) end of the spectrum. A warning will be given during processing if the chosen value deceeds the Nyquist limit (2 times the sampling interval). + + - Largest period: + The maximal period to scan for, this is the lower (in frequency) end of the spectrum. The inbuild Sinc filter will remove any periods larger than this form the data. Due to the 'roll off' of the filter, this value should be chosen generously. A warning will be given during processing if the chosen value exceeds the length of the time series. + + - Number of periods to scan for: + This is the the number of convolutions computed per pixel. + + Spectral resolution = ( biggest period - smallest period ) / number of periods + + - Tcutoff: + The cut-off period for the sinc filter, periods larger than this one will + be removed from the signal before the transform. If no value is given, + no detrending is performed. At least a gracious cut-off of around ~3 times + the largest period to be expected is recommended. + + - Sliding window size + Length (in time units, e.g. hours) of the sliding window to estimate + an amplitude envelope. The signal then gets normalized by this envelope, + meaning that all amplitudes will be around ~1 after the transform. The + advantage is that signal with strong amplitude trends will have more + meaningful Wavelet powers after normalization. + + + ]]></help> + <citations> + <citation type="doi">10.1101/2020.04.29.067744</citation> + </citations> +</tool>
--- a/spyboat_cli.py Thu Nov 26 16:40:47 2020 +0000 +++ b/spyboat_cli.py Sat Nov 28 18:50:09 2020 +0000 @@ -1,15 +1,15 @@ #!/usr/bin/env python -## Gets interfaced by Galaxy or can be used for bash scripting +# Gets interfaced by Galaxy or can be used for bash scripting import argparse -import sys, os import logging +import os +import sys -from skimage import io +import output_report +import spyboat from numpy import float32 - -import spyboat -import output_report +from skimage import io logging.basicConfig(level=logging.INFO, stream=sys.stdout, force=True) logger = logging.getLogger('spyboat-cli') @@ -20,12 +20,11 @@ # I/O parser.add_argument('--input_path', help="Input movie location", required=True) -parser.add_argument('--phase_out', help='Phase output file name', required=True) -parser.add_argument('--period_out', help='Period output file name', required=True) -parser.add_argument('--power_out', help='Power output file name', required=True) -parser.add_argument('--amplitude_out', help='Amplitude output file name', required=True) -parser.add_argument('--preprocessed_out', help="Preprocessed-input output file name, 'None'", required=False) - +parser.add_argument('--phase_out', help='Phase output file name', required=False) +parser.add_argument('--period_out', help='Period output file name', required=False) +parser.add_argument('--power_out', help='Power output file name', required=False) +parser.add_argument('--amplitude_out', help='Amplitude output file name', required=False) +parser.add_argument('--preprocessed_out', help="Preprocessed-input output file name", required=False) # (Optional) Multiprocessing @@ -33,10 +32,11 @@ required=False, type=int, default=1) # Optional spatial downsampling -parser.add_argument('--rescale', help='Rescale the image by a factor given in %%, None means no rescaling', +parser.add_argument('--rescale_factor', help='Rescale the image by a factor given in %%, None means no rescaling', required=False, type=int) # Optional Gaussian smoothing -parser.add_argument('--gauss_sigma', help='Gaussian smoothing parameter, None means no smoothing', required=False, type=float) +parser.add_argument('--gauss_sigma', help='Gaussian smoothing parameter, None means no smoothing', required=False, + type=float) # Wavelet Analysis Parameters parser.add_argument('--dt', help='Sampling interval', required=True, type=float) @@ -49,14 +49,15 @@ required=False, type=float) # Optional masking -parser.add_argument('--masking', help="Set to either 'dynamic', 'static' or 'None' which is the default", default='None', required=False, type=str) +parser.add_argument('--masking', help="Set to either 'dynamic', 'static' or 'None' which is the default", + default='None', required=False, type=str) parser.add_argument('--mask_frame', help="The frame of the input movie to create a static mask from, needs masking set to 'static'", required=False, type=int) - -parser.add_argument('--mask_thresh', help='The threshold of the mask, all pixels with less than this value get masked (if masking enabled).', +parser.add_argument('--mask_thresh', + help='The threshold of the mask, all pixels with less than this value get masked (if masking enabled).', required=False, type=float, default=0) @@ -64,7 +65,8 @@ parser.add_argument('--html_fname', help="Name of the html report.", default='OutputReport.html', required=False, type=str) -parser.add_argument('--report_img_path', help="For the html report, to be set in Galaxy. Without galaxy leave at cwd!", default='.', required=False, type=str) +parser.add_argument('--report_img_path', help="For the html report, to be set in Galaxy. Without galaxy leave at cwd!", + default='.', required=False, type=str) parser.add_argument('--version', action='version', version='0.1.0') @@ -85,7 +87,7 @@ sys.exit(1) # -------- Do (optional) spatial downsampling --------------------------- -scale_factor = arguments.rescale +scale_factor = arguments.rescale_factor # defaults to None if not scale_factor: @@ -121,13 +123,13 @@ sys.exit(1) else: - logger.info(f'Creating static mask from frame {arguments.mask_frame} with threshold {arguments.mask_thresh}') + logger.info(f'Creating static mask from frame {arguments.mask_frame} with threshold {arguments.mask_thresh}') mask = spyboat.create_static_mask(movie, arguments.mask_frame, - arguments.mask_thresh) + arguments.mask_thresh) elif arguments.masking == 'dynamic': logger.info(f'Creating dynamic mask with threshold {arguments.mask_thresh}') mask = spyboat.create_dynamic_mask(movie, arguments.mask_thresh) - + else: logger.info('No masking requested..') @@ -135,11 +137,11 @@ Wkwargs = {'dt': arguments.dt, 'Tmin': arguments.Tmin, - 'Tmax': arguments.Tmax, + 'Tmax': arguments.Tmax, 'nT': arguments.nT, - 'T_c' : arguments.Tcutoff, # defaults to None - 'win_size' : arguments.win_size # defaults to None -} + 'T_c': arguments.Tcutoff, # defaults to None + 'win_size': arguments.win_size # defaults to None + } # --- start parallel processing --- @@ -161,51 +163,55 @@ if arguments.report_img_path != '.': logger.info(f'Creating report directory {arguments.report_img_path}') - os.mkdir(arguments.report_img_path) + os.mkdir(arguments.report_img_path) - # 4 snapshots each + # 4 snapshots each Nsnap = 7 NFrames = movie.shape[0] # show only frames at least one Tmin # away from the edge (-effects) - start_frame = int(Wkwargs['Tmin']/Wkwargs['dt']) - - if (start_frame > NFrames//2): + start_frame = int(Wkwargs['Tmin'] / Wkwargs['dt']) + + if (start_frame > NFrames // 2): logger.warning("Smallest period already is larger than half the observation time!") # set to 0 in this case start_frame = 0 - - frame_increment = int( (NFrames - 2*start_frame) / Nsnap) + + frame_increment = int((NFrames - 2 * start_frame) / Nsnap) snapshot_frames = range(start_frame, NFrames - start_frame, frame_increment) - for snapshot_frame in snapshot_frames: + for snapshot_frame in snapshot_frames: output_report.produce_snapshots(movie, results, snapshot_frame, Wkwargs, img_path=arguments.report_img_path) - + output_report.produce_distr_plots(results, Wkwargs, img_path=arguments.report_img_path) - + output_report.create_html(snapshot_frames, arguments.html_fname) - + except FileExistsError as e: logger.critical(f"Could not create html report directory: {repr(e)}") - # --- save out result movies --- -# save phase movie -io.imsave(arguments.phase_out, results['phase'], plugin="tifffile") -logger.info(f'Written {arguments.phase_out}') -# save period movie -io.imsave(arguments.period_out, results['period'], plugin="tifffile") -logger.info(f'Written {arguments.period_out}') -# save power movie -io.imsave(arguments.power_out, results['power'], plugin="tifffile") -logger.info(f'Written {arguments.power_out}') -# save amplitude movie -io.imsave(arguments.amplitude_out, results['amplitude'], plugin="tifffile") -logger.info(f'Written {arguments.amplitude_out}') +# None means output is filtered from galaxy settings +if arguments.phase_out is not None: + # save phase movie + io.imsave(arguments.phase_out, results['phase'], plugin="tifffile") + logger.info(f'Written phase to {arguments.phase_out}') +if arguments.period_out is not None: + # save period movie + io.imsave(arguments.period_out, results['period'], plugin="tifffile") + logger.info(f'Written period to {arguments.period_out}') +if arguments.power_out is not None: + # save power movie + io.imsave(arguments.power_out, results['power'], plugin="tifffile") + logger.info(f'Written power to {arguments.power_out}') +if arguments.amplitude_out is not None: + # save amplitude movie + io.imsave(arguments.amplitude_out, results['amplitude'], plugin="tifffile") + logger.info(f'Written amplitude to {arguments.amplitude_out}') # save out the probably pre-processed (scaled and blurred) input movie for # direct comparison to results and coordinate mapping etc. -if arguments.preprocessed_out: - io.imsave(arguments.preprocessed_out, movie, plugin='tifffile') - logger.info(f'Written {arguments.preprocessed_out}') +if arguments.preprocessed_out is not None: + io.imsave(arguments.preprocessed_out, movie.astype(float32), plugin='tifffile') + logger.info(f'Written preprocessed to {arguments.preprocessed_out}')
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test-data/output1.html Sat Nov 28 18:50:09 2020 +0000 @@ -0,0 +1,334 @@ + + <html> + <!-- this file got automatically created by 'output_report.py' --> + <title>SpyBOAT Output Report</title> + <head> + <!-- that doesn't work with galaxy.. --> + <!--link rel="stylesheet" href="styles.css"--> + <style type="text/css"> + body{ margin:10 100; background:whitesmoke; } + /*body{ margin:10 100; background:darkslategrey; }*/ + .center{ + text-align: center; + display: block; + margin-left: auto; + margin-right: auto; + width: 100%;} + + /* matplotlib output at 1600x1200 */ + .distr_gallery { + display: grid; + margin: 0 auto; + text-align: center; + /* border: 1px dashed rgba(4, 4, 4, 0.35); */ + grid-template-columns: repeat(3,1fr); + grid-template-rows: 20vw; + grid-gap: 0px; + column-gap: 0px + } + .distr_gallery__img { + width: 100%; + height: 100%; + object-fit: contain; + } + + + /* matplotlib output at 1600x1200 */ + .snapshot_gallery { + display: grid; + margin: 0 auto; + border: 1px dashed rgba(4, 4, 4, 0.35); + text-align: center; + grid-template-columns: repeat(2,1fr); + grid-template-rows: repeat(2,20vw); + grid-gap: 5px; + } + .snapshot_gallery__img { + width: 100%; + height: 100%; + object-fit: contain; + } + .subheader{ + text-align:center; + font-size: 160%; + color:#363333;} + </style> + </head> + <body> + <h1 style="text-align:center; color:#363333">SpyBOAT Results Report</h1> + <hr style="width:50%"> + <h1 class="subheader"> Distribution Dynamics </h1> + <div class="distr_gallery"> + <figure class=”distr_gallery__item distr_gallery__item--1"> + <img src="period_distr.png" alt="Period" class="distr_gallery__img"> + </figure> + + <figure class=”distr_gallery__item distr_gallery__item--2"> + <img src="power_distr.png" alt="Power" class="distr_gallery__img"> + </figure> + + <figure class=”distr_gallery__item distr_gallery__item--3"> + <img src="phase_distr.png" alt="Phase" class="distr_gallery__img"> + </figure> + + </div> + + <h1 class="subheader"> Output Movie Snapshots </h1> + + <!-- trigger the javascript at the end---> + <div class="center"> + <button class="w3-button" onclick="plusDivs(-1)">❮ Prev</button> + <button class="w3-button" onclick="plusDivs(1)">Next ❯</button> + </div> + + <!-- defines all elements of the "FrameSlides" class ---> + + <div class="FrameSlides"> + <h3 style="text-align:center; color=#363333"> + Frame Nr. 20 </h3> + + <div class="snapshot_gallery"> + + <figure class=”snapshot_gallery__item + snapshot_gallery__item--1"> + <img src="input_frame20.png" alt="The Input" + class="snapshot_gallery__img"> + </figure> + + <figure class=”snapshot_gallery__item + snapshot_gallery__item--2"> + <img src="phase_frame20.png" alt="Phase" + class="snapshot_gallery__img"> + </figure> + + <figure class=”snapshot_gallery__item + snapshot_gallery__item--3"> + <img src="period_frame20.png" + alt="Period" class="snapshot_gallery__img"> + </figure> + + <figure class=”snapshot_gallery__item + snapshot_gallery__item--4"> + <img src="amplitude_frame20.png" + alt="Amplitude" class="snapshot_gallery__img"> + </figure> + </div> + </div> + + <div class="FrameSlides"> + <h3 style="text-align:center; color=#363333"> + Frame Nr. 28 </h3> + + <div class="snapshot_gallery"> + + <figure class=”snapshot_gallery__item + snapshot_gallery__item--1"> + <img src="input_frame28.png" alt="The Input" + class="snapshot_gallery__img"> + </figure> + + <figure class=”snapshot_gallery__item + snapshot_gallery__item--2"> + <img src="phase_frame28.png" alt="Phase" + class="snapshot_gallery__img"> + </figure> + + <figure class=”snapshot_gallery__item + snapshot_gallery__item--3"> + <img src="period_frame28.png" + alt="Period" class="snapshot_gallery__img"> + </figure> + + <figure class=”snapshot_gallery__item + snapshot_gallery__item--4"> + <img src="amplitude_frame28.png" + alt="Amplitude" class="snapshot_gallery__img"> + </figure> + </div> + </div> + + <div class="FrameSlides"> + <h3 style="text-align:center; color=#363333"> + Frame Nr. 36 </h3> + + <div class="snapshot_gallery"> + + <figure class=”snapshot_gallery__item + snapshot_gallery__item--1"> + <img src="input_frame36.png" alt="The Input" + class="snapshot_gallery__img"> + </figure> + + <figure class=”snapshot_gallery__item + snapshot_gallery__item--2"> + <img src="phase_frame36.png" alt="Phase" + class="snapshot_gallery__img"> + </figure> + + <figure class=”snapshot_gallery__item + snapshot_gallery__item--3"> + <img src="period_frame36.png" + alt="Period" class="snapshot_gallery__img"> + </figure> + + <figure class=”snapshot_gallery__item + snapshot_gallery__item--4"> + <img src="amplitude_frame36.png" + alt="Amplitude" class="snapshot_gallery__img"> + </figure> + </div> + </div> + + <div class="FrameSlides"> + <h3 style="text-align:center; color=#363333"> + Frame Nr. 44 </h3> + + <div class="snapshot_gallery"> + + <figure class=”snapshot_gallery__item + snapshot_gallery__item--1"> + <img src="input_frame44.png" alt="The Input" + class="snapshot_gallery__img"> + </figure> + + <figure class=”snapshot_gallery__item + snapshot_gallery__item--2"> + <img src="phase_frame44.png" alt="Phase" + class="snapshot_gallery__img"> + </figure> + + <figure class=”snapshot_gallery__item + snapshot_gallery__item--3"> + <img src="period_frame44.png" + alt="Period" class="snapshot_gallery__img"> + </figure> + + <figure class=”snapshot_gallery__item + snapshot_gallery__item--4"> + <img src="amplitude_frame44.png" + alt="Amplitude" class="snapshot_gallery__img"> + </figure> + </div> + </div> + + <div class="FrameSlides"> + <h3 style="text-align:center; color=#363333"> + Frame Nr. 52 </h3> + + <div class="snapshot_gallery"> + + <figure class=”snapshot_gallery__item + snapshot_gallery__item--1"> + <img src="input_frame52.png" alt="The Input" + class="snapshot_gallery__img"> + </figure> + + <figure class=”snapshot_gallery__item + snapshot_gallery__item--2"> + <img src="phase_frame52.png" alt="Phase" + class="snapshot_gallery__img"> + </figure> + + <figure class=”snapshot_gallery__item + snapshot_gallery__item--3"> + <img src="period_frame52.png" + alt="Period" class="snapshot_gallery__img"> + </figure> + + <figure class=”snapshot_gallery__item + snapshot_gallery__item--4"> + <img src="amplitude_frame52.png" + alt="Amplitude" class="snapshot_gallery__img"> + </figure> + </div> + </div> + + <div class="FrameSlides"> + <h3 style="text-align:center; color=#363333"> + Frame Nr. 60 </h3> + + <div class="snapshot_gallery"> + + <figure class=”snapshot_gallery__item + snapshot_gallery__item--1"> + <img src="input_frame60.png" alt="The Input" + class="snapshot_gallery__img"> + </figure> + + <figure class=”snapshot_gallery__item + snapshot_gallery__item--2"> + <img src="phase_frame60.png" alt="Phase" + class="snapshot_gallery__img"> + </figure> + + <figure class=”snapshot_gallery__item + snapshot_gallery__item--3"> + <img src="period_frame60.png" + alt="Period" class="snapshot_gallery__img"> + </figure> + + <figure class=”snapshot_gallery__item + snapshot_gallery__item--4"> + <img src="amplitude_frame60.png" + alt="Amplitude" class="snapshot_gallery__img"> + </figure> + </div> + </div> + + <div class="FrameSlides"> + <h3 style="text-align:center; color=#363333"> + Frame Nr. 68 </h3> + + <div class="snapshot_gallery"> + + <figure class=”snapshot_gallery__item + snapshot_gallery__item--1"> + <img src="input_frame68.png" alt="The Input" + class="snapshot_gallery__img"> + </figure> + + <figure class=”snapshot_gallery__item + snapshot_gallery__item--2"> + <img src="phase_frame68.png" alt="Phase" + class="snapshot_gallery__img"> + </figure> + + <figure class=”snapshot_gallery__item + snapshot_gallery__item--3"> + <img src="period_frame68.png" + alt="Period" class="snapshot_gallery__img"> + </figure> + + <figure class=”snapshot_gallery__item + snapshot_gallery__item--4"> + <img src="amplitude_frame68.png" + alt="Amplitude" class="snapshot_gallery__img"> + </figure> + </div> + </div> + + </div> + + <!-- javascript with escaped '{'---> + <script> + var slideIndex = 1; + showDivs(slideIndex); + + function plusDivs(n) { + showDivs(slideIndex += n); + } + + function showDivs(n) { + var i; + var x = document.getElementsByClassName("FrameSlides"); + if (n > x.length) {slideIndex = 1} + if (n < 1) {slideIndex = x.length} ; + for (i = 0; i < x.length; i++) { + x[i].style.display = "none"; + } + x[slideIndex-1].style.display = "block"; + } + </script> + </body> + </html> + \ No newline at end of file