From 168f6372e39a4122f71250fd0ca311c8f8002531 Mon Sep 17 00:00:00 2001 From: "Thomas G. Woodcock" Date: Wed, 27 Sep 2023 13:02:29 +0200 Subject: [PATCH] Update README.md --- README.md | 64 ++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 56 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index e90de38..649523a 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,11 @@ # sem_io -Provides some helper functions to extract and view parameters stored in the header of SEM images (.tif) recorded using the software Zeiss SmartSEM V06. +Provides some helper functions to extract and view parameters stored in the header of SEM images (.tif) recorded using either Zeiss SmartSEM or Thermo Fisher Scientific xT software. This is a single Python module and can either be installed or easily incorporated into other projects (the license must be retained in this case). +
+ ### Installation Please clone/download the repository and install with pip @@ -13,6 +15,9 @@ cd sem_io pip install . ``` +
+ + ### Usage *Command line* @@ -23,6 +28,9 @@ To print an overview of parameters from the image header in the console, at the sem_io path_to_my_image.tif ``` +
+ + *Python* You can also import the module and use the functions directly in Python. @@ -31,28 +39,63 @@ You can also import the module and use the functions directly in Python. >>> import sem_io ``` +
+ To print an overview of parameters from the image header in the console: ```python >>> my_params = sem_io.SEMparams("path_to_my_image.tif") ``` +
+ + If you just want to collect and store the parameters and not print them, you can do: ```python >>> my_params = sem_io.SEMparams("path_to_my_image.tif", verbose=False) ``` -Then, to extract a particular parameter, you can then do: +
+ + +You can print ALL the header parameters to the console like this: + +```python +>>> my_params.print_param_dict(my_params.params) +``` + +
+ + +You can print A SELECTION OF the header parameters (given in the class definition) to the console like this: ```python ->>> my_params.get_parameter("Aperture Size") -(120.0, 'µm') ->>> my_params.get_parameter("Date") -'25 Nov 2020' +>>> my_params.print_param_dict(my_params.params_grouped) ``` -Parameters with a value and a unit are returned as a 2-Tuple. Other parameters are returned as a string. +
+ + +Both my_params.params and my_params.params_groups are dictionaries and any parameter can be accessed, e.g. + +```python +>>> date = my_params.params_grouped["General"]["Date"] +``` + +
+ + +Alternatively you can dump all the header parameters to a json file (optionally including a key giving the original image path) like this: + +```python +>>> my_params.dump_params_to_json(my_params.params, "my_json_path.json", image_path=my_params.img_path) +``` + + +
+ +### Getting the Image Pixel Size and Adding a Scalebar All the functions are staticmethods, so you don't need to instantiate the SEMparams class at all. For example, there is a bespoke function for getting the image pixel size and its unit in one line of code: @@ -74,11 +117,16 @@ This is useful if you want to plot the SEM image using [matplotlib](https://matp >>> ax.add_artist(my_scalebar) ``` +*Even Electron Channeling Patterns acquired in rocking beam mode are correctly handled by sem_io.SEMparams.get_image_pixel_size()* + +
+ + ### Dependencies * [Pillow](https://python-pillow.org/) ### General -* The parameters defined in SEMparams form a subset of those available in the header of the .tif image. If you are interested in other parameters, the program can be easily customised. +* The selected parameters defined in the class definition of SEMparams form a subset of those available in the header of the .tif image. If you are interested in other parameters, the program can be easily customised - all the header parameters are extracted and are available as the "params" instance attribute. * If there are any issues, please feel free to get in touch using the [issues mechanism](https://github.com/tgwoodcock/sem_io/issues)