| Bsoft 2.0.5 Bernard's software package

bmgft.cpp
Go to the documentation of this file.
1
9 #include "mg_tomo_rec.h"
10 #include "mg_tomography.h"
11 #include "rwmg.h"
12 #include "utilities.h"
13 #include "options.h"
14 #include "timer.h"
15
16 // Declaration of global variables
17 extern int verbose; // Level of output to the screen
18
19 // Usage assistance
20 const char* use[] = {
21 " ",
22 "Usage: bmgft [options] input.star [input2.star]",
23 "-----------------------------------------------",
24 "Fourier transforms micrographs from a tomographic tilt series.",
25 " ",
26 "Actions:",
27 "-removemarkers 14 Mask out markers with this radius (pixels) before transformation.",
28 " ",
29 "Parameters:",
30 "-verbose 7 Verbosity of output.",
31 "-datatype u Force writing of a new data type.",
32 "-select 23,45,66 Micrograph selection (default all).",
33 "-size 1024,1024,200 Intended reconstruction size (default from micrograph).",
34 "-scale 0.5 Scale of intended reconstruction (default 1).",
35 "-pad 3 Image padding factor (default 2).",
36 "-fill 127 Fill value for erasing/painting markers (default average).",
37 " ",
38 "Output:",
39 "-output file.star Output STAR file name.",
40 " ",
41 NULL
42 };
43
44 int main(int argc, char **argv)
45 {
46 double marker_radius(0); // Radius to mask out markers
47 DataType nudatatype(Unknown_Type); // Conversion to new type
48 Bstring mg_select; // Micrograph selection, default all
49 Vector3<long> size; // Default use micrograph dimension
50 double scale(1); // Intended reconstruction scale
51 int pad_factor(2); // Image padding factor
52 int fill_type(FILL_AVERAGE); // Type of fill value
53 double fill(0); // Fill value for new areas
54 Bstring outfile; // Output STAR file
55
56 int optind;
57 Boption* option = get_option_list(use, argc, argv, optind);
58 Boption* curropt;
59 for ( curropt = option; curropt; curropt = curropt->next ) {
60 if ( curropt->tag == "removemarkers" )
61 if ( ( marker_radius = curropt->value.real() ) < 1 )
62 cerr << "-removemarkers: A marker radius must be specified!" << endl;
63 if ( curropt->tag == "datatype" )
64 nudatatype = curropt->datatype();
65 if ( curropt->tag == "select" )
66 mg_select = curropt->value;
67 if ( curropt->tag == "size" )
68 size = curropt->size();
69 if ( curropt->tag == "scale" )
70 if ( ( scale = curropt->value.real() ) < 0.0001 )
71 cerr << "-scale: A scale must be specified!" << endl;
72 if ( curropt->tag == "pad" )
73 if ( ( pad_factor = curropt->value.integer() ) < 0 )
74 cerr << "-pad: An integer factor must be specified!" << endl;
75 if ( curropt->tag == "fill" )
76 fill = curropt->fill(fill_type);
77 if ( curropt->tag == "output" )
78 outfile = curropt->filename();
79 }
80 option_kill(option);
81
82 double ti = timer_start();
83
84 // Read all the parameter files
85 Bstring* file_list = NULL;
86 while ( optind < argc ) string_add(&file_list, argv[optind++]);
87 if ( !file_list ) {
88 cerr << "Error: No parameter files specified!" << endl;
89 bexit(-1);
90 }
91
92 Bproject* project = read_project(file_list);
93 string_kill(file_list);
94
95 if ( project == NULL ) {
96 cerr << "Error: No input file read!" << endl;
97 bexit(-1);
98 }
99
100 project_update_comment(project, argc, argv);
101
102 if ( mg_select.length() ) project_mg_select(project, mg_select);
103
104 Bstring label = get_cmd_line(argc, argv);
105
106 int n = mg_fft_write(project, size, scale, pad_factor, label,
107 nudatatype, marker_radius, fill_type, fill);
108
109 if ( n && project && outfile.length() ) {
110 project_update_comment(project, argc, argv);
111 write_project(outfile, project, 0, 0);
112 }
113
114 project_kill(project);
115
116 if ( verbose & VERB_TIME )
117 timer_report(ti);
118
119 bexit(0);
120 }
121
write_project
int write_project(const char *filename, Bproject *project)
Writing micrograph parameters to a file.
Definition: rwmg.cpp:320
rwmg.h
Header file for reading and writing micrograph parameters.
Bstring::real
double real()
Definition: Bstring.cpp:545
Boption::fill
double fill(int &fill_type)
Definition: options.h:138
string_add
Bstring * string_add(Bstring **list, const char *string)
Adds a string to a linked list.
Definition: Bstring.cpp:705
DataType
DataType
Base data type specifier.
Definition: utilities.h:146
use
const char * use[]
Definition: bmgft.cpp:20
utilities.h
Header file for general utilities.
Boption::value
Bstring value
Definition: options.h:30
Boption::tag
Bstring tag
Definition: options.h:29
project_mg_select
long project_mg_select(Bproject *project, Bstring &mg_select)
Selects micrographs in a project hierarchy.
Definition: mg_tomography.cpp:1585
read_project
Bproject * read_project(const char *filename, int flags=0)
Reading micrograph parameters from files.
Definition: rwmg.cpp:140
FILL_AVERAGE
#define FILL_AVERAGE
Definition: utilities.h:173
Bstring::length
long length() const
Definition: Bstring.cpp:263
project
Bproject * project
Definition: bshow.cpp:31
get_option_list
Boption * get_option_list(const char *use[], int argc, char *argv[], int &optind)
Parses command line arguments based on a template.
Definition: options.cpp:40
get_cmd_line
string get_cmd_line(int argc, char **argv)
Returns the command line as a string.
Definition: utilities.cpp:36
Boption::filename
Bstring filename()
Definition: options.h:85
timer.h
Utilities for timing functions.
Boption::size
Vector3< long > size()
Definition: options.h:163
Boption
A class for a command line input option.
Definition: options.h:26
VERB_TIME
#define VERB_TIME
Definition: utilities.h:110
mg_tomography.h
Header file for single particle image processing in Bsoft.
verbose
int verbose
Boption::datatype
DataType datatype()
Definition: options.h:93
Boption::next
Boption * next
Definition: options.h:28
Bstring
Definition: Bstring.h:29
project_kill
int project_kill(Bproject *project)
Frees a whole project.
Definition: mg_processing.cpp:1224
Vector3< long >
timer_report
double timer_report(double lasttime)
Reports the time elapsed since a given time.
Definition: timer.cpp:67
mg_tomo_rec.h
Functions to do a tomographic reconstruction.
option_kill
int option_kill(Boption *option)
Deallocates a linked list of option structures.
Definition: options.cpp:109
Bstring::integer
long integer()
Definition: Bstring.cpp:539
Unknown_Type
Definition: utilities.h:147
options.h
Header file for option handlers.
mg_fft_write
int mg_fft_write(Bproject *project, Vector3< int > size, double scale, int pad_factor, Bstring &label, DataType datatype, double marker_radius, int fill_type, double fill)
Fourier transform micrographs and write to disk.
Definition: mg_tomo_rec.cpp:986
project_update_comment
int project_update_comment(Bproject *project, int n, char **strings)
Puts a set of strings and time in the main comment of a project.
Definition: rwmg.cpp:468
main
int main(int argc, char **argv)
Definition: bmgft.cpp:44
bexit
int bexit(int value)
Exit function for cleanup and debugging.
Definition: utilities.cpp:273
timer_start
double timer_start()
Starts timer and prints the time.
Definition: timer.cpp:52
Bproject
Definition: mg_processing.h:333
string_kill
int string_kill(Bstring *list)
Kills a string linked list.
Definition: Bstring.cpp:760