Skip to content

Commit 44570f5

Browse files
committed
Another local pass was made through the document
1 parent c632c53 commit 44570f5

File tree

2 files changed

+29
-46
lines changed

2 files changed

+29
-46
lines changed

docs/source/workflows/2d_EM.rst

Lines changed: 26 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
11
******
2-
2D Electron Microscopy Workflow (formally internally DM conversion workflow)
2+
Small 2D Workflow (EM Microscopy)
33
******
44

55
Overview:
66

7-
This workflow supports generating thumbnails and key images form input images. Certain EM file formats and contents
7+
This workflow generates a thumbnail and a key images for each input image in a directory. Specific EM file formats
88
use enhanced resampling and filtering techniques to reduce noise while adjusting the dynamic range of the images. This
99
workflow originally was designed to handle DM3 files from TEM or STEM microscopes but has been extended to handle
10-
other 2D EM image file formats, including MRC and TIFF files.
10+
other 2D image file formats, including MRC, TIFF files and color figures.
1111

1212
Outputs:
1313
1. A thumbnail image for each input image.
14+
- An JPEG image with a maximum size of 300 pixels in both dimension.
15+
- The aspect ratio is preserved and may be shortened to fit within the maximum size without padding.
16+
- The image may be 8-bit RGB(A) or 8-bit gray-scale.
1417
2. A key image for each input image.
18+
- Similar to the thumbnail image but with a maximum size of 1024 pixels in both dimension.
1519

1620
.. list-table:: Supported Extensions for File Formats
1721
:header-rows: 1
@@ -20,10 +24,10 @@ Outputs:
2024
- Description
2125
- Extensions
2226
* - DM3
23-
- image format used by Digital Micrograph
27+
- image format used by Digital Micrograph
2428
- dm3
2529
* - DM4
26-
- image format used by Digital Micrograph, possibly limited to 64-bit integers
30+
- image format used by Digital Micrograph, maybe limited to 64-bit integers
2731
- dm4
2832
* - MRC
2933
- image format used by the IMOD tool suite
@@ -52,7 +56,7 @@ processing tasks.
5256
- Processing Information
5357
* - JPEG, PNG, TIFF
5458
- 8-bit RGB (palette) or RGBA
55-
- Images may be figures or rendered EM image of wells?.
59+
- Example images include figure, TEM grid image or other illustrative images rendered into a color image.
5660
- Images should directly resized without intensity scaling or advanced filtering.
5761
* - TIFF, PNG, JPEG
5862
- 8-bit gray-scale
@@ -61,8 +65,7 @@ processing tasks.
6165
* - TIFF
6266
- 16-bit (signed or unsigned) gray-scale
6367
- EM images with a high dynamic range.
64-
- Convert to 8-bit
65-
- Use IMOD's `newstack`_ tool to resample, filter, and scale intensities to 8-bit.
68+
- Use IMOD's `newstack`_ tool to resample, filter, and scale intensities to 8-bit.
6669
* - DM4 or DM3 Images
6770
- 32-bit float (after MRC conversion)
6871
- Minimally processed EM images with a high dynamic range.
@@ -74,51 +77,31 @@ processing tasks.
7477
- Convert to 8-bit TIFF via `newstack`_ command to resample, filter, and scale intensities to 8-bit.
7578

7679

77-
Format Conversion
78-
+++++++++++++++++
79-
80-
The first step is to convert the input to a format compatible with the IMOD tool suite (e.g., MRC or TIFF).
81-
82-
Inputs: DM3, DM4, MRC, or TIFF files
83-
Outputs: MRC or TIFF files
84-
Steps:
85-
1. Use the `dm2mrc`_ tool to convert DM3 or DM4 files to MRC format.
86-
2. For MRC files, no additional conversion is required.
87-
3. For 16-bit TIFF files, convert them to 8-bit TIFF using the `newstack`_ tool.
80+
EM Image Conversion
81+
+++++++++++++++++++
8882

89-
Resampling
90-
++++++++++
83+
High dynamic range EM images need to be rendered into an image that is suitable for display. The EM images are
84+
resampled, filtered and resized to reduce the dynamic range and improve the signal-to-noise ratio.
9185

92-
The EM images can be broadly characterized as having a low signal-to-noise ratio and a high dynamic range with potential
93-
outliers. The resampling or resizing of these images requires advanced algorithms and options that are not available
94-
with conventional image processing tools. Through proper resampling and filtering, the images' signal-to-noise ratio
95-
can be improved, and the dynamic range can be reduced for better visualization.
9686

97-
The IMOD tool `newstack`_ is used to resample the images.
98-
99-
Inputs: MRC or TIFF files
100-
Outputs: TIFF files as 8-bit images
87+
Inputs: DM3, DM4, MRC, or TIFF (16-bit) file
88+
Output: TIFF file
10189
Steps:
102-
1. Determine the size or dimensions of the input images.
103-
2. Compute the factor to reduce the size of the input image to the desired key image size.
104-
3. Use the `newstack`_ tool to filter and resize/shrink the input image to approximately the desired size.
105-
106-
.. code-block:: bash
90+
1. If the input image is a DM4 or DM3 then the `dm2mrc`_ tool converts the input to an MRC format.
91+
process also converts the pixel type to 32-bit float.
92+
2. After computing the input image size, the `newstack`_ tool is used to resample and filter the image to reduce the
93+
dynamic range and improve the signal-to-noise ratio. The `newstack`_ tool also converts the pixel type to 8-bit
94+
unsigned integer.
10795

108-
newstack -format TIFF -shrink $shrink_factor -antialias 6 -mode 0 -float 1 input.tiff output.tiff
10996

110-
Conditionals:
111-
- If the input image size is less than the desired key image size, then `-shrink` and `-antialias` options are not
112-
used.
113-
- If the input pixel type is 8-bit, then the `float` option is not used.
97+
.. code-block:: bash
98+
newstack -format TIFF -shrink $shrink_factor -antialias 6 -mode 0 [-float 1|-meansd 140,50] input.tiff output.tiff
11499
115-
The above command converts any supported scalar pixel input type to an 8-bit image with a dynamic range reasonable for
116-
visualization. The `float` option is used so the resampled pixel intensities are normalized to fill the output range.
117100
118101
Output Generation
119102
+++++++++++++++++
120103

121-
The final step is to generate the thumbnail and key images using `SimpleITK`. The compression and filtering options are
104+
The final step is to generate the thumbnail and key image using `SimpleITK`. The compression and filtering options are
122105
tuned for web display.
123106

124107
Inputs: TIFF files
@@ -132,7 +115,7 @@ Steps:
132115
sitk.WriteImage(img, output_path, useCompression=True, compressionLevel=compression_level)
133116
134117
Note: The resizing operation ensures that the maximum dimension of the output matches the desired size, while preserving
135-
the input aspect ratio. The compression level is tunable and varies between thumbnails and key images.
118+
the input aspect ratio. If the input image is smaller than the desired size, it will not be resized.
136119

137120
.. _IMOD: https://bio3d.colorado.edu/imod/
138121
.. _dm2mrc: https://bio3d.colorado.edu/imod/doc/man/dm2mrc.html

em_workflows/dm_conversion/flow.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,9 @@ def convert_em_to_tiff(file_path: FilePath) -> Path:
115115
Performs the conversion of EM images to tiff format, adjusting the dynamic range and reducing the size of the image.
116116
117117
Three types of files are detected to need conversion:
118-
- mrc files are converted to tiff using newstack
119-
- 16-bit tiff files are converted to 8 bit tiff
120-
- dm3/dm4 files are converted to mrc using dm2mrc, then to tiff using newstack
118+
- mrc files are converted to tiff using newstack
119+
- 16-bit tiff files are converted to 8-bit tiff
120+
- dm3/dm4 files are converted to mrc using dm2mrc, then to tiff using newstack
121121
122122
EM images are broadly characterized by a low signal-to-noise ratio and a high dynamic range, often with potential
123123
outliers. Using newstack with shrink and antialiasing kernels is required to reduce the noise to produce a

0 commit comments

Comments
 (0)