Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the option to save as a tif file #778

Merged
merged 7 commits into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -263,10 +263,13 @@ topostats process --cmap rainbow

Matplotlib, and by extension TopoStats, supports saving images in a range of different formats including `png`
([Portable Network Graphic](https://en.wikipedia.org/wiki/PNG)), `svg` ([Scalable Vector
Graphics](https://en.wikipedia.org/wiki/SVG)) and `pdf` ([Portable Document
Format](https://en.wikipedia.org/wiki/PDF)). The default is `png` but, as with both DPI and Colormap, these can be
easily changed via a custom configuration file or command line options to change these without having to edit
the [Matplotlib Style file](matplotlib-style).
Graphics](https://en.wikipedia.org/wiki/SVG)), `pdf` ([Portable Document
Format](https://en.wikipedia.org/wiki/PDF)), and `tif` ([Tag Image File
Format](https://en.wikipedia.org/wiki/TIFF)). The default is `png` but, as with both DPI and Colormap, these can be
easily changed via a custom configuration file or command line options to change these without having to edit the
[Matplotlib Style file](matplotlib-style). If using `tif` it is worth being aware that although the image will be saved,
this will be without metadata since this is not supported for `tif` files (see the note under `metadata` of [Matplotlib
savefig](https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.savefig.html)).

If you want to modify the output file format that is used you have two options. Firstly you can [generate a
configuration](generating-a-configuration) file and modify the field `savefig_format` to your choice. The example below
Expand Down
2 changes: 1 addition & 1 deletion topostats/default_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ dnatracing:
plotting:
run: true # Options : true, false
style: topostats.mplstyle # Options : topostats.mplstyle or path to a matplotlibrc params file
savefig_format: null # Options : null (defaults to png) or see https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.savefig.html
savefig_format: null # Options : null, png, svg or pdf. tif is also available although no metadata will be saved. (defaults to png) See https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.savefig.html
savefig_dpi: null # Options : null (defaults to figure) see https://afm-spm.github.io/TopoStats/main/configuration.html#further-customisation and https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.savefig.html
pixel_interpolation: null # Options : https://matplotlib.org/stable/gallery/images_contours_and_fields/interpolation_methods.html
image_set: core # Options : all, core
Expand Down
4 changes: 3 additions & 1 deletion topostats/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -897,7 +897,9 @@ def validate_config(config: dict, schema: Schema, config_type: str) -> None:
"png",
"pdf",
"svg",
error=("Invalid value in config 'savefig_format', valid values are 'png', 'pdf' or 'svg' "),
"tiff",
"tif",
error=("Invalid value in config 'savefig_format', valid values are 'png', 'pdf', 'svg' or 'tif'"),
),
"pickle_plots": Or(
True,
Expand Down
Loading