Skip to content

Commit

Permalink
Merge pull request #778 from AFM-SPM/derollins/tiff_validation
Browse files Browse the repository at this point in the history
Add the option to save as a `tif` file
  • Loading branch information
MaxGamill-Sheffield committed Feb 7, 2024
2 parents 0e77bcf + 50f94db commit 7ec11bd
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
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

0 comments on commit 7ec11bd

Please sign in to comment.