Version: 11.0
Contact: hsharma@anl.gov
The purpose of this software and the procedures outlined below is to perform a near-field calibration. The goal is to determine the exact X-ray beam position on the detector and the precise sample-to-detector distance for multiple detector positions. This is accomplished using a known calibrant sample, such as single-crystal gold (Au).
Note
This manual uses the modern PyQtGraph-based viewer nf_qt.py. The legacy nf.py has been archived to gui/archive/nf.py.
This manual is divided into two primary sections, mirroring the calibration workflow:
- Part I: Determining the Beam Center: Finding the central pixel of the direct beam at each detector distance.
- Part II: Determining Detector Positions: Using diffraction spots from a gold standard to calculate the precise distance from the sample to each detector.
Important
This procedure assumes 5mm as the first detector distance.
-
Launch the Application:
- Open the GUI by executing the following command in your terminal:
python ~/opt/MIDAS/gui/nf_qt.py &
- Open the GUI by executing the following command in your terminal:
-
Load the Beam Position Scan File:
- Click the
First Filebutton. - Navigate to your data folder. For Part I, select the Au 5mm beam position scan file. The filename stem will typically be "DetZBeamPosScan".
- If no "DetZBeamPosScan" files exist, load the first image from your "Au_NF" folder for that distance.
- The GUI will auto-populate the
Folder,FNStem, andStartFileNumberFirstLayerfields.
- Click the
Tip
Shortcut: You can also launch the GUI directly from the data folder:
cd /path/to/Au_DetZBeamPos_72keV
python ~/opt/MIDAS/gui/nf_qt.py &When the folder name contains BeamPos or DetZBeamPos, the GUI automatically enters BeamPos mode: all .tif files are sorted by numeric suffix, and Frame becomes an index into this list. This lets you step through files with different stems using ← / → keys or the Frame spinner.
- Display the Image:
- Click the large
Loadbutton. The detector image will appear in the left-hand window.
- Click the large
In this part, we will find the average horizontal and vertical center of the beam for each detector position (e.g., 5mm, 7mm, 9mm). The detector image will show the beam as one or two white horizontal lines.
graph TD
subgraph "Beam Center Workflow"
Start[Load DetZBeamPosScan] --> Identify{Identify Beam Lines}
Identify -->|Two Lines| Lower[Use Lower Line]
Identify -->|One Line| Single[Use Single Line]
Lower --> EdgeL[Analyze Left Edge]
Single --> EdgeL
EdgeL --> BoxHorL[BoxOutHor: Get X_left]
EdgeL --> BoxVerL[BoxOutVer: Get Y_left]
BoxHorL --> EdgeR[Analyze Right Edge]
BoxVerL --> EdgeR
EdgeR --> BoxHorR[BoxOutHor: Get X_right]
EdgeR --> BoxVerR[BoxOutVer: Get Y_right]
BoxHorR --> Avg["Calculate Average (X, Y)"]
BoxVerR --> Avg
Avg --> Next[Repeat for Next Distance]
end
- If a
DetZBeamPosScanwas used, you will see a single horizontal diffraction line.
Tip
It is recommended to use the DetZBeamPosScan at 0 and 90 degrees to compute the rotation axis position.
- If using standard Au scan data, you may see two horizontal lines. For this calibration, use the lower of the two lines.
We will determine the center of the left and right edges of this line and average the results.
(a) Find the Horizontal Center of the Left Edge:
- Click the
Box Hbutton. A rectangular ROI appears on the image. - Drag the ROI over the left edge of the beam, ensuring it fully encompasses the edge.
- An intensity profile will appear in the right-hand panel. This curve shows the integrated intensity vs. horizontal pixel position.
- Hover your mouse over this curve. The coordinates are displayed in the status bar.
- Identify the x value at the center of the slope. Record this value.
(b) Find the Vertical Center of the Left Edge:
- Click the
Box Vbutton. - Drag the ROI over the left edge of the beam.
- A new intensity profile will appear on the right, showing intensity vs. vertical pixel position.
- Hover your mouse over the curve and identify the x value at the center of the peak. Record this value.
- Repeat the steps from (a) and (b) for the right edge of the beam.
- Record the horizontal and vertical center values for the right edge.
- Average Horizontal Center: (Left Edge Horizontal Value + Right Edge Horizontal Value) / 2
- Average Vertical Center: (Left Edge Vertical Value + Right Edge Vertical Value) / 2
- Record these two final average values. They are the beam center for the 5mm detector distance.
Note
If using AU scans, use the BoxOutHor button to plot the intensity along the x-ray beam to determine an intensity dip across the Au-sample. Compute the middle of this dip and use that as the Average Horizontal Center.
- Using the
Distspinner, change the value from0to1(for the second distance, e.g., 7mm). - The image for the next detector position will load automatically.
- Repeat Steps 1, 2, and 3 to find the average beam center for this distance.
- Change
Distto2(for the third distance, e.g., 9mm) and repeat the process again.
You should now have three pairs of (horizontal, vertical) beam center coordinates, one for each detector distance.
Now we will use the gold calibration scan data and the beam center values from Part I to calculate the precise detector distances.
graph TD
subgraph "Detector Position Workflow"
Start[Load Gold Calibration Data] --> EnterBC[Enter Beam Centers]
EnterBC --> InputBCs[Input: Horizontal/Vertical Centers, DistDiff]
InputBCs --> ConfirmBC[Confirm & Close]
ConfirmBC --> Select[Select Spots Mode]
Select --> Pick1["RIGHT-CLICK spot on Det N"]
Pick1 --> Confirm1[Confirm Selection]
Confirm1 --> Pick2["RIGHT-CLICK SAME spot on Det N-1"]
Pick2 --> Confirm2[Confirm Selection]
Confirm2 --> Finished[Click Finished]
Finished --> Result["Auto: Visual Results Dialog<br>Crop patches + Ray triangulation"]
end
- Click
First File. - Select the first gold calibration scan file. The folder is typically "Au_NF", and you should choose the first image number for the 5mm detector distance.
- Ensure
Distis set to0and the image will load automatically.
- Click the
Beam Centerbutton. A new window titled "Enter beam center values (pixels)" will open. - Left Column: Enter the three horizontal center values of the Au sample you just calculated in part I (one for each distance).
- Right Column: Enter the three average vertical beam center values you calculated in Part I (one for each distance).
- Difference in distances: Enter the approximate distance between your detectors in microns (e.g.,
2000for 2mm). - Click "Press this once done".
- Click the
Select Spotsbutton. A help window will appear. Read the instructions and clickReady!. - Make sure you are viewing the last detector distance (
Dist=2, e.g., 9mm). - Use the
Framespinner or the ← / → keys to cycle through scan images until you find a clear, strong diffraction spot. - Use left-click-drag to zoom into the spot area (rectangle zoom remains active throughout).
- Right-click on the pixel with the maximum intensity. A cyan crosshair appears confirming your click position.
- Click the
Confirm Selectionbutton in the status bar.
Tip
During spot selection, the ViewBox context menu is disabled so right-clicks register as spot picks instead of opening a menu. The status bar reminds you to "RIGHT-CLICK on a diffraction spot".
- A dialog box will pop up. Enter
1as the new distance and clickLoad. The GUI will show the middle detector distance. - The diffraction spot will have moved. Use left-click-drag zoom if needed to find the same spot.
- Right-click on the pixel with the max intensity in this new location. Verify the cyan crosshair position. Click
Confirm Selection. - The dialog box will pop up again. Enter
0as the new distance and clickLoad. - Find and right-click the same spot on this first detector. Click
Confirm Selection. - In the final pop-up, click
Finished.
Note
You may skip distances if a spot is unclear at some positions. At least 2 confirmed spots are required for triangulation. Only confirmed (non-zero) spots are used in the computation.
- After clicking Finished, distances are automatically computed and a visual dialog appears.
- The dialog shows:
- Crop patches — 100×100 px image windows around each confirmed spot, with a cyan crosshair at center.
- Ray triangulation diagram — rays drawn from the computed sample position through each spot on each detector, color-coded by distance.
- Detailed results — per-distance spot positions (Y, Z, R relative to beam center), per-pair Lsd and grainY values, and mean Lsd.
- The mean Lsd is auto-filled in the main window.
- Record these values.
The initial calibration is now complete. The beam center and detector distances from Parts I and II provide the initial guess for the parameter file. Proceed to the iterative optimization workflow below.
After computing initial beam center and detector distances, use the following iterative workflow to refine the geometry and achieve the highest-confidence reconstruction. This procedure alternates between parameter refinement and full reconstruction until convergence.
Important
For command-line details and parameter file format, see NF_Analysis.md.
graph TD
A["Initial Calibration<br>(Parts I & II)"] --> B["Update Parameter File<br>with Lsd, BC values"]
B --> C["Single-Point Optimization<br>(2-3 iterations)"]
C --> D["Full Reconstruction"]
D --> E["Inspect .mic in GUI<br>(Load Mic → .map file)"]
E --> F["Select 5-10 GridPoints<br>from high-confidence grains"]
F --> G["Multi-Point Optimization<br>(2-3 iterations)"]
G --> H["Full Reconstruction"]
H --> I{"Confidence<br>acceptable?"}
I -->|No| G
I -->|Yes| J["Done — Final .mic"]
- Update the parameter file with the
LsdandBCvalues from Part II (Steps 5–9). - Run single-point refinement a few times, updating the parameter file with the optimized values after each run:
python nf_MIDAS.py -paramFN nf_params.txt -nCPUs 8 -refineParameters 1 -multiGridPoints 0
- The script will prompt for
(x, y)coordinates. Choose a point near the center of your sample. - After each run, the refined
Lsd,BC, and tilt values are printed to the console. Update them in your parameter file before the next iteration. - Repeat 2–3 times until values stabilize.
Run a full reconstruction with the refined parameters:
python nf_MIDAS.py -paramFN nf_params.txt -nCPUs 8This produces a .mic text file and a .map binary file.
-
Open the reconstruction in the GUI:
cd <DataDirectory> python ~/opt/MIDAS/gui/nf_qt.py &
Click Load Mic and select the
.mapfile (preferred — faster rendering viaimshow). -
Set the visualization to
Confidenceusing the radio buttons. -
Identify 5–10 high-quality grid points with the following criteria:
- Confidence value less than 1 (i.e., not a perfect match — these are suspicious)
- Not on grain boundaries — at this early stage, grain boundary voxels do not have correctly determined orientations. Multi-point optimization cannot search over all possible orientations; it assumes the orientation assigned to the voxel is approximately correct. If a grain boundary voxel is chosen, its orientation guess may be wrong, leading the optimizer to refine geometry toward incorrect parameters.
- Close to, but not at, grain boundaries — these provide geometric diversity
- Distributed across all four quadrants of the sample (roughly balanced)
-
Open the
.mictext file in a text editor. Each line is a grid point with columns:OrientRowNr ID Time X Y Size UD Euler1 Euler2 Euler3 Confidence -
Copy the full lines corresponding to your selected points and add them to the parameter file, prefixing each line with
GridPoints:GridPoints 0 0 0 -123.4 456.7 5.0 1 0.123 0.456 0.789 0.85 GridPoints 0 0 0 234.5 -345.6 5.0 1 1.234 0.567 0.890 0.82 ...
- Run multi-point refinement:
python nf_MIDAS.py -paramFN nf_params.txt -nCPUs 8 -refineParameters 1 -multiGridPoints 1
- Update the parameter file with the refined values printed to the console.
- Repeat the multi-point refinement 2–3 times until values stabilize.
- Run a full reconstruction again:
python nf_MIDAS.py -paramFN nf_params.txt -nCPUs 8
- Inspect the new reconstruction in the GUI. If confidence is not yet satisfactory, re-run multi-point optimization (the
GridPointslines in the parameter file can remain from the previous iteration). - Iterate until you achieve a high-confidence map you are satisfied with.
The beam center finding logic relies on 1D Integrated Profiling. When you draw a box using BoxOutHor or BoxOutVer:
- The software sums the pixel intensities along the orthogonal direction (e.g., summing rows for a horizontal profile).
- This improves the Signal-to-Noise Ratio (SNR) significantly compared to looking at single pixel lines.
- The "edges" of the beam are determined by the steep gradients in this integrated profile, allowing for sub-pixel visual estimation of the beam center (centroid of the rectangular beam profile).
The Compute Distances function employs a Ray-Triangulation method based on the intercept theorem.
- Assumption: Diffraction occurs at a point source (the sample) and expands as a cone.
-
Input: Spot radii (
$R_1, R_2, ...$ ) measured from the beam center at known relative detector shifts ($\Delta d$ ). -
Calculation: For every pair of detector positions (
$i, j$ ), the Sample-to-Detector distance to the first position ($LSD_0$ ) is calculated as: $$ LSD_0 = \frac{R_i \cdot (j-i) \cdot \Delta d}{R_j - R_i} - (i \cdot \Delta d) $$ -
Result: The final reported distance is the arithmetic mean of the calculated
$LSD$ values from all possible pairs of detector positions, providing a robust estimate that minimizes random measurement errors.
| Button/Field | Function |
|---|---|
Load |
Loads or reloads the image display based on the current settings (file, frame, thresholds, etc.). |
MinI/MaxI |
Adjusts the minimum/maximum intensity values for the image display (contrast). |
Log |
Toggles a logarithmic color scale for the image, useful for seeing faint features. |
LineOutH/V |
Draggable 1D line profile ROI — shows intensity along a line. |
Box H / Box V |
Draggable rectangular ROI — shows integrated 1D profile summed across the short axis. |
Load Mic |
Loads a microstructure (.mic or .map) file for display in the right-hand panel. |
Select Point |
Click on mic map to auto-populate grain parameters for spot simulation. |
Load Grain |
Opens a window to manually input crystal orientation, position, and lattice parameters for simulation. |
Make Spots |
Simulates diffraction spots based on the currently loaded grain information. |
Subt. Median |
Toggles the subtraction of a pre-calculated median background image. |
Calc Median |
Calculates a median background image from all frames per distance. Auto-enables Subt. Median and reloads the image on completion. Output stored in a temporary directory (not persisted). |
Select Spots |
Starts the interactive spot-selection workflow. Right-click to pick spots while keeping left-click rectangle zoom active. Cyan crosshairs show click positions. |
Compute Distances |
Auto-computed when clicking Finished in Select Spots. Shows visual dialog with crop patches and ray triangulation diagram. |
- NF_Analysis.md — Single-resolution NF-HEDM reconstruction
- NF_MultiResolution_Analysis.md — Multi-resolution iterative NF-HEDM reconstruction
- NF_GUI.md — NF-HEDM GUI reference
- README.md — High-level MIDAS overview and manual index
If you encounter any issues or have questions, please open an issue on this repository.