Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
tgwoodcock authored Sep 27, 2023
1 parent 6b1d3c6 commit 168f637
Showing 1 changed file with 56 additions and 8 deletions.
64 changes: 56 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -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).

<BR>

### Installation

Please clone/download the repository and install with pip
Expand All @@ -13,6 +15,9 @@ cd sem_io
pip install .
```

<BR>


### Usage

*Command line*
Expand All @@ -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
```

<BR>


*Python*

You can also import the module and use the functions directly in Python.
Expand All @@ -31,28 +39,63 @@ You can also import the module and use the functions directly in Python.
>>> import sem_io
```

<BR>

To print an overview of parameters from the image header in the console:

```python
>>> my_params = sem_io.SEMparams("path_to_my_image.tif")
```

<BR>


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:
<BR>


You can print ALL the header parameters to the console like this:

```python
>>> my_params.print_param_dict(my_params.params)
```

<BR>


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.
<BR>


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"]
```

<BR>


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)
```


<BR>

### 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:

Expand All @@ -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()*

<BR>


### 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)

0 comments on commit 168f637

Please sign in to comment.