HTML writer module
This creates html files with the images and movies from an experiment, which can be viewed as a webpage.
These have the advantage over pdfs when dealing with in situ data, that movies can be played. The downside is that the media files are only linked in the html file, and therefore to share the file the images and movies need to be shared as well.
There is also a function to write a css file which gives the document basic formatting, this is far from high quality formating but is a start.
I recommend using a directory structure something like this:
Experiment>Media>Images Experiment>Media>Videos
Where experiment contains the raw data, media contains the html and css and Images & Videos contain the .jpg (or .tif/.png) images and .mp4 videos respectively Then run the functions below from the media folder.
Usage
Simple usage is summed up below:
#import module
from SimpliPyTEM.html_writer import *
#if you are not already in the Media directory (shown above) use:
import os
os.chdir(/Path/To/Media)
#Get files in lists
image_files, video_files = get_files(Images_dir, Video_dir)
#Write the html file
html_writer(image_files, video_files, title='Experiment title', note='Add some notes about the experiment here...')
#Write the css file
write_css()
- html_writer.get_files_html(imagedir, videodir=None, image_pattern='', video_pattern='')
Simple method for getting the image and video files.
Parameters
- imagedir:str
Directory containing the images (jpg, png or tif format)
- videodir:str
Directory containing videos. Videos must be .mp4
- image_pattern:str
Pattern which the images contain, it is assumed they will be .jpg but if any more specific patterns in the filename are required (E.g. to only include a single sample) It can be added here.
- video_pattern:str
As image pattern but for videos.
- html_writer.write_css(outdir=None)
Writes a basic css document called style.css, this is linked in the html generated. This gives it some basic formatting. You may consider making your own css for better formatting.
- html_writer.write_html(images, videos=None, title='Default_experiment_title', notes='', **kwargs)
Writes html file containing the images and videos from an experiment so they can be viewed on a webbrowser. This can be preferable over PDFS as the videos can be played. The images and videos are only linked in this html, so in order to share the page these need to be sent as well.
Parameters
- Images:list
List of images (including their path from the current directory), can be made with get_files_html()
- Videos: list
List of videos (including their path from the current directory), can be made with get_files_html()
- title:str
The title for the experiment (name of html doc and title of the resulting page)
- notes:str
Accompanying notes for the experiment, included at the top of the doc.
Output
HTML document {title}.html saved in the current working directory. This html document has the images from an experiment as well as playable videos.