SerialEM Note: Utilize JPG File format
- Author:
Chen Xu
- Contact:
- Created:
Apr 29, 2018
- Updated:
Apr 20, 2021
- Abstract
SerialEM supprots MRC and TIF file formats. Although SerialEM doesn’t directly save JPG file from graphic interface as default, it does support JPG file format.
JPG file format can be very convenient for sharing and viewing due to its small file size. When we send screening results to users via DropBox, we also upload all the JPG files for LMM, MMM maps and single record shots. These JPG files take very little disc space and can be directly viewed on the web browers. People love this feature.
In this doc, two scripts or functions were introduced to conveniently save maps and single shots to JPG format. It is nice to be able to do it in-the-fly with SerialEM imaging.
Save Map Overview to JPG
The function to save maps to JPG is below.
1 Function MapToJPG 0 0
2
3 # SerialEM Script to convert map overview to a jpg image.
4 # it works on currently selected map item and should work for "Acquire at points..."
5 # for multiple map items.
6
7 # skip non-map item
8 ReportNavItem
9 If $RepVal5 != 2 # if not a map item
10 Echo -> Not a map item, exit!
11 Exit
12 EndIf
13
14 # load map overview into Q unbinned
15 SetUserSetting BufferToReadInto 16 # Q is 16th in alphabet, if A is 0.
16 SetUserSetting LoadMapsUnbinned 1
17 LoadNavMap
18
19 # make a jpeg image
20 ReduceImage Q 2 # loading buffer Q, factor 2 to make JPG image density range more pleasant
21 SaveToOtherFile A JPG JPG $navNote.jpg
22 EndFunction
One of tricks here is to load map into a buffer unbinned before saving to JPG. When we make montage maps using script to open montage files, the default binning for overview display is usually not 1. To take advantage of full resolution of the map, we load it unbinned. The other trick is to define a temporary loading (Read-in) buffer so the read-in buffer setup in Buffer Control panel becomes irrelevant.
This function can be used by inserting a line right below line NewMap in
your script like here:
NewMap
CallFunction MyFuncs::MapToJPG
It can also be used standalone as a script for multiple maps using “Acquire at points…”.
ScriptName MapToJPG
CallFunction MyFuncs::MapToJPG
This function and its script work on current item of map. However, if you run on a point item and create a map from this, the above function or script won’t work on this in-the-fly situation because current item is the very point item instead of newly created map. For this, one needs to use a slight different one as below.
1Function NewMapToJPG 0 0
2#
3# SerialEM Script to convert last map item to a jpg image.
4# It uses Note string as part of jpg filename.
5# it works on an item which creates a map and should work for "Acquire at points..."
6# as post-action.
7
8# skip non-map item
9ReportOtherItem -1 # last item - supposedly the newly created map.
10If $RepVal5 != 2 # if not a map item
11 Echo -> Not a map item, exit ...
12 Exit
13EndIf
14
15# load map overview into Q unbinned
16SetUserSetting BufferToReadInto 16 # Q is 16th in alphabet, if A is 0.
17SetUserSetting LoadMapsUnbinned 1
18LoadOtherMap -1 # last item on the nav list
19
20# make a jpeg image
21ReduceImage Q 2 # assuming loading buffer is Q, and reduce 2 to make JPG image density range more pleasant
22SaveToOtherFile A JPG JPG $navNote.jpg
23EndFunction
The trick here is to Report and Load the last item in the nav list which is the newly created map.
Save Single Shots to JPG
We can also save every single shot to JPG format along with MRC images. The MRC file is required to be opened. The JPG filename contains root name of the MRC file and section numbers.
1Function AToJPG 0 0
2
3# SerialEM Script to save image in buffer A to a jpg image.
4# It reduces image in A by 2 for comfortable JPG density range. It
5# takes current filename and Z into jpg filename. Therefore, MRC file
6# is required to be opened.
7
8ReportCurrentFilename 1
9root = $RepVal1
10ReportFileZsize
11z = $RepVal1
12
13ReduceImage A 2
14SaveToOtherFile A JPG JPG $root-$z.jpg
It can be used after saving MRC image for each exposure, like below:
Record
Save
CallFunction MyFuncs::AToJPG