4 # @brief Procedures to manage tomographic images
6 # @author Bernard Heymann
7 # @date Created: 20021112
8 # @date Modified: 20200325
11 set show_marker_errors 1
12 set show_marker_labels 1
14 set markers_selected []
19 set norm_type "Simple"
23 ## @brief Dialog box to manage tomographic information
27 # puts "In Tomography"
28 global tool project_item theimg imgtype
31 global thickness tilt_axis marker_radius
33 if ![Bimage exists $theimg] {
34 tk_dialog .dialog "No image in memory!" \
35 {Please read in an appropriate image first.} \
40 set c [getImageCanvas $theimg]
45 Bmg set $project_item axis $tilt_axis
46 Bmg set $project_item marker_radius $marker_radius
47 # puts "Setting tilt axis in the project"
49 set axis [expr [Bmg get $project_item axis] ]
50 if { $axis > -1000 } {
52 # puts "Getting tilt axis from the project"
54 set r [Bmg get $project_item marker_radius]
58 # set marker_radius 10
59 Bmg set $project_item marker_radius $marker_radius
63 set field [Bmg get $project_item field]
64 set nmg [Bmg get $project_item number_of_mg]
65 set nrec [Bmg get $project_item number_of_rec]
67 # puts "Number of micrographs: $nmg"
68 # puts "Number of reconstructions: $nrec"
69 # puts "Field: $field"
70 # puts "Marker radius: $marker_radius"
71 # puts "Tilt axis: $tilt_axis"
74 if ![winfo exists $w] {
76 menu $w.menuBar -tearoff 0
77 $w.menuBar add cascade -menu $w.menuBar.tomo -label "Tomography" -underline 0
78 menu $w.menuBar.tomo -tearoff 0
79 $w configure -menu $w.menuBar
80 $w.menuBar.tomo add command -label "Help" -underline 0 \
81 -command { showURL "file://$Bsoft/doc/bshow/bshow_tomo.html" }
82 # -command { showHelp bshow_tomo.hlp }
83 $w.menuBar.tomo add command -label "Set tilt angles" \
84 -command { Tilts } -underline 0
85 $w.menuBar.tomo add command -label "Read tilt angles file" \
86 -command { readTlt } -underline 0
87 # $w.menuBar.tomo add command -label "Find markers in all images" \
88 # -command { markerFind -1 } -underline 0
89 $w.menuBar.tomo add command -label "Renumber markers in current image" \
90 -command { markerRenumber } -underline 0
91 $w.menuBar.tomo add command -label "Center markers in current image" \
92 -command { markerCenter } -underline 0
93 $w.menuBar.tomo add command -label "Extract markers" \
94 -command { markerExtract } -underline 0
95 $w.menuBar.tomo add command -label "Show marker table" \
96 -command { markerTable } -underline 0
97 $w.menuBar.tomo add command -label "Delete selected markers" \
98 -command { markerDeleteSelected } -underline 0
99 $w.menuBar.tomo add command -label "Delete selected markers in all images" \
100 -command { markerDeleteSelectedAll } -underline 0
101 $w.menuBar.tomo add command -label "Delete all markers" \
102 -command { markerDeleteAll } -underline 0
103 $w.menuBar.tomo add command -label "Close" \
104 -command "destroy $w" -underline 0
106 $w.menuBar add cascade -menu $w.menuBar.tomoflow -label "Workflow" -underline 0
107 menu $w.menuBar.tomoflow -tearoff 0
108 $w configure -menu $w.menuBar
109 $w.menuBar.tomoflow add command -label "Align and sum frames" \
110 -command { alignSumFrames } -underline 0
111 $w.menuBar.tomoflow add command -label "Normalize images" \
112 -command { normalizeImages } -underline 0
113 $w.menuBar.tomoflow add command -label "Align micrographs" \
114 -command { alignMicrographs } -underline 0
115 $w.menuBar.tomoflow add command -label "Find markers in current image" \
116 -command { markerFind [.image.scale get] } -underline 0
117 $w.menuBar.tomoflow add command -label "Generate markers from seed" \
118 -command { markerGenerate } -underline 0
119 $w.menuBar.tomoflow add command -label "Find tilt axis" \
120 -command { findTiltAxis } -underline 0
121 $w.menuBar.tomoflow add command -label "Transfer markers to second series" \
122 -command { markerTransfer } -underline 0
123 $w.menuBar.tomoflow add command -label "Track markers" \
124 -command { markerTrack } -underline 0
125 $w.menuBar.tomoflow add command -label "Refine alignment" \
126 -command { markerRefine } -underline 0
127 $w.menuBar.tomoflow add command -label "Calculate and fit power spectra" \
128 -command { tomoPowerSpectra } -underline 0
129 $w.menuBar.tomoflow add command -label "Estimate resolution" \
130 -command { tomoResolution } -underline 0
131 $w.menuBar.tomoflow add command -label "Reconstruct" \
132 -command { tomoReconstruct } -underline 0
133 $w.menuBar.tomoflow add command -label "Denoise" \
134 -command { tomoDenoise } -underline 0
137 checkbutton $w.switches.markers -text "Show markers" -variable show_markers \
138 -command { markerDrawAll }
139 checkbutton $w.switches.errors -text "Show errors" -variable show_marker_errors \
140 -command { markerDrawAll }
141 checkbutton $w.switches.labels -text "Show labels" -variable show_marker_labels \
142 -command { markerDrawAll }
143 pack $w.switches.markers $w.switches.errors $w.switches.labels -side left -ipadx 2 -ipady 5 -pady 5 -padx 1m
145 setupEntry $w.thick "Thickness " double $thickness "The tomogram thickness estimate set by the user or determined using the proportionality parameter, lambda."
146 label $w.thick.unit -text "Å" -width 3 -font $helv12 -anchor w
147 # button $w.thick.update -text "Fit intensities" \
148 # -relief raised -command "fitIntensities"
149 label $w.thick.update -text "Update" -relief raised
150 set m [menu $w.thick.pup]
151 $m add command -label "Fit intensities" -command "fitIntensities"
152 $m add command -label "Marker range" -command "markerRange"
153 pack $w.thick.unit $w.thick.update -side left -padx 1m
154 bind $w.thick.update <1> [list tk_popup "$w.thick.pup" %X %Y]
156 setupEntry $w.tilt_axis "Tilt axis " double $tilt_axis "The general tilt axis angle starting from the x-axis and proceeding counter-clockwise"
157 checkbutton $w.tilt_axis.show -text "Show" -variable show_tilt_axis \
158 -command { drawTiltAxis }
159 bind $w.tilt_axis.e <Return> { setTiltAxis }
160 pack $w.tilt_axis.show -side left -padx 1m
162 setupEntry $w.marker_radius "Marker radius " double $marker_radius "The typical radius of fidicial markers in pixels"
165 label $w.marker.tag -text "Markers" -width 20 -anchor w
166 label $w.marker.num -width 10 -text "0" -relief sunken -bd 1 -anchor w
167 button $w.marker.tabbut -text "Marker table" \
168 -relief raised -command "markerTable"
169 pack $w.marker.tag $w.marker.num $w.marker.tabbut -side left -padx 1m
172 label $w.selected.numtag -text "Selected marker" -width 20 -anchor w
173 label $w.selected.num -width 4 -text "" -relief sunken -bd 1 -anchor w
174 label $w.selected.restag -text "Residual" -width 10 -anchor e
175 label $w.selected.res -width 6 -text "" -relief sunken -bd 1 -anchor w
176 label $w.selected.fomtag -text "FOM" -width 5 -anchor e
177 label $w.selected.fom -width 6 -text "" -relief sunken -bd 1 -anchor w
178 button $w.selected.refbut -text "Refine" \
179 -relief raised -command "refineMarker"
180 pack $w.selected.numtag $w.selected.num $w.selected.restag \
181 $w.selected.res $w.selected.fomtag $w.selected.fom \
182 $w.selected.refbut -side left -padx 1m
185 label $w.resid.tag -text "Residual" -width 20 -anchor w
186 label $w.resid.val -width 10 -text "" -relief sunken -bd 1 -anchor w
187 button $w.resid.update -text "Update" \
188 -relief raised -command "updateTomoTable"
189 pack $w.resid.tag $w.resid.val $w.resid.update -side left -padx 1m
192 label $w.fom.label -text "FOM cutoff" -width 20 -anchor w
193 scale $w.fom.scale -orient horizontal -length 300 -from 0 -to 1 \
194 -command { setFOMcutoff } -resolution 0.001
195 pack $w.fom.label $w.fom.scale -side left -padx 1m
198 label $w.field.tag -text "Field" -width 20 -anchor w
199 label $w.field.str -width 50 -text $field -relief sunken -bd 1 -anchor w
200 pack $w.field.tag $w.field.str -side left -padx 1m
202 setupMicrographButtons $w.neighbor "micrograph"
204 label $w.header -font $helv12 -anchor w \
205 -text " Mg Tilt Axis Level OriginX OriginY ScaleX ScaleY Residual"
208 text $w.table -relief sunken -bd 2 -width 70\
209 -yscrollcommand ".wtomo.yscroll set" \
210 -setgrid 1 -highlightthickness 0 -pady 2 -padx 3 -font $cour12
211 scrollbar $w.yscroll -command ".wtomo.table yview" \
212 -highlightthickness 0 -orient vertical
213 grid $w.table -in $w.frame -padx 1 -pady 1 \
214 -row 0 -column 0 -rowspan 1 -columnspan 1 -sticky news
215 grid $w.yscroll -in $w.frame -padx 1 -pady 1 \
216 -row 0 -column 1 -rowspan 1 -columnspan 1 -sticky news
217 grid rowconfig $w.frame 0 -weight 1 -minsize 0
218 grid columnconfig $w.frame 0 -weight 1 -minsize 0
220 pack $w.switches $w.thick $w.tilt_axis $w.marker_radius $w.marker $w.selected \
221 $w.resid $w.fom $w.field $w.neighbor -side top -pady 2 -padx 5 -anchor w
222 pack $w.header -side top -fill x -padx 5
223 pack $w.frame -expand yes -fill both -padx 5 -pady 5
225 # puts "Tomo window setup done"
229 # puts [getPixelSizeEntry]
237 wm title $w "Tomography"
238 wm iconname $w "Tomography"
239 if { $tool == "marker_group" } {
240 set n [.image.scale get]
241 set mg_item [micrographItem $n]
242 set markers_selected [Bmg marker $mg_item selectrect -10000 -10000 10000 10000]
245 .menuBar.window entryconfigure "Tomography" -state normal
246 bind $c <1> "markerCreateSelect %x %y"
247 bind $c <2> "markerCreateSelect %x %y"
248 bind $c <Shift-1> "markerDelete %x %y"
249 bind $c <Shift-2> "markerDelete %x %y"
250 bind $c <B1-Motion> "markerMove %x %y"
251 bind $c <B2-Motion> "markerMove %x %y"
252 bind $c <ButtonRelease-1> "markerSetSelection %x %y"
253 bind $c <ButtonRelease-2> "markerSetSelection %x %y"
254 bind $w <Return> "Update 0"
255 bind $w <Control-w> { destroy .wtomo }
256 bind $w <Command-w> { destroy .wtomo }
257 bind . <Key-a> "markerAcceptModelLocation"
258 # bind . <Key-i> "invertSelection $c"
259 bind $c <Control-1> "markerSelectAppend %x %y"
260 bind $c <Command-1> "markerSelectAppend %x %y"
263 ## @brief Sets the tilt axis angle
266 proc setTiltAxis { } {
267 global tilt_axis project_item
268 set tilt_axis [.wtomo.tilt_axis.e get]
270 Bmg set $project_item axis $tilt_axis
275 ## @brief Dialog box to set the tilts for a tomographic series
279 global tilt_axis project_item
280 set tilt_axis [.wtomo.tilt_axis.e get]
284 set mg_item [micrographItem 0]
285 set tilt_axis [expr [Bmg get $mg_item axis]]
286 set tilt_start [expr [Bmg get $mg_item tilt]]
287 set mg_item [micrographItem 1]
288 set tilt_step [expr [Bmg get $mg_item tilt] - $tilt_start]
291 if ![winfo exists $w] {
294 setupEntry $w.tilt_step "Tilt step " double $tilt_step \
295 "The angular increment between micrographs"
297 setupEntry $w.tilt_start "Starting angle" double $tilt_start \
298 "The tilt angle of the first micrograph"
300 pack $w.tilt_start $w.tilt_step -side top -fill x -pady 2 -padx 2
303 button $w.buttons.ok -text OK -command "setTilts .wtilt"
304 button $w.buttons.cancel -text Cancel -command "destroy .wtilt"
305 pack $w.buttons -side bottom -fill x -pady 2m
306 pack $w.buttons.ok $w.buttons.cancel -side left -expand 1
308 bind $w <Return> "setTilts .wtilt"
314 wm iconname $w "Tilts"
317 ## @brief Generates the tilt list for a tomographic series.
319 # @param w the window to destroy.
321 proc setTilts { w } {
322 global tilt_axis project_item
323 set step [expr [$w.tilt_step.e get]]
324 set start [expr [$w.tilt_start.e get]]
326 set nimg [Bmg get $project_item number_of_mg]
327 # puts "Number of micrographs = $nimg"
329 for {set i 0} {$i < $nimg} {incr i 1} {
330 set tilt [expr $start + $i * $step]
331 set mg_item [micrographItem $i]
332 Bmg set $mg_item tilt $tilt
338 ## @brief Reads tilt angles from a rawtlt file
344 {"tlt files" {.tlt .TLT} }
345 {"rawtlt files" {.rawtlt .RAWTLT} }
347 set rawtltfile [tk_getOpenFile -filetypes $types]
348 if { [string length $rawtltfile] < 1 } { return }
349 set rawtltID [open $rawtltfile r]
350 set nimg [Bmg get $project_item number_of_mg]
352 foreach line [split [read $rawtltID] \n] {
353 if { [scan $line "%g" tilt ] > 0 } {
355 Bmg set $project_item tilt $tilt $i
361 set tilt_axis [.wtomo.tilt_axis.e get]
366 ## @brief Draws the tilt axis on the canvas
369 proc drawTiltAxis { } {
371 global show_tilt_axis project_item
372 if ![Bmg exists] { return }
373 set c [getImageCanvas $theimg]
374 set wc [getControlWindow $theimg]
376 if { [$wc.slice.scale get] > 1 } { set show_tilt_axis 0 }
377 if { $show_tilt_axis < 1 } { return }
378 set img_num [$wc.image.scale get]
379 set mg_item [micrographItem $img_num]
380 set tax [expr [Bmg get $mg_item axis] * $PI/180.0]
381 set ang [expr [Bmg get $mg_item tilt] * $PI/180.0]
382 # puts "$mg_item $tax $ang"
383 set img_num [$wc.image.scale get]
384 set scale [$wc.scale.scale get]
385 set height [Bimage get $theimg height]
386 set radius [expr $height * $scale / 2]
387 set origin [Bmg get $mg_item origin]
388 set ox [expr [lindex $origin 0] * $scale]
389 set oy [expr ($height - [lindex $origin 1] - 1) * $scale]
390 set ct [expr cos($tax)]
391 set st [expr sin($tax)]
392 set dx [expr $radius*$ct]
393 set dy [expr $radius*$st]
394 set xs [expr $ox - $dx]
395 set ys [expr $oy + $dy]
396 set xe [expr $ox + $dx]
397 set ye [expr $oy - $dy]
398 $c create line $xs $ys $xe $ye -fill LightBlue -dash - -width 1.5 -tags tilt_axis
399 # puts "$tax $xs $ys $xe $ye"
400 # Note that this line points to the tomogram z-axis
401 set vlen [expr 0.1 * $height * $scale * sin($ang)]
402 set xe [expr $ox + $vlen*$st]
403 set ye [expr $oy + $vlen*$ct]
404 $c create line $ox $oy $xe $ye -fill LightBlue -width 1.5 -tags tilt_axis
405 # puts "$vlen $ox $oy $xe $ye"
408 ## @brief Selects a marker
411 # @param y Marker position in canvas coordinates.
413 proc markerSelect { x y } {
414 if ![winfo exists .wtomo] { return }
415 global theimg project_item
416 global marker_radius markers_selected
419 set c [getImageCanvas $theimg]
420 set wc [getControlWindow $theimg]
421 set marker_radius [.wtomo.marker_radius.e get]
422 Bmg set $project_item marker_radius $marker_radius
423 # puts $marker_radius
424 set n [$wc.image.scale get]
425 set z [$wc.slice.scale get]
426 set scale [$wc.scale.scale get]
427 set px [expr floor( [$c canvasx $x] / $scale ) ]
428 set py [expr floor( [$c canvasy $y] / $scale ) ]
429 set mx [expr int($px)]
430 set my [expr int($py)]
432 set mg_item [micrographItem $n]
433 set id [Bmg marker $mg_item select $mx $myi $z]
434 set markers_selected $id
435 set res [Bmg marker $mg_item residual $id]
436 set fom [Bmg marker $mg_item fom $id]
437 .wtomo.selected.num config -text "$id"
438 .wtomo.selected.res config -text "$res"
439 .wtomo.selected.fom config -text "$fom"
443 ## @brief Appends marker at a location to list of selected markers.
446 # @param y Cursor position in window coordinates.
448 proc markerSelectAppend { x y } {
449 global markers_selected
450 set id [markerSelect $x $y]
451 if { $id < 1 } { return }
452 if { [lsearch $markers_selected $id] < 0 } {
453 lappend markers_selected $id
457 ## @brief The marker selection is reset and set to within a rectangle.
460 # @param y Marker position in canvas coordinates.
462 proc markerSetSelection { x y } {
463 global theimg project_item
464 global markers_selected
467 # set markers_selected []
468 if { $tool != "marker_group" } { return }
469 set c [getImageCanvas $theimg]
470 set wc [getControlWindow $theimg]
471 set scale [$wc.scale.scale get]
472 set n [$wc.image.scale get]
475 set x2 [expr [$c canvasx $x] / $scale ]
476 set y2 [yFlip [expr [$c canvasx $y] / $scale ]]
477 # puts "$x1 $y1 $x2 $y2"
478 set mg_item [micrographItem $n]
479 set markers_selected [Bmg marker $mg_item selectrect $x1 $y1 $x2 $y2]
480 # puts "selected IDS = $markers_selected"
484 ## @brief Selects or creates a marker
487 # @param y Marker position in canvas coordinates.
489 proc markerCreateSelect { x y } {
490 if ![winfo exists .wtomo] { return }
491 global theimg project_item
492 global marker_radius markers_selected
496 set c [getImageCanvas $theimg]
497 set wc [getControlWindow $theimg]
498 set marker_radius [.wtomo.marker_radius.e get]
499 Bmg set $project_item marker_radius $marker_radius
500 # puts $marker_radius
501 set n [$wc.image.scale get]
502 set z [$wc.slice.scale get]
503 set scale [$wc.scale.scale get]
504 set px [expr floor( [$c canvasx $x] / $scale ) ]
505 set py [expr floor( [$c canvasy $y] / $scale ) ]
506 set mx [expr int($px)]
507 set my [expr int($py)]
509 set mg_item [micrographItem $n]
510 set id [Bmg marker $mg_item select $mx $myi $z]
511 # puts "selected ID = $id"
514 if { $tool == "marker" } {
515 set id [Bmg marker $mg_item create $mx $myi $z]
516 # puts "created ID = $id"
518 if { $tool == "marker_group" } {
519 set markers_selected []
522 if { $tool == "marker_group" } {
523 if { $id > 0 && [llength $markers_selected] == 0 } {
524 set markers_selected [Bmg marker $mg_item ids 0]
529 set markers_selected $id
530 # Bmg marker $mg_item snap $id
531 set res [Bmg marker $mg_item residual $id]
532 set fom [Bmg marker $mg_item fom $id]
533 .wtomo.selected.num config -text "$id"
534 .wtomo.selected.res config -text "$res"
535 .wtomo.selected.fom config -text "$fom"
537 # puts "Selected IDs = $markers_selected"
542 ## @brief Generates markers from a seed.
545 proc markerGenerate { } {
547 global show_tilt_axis project_item
549 Bmg marker $project_item generate
554 ## @brief Extracts markers from a micrograph.
557 proc markerExtract { } {
559 global filename project_item theimg
560 if ![winfo exists .wtomo] { return }
561 set wc [getControlWindow $theimg]
562 set xname [file root [file tail $filename]]
563 set xdir [file dirname $filename]
564 append xname "_marker.mrc"
565 set xname [tk_getSaveFile -filetypes $filetypes \
566 -initialfile $xname -initialdir $xdir -defaultextension .mrc]
567 if { [string length $xname] < 1 } { return }
569 set n [$wc.image.scale get]
570 set mg_item [micrographItem $n]
571 Bmg marker $mg_item extract $xname
574 ## @brief Moves the selected markers
577 # @param y Mouse position in canvas coordinates.
579 proc markerMove { x y } {
580 if ![winfo exists .wtomo] { return }
582 global markers_selected project_item
585 set c [getImageCanvas $theimg]
586 set wc [getControlWindow $theimg]
587 set scale [$wc.scale.scale get]
588 set cx [$c canvasx $x]
589 set cy [$c canvasy $y]
590 if { $tool == "marker_group" && [llength $markers_selected] == 0 } {
592 set cpx [expr int($px * $scale)]
593 set cpy [expr int($py * $scale) ]
594 $c create rectangle $cpx $cpy $cx $cy -tags selection -outline red
597 set n [$wc.image.scale get]
598 set ix [expr $cx / $scale ]
599 set iy [expr $cy / $scale ]
600 set dx [expr $ix - $px]
601 set dy [expr $py - $iy]
604 set mg_item [micrographItem $n]
605 foreach id $markers_selected {
606 Bmg marker $mg_item move $id $dx $dy
611 ## @brief Draws a marker with an error line and label.
613 # @param id Marker identifier.
615 proc markerDraw { id } {
616 global theimg project_item
617 global show_marker_errors show_marker_labels
618 global marker_color marker2_color marker_select_color error_color error_select_color
619 global marker_radius markers_selected
620 if ![winfo exists .wtomo] { return }
621 set c [getImageCanvas $theimg]
622 set wc [getControlWindow $theimg]
623 set z [$wc.slice.scale get]
624 set n [$wc.image.scale get]
625 set mg_item [micrographItem $n]
626 set locerr [Bmg marker $mg_item location $id]
628 set selflag [Bmg marker $mg_item getflag $id]
630 set zr [expr abs([lindex $locerr 2] - $z)]
631 set marker_radius [.wtomo.marker_radius.e get]
632 if { $zr > $marker_radius } { return }
634 if { $zr > 0.1 && $marker_radius > 0 } {
635 set zr2 [expr sqrt(1 - $zr*$zr*1.0/($marker_radius*$marker_radius))]
637 set scale [$wc.scale.scale get]
638 set x [expr [lindex $locerr 0] * $scale ]
639 set y [expr [yFlip [lindex $locerr 1]] * $scale ]
640 set radius [expr $marker_radius * $scale * $zr2]
641 set ex [expr $x + [lindex $locerr 3] * $scale ]
642 set ey [expr $y - [lindex $locerr 4] * $scale ]
644 set xmin [expr $x - $radius ]
645 set xmax [expr $x + $radius ]
646 set ymin [expr $y - $radius ]
647 set ymax [expr $y + $radius ]
648 if { [lsearch $markers_selected $id] >= 0 } {
649 set markcolorshow $marker_select_color;
650 set errcolorshow $error_select_color;
651 } elseif { $selflag == 2 } {
652 set markcolorshow $marker2_color;
653 set errcolorshow $error_color;
655 set markcolorshow $marker_color;
656 set errcolorshow $error_color;
658 set idtag [format "m%d" $id]
659 $c create oval $xmin $ymin $xmax $ymax -outline $markcolorshow -width 1 -tags [list marker $idtag]
660 if { $show_marker_errors } {
661 $c create line $x $y $ex $ey -fill $errcolorshow -width 2 -tags [list marker $idtag]
663 if { $show_marker_labels } {
664 $c create text $xmax $y -text $id -fill $markcolorshow -anchor w -tags [list marker $idtag]
668 ## @brief Redraws all markers on the canvas
671 proc markerDrawAll {} {
672 global theimg project_item
675 if ![winfo exists .wtomo] { return }
676 set c [getImageCanvas $theimg]
677 set wc [getControlWindow $theimg]
679 if { $show_markers < 1 } { return }
680 set n [$wc.image.scale get]
681 set mg_item [micrographItem $n]
682 # puts "markerDrawAll $mg_item"
683 set ids [Bmg marker $mg_item ids $fom_cutoff]
684 # puts "fom_cutoff = $fom_cutoff"
690 set nsel [Bmg marker $project_item count]
691 .wtomo.marker.num config -text "$nsel"
694 ## @brief Deletes the selected marker.
697 # @param y Marker position in canvas coordinates.
699 proc markerDelete { x y } {
700 global project_item theimg
701 set wc [getControlWindow $theimg]
702 set n [$wc.image.scale get]
703 set id [markerSelect $x $y]
704 set mg_item [micrographItem $n]
706 Bmg marker $mg_item delete $id
711 ## @brief Deletes the selected marker.
713 # @param id Marker identifier.
715 proc markerDeleteID { id } {
716 global project_item theimg
717 set wc [getControlWindow $theimg]
718 set n [$wc.image.scale get]
719 set mg_item [micrographItem $n]
721 Bmg marker $mg_item delete $id
726 ## @brief Deletes all the selected markers.
729 proc markerDeleteSelected { } {
730 global markers_selected project_item theimg
731 set wc [getControlWindow $theimg]
732 set n [$wc.image.scale get]
733 # puts "IDs = $markers_selected"
734 set mg_item [micrographItem $n]
735 foreach id $markers_selected {
736 Bmg marker $mg_item delete $id
741 ## @brief Deletes all the selected markers in all images.
744 proc markerDeleteSelectedAll { } {
745 global markers_selected project_item
746 # puts "IDs = $markers_selected"
747 foreach id $markers_selected {
748 Bmg marker all delete $id
753 ## @brief Deletes all markers.
756 proc markerDeleteAll { } {
757 global theimg project_item
758 set c [getImageCanvas $theimg]
759 Bmg marker all delete all
761 .wtomo.marker.num config -text "0"
764 ## @brief Renumbers markers in the current micrograph.
767 proc markerRenumber { } {
768 global project_item theimg
769 set wc [getControlWindow $theimg]
770 set n [$wc.image.scale get]
771 set mg_item [micrographItem $n]
772 Bmg marker $mg_item renumber
776 ## @brief Centers markers in the current micrograph.
779 proc markerCenter { } {
780 global project_item theimg
781 set wc [getControlWindow $theimg]
782 set n [$wc.image.scale get]
783 set mg_item [micrographItem $n]
784 Bmg marker $mg_item center
789 ## @brief Finds markers in a file.
791 # @param n Image number.
793 proc markerFind { n } {
796 global fom_cutoff project_item
797 if ![winfo exists .wtomo] { return }
798 set marker_radius [.wtomo.marker_radius.e get]
799 set mg_item [micrographItem $n]
800 set nmark [Bmg marker $mg_item find $marker_radius]
802 tk_messageBox -icon error -type ok -title "Error" -message \
807 set max_fom [Bmg marker $mg_item fom_maximum]
808 set fom_cutoff [expr $max_fom / 2]
809 set fom_inc [expr $max_fom/100]
810 set h [Bimage get $theimg height]
811 set maxedge [expr int($h / 4)]
818 wm title $w "Set the FOM cutoff"
819 wm iconname $w "FOMcut"
823 label $w.fom.label -text "Choose a FOM cutoff and close this window before doing anything else" -anchor w
824 scale $w.fom.scale -orient horizontal -length 500 -from 0 -to $max_fom \
825 -command { setFOMcutoff } -resolution $fom_inc
826 label $w.fom.edgelabel -text "Choose an edge width in pixels to exclude markers" -anchor w
827 scale $w.fom.edge -orient horizontal -length 500 -from 0 -to $maxedge \
828 -command { setEdge } -resolution 1
829 button $w.fom.done -text "Done" -relief raised -command { destroy .wtomfom }
830 pack $w.fom.label -side top -fill x
831 pack $w.fom.scale -side top -fill x
832 pack $w.fom.edgelabel -side top -fill x
833 pack $w.fom.edge -side top -fill x
834 pack $w.fom.done -side right
835 $w.fom.scale set $fom_cutoff
836 pack $w.fom -side top -fill x -pady 2
840 Bmg marker $mg_item delete fom $fom_cutoff
841 Bmg marker $mg_item renumber
846 proc setEdge { edge } {
847 global project_item theimg
848 set wc [getControlWindow $theimg]
849 set n [$wc.image.scale get]
850 set mg_item [micrographItem $n]
851 Bmg marker $mg_item edge $edge
855 ## @brief Centers the selected marker.
858 # @param y Marker position in canvas coordinates.
860 proc markerSnap { x y } {
861 global project_item theimg
862 set wc [getControlWindow $theimg]
863 set n [$wc.image.scale get]
864 set id [markerSelect $x $y]
865 set mg_item [micrographItem $n]
867 Bmg marker $mg_item snap $id
872 ## @brief Updates the residual calculation which also sets all marker residuals.
875 proc updateResidual { } {
877 if ![winfo exists .wtomo] { return }
878 # puts "Updating residuals"
879 set resid [Bmg marker $project_item residual]
880 .wtomo.resid.val config -text $resid
883 ## @brief Updates the tomographic table from the micrograph parameters in memory.
886 proc updateTomoTable { } {
887 global tilt_axis project_item
888 if ![winfo exists .wtomo] { return }
889 if ![Bmg exists] { return }
890 set act [Bmg get all active]
891 # puts "Updating tomo table with active = $act"
892 set nmg [Bmg get $project_item number_of_mg]
893 if { $nmg < 1 } { return }
894 # puts "Number of micrographs: $nmg"
900 for { set i 0 } { $i < $nmg } { incr i 1 } {
901 set mg_item [micrographItem $i]
902 # puts "Project: $project_item mg: $mg_item"
903 set axis [expr [Bmg get $mg_item axis]]
904 set tilt [expr [Bmg get $mg_item tilt]]
905 set level [expr [Bmg get $mg_item level]]
906 set origin [Bmg get $mg_item origin]
907 set scale [Bmg get $mg_item scale]
908 set ox [lindex $origin 0]
909 set oy [lindex $origin 1]
910 set sx [lindex $scale 0]
911 set sy [lindex $scale 1]
912 set fom [Bmg get $mg_item fom]
913 # puts "$i $tilt $axis $level $ox $oy $sx $sy $fom"
914 append table [format " %3d %6.2f %6.2f %6.2f %6.1f %6.1f %5.3f %5.3f %6.3f\n" $i $tilt $axis $level $ox $oy $sx $sy $fom]
915 if { [expr abs($tilt)] > 2 } {
916 set w1 [expr 1 - exp(-$tilt*$tilt/0.5)]
917 set tax [expr $tax + $axis]
918 set wt [expr $wt + $w1]
921 Bmg set all active $act
922 if { $wt } { set tilt_axis [expr $tax / $wt] }
923 .wtomo.tilt_axis.e delete 0 end
924 .wtomo.tilt_axis.e insert 0 $tilt_axis
925 .wtomo.field.str config -text [Bmg get $project_item field]
926 .wtomo.table delete 1.0 end
927 .wtomo.table insert 1.0 $table
931 ## @brief Updates marker parameters from the micrograph parameters in memory.
934 proc updateMarkerParam { } {
935 global marker_radius project_item
936 if ![Bmg exists] { return }
937 # puts "Updating marker parameters"
939 set r [Bmg get $project_item marker_radius]
943 Bmg set $project_item marker_radius $r
945 if [winfo exists $w] {
946 # updateItemID $w.itemid
947 $w.marker_radius.e delete 0 end
948 $w.marker_radius.e insert 0 $marker_radius
952 ## @brief Sets the selection flag for the selected markers.
955 proc markerSetSelectFlag { } {
956 global markers_selected project_item theimg
957 set wc [getControlWindow $theimg]
958 set n [$wc.image.scale get]
959 set mg_item [micrographItem $n]
960 foreach id $markers_selected {
961 Bmg marker $mg_item setflag $id
966 ## @brief Clears the selection flag for the selected markers.
969 proc markerClearSelectFlag { } {
970 global markers_selected project_item theimg
971 set wc [getControlWindow $theimg]
972 set n [$wc.image.scale get]
973 set mg_item [micrographItem $n]
974 foreach id $markers_selected {
975 Bmg marker $mg_item clearflag $id
980 ## @brief Sets up the window for the marker table and updates it.
983 proc markerTable { } {
984 if ![winfo exists .wtomo] { return }
985 if ![Bmg exists] { return }
987 global refop hires lores
989 if ![winfo exists $w] {
993 text $w.table -relief sunken -bd 2 -width 40\
994 -yscrollcommand "$w.yscroll set" \
995 -setgrid 1 -highlightthickness 0 -pady 2 -padx 3 -font $cour12
996 scrollbar $w.yscroll -command "$w.table yview" \
997 -highlightthickness 0 -orient vertical
998 grid $w.table -in $w.frame -padx 1 -pady 1 \
999 -row 0 -column 0 -rowspan 1 -columnspan 1 -sticky news
1000 grid $w.yscroll -in $w.frame -padx 1 -pady 1 \
1001 -row 0 -column 1 -rowspan 1 -columnspan 1 -sticky news
1002 grid rowconfig $w.frame 0 -weight 1 -minsize 0
1003 grid columnconfig $w.frame 0 -weight 1 -minsize 0
1005 label $w.header -font $helv12 -anchor w \
1006 -text " Mg Marker Residual FOM Select"
1008 pack $w.header -side top -fill x -padx 5
1009 pack $w.frame -expand yes -fill both -padx 5 -pady 5
1012 label $w.butres.label -font $helv12 -anchor w -text Residual -width 8
1013 button $w.butres.min -text "|<" -command "markerNextResidual $w min"
1014 button $w.butres.lower -text "<" -command "markerNextResidual $w lower"
1015 button $w.butres.higher -text ">" -command "markerNextResidual $w higher"
1016 button $w.butres.max -text ">|" -command "markerNextResidual $w max"
1017 entry $w.butres.entry -width 10 -validate key -vcmd [list checkType double %P]
1020 label $w.butfom.label -font $helv12 -anchor w -text FOM -width 8
1021 button $w.butfom.min -text "|<" -command "markerNextFOM $w min"
1022 button $w.butfom.lower -text "<" -command "markerNextFOM $w lower"
1023 button $w.butfom.higher -text ">" -command "markerNextFOM $w higher"
1024 button $w.butfom.max -text ">|" -command "markerNextFOM $w max"
1025 entry $w.butfom.entry -width 10 -validate key -vcmd [list checkType double %P]
1028 button $w.flag.clear -text "Clear selection" -command "markerClearSelectFlag"
1029 button $w.flag.set -text "Set selection" -command "markerSetSelectFlag"
1032 button $w.buttons.update -text Update -command "updateMarkerTable"
1033 button $w.buttons.close -text Close -command "destroy $w"
1035 pack $w.butres.label $w.butres.min $w.butres.lower \
1036 $w.butres.entry $w.butres.higher $w.butres.max -side left -expand 1
1037 pack $w.butfom.label $w.butfom.min $w.butfom.lower \
1038 $w.butfom.entry $w.butfom.higher $w.butfom.max -side left -expand 1
1039 # pack $w.flag.clear $w.flag.set -side left -expand 1
1040 pack $w.buttons.update $w.buttons.close -side left -expand 1
1042 pack $w.buttons -side bottom -fill x -pady 2m
1043 pack $w.flag -side bottom -fill x -pady 2m
1044 pack $w.butfom -side bottom -fill x -pady 2m
1045 pack $w.butres -side bottom -fill x -pady 2m
1047 $w.table tag configure selmark -background #a0b7ce
1052 wm title $w "Marker list"
1053 wm iconname $w "Markers"
1057 ## @brief Updates the marker table.
1060 proc updateMarkerTable {} {
1061 global markers_selected project_item
1062 if ![winfo exists .wmark] { return }
1063 # puts "Updating tomography table parameters"
1065 set m [Bmg marker $project_item list]
1067 foreach {img_num id res fom sel} $m {
1068 append table [format " %4d %4d %7.3f %7.3f %4d\n" $img_num $id $res $fom $sel]
1070 .wmark.table delete 1.0 end
1071 .wmark.table insert 1.0 $table
1074 ## @brief Centers the viewable canvas on the location in the image.
1076 # @param img_num image number.
1077 # @param loc location list.
1079 proc moveCanvasTo { img_num loc } {
1081 set c [getImageCanvas $theimg]
1082 set wc [getControlWindow $theimg]
1083 $wc.image.scale set $img_num
1084 set scale [$wc.scale.scale get]
1085 set wd [Bimage get $theimg width]
1086 set ht [Bimage get $theimg height]
1087 set ws [expr [winfo width $c] / (2.0 * $scale)]
1088 set hs [expr [winfo height $c] / (2.0 * $scale)]
1089 set fx [expr ([lindex $loc 0] - $ws) / $wd ]
1090 set fy [expr ($ht - [lindex $loc 1] - 1 - $hs) / $ht ]
1095 ## @brief Goes to a marker.
1097 # @param w dialog window.
1098 # @param id marker identifier
1099 # @param isel offset in table ?
1100 # @param img micrograph index
1102 proc goToMarker { w id isel img } {
1103 global markers_selected project_item
1104 if { $id <= 0 } { return }
1105 set markers_selected $id
1106 set mg_item [micrographItem $img]
1107 set locerr [Bmg marker $mg_item location $id]
1108 moveCanvasTo $img $locerr
1109 $w.butres.entry delete 0 end
1110 $w.butres.entry insert 0 [Bmg marker $mg_item residual $id]
1111 $w.butfom.entry delete 0 end
1112 $w.butfom.entry insert 0 [Bmg marker $mg_item fom $id]
1113 $w.table tag add selmark $isel.0 $isel.end
1114 set isel [expr $isel - 3]
1115 if { $isel < 0 } { set isel 0 }
1116 $w.table yview $isel
1120 ## @brief Goes to the next marker based on its residual.
1122 # @param w dialog window.
1123 # @param dir direction: min, lower, higher, max
1125 proc markerNextResidual { w dir } {
1126 global markers_selected
1127 global theimg project_item
1128 set wc [getControlWindow $theimg]
1129 $w.table tag remove selmark 1.0 end
1135 if { $dir == "min" || $dir == "higher" } {
1139 if { $dir == "max" } { set prevres 1e10 }
1140 if { $dir == "min" || $dir == "max" } {
1141 set markers_selected []
1143 if { [llength $markers_selected] > 0 } {
1144 set n [$wc.image.scale get]
1145 set mg_item [micrographItem $n]
1146 set previd [lindex $markers_selected 0]
1147 set prevres [Bmg marker $mg_item residual $previd]
1148 # puts "1. $n $previd $prevres"
1150 set m [Bmg marker $project_item list]
1155 foreach {img_num id res fom sel} $m {
1158 set dr [expr $sgn * ($ressel - $res)]
1159 set pdr [expr $sgn * ($res - $prevres)]
1160 if { !($img_num == $n && $id == $previd) && $dr < 0 && $pdr < 0 } {
1169 goToMarker $w $idsel $isel $img
1171 # puts "2. $img $idsel $ressel"
1174 ## @brief Goes to next marker based on its FOM.
1176 # @param w dialog window.
1177 # @param dir direction: min, lower, higher, max
1179 proc markerNextFOM { w dir } {
1180 global markers_selected
1181 global theimg project_item
1182 set wc [getControlWindow $theimg]
1183 $w.table tag remove selmark 1.0 end
1189 if { $dir == "min" || $dir == "higher" } {
1193 if { $dir == "max" } { set prevfom 1e10 }
1194 if { $dir == "min" || $dir == "max" } {
1195 set markers_selected []
1197 if { [llength $markers_selected] > 0 } {
1198 set n [$wc.image.scale get]
1199 set mg_item [micrographItem $n]
1200 set previd [lindex $markers_selected 0]
1201 set prevfom [Bmg marker $mg_item fom $previd]
1202 # puts "1. $n $previd $prevfom"
1204 set m [Bmg marker $project_item list]
1209 foreach {img_num id res fom sel} $m {
1212 set df [expr $sgn * ($fomsel - $fom)]
1213 set pdf [expr $sgn * ($fom - $prevfom)]
1214 if { !($img_num == $n && $id == $previd) && $df < 0 && $pdf < 0 } {
1223 goToMarker $w $idsel $isel $img
1225 # puts "2. $img $idsel $fomsel"
1228 ## @brief Accepts the model locations of selected markers.
1231 proc markerAcceptModelLocation { } {
1232 global markers_selected
1233 global theimg project_item
1234 if { [llength $markers_selected] < 1 } { return }
1235 set wc [getControlWindow $theimg]
1236 set n [$wc.image.scale get]
1237 set mg_item [micrographItem $n]
1238 foreach id $markers_selected {
1239 Bmg marker $mg_item accept $id
1245 ##### Workflow #####
1247 ## @brief Aligns a series of frames from dose fractionation.
1250 proc alignSumFrames {} {
1251 global paramfile counts
1254 if ![winfo exists $w] {
1257 set newfile [newParamFile "_framesum.star"]
1258 if ![string length $newfile] { destroy $w; return }
1261 label $w.head.lab -text \
1262 "Frame alignment and summation will be done using the currently saved parameter file:\n$paramfile"
1264 setupNewFileEntry $w.file "Output parameter file" $newfile \
1265 "New parameter file written after summing the frames"
1267 radiobutton $w.count -text "Convert to counts" -variable counts -value 1
1269 setupEntry $w.refnum "Reference frame" integer 3 "Number of reference frame to use for the initial progressive alignment"
1271 labelframe $w.res -text "Resolution limits"
1272 setupEntry $w.res.hi "High" double 20 "High resolution limit in Å"
1273 setupEntry $w.res.lo "Low" double 1000 "Low resolution limit in Å"
1274 pack $w.res.hi $w.res.lo -side top -fill x
1276 setupEntry $w.bin "Binning " integer 2 "Binning to speed up alignment"
1278 setupEntry $w.shift "Shift limit " double 20 "Limit to cross-correlation shift allowed"
1280 setupEntry $w.dose "Dose/frame " double 1 "Dose rate in electrons per frame per Ångstrom squared"
1283 pack $w.head $w.file -side top -pady 2 -padx 2 -fill x
1284 pack $w.head $w.count -side top -pady 2 -padx 2 -anchor w
1285 pack $w.head $w.refnum $w.res $w.bin $w.shift $w.dose \
1286 -side top -pady 2 -padx 2 -fill x
1289 button $w.buttons.do -text Do -command "doAlignSumFrames $w"
1290 button $w.buttons.close -text Close -command "destroy $w"
1291 pack $w.buttons -side bottom -fill x -pady 2m
1292 pack $w.buttons.do $w.buttons.close -side left -expand 1
1294 bind $w <Return> "doAlignSumFrames $w"
1299 wm title $w "AlignFrames"
1300 wm iconname $w "AlignFrames"
1303 ## @brief Aligns and averages frames.
1305 # @param w dialog window.
1307 proc doAlignSumFrames { w } {
1308 global env paramfile counts
1309 set newfile [$w.file.e get]
1310 set refnum [$w.refnum.e get]
1311 set hires [$w.res.hi.e get]
1312 set lores [$w.res.lo.e get]
1313 set bin [$w.bin.e get]
1314 set shift [$w.shift.e get]
1315 set dose [$w.dose.e get]
1317 if { ![file exists $paramfile] } {
1318 # puts "$paramfile not found!"
1319 tk_dialog .dialog "$paramfile not found!" \
1320 {Please save an appropriate parameter file first.} \
1328 set logfile "[file rootname $newfile].log"
1329 set cmd "$env(BSOFT)/bin/bseries -verb 1 -frames $c -rate $dose -align $refnum -resol $hires,$lores -shift $shift -bin $bin -write sum -out $newfile $paramfile"
1330 executeCommand $cmd $logfile
1333 ## @brief Fit the intensities of a tilt series.
1336 proc fitIntensities {} {
1337 global paramfile project_root
1338 global thickness lambda adjust_tilt
1340 if ![winfo exists $w] {
1345 checkbutton $w.flag -text "Apply tilt adjustment" \
1346 -variable adjust_tilt -relief raised
1348 set psfile [newParamFile "_int.ps"]
1349 setupPostscriptEntry $w.file "Postscript file" $psfile \
1350 "Postscript file with the fitted intensity-tilt plot"
1352 pack $w.flag $w.file -side top -pady 2 -padx 10
1355 button $w.buttons.do -text Fit -command "doFitIntensities $w"
1356 button $w.buttons.close -text Close -command "destroy $w"
1357 pack $w.buttons -side bottom -fill x -pady 2m
1358 pack $w.buttons.do $w.buttons.close -side left -expand 1
1360 bind $w.lambda.e <Return> "doFitIntensities $w"
1365 wm title $w "Fit thickness"
1366 wm iconname $w "Fit"
1371 ## @brief Fits the intensities of a tilt series.
1374 proc doFitIntensities { w } {
1375 global paramfile thickness lambda adjust_tilt
1376 set lambda [$w.lambda.e get]
1377 set psfile [$w.file.e get]
1378 set thickness [Bmg thickness $lambda $adjust_tilt $psfile]
1379 updateThickness .wtomo
1383 ## @brief Calcul;ates the thickness from the marker range.
1386 proc markerRange { } {
1387 global project_item thickness
1388 set thickness [Bmg marker $project_item z_range]
1389 updateThickness .wtomo
1393 ## @brief Normalizes a series of images based on simple statistics.
1396 proc normalizeImages {} {
1401 if ![winfo exists $w] {
1404 set newfile [newParamFile "_norm.star"]
1405 if ![string length $newfile] { destroy $w; return }
1408 label $w.head.lab -text \
1409 "The normalization will be done using the currently saved parameter file:\n$paramfile"
1411 setupNewFileEntry $w.file "Output parameter file" $newfile \
1412 "New parameter file written after normalizing the micrographs"
1415 label $w.type.l -text "Normalization type"
1416 tk_optionMenu $w.type.v norm_type "Simple" "Gaussian" "Poisson"
1417 pack $w.type.l $w.type.v -side left -ipadx 2 -fill x
1420 pack $w.head $w.file $w.type -side top -pady 2 -padx 2 -anchor w
1423 button $w.buttons.do -text Do -command "doNormalizeImages $w"
1424 button $w.buttons.close -text Close -command "destroy $w"
1425 pack $w.buttons -side bottom -fill x -pady 2m
1426 pack $w.buttons.do $w.buttons.close -side left -expand 1
1428 bind $w <Return> "doNormalizeImages $w"
1433 wm title $w "Normalize"
1434 wm iconname $w "Normalize"
1437 ## @brief Normalizes images.
1439 # @param w dialog window.
1441 proc doNormalizeImages { w } {
1442 global env paramfile
1444 set newfile [$w.file.e get]
1446 if { ![file exists $paramfile] } {
1447 # puts "$paramfile not found!"
1448 tk_dialog .dialog "$paramfile not found!" \
1449 {Please save an appropriate parameter file first.} \
1453 set logfile "[file rootname $newfile].log"
1454 set cmd "$env(BSOFT)/bin/bnorm -v 1 -data float -type $norm_type -out $newfile $paramfile"
1455 executeCommand $cmd $logfile
1458 ## @brief Aligns a tilt series by cross correlation.
1461 proc alignMicrographs {} {
1465 if ![winfo exists $w] {
1468 set newfile [newParamFile "_aln.star"]
1469 if ![string length $newfile] { destroy $w; return }
1472 label $w.head.lab -text \
1473 "Micrograph alignment will be done using the currently saved parameter file:\n$paramfile"
1475 setupNewFileEntry $w.file "Output parameter file" $newfile \
1476 "New parameter file written after aligning micrographs"
1478 setupEntry $w.iter "Iterations " integer 3 "Maximum number of iterations for alignment refinement"
1480 setupEntry $w.stop "Stopping condition " double 1.0 "Stop iterations when the average change in shift drops below this number of pixels"
1482 setupEntry $w.adj "Adjcent micrographs" integer 3 "Number of adjacent micrographs to include in each subtomogram reconstruction"
1484 setupResolutionEntry $w
1487 pack $w.head $w.file $w.iter $w.stop $w.adj $w.res \
1488 -side top -pady 2 -padx 2 -fill x
1491 button $w.buttons.do -text Do -command "doAlignMicrographs $w"
1492 button $w.buttons.close -text Close -command "destroy $w"
1493 pack $w.buttons -side bottom -fill x -pady 2m
1494 pack $w.buttons.do $w.buttons.close -side left -expand 1
1496 bind $w <Return> "doAlignMicrographs $w"
1501 wm title $w "AlignMicrographs"
1502 wm iconname $w "AlignMicrographs"
1505 ## @brief Aligns Micrographs.
1507 # @param w dialog window.
1509 proc doAlignMicrographs { w } {
1510 global env paramfile lambda
1511 set newfile [$w.file.e get]
1512 set iter [$w.iter.e get]
1513 set stop [$w.stop.e get]
1514 set adj [$w.adj.e get]
1515 set hires [$w.res.hi.e get]
1516 set lores [$w.res.lo.e get]
1518 if { ![file exists $paramfile] } {
1519 # puts "$paramfile not found!"
1520 tk_dialog .dialog "$paramfile not found!" \
1521 {Please save an appropriate parameter file first.} \
1525 set logfile "[file rootname $newfile].log"
1526 set cmd "$env(BSOFT)/bin/btomaln -verb 1 -align $iter,$stop,$adj -resol $hires,$lores -edge 20,3 -lambda $lambda -out $newfile $paramfile"
1527 executeCommand $cmd $logfile
1531 # Locates the tilt axis.
1534 proc findTiltAxis { } {
1539 if ![winfo exists $w] {
1542 set newfile [newParamFile "_findaxis.star"]
1543 if ![string length $newfile] { destroy $w; return }
1546 label $w.head.lab -text \
1547 "The search for the tilt axis angle will use the currently saved parameter file:\n$paramfile"
1549 setupNewFileEntry $w.file "Output parameter file" $newfile \
1550 "New parameter file written after searching for the tilt axis"
1552 setupEntry $w.tlt "Tilt angle" double 15 "Tilt angle to find tilt axis"
1554 labelframe $w.tax -text "Tilt axis search range"
1555 setupEntry $w.tax.start "Start" double -180 "Starting angle to test for the tilt axis"
1556 setupEntry $w.tax.end "End" double 180 "Ending angle to test for the tilt axis"
1557 setupEntry $w.tax.inc "Increment" double 1 "Angle increment to test for the tilt axis"
1558 pack $w.tax.start $w.tax.end $w.tax.inc -side top -fill x
1560 setupResolutionEntry $w
1563 pack $w.head $w.file $w.tlt $w.tax $w.res -side top -fill x -pady 2 -padx 2
1566 button $w.buttons.do -text Do -command "doFindTiltAxis $w"
1567 button $w.buttons.close -text Close -command "destroy $w"
1568 pack $w.buttons -side bottom -fill x -pady 2m
1569 pack $w.buttons.do $w.buttons.close -side left -expand 1
1571 bind $w <Return> "doFindTiltAxis $w"
1576 wm title $w "FindAxis"
1577 wm iconname $w "FindAxis"
1580 ## @brief Executes the tilt axis search.
1582 # @param w dialog window.
1584 proc doFindTiltAxis { w } {
1585 global env paramfile
1586 global tilt_axis hires lores
1587 set newfile [$w.file.e get]
1588 set tlt [$w.tlt.e get]
1589 set start [$w.tax.start.e get]
1590 set end [$w.tax.end.e get]
1591 set step [$w.tax.inc.e get]
1592 set hires [$w.res.hi.e get]
1593 set lores [$w.res.lo.e get]
1595 if { ![file exists $paramfile] } {
1596 # puts "$paramfile not found!"
1597 tk_dialog .dialog "$paramfile not found!" \
1598 {Please save an appropriate parameter file first.} \
1602 set logfile "[file rootname $newfile].log"
1603 # Bmg findaxis $axis $start $end $step $hires $lores
1604 set cmd "$env(BSOFT)/bin/btrack -verb 1 -findaxis $tlt,$step,$start,$end -resol $hires,$lores -out $newfile $paramfile"
1605 executeCommand $cmd $logfile
1609 # Transfers markers from one tilt series to a second.
1612 proc markerTransfer { } {
1614 global hires lores refine
1617 if ![winfo exists $w] {
1620 labelframe $w.ang -text "Rotation angle search range"
1621 setupEntry $w.ang.start "Start" double -180 "Starting angle to find transfer rotation"
1622 setupEntry $w.ang.end "End" double 180 "Ending angle to find transfer rotation"
1623 setupEntry $w.ang.inc "Increment" double 1 "Angle increment to find transfer rotation"
1624 pack $w.ang.start $w.ang.end $w.ang.inc -side top -fill x
1626 setupResolutionEntry $w
1628 setupEntry $w.shift "Shift limit" double 100 "Limit on how much the second image may shift to fit the first"
1630 checkbutton $w.refine -text "Refine markers" \
1631 -variable refine -anchor w
1633 pack $w.ang $w.res $w.shift -side top -fill x -pady 2 -padx 2
1634 pack $w.ang $w.refine -side top -pady 2 -padx 2
1637 button $w.buttons.do -text Do -command "doMarkerTransfer $w"
1638 button $w.buttons.close -text Close -command "destroy $w"
1639 pack $w.buttons -side bottom -fill x -pady 2m
1640 pack $w.buttons.do $w.buttons.close -side left -expand 1
1642 bind $w <Return> "doMarkerTransfer $w"
1647 wm title $w "Transfer"
1648 wm iconname $w "Transfer"
1651 ## @brief Executes the marker transfer.
1653 # @param w dialog window.
1655 proc doMarkerTransfer { w } {
1656 global env paramfile
1657 global tilt_axis hires lores refine
1658 set start [$w.ang.start.e get]
1659 set end [$w.ang.end.e get]
1660 set step [$w.ang.inc.e get]
1661 set hires [$w.res.hi.e get]
1662 set lores [$w.res.lo.e get]
1663 set shift [$w.shift.e get]
1665 if { ![file exists $paramfile] } {
1666 # puts "$paramfile not found!"
1667 tk_dialog .dialog "$paramfile not found!" \
1668 {Please save an appropriate parameter file first.} \
1672 Bmg transfer $start $end $step $hires $lores $shift $refine
1678 ## @brief Tracks the markers through the tilt series.
1681 proc markerTrack { } {
1683 global hires lores recenter cc_type refine
1684 global shift_limit thickness
1687 if ![winfo exists $w] {
1690 set newfile [newParamFile "_trk.star"]
1691 if ![string length $newfile] { destroy $w; return }
1693 set logfile [file rootname $paramfile]
1694 append logfile "_trk.log"
1697 label $w.head.lab -text \
1698 "Tracking will be done on the currently saved parameter file:\n $paramfile"
1701 setupNewFileEntry $w.file "Output parameter file" $newfile \
1702 "New parameter file written after tracking"
1704 setupEntry $w.track "Iterations " integer 5 "Number of iterative tracking cycles"
1705 setupEntry $w.term "Target residual " double 1 \
1706 "The desired residual to terminate before the set number of cycles"
1708 setupResolutionEntry $w
1710 setupEntry $w.shift "Shift limit " double $shift_limit \
1711 "The maximum number of pixels of shift allowed"
1712 setupEntry $w.thick "Thickness " double $thickness \
1713 "The estimated maximum thickness of the tomogram"
1716 checkbutton $w.cb.cc_type -text "Cross-correlate markers" -anchor e -variable cc_type
1717 checkbutton $w.cb.recenter -text "Recenter" -anchor e -variable recenter
1718 checkbutton $w.cb.refine -text "Refine markers" -variable refine
1719 pack $w.cb.cc_type $w.cb.recenter $w.cb.refine -side left -pady 2 -padx 10
1721 pack $w.head $w.file $w.track $w.term $w.res $w.shift \
1722 $w.thick $w.cb -side top -pady 2 -padx 10 -fill x
1723 # pack $w.cc_type $w.recenter -side top -pady 2 -padx 10
1726 button $w.buttons.do -text Do -command "doMarkerTrack $w"
1727 button $w.buttons.close -text Close -command "destroy $w"
1728 pack $w.buttons -side bottom -fill x -pady 2m
1729 pack $w.buttons.do $w.buttons.close -side left -expand 1
1731 bind $w <Return> "doMarkerTrack $w"
1737 wm iconname $w "Track"
1740 ## @brief Executes marker tracking.
1742 # @param w dialog window.
1744 proc doMarkerTrack { w } {
1745 global env paramfile
1746 global hires lores recenter cc_type refine
1747 global shift_limit thickness
1748 set newfile [$w.file.e get]
1749 set iter [$w.track.e get]
1750 set term [$w.term.e get]
1751 set hires [$w.res.hi.e get]
1752 set lores [$w.res.lo.e get]
1753 set shift_limit [$w.shift.e get]
1754 set thickness [$w.thick.e get]
1756 if { ![file exists $paramfile] } {
1757 # puts "$paramfile not found!"
1758 tk_dialog .dialog "$paramfile not found!" \
1759 {Please save an appropriate parameter file first.} \
1766 if { $cc_type } { set cct "-cross" }
1767 if { $recenter } { set rec "-recenter" }
1768 if { $refine } { set ref "-refine m" }
1769 if { $term < 0.1 } { set term 1 }
1770 set logfile "[file rootname $newfile].log"
1771 set psfile "[file rootname $newfile].ps"
1772 # puts "logfile = $logfile"
1773 set cmd "$env(BSOFT)/bin/btrack -verb 1 -reset -update -track $iter,$term -resol $hires,$lores -shift $shift_limit -thick $thickness $cct $rec $ref -Post $psfile -out $newfile $paramfile"
1774 executeCommand $cmd $logfile
1777 ## @brief Refines marker positions and micrograph geometry.
1780 proc markerRefine { } {
1782 global hires lores ref_iter
1784 if ![winfo exists $w] {
1788 button $w.mark.b -text "Refine marker locations" -command "doMarkerRefine $w m"
1789 pack $w.mark.b -side left -pady 5
1791 setupResolutionEntry $w
1794 button $w.aln.b -text "Refine alignment" -command "doMarkerRefine $w a"
1795 label $w.aln.tag -text Iterations
1796 tk_optionMenu $w.aln.iter ref_iter 1 2 3 4 5 6 7 8 9 10
1797 pack $w.aln.b $w.aln.tag $w.aln.iter -side left -padx 1m
1800 checkbutton $w.z.z -text "Marker z-coordinates" -variable ref_z
1803 label $w.mg.g -text "Micrographs"
1804 checkbutton $w.mg.v -text "Views" -variable ref_view
1805 checkbutton $w.mg.o -text "Origins" -variable ref_ori
1806 checkbutton $w.mg.s -text "Scales" -variable ref_scale
1810 pack $w.z.z -side left -pady 5
1811 pack $w.mg.g $w.mg.v $w.mg.o $w.mg.s -side left -pady 5
1812 pack $w.mark $w.res $w.aln $w.z $w.mg $w.iter \
1813 -side top -fill x -pady 2 -padx 2
1816 # button $w.buttons.do -text Refine -command "doMarkerRefine $w"
1817 button $w.buttons.close -text Close -command "destroy $w"
1818 pack $w.buttons -side bottom -fill x -pady 2m
1819 pack $w.buttons.close -side left -expand 1
1821 bind $w <Return> "doMarkerRefine $w a"
1826 wm title $w "Refine"
1827 wm iconname $w "Refine"
1830 ## @brief Does a refinement of markers or views.
1832 # @param w dialog window.
1834 proc doMarkerRefine { w refop } {
1835 global ref_z ref_view ref_ori ref_scale
1836 global hires lores ref_iter
1838 if { $refop == "m" } {
1839 set hires [$w.res.hi.e get]
1840 set lores [$w.res.lo.e get]
1841 Bmg refine $refop $hires $lores
1844 if $ref_z { append refop "z" }
1845 if $ref_view { append refop "v" }
1846 if $ref_ori { append refop "o" }
1847 if $ref_scale { append refop "s" }
1848 puts "doMarkerRefine: $refop $ref_iter"
1849 # Bmg refine $refop $ref_view $ref_ori $ref_scale
1850 Bmg refine $refop $ref_iter
1857 ## @brief Refines one marker position.
1860 proc refineMarker { } {
1861 global markers_selected
1866 if [winfo exists $w] {
1867 set hires [$w.res.hi get]
1868 set lores [$w.res.lo get]
1870 Bmg refine_one $markers_selected $hires $lores
1875 ## @brief Dialog box for calculating tilt-adjusted power spectra
1878 proc tomoPowerSpectra { } {
1879 global paramfile theimg
1880 global volt Cs amp_fac defocus
1881 global tilex tiley tilez
1885 if ![winfo exists $w] {
1888 set newfile [newParamFile "_ps.star"]
1889 if ![string length $newfile] { destroy $w; return }
1892 label $w.head.lab -text \
1893 "The power spectra will be calculated using the currently saved parameter file:\n$paramfile"
1896 setupNewFileEntry $w.file "Output parameter file" $newfile \
1897 "New parameter file written after calculating the power spectra"
1899 setupEntry $w.volt "Acceleration voltage" double $volt "Acceleration voltage in kV"
1900 setupEntry $w.cs "Spherical aberration" double $Cs "Spherical aberration in mm"
1901 setupEntry $w.amp "Amplitude fraction " double $amp_fac "Amplitude contrast as a fraction"
1902 setupEntry $w.def "Defocus " double $defocus "Average defocus in um"
1904 labelframe $w.tiles -text "Tile size:"
1905 setupEntry $w.tiles.x "x" integer $tilex "X-size for tiles to calculate power spectra"
1906 setupEntry $w.tiles.y "y" integer $tiley "Y-size for tiles to calculate power spectra"
1907 pack $w.tiles.x $w.tiles.y -side top -fill x
1909 labelframe $w.res -text "Resolution limits"
1910 setupEntry $w.res.hi "High" double 8 "High resolution limit in Å"
1911 setupEntry $w.res.lo "Low" double 30 "Low resolution limit in Å"
1912 pack $w.res.hi $w.res.lo -side top -fill x
1914 labelframe $w.deflim -text "Defocus limits"
1915 setupEntry $w.deflim.lo "Low" double 1.0 "Low defocus limit in µm"
1916 setupEntry $w.deflim.hi "High" double 5.0 "High defocus limit in µm"
1917 pack $w.deflim.lo $w.deflim.hi -side top -fill x
1919 pack $w.head $w.file $w.volt $w.cs $w.amp $w.def $w.tiles $w.res \
1920 $w.deflim -side top -fill x -pady 2 -padx 2
1923 button $w.buttons.do -text Do -command "doTomoPowerSpectra $w"
1924 button $w.buttons.close -text Close -command "destroy $w"
1925 pack $w.buttons -side bottom -fill x -pady 2m
1926 pack $w.buttons.do $w.buttons.close -side left -expand 1
1928 bind $w <Return> "doTomoResolution $w"
1933 wm title $w "Power spectrum"
1934 wm iconname $w "Power spectrum"
1937 ## @brief Calculating tilt-adjusted power spectra
1940 proc doTomoPowerSpectra { w } {
1941 global env paramfile
1942 global volt Cs amp_fac defocus
1943 global tilex tiley tilez
1944 global hires lores recenter
1945 set newfile [$w.file.e get]
1946 set volt [$w.volt.e get]
1947 set Cs [$w.cs.e get]
1948 set amp_fac [$w.amp.e get]
1949 set defocus [$w.def.e get]
1950 set tilex [$w.tiles.x.e get]
1951 set tiley [$w.tiles.y.e get]
1952 set hires [$w.res.hi.e get]
1953 set lores [$w.res.lo.e get]
1954 set lodef [$w.deflim.lo.e get]
1955 set hidef [$w.deflim.hi.e get]
1957 if { ![file exists $paramfile] } {
1958 # puts "$paramfile not found!"
1959 tk_dialog .dialog "$paramfile not found!" \
1960 {Please save an appropriate parameter file first.} \
1964 set logfile "[file rootname $newfile].log"
1965 set cmd "$env(BSOFT)/bin/bctf -verb 1 -act prepfit -tile $tilex,$tiley,1 -Volt $volt -Cs $Cs -Amp $amp_fac -Defocus $defocus -Range $lodef,$hidef -resol $hires,$lores -fitastig 2 -out $newfile $paramfile"
1966 executeCommand $cmd $logfile
1969 ## @brief Estimates the resolution of images in a tilt series.
1972 proc tomoResolution { } {
1973 global paramfile theimg
1977 if ![winfo exists $w] {
1981 label $w.head.lab -text \
1982 "Resolution will be estimated using the currently saved parameter file: $paramfile"
1985 set psfile [newParamFile "_res.ps"]
1986 if ![string length $psfile] { destroy $w; return }
1987 setupPostscriptEntry $w.ps "Postscript file" $psfile \
1988 "Postscript file with the tilt-resolution plot"
1990 setupEntry $w.fast "Fast angle " double 10 "Limit images added to each reconstruction"
1991 setupEntry $w.res "High resolution" double $hires "Spatial frequency limit for reconstructions"
1992 setupEntry $w.rat "Sampling ratio " double $samrat "Ratio to average adjacent frequency shells (≥1)"
1993 setupEntry $w.cut "FRC cutoff " double 0.3 "Fourier ring correlation threshold to report resolution"
1994 setupEntry $w.ctf "CTF correction " alnum "none" "Contrast transfer function correction algorithm"
1996 pack $w.head $w.ps $w.fast $w.res $w.rat $w.cut $w.ctf -side top -fill x -pady 2 -padx 2
1999 button $w.buttons.do -text Do -command "doTomoResolution $w"
2000 button $w.buttons.close -text Close -command "destroy $w"
2001 pack $w.buttons -side bottom -fill x -pady 2m
2002 pack $w.buttons.do $w.buttons.close -side left -expand 1
2004 bind $w <Return> "doTomoResolution $w"
2009 wm title $w "Resolution"
2010 wm iconname $w "Resolution"
2013 ## @brief Executes estimation of the resolution of the tilt series.
2015 # @param w dialog window.
2017 proc doTomoResolution { w } {
2018 global env paramfile
2020 set psfile [$w.ps.e get]
2021 set fast [$w.fast.e get]
2022 set hires [$w.res.e get]
2023 set samrat [$w.rat.e get]
2024 set cut [$w.cut.e get]
2025 set ctf [$w.ctf.e get]
2026 if { $ctf == "none" } {
2032 if { ![file exists $paramfile] } {
2033 # puts "$paramfile not found!"
2034 tk_dialog .dialog "$paramfile not found!" \
2035 {Please save an appropriate parameter file first.} \
2039 set logfile "[file rootname $psfile].log"
2040 set cmd "$env(BSOFT)/bin/btomres -verb 1 -fast $fast -resol $hires -ratio $samrat $ctf -cut $cut -Post $psfile $paramfile"
2041 executeCommand $cmd $logfile
2044 ## @brief Reconstructs a tomogram.
2047 proc tomoReconstruct { } {
2048 global paramfile theimg project_item
2052 if ![winfo exists $w] {
2055 set sz [Bmg get $project_item size]
2056 set x [lindex $sz 0]
2057 set y [lindex $sz 1]
2060 set recfile [newParamFile "_rec.mrc"]
2061 if ![string length $recfile] { destroy $w; return }
2062 set newfile [newParamFile "_rec.star"]
2063 if ![string length $newfile] { destroy $w; return }
2066 label $w.head.lab -text \
2067 "Reconstruction will be done using the currently saved parameter file:\n$paramfile"
2069 setupFileEntry $w.rec "Output reconstruction " $recfile \
2070 "New tomographic reconstruction file name"
2072 setupNewFileEntry $w.file "Output parameter file " $newfile \
2073 "New parameter file written after reconstruction"
2075 setupEntry $w.interp "Type " integer 0 "Reconstruction interpolation type: 0=nearest neighbor, 1=weighted, 2=trilinear"
2077 labelframe $w.size -text "Reconstruction size"
2078 setupEntry $w.size.x "x" double $x "Reconstruction x size"
2079 setupEntry $w.size.y "y" double $y "Reconstruction y size"
2080 setupEntry $w.size.z "z" double $z "Reconstruction z size"
2081 pack $w.size.x $w.size.y $w.size.z -side top -fill x
2083 setupEntry $w.scale "Scale " double 1 "Reconstruction scale"
2084 setupEntry $w.res "High resolution " double $hires "Spatial frequency limit for reconstruction"
2085 setupEntry $w.remark "Marker deletion radius" double 0 "If greater than 0, discs of this radius will be deleted from micrographs"
2086 setupEntry $w.edge "Edge smoothing width " double 3 "If greater than 0, the micrograph edges and extraneous areas will be deleted"
2087 setupEntry $w.ctf "CTF correction " alnum "none" "Contrast transfer function correction algorithm"
2090 button $w.mem.b -text "Memory required" -command "tomoRecMemory $w"
2091 label $w.mem.v -text "" -relief sunken -bd 1 -width 16 -anchor w
2092 pack $w.mem.b $w.mem.v -side left
2095 # pack $w.file.lab $w.file.entry $w.file.load -side left -pady 5
2096 pack $w.head $w.rec $w.file $w.interp $w.size $w.scale $w.res $w.remark $w.edge $w.ctf $w.mem -side top -fill x -pady 2 -padx 2
2099 button $w.buttons.do -text Do -command "doTomoReconstruct $w"
2100 button $w.buttons.close -text Close -command "destroy $w"
2101 pack $w.buttons -side bottom -fill x -pady 2m
2102 pack $w.buttons.do $w.buttons.close -side left -expand 1
2104 bind $w <Return> "doTomoReconstruct $w"
2109 wm title $w "Reconstruct"
2110 wm iconname $w "Reconstruct"
2113 ## @brief Executes tomogram reconstruction.
2115 # @param w dialog window.
2117 proc tomoRecMemory { w } {
2118 set x [$w.size.x.e get]
2119 set y [$w.size.y.e get]
2120 set z [$w.size.z.e get]
2121 set mem [expr 20 * $x * $y * $z]
2122 set p [expr round ($mem * 100.0 / [systemMemory] ) ]
2123 set mem [ expr round($mem * 1.0e-9) ]
2124 $w.mem.v config -text "$mem Gb ($p %)"
2127 ## @brief Executes tomogram reconstruction.
2129 # @param w dialog window.
2131 proc doTomoReconstruct { w } {
2132 global env paramfile
2134 set recfile [$w.rec.e get]
2135 set newfile [$w.file.e get]
2136 set interp [$w.interp.e get]
2137 set x [$w.size.x.e get]
2138 set y [$w.size.y.e get]
2139 set z [$w.size.z.e get]
2140 set scale [$w.scale.e get]
2141 set hires [$w.res.e get]
2142 set remark [$w.remark.e get]
2143 set edge [$w.edge.e get]
2144 set ctf [$w.ctf.e get]
2146 if { $remark > 0 } { set remove "-remove $remark" }
2148 if { $edge > 0 } { set smooth "-edge $edge" }
2149 if { $ctf == "none" } {
2155 if { ![file exists $paramfile] } {
2156 # puts "$paramfile not found!"
2157 tk_dialog .dialog "$paramfile not found!" \
2158 {Please save an appropriate parameter file first.} \
2162 set logfile "[file rootname $newfile].log"
2163 set cmd "$env(BSOFT)/bin/btomrec -verb 1,tim -interp $interp -size $x,$y,$z -scale $scale -resol $hires $ctf -rescale 0,1 -trans full $remove $smooth -rec $recfile -out $newfile $paramfile"
2164 executeCommand $cmd $logfile
2167 ## @brief Denoises a tomogram.
2170 proc tomoDenoise { } {
2171 global paramfile theimg project_item
2175 if ![winfo exists $w] {
2178 set denfile [file rootname [Bmg get $project_item filename rec]]
2179 # set denfile [file rootname $paramfile]
2180 append denfile "_den.mrc"
2181 set newfile [newParamFile "_den.star"]
2182 if ![string length $newfile] { destroy $w; return }
2185 label $w.head.lab -text \
2186 "Denoising will be done using the currently saved parameter file: \n$paramfile"
2189 label $w.den.l -text "Output denoised map " -anchor w
2190 entry $w.den.e -width 40
2191 $w.den.e insert 0 $denfile
2192 pack $w.den.l $w.den.e -side left -pady 5
2194 setupNewFileEntry $w.file "Output parameter file" $newfile \
2195 "New parameter file written after denoising"
2197 setupEntry $w.iter "Iterations " integer 100 "Number of iterative denoising cycles"
2198 setupEntry $w.out "Output frequency" integer 10 "Number of iterations between writing intermediate denoised images"
2199 setupEntry $w.slab "Slab size " integer 100 "Denoising slab size for parallel processing"
2202 # pack $w.log.lab $w.log.entry -side left -pady 5
2203 pack $w.head $w.den $w.file $w.iter $w.out $w.slab -side top -fill x -pady 2 -padx 2
2206 button $w.buttons.do -text Do -command "doTomoDenoise $w"
2207 button $w.buttons.close -text Close -command "destroy $w"
2208 pack $w.buttons -side bottom -fill x -pady 2m
2209 pack $w.buttons.do $w.buttons.close -side left -expand 1
2211 bind $w <Return> "doTomoDenoise $w"
2216 wm title $w "Denoise"
2217 wm iconname $w "Denoise"
2220 ## @brief Executes tomogram denoising.
2222 # @param w dialog window.
2224 proc doTomoDenoise { w } {
2225 global env paramfile project_item
2227 set recfile [Bmg get $project_item filename rec]
2228 set denfile [$w.den.e get]
2229 set newfile [$w.file.e get]
2230 set iter [$w.iter.e get]
2231 set out [$w.out.e get]
2232 set slab [$w.slab.e get]
2234 if { ![file exists $paramfile] } {
2235 # puts "$paramfile not found!"
2236 tk_dialog .dialog "$paramfile not found!" \
2237 {Please save an appropriate parameter file first.} \
2241 set logfile "[file rootname $newfile].log"
2242 # set cmd "$env(BSOFT)/bin/bnad -verb 1 -iter $iter -out $out -slab $slab -map $denfile -out $newfile $paramfile"
2243 set cmd "$env(BSOFT)/bin/bnad -verb 1 -iter $iter -out $out -slab $slab $recfile $denfile"
2244 executeCommand $cmd $logfile