<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://viper.lbl.gov:8080/cctbx.xfel/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Aaron</id>
	<title>cctbx_xfel - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="http://viper.lbl.gov:8080/cctbx.xfel/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Aaron"/>
	<link rel="alternate" type="text/html" href="http://viper.lbl.gov:8080/cctbx.xfel/index.php/Special:Contributions/Aaron"/>
	<updated>2026-09-04T20:10:11Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.39.15</generator>
	<entry>
		<id>http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Cctbx.xfel.merge&amp;diff=1790</id>
		<title>Cctbx.xfel.merge</title>
		<link rel="alternate" type="text/html" href="http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Cctbx.xfel.merge&amp;diff=1790"/>
		<updated>2026-08-21T23:44:27Z</updated>

		<summary type="html">&lt;p&gt;Aaron: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{DISPLAYTITLE:&#039;&#039;cctbx.xfel.merge&#039;&#039;}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;cctbx.xfel.merge&#039;&#039;&#039;&#039;&#039; is the scaling, post-refinement and merging program of cctbx.xfel. It takes&lt;br /&gt;
the per-image integrated results produced by &#039;&#039;[[dials.stills_process]]&#039;&#039; — one crystal per still shot —&lt;br /&gt;
and reduces the whole ensemble to a single set of merged structure-factor intensities (an MTZ file)&lt;br /&gt;
suitable for structure solution and refinement, together with the crystallographic quality&lt;br /&gt;
statistics (completeness, multiplicity, ⟨I/σ⟩, CC½, CC&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt;, R-factors, etc.).&lt;br /&gt;
&lt;br /&gt;
Because serial datasets routinely contain tens of thousands to millions of still shots,&lt;br /&gt;
&amp;lt;code&amp;gt;cctbx.xfel.merge&amp;lt;/code&amp;gt; is built from the ground up to run under MPI across many nodes. It is&lt;br /&gt;
almost always launched with &amp;lt;code&amp;gt;mpirun&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;srun&amp;lt;/code&amp;gt;.  Note that MPI uses the term &#039;ranks&#039;&lt;br /&gt;
to distinguish independent processes that are running across one or more nodes.&lt;br /&gt;
&lt;br /&gt;
= Overview =&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;cctbx.xfel.merge&amp;lt;/code&amp;gt; is organized as a sequence of &#039;&#039;&#039;workers&#039;&#039;&#039;. Each worker performs one&lt;br /&gt;
task — reading data, applying a correction, filtering, scaling, post-refining, computing a statistic,&lt;br /&gt;
or merging — and passes its (possibly modified) experiments and reflections on to the next worker.&lt;br /&gt;
The list of workers to run is the &amp;quot;step list&amp;quot;, and it is fully configurable: you can add, remove or&lt;br /&gt;
reorder steps with &amp;lt;code&amp;gt;dispatch.step_list&amp;lt;/code&amp;gt;. This is what makes the program flexible enough to&lt;br /&gt;
scale-and-merge in one pass, to scale subsets separately and merge later, or to run a reference-free&lt;br /&gt;
bootstrap.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;default&#039;&#039;&#039; step list is:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! # !! Worker !! Purpose&lt;br /&gt;
|-&lt;br /&gt;
| 1 || &amp;lt;code&amp;gt;input&amp;lt;/code&amp;gt; || Read integrated experiments (&amp;lt;code&amp;gt;.expt&amp;lt;/code&amp;gt;) and reflections (&amp;lt;code&amp;gt;.refl&amp;lt;/code&amp;gt;) from disk in DIALS format.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || &amp;lt;code&amp;gt;balance&amp;lt;/code&amp;gt; || Redistribute the input load evenly across MPI ranks (needed when there are fewer or more input files than ranks).&lt;br /&gt;
|-&lt;br /&gt;
| 3 || &amp;lt;code&amp;gt;model_scaling&amp;lt;/code&amp;gt; || Build the full Miller list, model intensities from the reference, and the resolution binner used for scaling and post-refinement.&lt;br /&gt;
|-&lt;br /&gt;
| 4 || &amp;lt;code&amp;gt;modify&amp;lt;/code&amp;gt; || Apply per-reflection modifications, e.g. polarization correction (and optionally re-indexing to resolve indexing ambiguity — see &amp;lt;code&amp;gt;modify.cosym&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;reindex_to_reference&amp;lt;/code&amp;gt;).&lt;br /&gt;
|-&lt;br /&gt;
| 5 || &amp;lt;code&amp;gt;filter&amp;lt;/code&amp;gt; || Reject whole experiments (or reflections) by resolution, unit cell, correlation to the reference, energy, etc.&lt;br /&gt;
|-&lt;br /&gt;
| 6 || &amp;lt;code&amp;gt;scale&amp;lt;/code&amp;gt; || Scale each lattice to the reference dataset (&amp;lt;code&amp;gt;mark0&amp;lt;/code&amp;gt;) or simply average (&amp;lt;code&amp;gt;mark1&amp;lt;/code&amp;gt;).&lt;br /&gt;
|-&lt;br /&gt;
| 7 || &amp;lt;code&amp;gt;postrefine&amp;lt;/code&amp;gt; || Post-refine per-image crystal parameters and partialities (Sauter 2015).&lt;br /&gt;
|-&lt;br /&gt;
| 8 || &amp;lt;code&amp;gt;statistics_unitcell&amp;lt;/code&amp;gt; || Determine and store the average unit cell.&lt;br /&gt;
|-&lt;br /&gt;
| 9 || &amp;lt;code&amp;gt;statistics_beam&amp;lt;/code&amp;gt; || Determine and store the average wavelength.&lt;br /&gt;
|-&lt;br /&gt;
| 10 || &amp;lt;code&amp;gt;model_statistics&amp;lt;/code&amp;gt; || Rebuild the Miller list / binner for statistics (may use the average unit cell).&lt;br /&gt;
|-&lt;br /&gt;
| 11 || &amp;lt;code&amp;gt;statistics_resolution&amp;lt;/code&amp;gt; || Per-crystal resolution statistics.&lt;br /&gt;
|-&lt;br /&gt;
| 12 || &amp;lt;code&amp;gt;group&amp;lt;/code&amp;gt; || Redistribute reflections across ranks so that every observation of a given HKL is gathered on the same rank prior to merging.&lt;br /&gt;
|-&lt;br /&gt;
| 13 || &amp;lt;code&amp;gt;errors_merge&amp;lt;/code&amp;gt; || Correct the merged error estimates with a per-HKL error model (e.g. Ev11, Brewster 2019b, or MM24 (the default), Mittan-Moreau (2025)).&lt;br /&gt;
|-&lt;br /&gt;
| 14 || &amp;lt;code&amp;gt;statistics_intensity&amp;lt;/code&amp;gt; || Intensity statistics by resolution.&lt;br /&gt;
|-&lt;br /&gt;
| 15 || &amp;lt;code&amp;gt;merge&amp;lt;/code&amp;gt; || Merge symmetry-equivalent intensities, gather all HKLs at rank 0, and write &amp;quot;odd&amp;quot;, &amp;quot;even&amp;quot; and &amp;quot;all&amp;quot; MTZ files.&lt;br /&gt;
|-&lt;br /&gt;
| 16 || &amp;lt;code&amp;gt;statistics_intensity_cxi&amp;lt;/code&amp;gt; || Correlation and R-factor statistics (ported from cxi.merge): the &amp;quot;Table of Scaling Results&amp;quot; — CC½ (half-dataset correlation, labelled &amp;quot;CC int&amp;quot;), CC&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt;, R&amp;lt;sub&amp;gt;int&amp;lt;/sub&amp;gt;, R&amp;lt;sub&amp;gt;split&amp;lt;/sub&amp;gt;, R&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Additional, non-default workers are available and can be&lt;br /&gt;
inserted into the step list, including &amp;lt;code&amp;gt;tdata&amp;lt;/code&amp;gt; (write out unit cells for clustering),&lt;br /&gt;
&amp;lt;code&amp;gt;export&amp;lt;/code&amp;gt; (batch MTZ for &#039;&#039;Careless&#039;&#039;), &amp;lt;code&amp;gt;publish&amp;lt;/code&amp;gt; (upload merged files to a&lt;br /&gt;
Google Drive folder), &amp;lt;code&amp;gt;monitor&amp;lt;/code&amp;gt; (resource-usage logging), &amp;lt;code&amp;gt;integrate&amp;lt;/code&amp;gt;&lt;br /&gt;
(on-the-fly integration), &amp;lt;code&amp;gt;prepare&amp;lt;/code&amp;gt; (SpReAD energy binning), and&lt;br /&gt;
&amp;lt;code&amp;gt;lunus&amp;lt;/code&amp;gt; (diffuse-scattering deck). A &amp;lt;code&amp;gt;deltaccint&amp;lt;/code&amp;gt; worker (ΔCC½ lattice&lt;br /&gt;
filtering) can be added after &amp;lt;code&amp;gt;group&amp;lt;/code&amp;gt;. Custom workers can be supplied through the&lt;br /&gt;
&amp;lt;code&amp;gt;XFEL_CUSTOM_WORKER_PATH&amp;lt;/code&amp;gt; environment variable.&lt;br /&gt;
&lt;br /&gt;
= Basic usage =&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;cctbx.xfel.merge&amp;lt;/code&amp;gt; is run under MPI:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mpirun cctbx.xfel.merge merge.phil&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A typical &amp;lt;code&amp;gt;merge.phil&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
input.path=&amp;lt;path to data&amp;gt;&lt;br /&gt;
input.experiments_suffix=.expt&lt;br /&gt;
input.reflections_suffix=.refl&lt;br /&gt;
&lt;br /&gt;
filter.algorithm=unit_cell&lt;br /&gt;
filter.unit_cell.value.relative_length_tolerance=0.03&lt;br /&gt;
filter.outlier.min_corr=0.1&lt;br /&gt;
&lt;br /&gt;
select.algorithm=significance_filter&lt;br /&gt;
select.significance_filter.sigma=0.1&lt;br /&gt;
select.significance_filter.min_ct=200&lt;br /&gt;
select.significance_filter.max_ct=300&lt;br /&gt;
&lt;br /&gt;
scaling.model=&amp;lt;model.pdb or model.mtz&amp;gt;&lt;br /&gt;
scaling.resolution_scalar=0.96&lt;br /&gt;
&lt;br /&gt;
merging.d_min=1.8&lt;br /&gt;
merging.error.model=mm24&lt;br /&gt;
merging.merge_anomalous=True&lt;br /&gt;
&lt;br /&gt;
postrefinement.enable=True&lt;br /&gt;
statistics.n_bins=20&lt;br /&gt;
&lt;br /&gt;
output.output_dir=&amp;lt;output folder&amp;gt;&lt;br /&gt;
output.prefix=&amp;lt;prefix for output files&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Explore the parameters with:&lt;br /&gt;
* &amp;lt;code&amp;gt;cctbx.xfel.merge -c&amp;lt;/code&amp;gt; — show configurable parameters&lt;br /&gt;
* &amp;lt;code&amp;gt;cctbx.xfel.merge -c -e 10 -a 2&amp;lt;/code&amp;gt; — show all parameters (expert level 10) with full help text&lt;br /&gt;
&lt;br /&gt;
= Two-stage scaling and merging =&lt;br /&gt;
&lt;br /&gt;
For large, growing datasets (the mode used by the [[cctbx.xfel GUI]]), it is more efficient to scale&lt;br /&gt;
and post-refine each subset of data &#039;&#039;&#039;once&#039;&#039;&#039;, then merge repeatedly as more data arrive. This is&lt;br /&gt;
done by running the program twice with different step lists.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Stage 1 — scale each subset&#039;&#039;&#039; (stops after per-image work and writes intermediate DIALS files):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dispatch.step_list=input balance model_scaling modify filter scale postrefine \&lt;br /&gt;
    statistics_unitcell statistics_beam model_statistics statistics_resolution&lt;br /&gt;
output.save_experiments_and_reflections=True&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;output.save_experiments_and_reflections=True&amp;lt;/code&amp;gt; dumps the scaled/post-refined data as&lt;br /&gt;
experiment lists and reflection tables that the merge stage can read back in.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Stage 2 — merge the scaled subsets&#039;&#039;&#039; (add an &amp;lt;code&amp;gt;input.path&amp;lt;/code&amp;gt; for each finished subset):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dispatch.step_list=input model_scaling statistics_unitcell statistics_beam \&lt;br /&gt;
    model_statistics statistics_resolution group errors_merge statistics_intensity \&lt;br /&gt;
    merge statistics_intensity_cxi&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Merging without a reference (bootstrap / mark1) =&lt;br /&gt;
&lt;br /&gt;
If no scaling/merging reference is available, use a bootstrap procedure. First run the&lt;br /&gt;
&amp;lt;code&amp;gt;mark1&amp;lt;/code&amp;gt; algorithm, which simply averages the data (all per-image scale factors = 1, no&lt;br /&gt;
post-refinement), specifying the target cell and symmetry explicitly:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
scaling.algorithm=mark1&lt;br /&gt;
scaling.unit_cell=&amp;lt;unit cell&amp;gt;&lt;br /&gt;
scaling.space_group=&amp;lt;space group&amp;gt;&lt;br /&gt;
merging.error.model=errors_from_sample_residuals&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The resulting MTZ is then used as the reference (&amp;lt;code&amp;gt;scaling.model=&amp;lt;/code&amp;gt;) for subsequent regular&lt;br /&gt;
merges. Iterate a few cycles; CC½ typically improves and converges over the first few rounds.&lt;br /&gt;
&lt;br /&gt;
= Important parameters =&lt;br /&gt;
&lt;br /&gt;
Parameters are given by their full PHIL path with defaults in parentheses. The program exposes many&lt;br /&gt;
more parameters (see &amp;lt;code&amp;gt;-c -e 10 -a 2&amp;lt;/code&amp;gt;); those below are the ones most commonly set.&lt;br /&gt;
&lt;br /&gt;
== Input ==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.path&amp;lt;/code&amp;gt; || None || Path(s) to the integrated data — a folder, several folders, or individual files; wildcards allowed; may be repeated. Matching &amp;lt;code&amp;gt;.expt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;.refl&amp;lt;/code&amp;gt; files must both be present.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.experiments_suffix&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;_integrated.expt&amp;lt;/code&amp;gt; || Only load experiment files ending with this suffix.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.reflections_suffix&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;_integrated.refl&amp;lt;/code&amp;gt; || Only load reflection files ending with this suffix.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.parallel_file_load.method&amp;lt;/code&amp;gt; || uniform || &amp;lt;code&amp;gt;uniform&amp;lt;/code&amp;gt; spreads input files evenly over all ranks; &amp;lt;code&amp;gt;node_memory&amp;lt;/code&amp;gt; distributes so per-node memory limits are respected.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.alist.file&amp;lt;/code&amp;gt; || None || Path to a text file of experiment tags or filenames; combined with &amp;lt;code&amp;gt;input.alist.op=keep|reject&amp;lt;/code&amp;gt; to merge only (or exclude) a specified subset.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.persistent_refl_cols&amp;lt;/code&amp;gt; || None || Reflection-table columns to preserve through the pruning steps (and into saved tables).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Filtering whole experiments (&amp;lt;code&amp;gt;filter&amp;lt;/code&amp;gt;) ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;filter&amp;lt;/code&amp;gt; section accepts or rejects &#039;&#039;&#039;entire experiments&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.algorithm&amp;lt;/code&amp;gt; || (none) || One or more of &amp;lt;code&amp;gt;n_obs&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;resolution&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;unit_cell&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;energy&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bootstrap&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;experiment_prefix&amp;lt;/code&amp;gt;. Nothing is filtered unless listed.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.unit_cell.algorithm&amp;lt;/code&amp;gt; || value || How to restrict unit cells: &amp;lt;code&amp;gt;value&amp;lt;/code&amp;gt; (compare to a target), &amp;lt;code&amp;gt;range&amp;lt;/code&amp;gt;, or &amp;lt;code&amp;gt;cluster&amp;lt;/code&amp;gt; (use a precomputed covariance clustering).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.unit_cell.value.relative_length_tolerance&amp;lt;/code&amp;gt; || 0.1 || Fractional deviation of cell edge lengths allowed vs. the target cell. Often tightened (e.g. 0.03).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.unit_cell.value.absolute_angle_tolerance&amp;lt;/code&amp;gt; || 2.0 || Allowed cell-angle deviation (degrees) vs. the target.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.unit_cell.value.target_unit_cell&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;target_space_group&amp;lt;/code&amp;gt; || Auto || Target cell/symmetry; &amp;lt;code&amp;gt;Auto&amp;lt;/code&amp;gt; uses the scaling model.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.outlier.min_corr&amp;lt;/code&amp;gt; || 0.1 || Minimum correlation of an image&#039;s intensities to the reference model; images below this are rejected. Only applied when a scaling model is present. Use &amp;lt;code&amp;gt;-1&amp;lt;/code&amp;gt; to accept all images regardless of correlation.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.resolution.d_min&amp;lt;/code&amp;gt; || None || Reject an experiment unless some of its reflections extend beyond this resolution.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Selecting individual reflections (&amp;lt;code&amp;gt;select&amp;lt;/code&amp;gt;) ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;select&amp;lt;/code&amp;gt; section accepts or rejects &#039;&#039;&#039;individual reflections&#039;&#039;&#039; (contrast with&lt;br /&gt;
&amp;lt;code&amp;gt;filter&amp;lt;/code&amp;gt;, which acts on whole experiments).&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;select.algorithm&amp;lt;/code&amp;gt; || (none) || One or more of &amp;lt;code&amp;gt;significance_filter&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;panel&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cspad_sensor&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;isolation_forest&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;target_energy&amp;lt;/code&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;select.significance_filter.sigma&amp;lt;/code&amp;gt; || 0.5 || Trim each lattice at the resolution where the binned ⟨I/σ⟩ drops below this value.  Often reduced to 0.1.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;select.significance_filter.min_ct&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;max_ct&amp;lt;/code&amp;gt; || 10 / 50 || Target minimum/maximum mean reflections per resolution bin when choosing the number of bins. For large unit cells these are often raised (e.g. 200/300); for small cells, use the defaults.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Modifying intensities (&amp;lt;code&amp;gt;modify&amp;lt;/code&amp;gt;) ==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;modify.algorithm&amp;lt;/code&amp;gt; || polarization || Per-reflection corrections to apply (default applies the polarization correction).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;modify.cosym&amp;lt;/code&amp;gt; || — || Resolve an indexing ambiguity across the ensemble using the Gildea/Winter (Brehm/Diederichs) cosym method, optionally anchored to &amp;lt;code&amp;gt;scaling.model&amp;lt;/code&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;modify.reindex_to_reference&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;reindex_to_abc&amp;lt;/code&amp;gt; || — || Alternative re-indexing operators (to a reference model, or an explicit operator).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Scaling (&amp;lt;code&amp;gt;scaling&amp;lt;/code&amp;gt;) ==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;scaling.model&amp;lt;/code&amp;gt; || None || Reference dataset: a PDB file (uses the CRYST1 cell and computes model intensities, including bulk solvent) or an MTZ from a previous cycle. Required for &amp;lt;code&amp;gt;mark0&amp;lt;/code&amp;gt; scaling.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;scaling.algorithm&amp;lt;/code&amp;gt; || mark0 || &amp;lt;code&amp;gt;mark0&amp;lt;/code&amp;gt;: per-image scaling against the reference. &amp;lt;code&amp;gt;mark1&amp;lt;/code&amp;gt;: no scaling, just Monte-Carlo averaging (all scale factors = 1) — used for reference-free bootstrap.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;scaling.unit_cell&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;scaling.space_group&amp;lt;/code&amp;gt; || None || Cell/symmetry to use when no model is provided (i.e. &amp;lt;code&amp;gt;mark1&amp;lt;/code&amp;gt;).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;scaling.resolution_scalar&amp;lt;/code&amp;gt; || 0.969 || &amp;lt;code&amp;gt;merging.d_min&amp;lt;/code&amp;gt; is multiplied by this when deciding which reflections fall within the resolution limit, generating a few extra reference reflections to account for per-shot cell variation (e.g. set 0.96 for a few more).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;scaling.mtz.mtz_column_F&amp;lt;/code&amp;gt; || fobs || Column name in the reference MTZ containing the reference structure factors (intensities or amplitudes).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Post-refinement (&amp;lt;code&amp;gt;postrefinement&amp;lt;/code&amp;gt;) ==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;postrefinement.enable&amp;lt;/code&amp;gt; || True || Enable post-refinement of per-image parameters/partialities (Sauter 2015).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;postrefinement.algorithm&amp;lt;/code&amp;gt; || rs || Post-refinement protocol: &amp;lt;code&amp;gt;rs&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;rs2&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;rs_hybrid&amp;lt;/code&amp;gt;, or &amp;lt;code&amp;gt;eta_deff&amp;lt;/code&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Merging and error model (&amp;lt;code&amp;gt;merging&amp;lt;/code&amp;gt;) ==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;merging.d_min&amp;lt;/code&amp;gt; || None || High-resolution limit for scaling and merging.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;merging.d_max&amp;lt;/code&amp;gt; || None || Low-resolution limit (currently affects only CCiso).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;merging.merge_anomalous&amp;lt;/code&amp;gt; || False || &amp;lt;code&amp;gt;True&amp;lt;/code&amp;gt; merges Bijvoet mates together (higher multiplicity); &amp;lt;code&amp;gt;False&amp;lt;/code&amp;gt; keeps them separate to preserve the anomalous signal.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;merging.minimum_multiplicity&amp;lt;/code&amp;gt; || 2 || Do not produce a merged structure factor for HKLs measured fewer than this many times.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;merging.error.model&amp;lt;/code&amp;gt; || mm24 || Merged-sigma error model: &amp;lt;code&amp;gt;mm24&amp;lt;/code&amp;gt; (Mittan-Moreau 2025, current default), &amp;lt;code&amp;gt;ev11&amp;lt;/code&amp;gt; (Evans 2011 / sdfac-refine), &amp;lt;code&amp;gt;ha14&amp;lt;/code&amp;gt;, or &amp;lt;code&amp;gt;errors_from_sample_residuals&amp;lt;/code&amp;gt; (no refined error terms — used with &amp;lt;code&amp;gt;mark1&amp;lt;/code&amp;gt; bootstrap).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;merging.set_average_unit_cell&amp;lt;/code&amp;gt; || True || Output MTZ adopts the average unit cell of the data rather than the reference model&#039;s cell.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Statistics (&amp;lt;code&amp;gt;statistics&amp;lt;/code&amp;gt;) ==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;statistics.n_bins&amp;lt;/code&amp;gt; || 10 || Number of resolution bins in the statistics tables.  Often raised to 20.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;statistics.cciso.mtz_file&amp;lt;/code&amp;gt; || None || Isomorphous reference structure factors for R&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt; / CC&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;statistics.report_ML&amp;lt;/code&amp;gt; || True || Report per-frame max-likelihood attributes (domain size, mosaicity).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Output (&amp;lt;code&amp;gt;output&amp;lt;/code&amp;gt;) ==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.output_dir&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;.&amp;lt;/code&amp;gt; || Directory for output files (created if it does not exist).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.prefix&amp;lt;/code&amp;gt; || iobs || Prefix prepended to all output file names.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.save_experiments_and_reflections&amp;lt;/code&amp;gt; || False || Dump the final experiments/reflections from the last worker as DIALS files — used for the two-stage scale-then-merge workflow.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.do_timing&amp;lt;/code&amp;gt; || False || Log elapsed time per execution step.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.expanded_bookkeeping&amp;lt;/code&amp;gt; || False || Store extra provenance columns (input file/reflection indices, odd/even flag, original id) in the saved reflection tables.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Multiprocessing (&amp;lt;code&amp;gt;mp&amp;lt;/code&amp;gt;) ==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mp.method&amp;lt;/code&amp;gt; || mpi || Multiprocessing method (only &amp;lt;code&amp;gt;mpi&amp;lt;/code&amp;gt; is currently supported).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mp.debug.cProfile&amp;lt;/code&amp;gt; || False || Enable code profiling; a &amp;lt;code&amp;gt;.prof&amp;lt;/code&amp;gt; file is written per rank.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Output files =&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;merge&amp;lt;/code&amp;gt; worker gathers all HKLs at rank 0 and writes three MTZ files, prefixed with&lt;br /&gt;
&amp;lt;code&amp;gt;output.prefix&amp;lt;/code&amp;gt; (default &amp;lt;code&amp;gt;iobs&amp;lt;/code&amp;gt;):&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;amp;lt;prefix&amp;amp;gt;_all.mtz&amp;lt;/code&amp;gt; — the merged dataset using all observations (the main result for structure solution)&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;amp;lt;prefix&amp;amp;gt;_odd.mtz&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;&amp;amp;lt;prefix&amp;amp;gt;_even.mtz&amp;lt;/code&amp;gt; — the two half-datasets used for CC½ and related half-dataset statistics&lt;br /&gt;
&lt;br /&gt;
A main log records the per-step progress and the merging statistics tables by resolution bin:&lt;br /&gt;
completeness, multiplicity and ⟨I/σ⟩, plus the &amp;quot;Table of Scaling Results&amp;quot; reporting CC½ (the&lt;br /&gt;
half-dataset correlation, labelled &amp;quot;CC int&amp;quot;), CC&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt;, R&amp;lt;sub&amp;gt;int&amp;lt;/sub&amp;gt;, R&amp;lt;sub&amp;gt;split&amp;lt;/sub&amp;gt;&lt;br /&gt;
and R&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt;.  The merged MTZ can optionally be&lt;br /&gt;
uploaded to a shared [https://github.com/cctbx/cctbx_project/tree/master/xfel/merging/application/publish Google Drive folder] by adding the &amp;lt;code&amp;gt;publish&amp;lt;/code&amp;gt; worker.&lt;br /&gt;
&lt;br /&gt;
= References =&lt;br /&gt;
&lt;br /&gt;
* Sauter NK (2015). &#039;&#039;J Synchrotron Radiat&#039;&#039; &#039;&#039;&#039;22&#039;&#039;&#039;, 239–48. (post-refinement)&lt;br /&gt;
* Uervirojnangkoorn M, &#039;&#039;et al.&#039;&#039; (2015). &#039;&#039;eLife&#039;&#039; 10.7554/eLife.05421. (PRIME / bootstrap)&lt;br /&gt;
* Brewster AS, &#039;&#039;et al.&#039;&#039; (2018). &#039;&#039;Acta Cryst.&#039;&#039; D &#039;&#039;&#039;74&#039;&#039;&#039;, 877–894.&lt;br /&gt;
* Brewster AS, &#039;&#039;et al.&#039;&#039; (2019a). &#039;&#039;Computational Crystallography Newsletter&#039;&#039; &#039;&#039;&#039;10&#039;&#039;&#039;, 22–39. (XFEL GUI)&lt;br /&gt;
* Brewster AS, &#039;&#039;et al.&#039;&#039; (2019b). &#039;&#039;Acta Cryst.&#039;&#039; D &#039;&#039;&#039;75&#039;&#039;&#039;, 959–968. (error models)&lt;br /&gt;
* Mittan-Moreau (2025). (mm24 error model)&lt;br /&gt;
&lt;br /&gt;
= See also =&lt;br /&gt;
&lt;br /&gt;
* [[dials.stills_process]] — produces the integrated data that &amp;lt;code&amp;gt;cctbx.xfel.merge&amp;lt;/code&amp;gt; consumes&lt;br /&gt;
* [[cctbx.xfel GUI]] — orchestrates separate scaling and repeated merging as data are collected&lt;br /&gt;
* The program README at &amp;lt;code&amp;gt;xfel/merging/README.md&amp;lt;/code&amp;gt; in cctbx_project&lt;/div&gt;</summary>
		<author><name>Aaron</name></author>
	</entry>
	<entry>
		<id>http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Main_Page&amp;diff=1789</id>
		<title>Main Page</title>
		<link rel="alternate" type="text/html" href="http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Main_Page&amp;diff=1789"/>
		<updated>2026-08-21T23:42:11Z</updated>

		<summary type="html">&lt;p&gt;Aaron: /* cctbx.xfel resources */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;News! See our [[https://doi.org/10.1101/2025.05.04.652045 new preprint]]!  This paper shows current best practices using &#039;&#039;cctbx.xfel&#039;&#039; with &#039;&#039;DIALS&#039;&#039; for serial crystallographic data.&lt;br /&gt;
&lt;br /&gt;
= Open-source tools for serial crystallographic data processing =&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;cctbx.xfel&#039;&#039; is a suite of software tools designed to process diffraction data from serial femtosecond crystallography (SFX) measurements at an X-ray free-electron laser (XFEL) or a synchrotron.  Built on the Computational Crystallographic Toolbox ([https://cctbx.github.io/ &#039;&#039;cctbx&#039;&#039;]), the same toolbox on which [http://www.phenix-online.org &#039;&#039;PHENIX&#039;&#039;], and [http://dials.github.io DIALS] are built, it enables the user to solve difficult problems relating to processing serial crystallographic data.  The programs and modules provided by &#039;&#039;cctbx.xfel&#039;&#039; can reduce a large set of still diffraction images recorded at Stanford’s Linac Coherent Light Source ([http://lcls.slac.stanford.edu LCLS]), [http://sacla.xfel.jp SACLA], the [https://www.xfel.eu/ European XFEL], or a synchrotron, to a single MTZ file containing merged reflection intensities suitable for structure solution.&lt;br /&gt;
&lt;br /&gt;
== &#039;&#039;cctbx.xfel&#039;&#039; resources ==&lt;br /&gt;
&lt;br /&gt;
The current best resource is our pre-print, [https://doi.org/10.1101/2025.05.04.652045 &#039;&#039;cctbx.xfel: a suite for processing serial crystallographic data.&#039;&#039;].  This paper describes the algorithms and ideas behind the implementation and execution of the two main programs of &#039;&#039;cctbx.xfel&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;[[Dials.stills_process|dials.stills_process]]&#039;&#039;: this program runs through all the first steps of processing data using dials: import (reading image headers), spot finding, indexing, geometry refinement, and integration.  Serial images are independent from each other, so this program is optimized for massively parallel systems, but can be adapted to a variety of single and multi-processing modes.&lt;br /&gt;
* &#039;&#039;[[Cctbx.xfel.merge|cctbx.xfel.merge]]&#039;&#039;: this program runs through the remaining steps of processing: scaling and merging to produce a full dataset (.mtz file).  For documentation, see our [https://github.com/cctbx/cctbx_project/tree/master/xfel/merging Github project]&lt;br /&gt;
&lt;br /&gt;
Additional resources:&lt;br /&gt;
&lt;br /&gt;
* Our [http://cci.lbl.gov/publications/download/CCN_2019_p22_Brewster.pdf 2019 newsletter article] describes how to use the &#039;&#039;cctbx.xfel&#039;&#039; GUI, an interactive program for handling large XFEL datasets.&lt;br /&gt;
&lt;br /&gt;
* [[Overview]] to the system architecture at LCLS and real-time progress monitoring of data processing&lt;br /&gt;
* Installation: there are two ways to get &#039;&#039;cctbx.xfel&#039;&#039;:&lt;br /&gt;
** &#039;&#039;cctbx.xfel&#039;&#039; is installed for general use at SLAC.  To start using an existing installation, [[Using the pre-built cctbx at LCLS|simply source the current build]]. &lt;br /&gt;
** [https://dials.github.io/installation.html Download] a binary bundle of DIALS. Use this option if you will not be processing LCLS data because, for example, if you have serial crystallographic data from a synchrotron.&lt;br /&gt;
** Build a psana/cctbx.xfel build [https://github.com/cctbx/cctbx_project/tree/master/xfel/conda_envs from scratch]. Use this option if you want to process LCLS data outside of LCLS or want your own build.&lt;br /&gt;
* [[Tutorials]] on pre-processing, data reduction, and merging. &lt;br /&gt;
&lt;br /&gt;
Other related information:&lt;br /&gt;
&lt;br /&gt;
* [[Serial XFEL Crystallography References]]&lt;br /&gt;
&lt;br /&gt;
This project is under active development.  For any assistance, please contact the authors.&lt;/div&gt;</summary>
		<author><name>Aaron</name></author>
	</entry>
	<entry>
		<id>http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Dials.stills_process&amp;diff=1788</id>
		<title>Dials.stills process</title>
		<link rel="alternate" type="text/html" href="http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Dials.stills_process&amp;diff=1788"/>
		<updated>2026-08-21T23:40:33Z</updated>

		<summary type="html">&lt;p&gt;Aaron: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{DISPLAYTITLE:&#039;&#039;dials.stills_process&#039;&#039;}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;dials.stills_process&#039;&#039;&#039;&#039;&#039; is a stand-alone program for processing still diffraction images and is&lt;br /&gt;
the core data-reduction program of &#039;&#039;cctbx.xfel&#039;&#039;. It takes a set of&lt;br /&gt;
still diffraction images — typically serial femtosecond crystallography (SFX) snapshots from an&lt;br /&gt;
XFEL (LCLS, SACLA, EuXFEL) or still shots from a synchrotron — and analyzes each one, independently,&lt;br /&gt;
through the full DIALS pipeline: &#039;&#039;&#039;import → spot-finding → indexing → refinement → integration&#039;&#039;&#039;.&lt;br /&gt;
Its output (integrated intensities together with the per-image experimental models) is the input to&lt;br /&gt;
the merging program &#039;&#039;[[cctbx.xfel.merge]]&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Because every image is a separate still exposure of a different crystal (rather than a wedge of&lt;br /&gt;
a rotation series), each image is treated as its own experiment with its own crystal model. This&lt;br /&gt;
&amp;quot;one crystal per shot&amp;quot; model is what distinguishes stills processing from conventional rotation data&lt;br /&gt;
processing (e.g. &amp;lt;code&amp;gt;dials.import&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;dials.find_spots&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;dials.index&amp;lt;/code&amp;gt;, etc.), &lt;br /&gt;
and it drives most of the stills-specific defaults described below.&lt;br /&gt;
&lt;br /&gt;
= Overview =&lt;br /&gt;
&lt;br /&gt;
For each image, &amp;lt;code&amp;gt;dials.stills_process&amp;lt;/code&amp;gt; runs the following stages in order. Any stage can&lt;br /&gt;
be turned off with the &amp;lt;code&amp;gt;dispatch&amp;lt;/code&amp;gt; parameters; if a stage is disabled, processing stops&lt;br /&gt;
after the last enabled stage.&lt;br /&gt;
&lt;br /&gt;
# &#039;&#039;&#039;Import&#039;&#039;&#039; — read the image, apply reference geometry / gain / mask overrides, and build an experiment.&lt;br /&gt;
# &#039;&#039;&#039;Spot-finding&#039;&#039;&#039; — locate strong pixels and build strong reflections (&amp;lt;code&amp;gt;dispatch.find_spots&amp;lt;/code&amp;gt;).&lt;br /&gt;
# &#039;&#039;&#039;Hit finding&#039;&#039;&#039; — reject images with too few (or optionally too many) strong spots, so that only &amp;quot;hits&amp;quot; are indexed (&amp;lt;code&amp;gt;dispatch.hit_finder&amp;lt;/code&amp;gt;).&lt;br /&gt;
# &#039;&#039;&#039;Indexing&#039;&#039;&#039; — determine the crystal orientation and (optionally constrained) unit cell (&amp;lt;code&amp;gt;dispatch.index&amp;lt;/code&amp;gt;).&lt;br /&gt;
# &#039;&#039;&#039;Refinement&#039;&#039;&#039; — refine the crystal model and re-estimate the mosaic/domain-size parameters. Detector and beam are held fixed by default (&amp;lt;code&amp;gt;dispatch.refine&amp;lt;/code&amp;gt;).&lt;br /&gt;
# &#039;&#039;&#039;Integration&#039;&#039;&#039; — predict reflections and measure their intensities using the stills integrator (&amp;lt;code&amp;gt;dispatch.integrate&amp;lt;/code&amp;gt;), with an optional significance filter.&lt;br /&gt;
&lt;br /&gt;
The program applies a set of stills-specific defaults on top of the standard DIALS parameters,&lt;br /&gt;
including: indexing method &amp;lt;code&amp;gt;fft1d&amp;lt;/code&amp;gt;; the stills integrator with profile fitting turned off&lt;br /&gt;
(summation integration with a 2-D plane background); the stills refinement weighting strategy with&lt;br /&gt;
the detector and beam models fixed; and a re-estimation of per-crystal mosaic parameters&lt;br /&gt;
(domain size and mosaic angle) after refinement. These are sensible starting points for serial data&lt;br /&gt;
and normally do not need to be changed.&lt;br /&gt;
&lt;br /&gt;
Failures on individual images are, by default, caught and logged so that processing continues to the&lt;br /&gt;
next image (&amp;lt;code&amp;gt;dispatch.squash_errors=True&amp;lt;/code&amp;gt;) — essential when reducing tens of thousands of&lt;br /&gt;
shots of which only a fraction are hits.&lt;br /&gt;
&lt;br /&gt;
= Basic usage =&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Process a directory of CBF stills, constraining the target cell/symmetry,&lt;br /&gt;
# using 32 parallel processes on one node&lt;br /&gt;
dials.stills_process /path/to/images/*.cbf process.phil mp.nproc=32&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A typical &amp;lt;code&amp;gt;process.phil&amp;lt;/code&amp;gt; for XFEL data looks like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
spotfinder.filter.min_spot_size=2&lt;br /&gt;
spotfinder.threshold.dispersion.gain=1.0&lt;br /&gt;
spotfinder.threshold.dispersion.global_threshold=100&lt;br /&gt;
&lt;br /&gt;
indexing.known_symmetry.space_group=P43212&lt;br /&gt;
indexing.known_symmetry.unit_cell=78.9,78.9,38.1,90,90,90&lt;br /&gt;
indexing.method=fft1d&lt;br /&gt;
&lt;br /&gt;
input.reference_geometry=refined.expt   # from a previous metrology refinement&lt;br /&gt;
&lt;br /&gt;
output.output_dir=out&lt;br /&gt;
mp.nproc=32&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Useful command-line helpers:&lt;br /&gt;
* &amp;lt;code&amp;gt;dials.stills_process -h&amp;lt;/code&amp;gt; — help and usage&lt;br /&gt;
* &amp;lt;code&amp;gt;dials.stills_process -c -e 2&amp;lt;/code&amp;gt; — show the configurable parameters (expert level 2)&lt;br /&gt;
* &amp;lt;code&amp;gt;dials.stills_process -c -a2&amp;lt;/code&amp;gt; — include attributes (help text) for each parameter&lt;br /&gt;
* &amp;lt;code&amp;gt;dials.stills_process ... input.show_image_tags=True&amp;lt;/code&amp;gt; — list the image tags in a dataset without processing (useful for selecting subsets with &amp;lt;code&amp;gt;input.image_tag&amp;lt;/code&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
= Important parameters =&lt;br /&gt;
&lt;br /&gt;
The program exposes the entire DIALS parameter set (spot-finding, indexing, refinement, integration,&lt;br /&gt;
profile modelling, prediction). The parameters below are the ones most commonly adjusted for serial&lt;br /&gt;
still data. Parameters are given by their full PHIL path with their default value.&lt;br /&gt;
&lt;br /&gt;
== Input ==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.reference_geometry&amp;lt;/code&amp;gt; || None || Path to an &amp;lt;code&amp;gt;.expt&amp;lt;/code&amp;gt; file (or image) with a single detector model. Data are processed using &#039;&#039;this&#039;&#039; geometry instead of the geometry in the image headers. This is how a refined detector metrology from &amp;lt;code&amp;gt;cctbx.xfel&amp;lt;/code&amp;gt; ensemble refinement is applied — almost always set for XFEL data.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.sync_reference_geom&amp;lt;/code&amp;gt; || True || When a reference geometry is supplied, copy its refined local frames onto the image&#039;s detector hierarchy node-by-node (the hierarchies must match in shape). If False, the reference detector replaces the image detector wholesale.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.file_list&amp;lt;/code&amp;gt; || None || Path to a text file listing image paths, one per line (alternative to listing files on the command line).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.glob&amp;lt;/code&amp;gt; || None || Wildcard path(s) for large multi-file datasets (e.g. &amp;lt;code&amp;gt;*.cbf&amp;lt;/code&amp;gt;). May be given multiple times.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.image_tag&amp;lt;/code&amp;gt; || None || Process only images with the given tag(s). For single-image files the tag is the filename; for multi-image files (HDF5) it is &amp;lt;code&amp;gt;filename_imagenumber&amp;lt;/code&amp;gt; (image number is 5 digits with leading zeroes). Use &amp;lt;code&amp;gt;input.show_image_tags=True&amp;lt;/code&amp;gt; to list them.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.max_images&amp;lt;/code&amp;gt; || None || Limit the total number of images processed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Dispatch — controlling the pipeline ==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dispatch.find_spots&amp;lt;/code&amp;gt; || True || Do spot-finding. Required for indexing/integration.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dispatch.index&amp;lt;/code&amp;gt; || True || Attempt to index. Requires &amp;lt;code&amp;gt;find_spots=True&amp;lt;/code&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dispatch.integrate&amp;lt;/code&amp;gt; || True || Integrate indexed images. Ignored if indexing/spot-finding is off.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dispatch.refine&amp;lt;/code&amp;gt; || False || Run an explicit model-refinement step after indexing (the stills indexer already refines; this is an additional pass, rarely needed).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dispatch.squash_errors&amp;lt;/code&amp;gt; || True || If an image fails, log it and continue to the next image. Set False to halt and show the full error when debugging.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dispatch.hit_finder.enable&amp;lt;/code&amp;gt; || True || Enable hit-finding. If disabled, every image is passed to indexing.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dispatch.hit_finder.minimum_number_of_reflections&amp;lt;/code&amp;gt; || 16 || Images with fewer strong spots than this are discarded as non-hits before indexing.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dispatch.hit_finder.maximum_number_of_reflections&amp;lt;/code&amp;gt; || None || If set, images with more strong spots than this are discarded (e.g. ice/junk).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dispatch.process_percent&amp;lt;/code&amp;gt; || None || Process only this percentage of events (evenly sampled). Useful for a quick look at a large dataset.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dispatch.coset&amp;lt;/code&amp;gt; || False || During integration, also integrate a sublattice coset as a negative control for regions with no Bragg diffraction (see &amp;lt;code&amp;gt;integration.coset.transformation&amp;lt;/code&amp;gt;).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dispatch.pre_import&amp;lt;/code&amp;gt; || False || Import all data before processing. Only needed when processing multiple &#039;&#039;multi-image&#039;&#039; files at once (not a recommended workflow). Single-file datasets (e.g. HDF5) are always pre-imported automatically.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Spot-finding ==&lt;br /&gt;
&lt;br /&gt;
Spot-finding uses the standard DIALS dispersion thresholding. The most impactful parameters for&lt;br /&gt;
serial data:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spotfinder.filter.min_spot_size&amp;lt;/code&amp;gt; || Auto || Minimum connected pixels for a spot. Auto = 3 for pixel-array detectors (SENSOR_PAD), 6 otherwise. Often lowered to 2 for sparse serial patterns.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spotfinder.threshold.dispersion.gain&amp;lt;/code&amp;gt; || None || Detector gain used in thresholding. Set this &#039;&#039;or&#039;&#039; the detector-model gain, not both (see gain note below).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spotfinder.threshold.dispersion.sigma_strong&amp;lt;/code&amp;gt; || 3 || Number of sigma above background for a pixel to be &amp;quot;strong&amp;quot;.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spotfinder.threshold.dispersion.sigma_background&amp;lt;/code&amp;gt; || 6 || Number of sigma for the background/dispersion test.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spotfinder.threshold.dispersion.global_threshold&amp;lt;/code&amp;gt; || 0 || Absolute pixel intensity floor; pixels below this are never considered strong. Raising it (e.g. 100) suppresses noise on many detectors.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spotfinder.threshold.dispersion.kernel_size&amp;lt;/code&amp;gt; || 3 3 || Local-area kernel (pixels) for the dispersion calculation.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Gain note:&#039;&#039;&#039; the detector gain should be set on the detector model &#039;&#039;or&#039;&#039; in the processing&lt;br /&gt;
parameters, never both. If a supplied gain (&amp;lt;code&amp;gt;spotfinder.threshold.dispersion.gain&amp;lt;/code&amp;gt; or&lt;br /&gt;
&amp;lt;code&amp;gt;integration.summation.detector_gain&amp;lt;/code&amp;gt;) conflicts with a non-unity gain already on the&lt;br /&gt;
detector model, the program raises an error. Override with&lt;br /&gt;
&amp;lt;code&amp;gt;input.ignore_gain_mismatch=True&amp;lt;/code&amp;gt; only if you understand the consequences.&lt;br /&gt;
&lt;br /&gt;
== Indexing ==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;indexing.known_symmetry.space_group&amp;lt;/code&amp;gt; || None || Target space group. Strongly recommended for serial data — constrains indexing and improves the hit/index rate.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;indexing.known_symmetry.unit_cell&amp;lt;/code&amp;gt; || None || Target unit cell (a,b,c,α,β,γ). Used together with the space group as the indexing target.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;indexing.method&amp;lt;/code&amp;gt; || fft1d || Basis-vector search method (&amp;lt;code&amp;gt;dials.stills_process&amp;lt;/code&amp;gt; defaults to &amp;lt;code&amp;gt;fft1d&amp;lt;/code&amp;gt;; &amp;lt;code&amp;gt;fft3d&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;real_space_grid_search&amp;lt;/code&amp;gt; are also available).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;indexing.stills.method_list&amp;lt;/code&amp;gt; || None || Ordered list of indexing methods to try in turn; if one fails, the next is attempted (e.g. &amp;lt;code&amp;gt;fft1d real_space_grid_search&amp;lt;/code&amp;gt;).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;indexing.stills.known_orientations&amp;lt;/code&amp;gt; || None || Paths to previously-processed experiment lists. If given, images are &#039;&#039;not&#039;&#039; re-indexed; the stored crystal orientations are reused (e.g. to re-integrate with new parameters). Supports wildcards; may be repeated.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;indexing.stills.require_known_orientation&amp;lt;/code&amp;gt; || False || When known orientations are supplied but an image is not found among them, controls whether to skip it (True) or fall back to indexing from scratch (False).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;indexing.stills.reflection_subsampling.enable&amp;lt;/code&amp;gt; || False || Retry indexing on random subsets of the strong spots (from &amp;lt;code&amp;gt;step_start&amp;lt;/code&amp;gt;% down to &amp;lt;code&amp;gt;step_stop&amp;lt;/code&amp;gt;% in &amp;lt;code&amp;gt;step_size&amp;lt;/code&amp;gt;% steps). Can rescue images that fail to index on the full spot list.  Especially valuble for multi-lattice images (multiple crystals in the beam) but does increase execution time!&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Integration ==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;profile.gaussian_rs.parameters.sigma_b_cutoff&amp;lt;/code&amp;gt; || 0.1 || Maximum beam divergence (sigma_b, degrees) before an indexed crystal is rejected prior to integration. Guards against over-broad, poorly-modelled lattices.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;significance_filter.enable&amp;lt;/code&amp;gt; || False || Apply the stills significance filter, which trims each crystal to the resolution at which reflections remain statistically significant (see &amp;lt;code&amp;gt;significance_filter.isigi_cutoff&amp;lt;/code&amp;gt;, default 1.0).  Defaults to false here because it is typically applied in &#039;&#039;[[cctbx.xfel.merge]]&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;integration.integration_only_overrides.trusted_range&amp;lt;/code&amp;gt; || None || Override the panel trusted range [min, max] during integration only (e.g. to include pixels the header marks as untrusted).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;integration.coset.transformation&amp;lt;/code&amp;gt; || 6 || Which modulus-2 sublattice transformation defines the coset negative control when &amp;lt;code&amp;gt;dispatch.coset=True&amp;lt;/code&amp;gt; (0–6; 6 = body centering). See Sauter &amp;amp; Zwart, &#039;&#039;Acta Cryst.&#039;&#039; D (2009) &#039;&#039;&#039;65&#039;&#039;&#039;:553.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Output ==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.output_dir&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;.&amp;lt;/code&amp;gt; || Directory for output files.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.composite_output&amp;lt;/code&amp;gt; || True || If True, each process writes &#039;&#039;one&#039;&#039; concatenated set of &amp;lt;code&amp;gt;.expt&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;.refl&amp;lt;/code&amp;gt; files covering all its successful images. If False, a separate pair of files is written per image (generates a very large number of files). Composite output is strongly preferred for large serial datasets.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.logging_dir&amp;lt;/code&amp;gt; || None || Directory for log files. Under MPI, per-rank logs (&amp;lt;code&amp;gt;log_rankNNNN.out&amp;lt;/code&amp;gt;, etc.) are written here.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.logging_option&amp;lt;/code&amp;gt; || normal || &amp;lt;code&amp;gt;normal&amp;lt;/code&amp;gt; (all logging), &amp;lt;code&amp;gt;suppressed&amp;lt;/code&amp;gt; (silences verbose DIALS refine/index output), or &amp;lt;code&amp;gt;disabled&amp;lt;/code&amp;gt; (almost no logging).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.*_filename&amp;lt;/code&amp;gt; || (templates) || Output filename templates for each stage: &amp;lt;code&amp;gt;strong&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;indexed&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;refined_experiments&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;integrated&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;integrated_experiments&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;coset&amp;lt;/code&amp;gt;. A &amp;lt;code&amp;gt;%s&amp;lt;/code&amp;gt; in the template is replaced with the process number for composite mode or the per-image tag for non-composite mode.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.integration_pickle&amp;lt;/code&amp;gt; || None || Write legacy &amp;lt;code&amp;gt;cxi.merge&amp;lt;/code&amp;gt;/PRIME integration pickle files (e.g. &amp;lt;code&amp;gt;int-%d-%s.pickle&amp;lt;/code&amp;gt;). Only needed for legacy merging workflows.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Multiprocessing ==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mp.method&amp;lt;/code&amp;gt; || multiprocessing || Parallelization backend: &amp;lt;code&amp;gt;multiprocessing&amp;lt;/code&amp;gt; (single node), or &amp;lt;code&amp;gt;mpi&amp;lt;/code&amp;gt; for multi-node jobs (also &amp;lt;code&amp;gt;sge&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;lsf&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;pbs&amp;lt;/code&amp;gt;).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mp.nproc&amp;lt;/code&amp;gt; || 1 || Number of processes (for the &amp;lt;code&amp;gt;multiprocessing&amp;lt;/code&amp;gt; method). Set to the number of cores per node.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mp.composite_stride&amp;lt;/code&amp;gt; || None || For MPI composite output, how many ranks aggregate their results into one set of output files. Ideally set to the number of processes per node so that one composite file set is written per node rather than per rank.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Under MPI with more than two ranks, the program runs a client/server model: rank 0 (or rank 2 for&lt;br /&gt;
psana2 &amp;lt;code&amp;gt;.loc&amp;lt;/code&amp;gt; inputs) hands out images to worker ranks on demand, giving good load&lt;br /&gt;
balancing across the many fast-failing non-hits typical of serial data.&lt;br /&gt;
&lt;br /&gt;
= Output files =&lt;br /&gt;
&lt;br /&gt;
With the default composite output, each process (or each aggregating rank under MPI) writes&lt;br /&gt;
concatenated files such as:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;amp;lt;tag&amp;amp;gt;_strong.refl&amp;lt;/code&amp;gt; — strong spots from spot-finding&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;amp;lt;tag&amp;amp;gt;_indexed.refl&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;&amp;amp;lt;tag&amp;amp;gt;_refined.expt&amp;lt;/code&amp;gt; — indexed reflections and their crystal models&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;amp;lt;tag&amp;amp;gt;_integrated.refl&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;&amp;amp;lt;tag&amp;amp;gt;_integrated.expt&amp;lt;/code&amp;gt; — integrated intensities and final models (the input to &#039;&#039;[[cctbx.xfel.merge]]&#039;&#039;)&lt;br /&gt;
&lt;br /&gt;
Per-image progress and status codes are recorded in &amp;lt;code&amp;gt;debug/debug_&amp;amp;lt;rank&amp;amp;gt;.txt&amp;lt;/code&amp;gt;, and&lt;br /&gt;
overall logging goes to &amp;lt;code&amp;gt;dials.process.log&amp;lt;/code&amp;gt; (or per-rank logs under MPI). These integrated&lt;br /&gt;
&amp;lt;code&amp;gt;.expt&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;.refl&amp;lt;/code&amp;gt; pairs are then scaled and merged with&lt;br /&gt;
&#039;&#039;[[cctbx.xfel.merge]]&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
= See also =&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;[[cctbx.xfel.merge]]&#039;&#039; — scaling, post-refinement and merging of the integrated data&lt;br /&gt;
* The [http://dials.github.io DIALS documentation] for the underlying spot-finding, indexing, refinement and integration algorithms&lt;/div&gt;</summary>
		<author><name>Aaron</name></author>
	</entry>
	<entry>
		<id>http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Dials.stills_process&amp;diff=1787</id>
		<title>Dials.stills process</title>
		<link rel="alternate" type="text/html" href="http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Dials.stills_process&amp;diff=1787"/>
		<updated>2026-08-21T23:39:39Z</updated>

		<summary type="html">&lt;p&gt;Aaron: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{DISPLAYTITLE:dials.stills_process}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;dials.stills_process&#039;&#039;&#039;&#039;&#039; is a stand-alone program for processing still diffraction images and is&lt;br /&gt;
the core data-reduction program of &#039;&#039;cctbx.xfel&#039;&#039;. It takes a set of&lt;br /&gt;
still diffraction images — typically serial femtosecond crystallography (SFX) snapshots from an&lt;br /&gt;
XFEL (LCLS, SACLA, EuXFEL) or still shots from a synchrotron — and analyzes each one, independently,&lt;br /&gt;
through the full DIALS pipeline: &#039;&#039;&#039;import → spot-finding → indexing → refinement → integration&#039;&#039;&#039;.&lt;br /&gt;
Its output (integrated intensities together with the per-image experimental models) is the input to&lt;br /&gt;
the merging program &#039;&#039;[[cctbx.xfel.merge]]&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Because every image is a separate still exposure of a different crystal (rather than a wedge of&lt;br /&gt;
a rotation series), each image is treated as its own experiment with its own crystal model. This&lt;br /&gt;
&amp;quot;one crystal per shot&amp;quot; model is what distinguishes stills processing from conventional rotation data&lt;br /&gt;
processing (e.g. &amp;lt;code&amp;gt;dials.import&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;dials.find_spots&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;dials.index&amp;lt;/code&amp;gt;, etc.), &lt;br /&gt;
and it drives most of the stills-specific defaults described below.&lt;br /&gt;
&lt;br /&gt;
= Overview =&lt;br /&gt;
&lt;br /&gt;
For each image, &amp;lt;code&amp;gt;dials.stills_process&amp;lt;/code&amp;gt; runs the following stages in order. Any stage can&lt;br /&gt;
be turned off with the &amp;lt;code&amp;gt;dispatch&amp;lt;/code&amp;gt; parameters; if a stage is disabled, processing stops&lt;br /&gt;
after the last enabled stage.&lt;br /&gt;
&lt;br /&gt;
# &#039;&#039;&#039;Import&#039;&#039;&#039; — read the image, apply reference geometry / gain / mask overrides, and build an experiment.&lt;br /&gt;
# &#039;&#039;&#039;Spot-finding&#039;&#039;&#039; — locate strong pixels and build strong reflections (&amp;lt;code&amp;gt;dispatch.find_spots&amp;lt;/code&amp;gt;).&lt;br /&gt;
# &#039;&#039;&#039;Hit finding&#039;&#039;&#039; — reject images with too few (or optionally too many) strong spots, so that only &amp;quot;hits&amp;quot; are indexed (&amp;lt;code&amp;gt;dispatch.hit_finder&amp;lt;/code&amp;gt;).&lt;br /&gt;
# &#039;&#039;&#039;Indexing&#039;&#039;&#039; — determine the crystal orientation and (optionally constrained) unit cell (&amp;lt;code&amp;gt;dispatch.index&amp;lt;/code&amp;gt;).&lt;br /&gt;
# &#039;&#039;&#039;Refinement&#039;&#039;&#039; — refine the crystal model and re-estimate the mosaic/domain-size parameters. Detector and beam are held fixed by default (&amp;lt;code&amp;gt;dispatch.refine&amp;lt;/code&amp;gt;).&lt;br /&gt;
# &#039;&#039;&#039;Integration&#039;&#039;&#039; — predict reflections and measure their intensities using the stills integrator (&amp;lt;code&amp;gt;dispatch.integrate&amp;lt;/code&amp;gt;), with an optional significance filter.&lt;br /&gt;
&lt;br /&gt;
The program applies a set of stills-specific defaults on top of the standard DIALS parameters,&lt;br /&gt;
including: indexing method &amp;lt;code&amp;gt;fft1d&amp;lt;/code&amp;gt;; the stills integrator with profile fitting turned off&lt;br /&gt;
(summation integration with a 2-D plane background); the stills refinement weighting strategy with&lt;br /&gt;
the detector and beam models fixed; and a re-estimation of per-crystal mosaic parameters&lt;br /&gt;
(domain size and mosaic angle) after refinement. These are sensible starting points for serial data&lt;br /&gt;
and normally do not need to be changed.&lt;br /&gt;
&lt;br /&gt;
Failures on individual images are, by default, caught and logged so that processing continues to the&lt;br /&gt;
next image (&amp;lt;code&amp;gt;dispatch.squash_errors=True&amp;lt;/code&amp;gt;) — essential when reducing tens of thousands of&lt;br /&gt;
shots of which only a fraction are hits.&lt;br /&gt;
&lt;br /&gt;
= Basic usage =&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Process a directory of CBF stills, constraining the target cell/symmetry,&lt;br /&gt;
# using 32 parallel processes on one node&lt;br /&gt;
dials.stills_process /path/to/images/*.cbf process.phil mp.nproc=32&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A typical &amp;lt;code&amp;gt;process.phil&amp;lt;/code&amp;gt; for XFEL data looks like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
spotfinder.filter.min_spot_size=2&lt;br /&gt;
spotfinder.threshold.dispersion.gain=1.0&lt;br /&gt;
spotfinder.threshold.dispersion.global_threshold=100&lt;br /&gt;
&lt;br /&gt;
indexing.known_symmetry.space_group=P43212&lt;br /&gt;
indexing.known_symmetry.unit_cell=78.9,78.9,38.1,90,90,90&lt;br /&gt;
indexing.method=fft1d&lt;br /&gt;
&lt;br /&gt;
input.reference_geometry=refined.expt   # from a previous metrology refinement&lt;br /&gt;
&lt;br /&gt;
output.output_dir=out&lt;br /&gt;
mp.nproc=32&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Useful command-line helpers:&lt;br /&gt;
* &amp;lt;code&amp;gt;dials.stills_process -h&amp;lt;/code&amp;gt; — help and usage&lt;br /&gt;
* &amp;lt;code&amp;gt;dials.stills_process -c -e 2&amp;lt;/code&amp;gt; — show the configurable parameters (expert level 2)&lt;br /&gt;
* &amp;lt;code&amp;gt;dials.stills_process -c -a2&amp;lt;/code&amp;gt; — include attributes (help text) for each parameter&lt;br /&gt;
* &amp;lt;code&amp;gt;dials.stills_process ... input.show_image_tags=True&amp;lt;/code&amp;gt; — list the image tags in a dataset without processing (useful for selecting subsets with &amp;lt;code&amp;gt;input.image_tag&amp;lt;/code&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
= Important parameters =&lt;br /&gt;
&lt;br /&gt;
The program exposes the entire DIALS parameter set (spot-finding, indexing, refinement, integration,&lt;br /&gt;
profile modelling, prediction). The parameters below are the ones most commonly adjusted for serial&lt;br /&gt;
still data. Parameters are given by their full PHIL path with their default value.&lt;br /&gt;
&lt;br /&gt;
== Input ==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.reference_geometry&amp;lt;/code&amp;gt; || None || Path to an &amp;lt;code&amp;gt;.expt&amp;lt;/code&amp;gt; file (or image) with a single detector model. Data are processed using &#039;&#039;this&#039;&#039; geometry instead of the geometry in the image headers. This is how a refined detector metrology from &amp;lt;code&amp;gt;cctbx.xfel&amp;lt;/code&amp;gt; ensemble refinement is applied — almost always set for XFEL data.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.sync_reference_geom&amp;lt;/code&amp;gt; || True || When a reference geometry is supplied, copy its refined local frames onto the image&#039;s detector hierarchy node-by-node (the hierarchies must match in shape). If False, the reference detector replaces the image detector wholesale.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.file_list&amp;lt;/code&amp;gt; || None || Path to a text file listing image paths, one per line (alternative to listing files on the command line).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.glob&amp;lt;/code&amp;gt; || None || Wildcard path(s) for large multi-file datasets (e.g. &amp;lt;code&amp;gt;*.cbf&amp;lt;/code&amp;gt;). May be given multiple times.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.image_tag&amp;lt;/code&amp;gt; || None || Process only images with the given tag(s). For single-image files the tag is the filename; for multi-image files (HDF5) it is &amp;lt;code&amp;gt;filename_imagenumber&amp;lt;/code&amp;gt; (image number is 5 digits with leading zeroes). Use &amp;lt;code&amp;gt;input.show_image_tags=True&amp;lt;/code&amp;gt; to list them.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.max_images&amp;lt;/code&amp;gt; || None || Limit the total number of images processed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Dispatch — controlling the pipeline ==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dispatch.find_spots&amp;lt;/code&amp;gt; || True || Do spot-finding. Required for indexing/integration.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dispatch.index&amp;lt;/code&amp;gt; || True || Attempt to index. Requires &amp;lt;code&amp;gt;find_spots=True&amp;lt;/code&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dispatch.integrate&amp;lt;/code&amp;gt; || True || Integrate indexed images. Ignored if indexing/spot-finding is off.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dispatch.refine&amp;lt;/code&amp;gt; || False || Run an explicit model-refinement step after indexing (the stills indexer already refines; this is an additional pass, rarely needed).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dispatch.squash_errors&amp;lt;/code&amp;gt; || True || If an image fails, log it and continue to the next image. Set False to halt and show the full error when debugging.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dispatch.hit_finder.enable&amp;lt;/code&amp;gt; || True || Enable hit-finding. If disabled, every image is passed to indexing.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dispatch.hit_finder.minimum_number_of_reflections&amp;lt;/code&amp;gt; || 16 || Images with fewer strong spots than this are discarded as non-hits before indexing.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dispatch.hit_finder.maximum_number_of_reflections&amp;lt;/code&amp;gt; || None || If set, images with more strong spots than this are discarded (e.g. ice/junk).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dispatch.process_percent&amp;lt;/code&amp;gt; || None || Process only this percentage of events (evenly sampled). Useful for a quick look at a large dataset.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dispatch.coset&amp;lt;/code&amp;gt; || False || During integration, also integrate a sublattice coset as a negative control for regions with no Bragg diffraction (see &amp;lt;code&amp;gt;integration.coset.transformation&amp;lt;/code&amp;gt;).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dispatch.pre_import&amp;lt;/code&amp;gt; || False || Import all data before processing. Only needed when processing multiple &#039;&#039;multi-image&#039;&#039; files at once (not a recommended workflow). Single-file datasets (e.g. HDF5) are always pre-imported automatically.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Spot-finding ==&lt;br /&gt;
&lt;br /&gt;
Spot-finding uses the standard DIALS dispersion thresholding. The most impactful parameters for&lt;br /&gt;
serial data:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spotfinder.filter.min_spot_size&amp;lt;/code&amp;gt; || Auto || Minimum connected pixels for a spot. Auto = 3 for pixel-array detectors (SENSOR_PAD), 6 otherwise. Often lowered to 2 for sparse serial patterns.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spotfinder.threshold.dispersion.gain&amp;lt;/code&amp;gt; || None || Detector gain used in thresholding. Set this &#039;&#039;or&#039;&#039; the detector-model gain, not both (see gain note below).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spotfinder.threshold.dispersion.sigma_strong&amp;lt;/code&amp;gt; || 3 || Number of sigma above background for a pixel to be &amp;quot;strong&amp;quot;.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spotfinder.threshold.dispersion.sigma_background&amp;lt;/code&amp;gt; || 6 || Number of sigma for the background/dispersion test.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spotfinder.threshold.dispersion.global_threshold&amp;lt;/code&amp;gt; || 0 || Absolute pixel intensity floor; pixels below this are never considered strong. Raising it (e.g. 100) suppresses noise on many detectors.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spotfinder.threshold.dispersion.kernel_size&amp;lt;/code&amp;gt; || 3 3 || Local-area kernel (pixels) for the dispersion calculation.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Gain note:&#039;&#039;&#039; the detector gain should be set on the detector model &#039;&#039;or&#039;&#039; in the processing&lt;br /&gt;
parameters, never both. If a supplied gain (&amp;lt;code&amp;gt;spotfinder.threshold.dispersion.gain&amp;lt;/code&amp;gt; or&lt;br /&gt;
&amp;lt;code&amp;gt;integration.summation.detector_gain&amp;lt;/code&amp;gt;) conflicts with a non-unity gain already on the&lt;br /&gt;
detector model, the program raises an error. Override with&lt;br /&gt;
&amp;lt;code&amp;gt;input.ignore_gain_mismatch=True&amp;lt;/code&amp;gt; only if you understand the consequences.&lt;br /&gt;
&lt;br /&gt;
== Indexing ==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;indexing.known_symmetry.space_group&amp;lt;/code&amp;gt; || None || Target space group. Strongly recommended for serial data — constrains indexing and improves the hit/index rate.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;indexing.known_symmetry.unit_cell&amp;lt;/code&amp;gt; || None || Target unit cell (a,b,c,α,β,γ). Used together with the space group as the indexing target.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;indexing.method&amp;lt;/code&amp;gt; || fft1d || Basis-vector search method (&amp;lt;code&amp;gt;dials.stills_process&amp;lt;/code&amp;gt; defaults to &amp;lt;code&amp;gt;fft1d&amp;lt;/code&amp;gt;; &amp;lt;code&amp;gt;fft3d&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;real_space_grid_search&amp;lt;/code&amp;gt; are also available).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;indexing.stills.method_list&amp;lt;/code&amp;gt; || None || Ordered list of indexing methods to try in turn; if one fails, the next is attempted (e.g. &amp;lt;code&amp;gt;fft1d real_space_grid_search&amp;lt;/code&amp;gt;).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;indexing.stills.known_orientations&amp;lt;/code&amp;gt; || None || Paths to previously-processed experiment lists. If given, images are &#039;&#039;not&#039;&#039; re-indexed; the stored crystal orientations are reused (e.g. to re-integrate with new parameters). Supports wildcards; may be repeated.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;indexing.stills.require_known_orientation&amp;lt;/code&amp;gt; || False || When known orientations are supplied but an image is not found among them, controls whether to skip it (True) or fall back to indexing from scratch (False).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;indexing.stills.reflection_subsampling.enable&amp;lt;/code&amp;gt; || False || Retry indexing on random subsets of the strong spots (from &amp;lt;code&amp;gt;step_start&amp;lt;/code&amp;gt;% down to &amp;lt;code&amp;gt;step_stop&amp;lt;/code&amp;gt;% in &amp;lt;code&amp;gt;step_size&amp;lt;/code&amp;gt;% steps). Can rescue images that fail to index on the full spot list.  Especially valuble for multi-lattice images (multiple crystals in the beam) but does increase execution time!&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Integration ==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;profile.gaussian_rs.parameters.sigma_b_cutoff&amp;lt;/code&amp;gt; || 0.1 || Maximum beam divergence (sigma_b, degrees) before an indexed crystal is rejected prior to integration. Guards against over-broad, poorly-modelled lattices.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;significance_filter.enable&amp;lt;/code&amp;gt; || False || Apply the stills significance filter, which trims each crystal to the resolution at which reflections remain statistically significant (see &amp;lt;code&amp;gt;significance_filter.isigi_cutoff&amp;lt;/code&amp;gt;, default 1.0).  Defaults to false here because it is typically applied in &#039;&#039;[[cctbx.xfel.merge]]&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;integration.integration_only_overrides.trusted_range&amp;lt;/code&amp;gt; || None || Override the panel trusted range [min, max] during integration only (e.g. to include pixels the header marks as untrusted).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;integration.coset.transformation&amp;lt;/code&amp;gt; || 6 || Which modulus-2 sublattice transformation defines the coset negative control when &amp;lt;code&amp;gt;dispatch.coset=True&amp;lt;/code&amp;gt; (0–6; 6 = body centering). See Sauter &amp;amp; Zwart, &#039;&#039;Acta Cryst.&#039;&#039; D (2009) &#039;&#039;&#039;65&#039;&#039;&#039;:553.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Output ==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.output_dir&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;.&amp;lt;/code&amp;gt; || Directory for output files.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.composite_output&amp;lt;/code&amp;gt; || True || If True, each process writes &#039;&#039;one&#039;&#039; concatenated set of &amp;lt;code&amp;gt;.expt&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;.refl&amp;lt;/code&amp;gt; files covering all its successful images. If False, a separate pair of files is written per image (generates a very large number of files). Composite output is strongly preferred for large serial datasets.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.logging_dir&amp;lt;/code&amp;gt; || None || Directory for log files. Under MPI, per-rank logs (&amp;lt;code&amp;gt;log_rankNNNN.out&amp;lt;/code&amp;gt;, etc.) are written here.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.logging_option&amp;lt;/code&amp;gt; || normal || &amp;lt;code&amp;gt;normal&amp;lt;/code&amp;gt; (all logging), &amp;lt;code&amp;gt;suppressed&amp;lt;/code&amp;gt; (silences verbose DIALS refine/index output), or &amp;lt;code&amp;gt;disabled&amp;lt;/code&amp;gt; (almost no logging).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.*_filename&amp;lt;/code&amp;gt; || (templates) || Output filename templates for each stage: &amp;lt;code&amp;gt;strong&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;indexed&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;refined_experiments&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;integrated&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;integrated_experiments&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;coset&amp;lt;/code&amp;gt;. A &amp;lt;code&amp;gt;%s&amp;lt;/code&amp;gt; in the template is replaced with the process number for composite mode or the per-image tag for non-composite mode.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.integration_pickle&amp;lt;/code&amp;gt; || None || Write legacy &amp;lt;code&amp;gt;cxi.merge&amp;lt;/code&amp;gt;/PRIME integration pickle files (e.g. &amp;lt;code&amp;gt;int-%d-%s.pickle&amp;lt;/code&amp;gt;). Only needed for legacy merging workflows.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Multiprocessing ==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mp.method&amp;lt;/code&amp;gt; || multiprocessing || Parallelization backend: &amp;lt;code&amp;gt;multiprocessing&amp;lt;/code&amp;gt; (single node), or &amp;lt;code&amp;gt;mpi&amp;lt;/code&amp;gt; for multi-node jobs (also &amp;lt;code&amp;gt;sge&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;lsf&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;pbs&amp;lt;/code&amp;gt;).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mp.nproc&amp;lt;/code&amp;gt; || 1 || Number of processes (for the &amp;lt;code&amp;gt;multiprocessing&amp;lt;/code&amp;gt; method). Set to the number of cores per node.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mp.composite_stride&amp;lt;/code&amp;gt; || None || For MPI composite output, how many ranks aggregate their results into one set of output files. Ideally set to the number of processes per node so that one composite file set is written per node rather than per rank.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Under MPI with more than two ranks, the program runs a client/server model: rank 0 (or rank 2 for&lt;br /&gt;
psana2 &amp;lt;code&amp;gt;.loc&amp;lt;/code&amp;gt; inputs) hands out images to worker ranks on demand, giving good load&lt;br /&gt;
balancing across the many fast-failing non-hits typical of serial data.&lt;br /&gt;
&lt;br /&gt;
= Output files =&lt;br /&gt;
&lt;br /&gt;
With the default composite output, each process (or each aggregating rank under MPI) writes&lt;br /&gt;
concatenated files such as:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;amp;lt;tag&amp;amp;gt;_strong.refl&amp;lt;/code&amp;gt; — strong spots from spot-finding&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;amp;lt;tag&amp;amp;gt;_indexed.refl&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;&amp;amp;lt;tag&amp;amp;gt;_refined.expt&amp;lt;/code&amp;gt; — indexed reflections and their crystal models&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;amp;lt;tag&amp;amp;gt;_integrated.refl&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;&amp;amp;lt;tag&amp;amp;gt;_integrated.expt&amp;lt;/code&amp;gt; — integrated intensities and final models (the input to &#039;&#039;[[cctbx.xfel.merge]]&#039;&#039;)&lt;br /&gt;
&lt;br /&gt;
Per-image progress and status codes are recorded in &amp;lt;code&amp;gt;debug/debug_&amp;amp;lt;rank&amp;amp;gt;.txt&amp;lt;/code&amp;gt;, and&lt;br /&gt;
overall logging goes to &amp;lt;code&amp;gt;dials.process.log&amp;lt;/code&amp;gt; (or per-rank logs under MPI). These integrated&lt;br /&gt;
&amp;lt;code&amp;gt;.expt&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;.refl&amp;lt;/code&amp;gt; pairs are then scaled and merged with&lt;br /&gt;
&#039;&#039;[[cctbx.xfel.merge]]&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
= See also =&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;[[cctbx.xfel.merge]]&#039;&#039; — scaling, post-refinement and merging of the integrated data&lt;br /&gt;
* The [http://dials.github.io DIALS documentation] for the underlying spot-finding, indexing, refinement and integration algorithms&lt;/div&gt;</summary>
		<author><name>Aaron</name></author>
	</entry>
	<entry>
		<id>http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Main_Page&amp;diff=1786</id>
		<title>Main Page</title>
		<link rel="alternate" type="text/html" href="http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Main_Page&amp;diff=1786"/>
		<updated>2026-08-21T23:32:10Z</updated>

		<summary type="html">&lt;p&gt;Aaron: /* cctbx.xfel resources */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;News! See our [[https://doi.org/10.1101/2025.05.04.652045 new preprint]]!  This paper shows current best practices using &#039;&#039;cctbx.xfel&#039;&#039; with &#039;&#039;DIALS&#039;&#039; for serial crystallographic data.&lt;br /&gt;
&lt;br /&gt;
= Open-source tools for serial crystallographic data processing =&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;cctbx.xfel&#039;&#039; is a suite of software tools designed to process diffraction data from serial femtosecond crystallography (SFX) measurements at an X-ray free-electron laser (XFEL) or a synchrotron.  Built on the Computational Crystallographic Toolbox ([https://cctbx.github.io/ &#039;&#039;cctbx&#039;&#039;]), the same toolbox on which [http://www.phenix-online.org &#039;&#039;PHENIX&#039;&#039;], and [http://dials.github.io DIALS] are built, it enables the user to solve difficult problems relating to processing serial crystallographic data.  The programs and modules provided by &#039;&#039;cctbx.xfel&#039;&#039; can reduce a large set of still diffraction images recorded at Stanford’s Linac Coherent Light Source ([http://lcls.slac.stanford.edu LCLS]), [http://sacla.xfel.jp SACLA], the [https://www.xfel.eu/ European XFEL], or a synchrotron, to a single MTZ file containing merged reflection intensities suitable for structure solution.&lt;br /&gt;
&lt;br /&gt;
== &#039;&#039;cctbx.xfel&#039;&#039; resources ==&lt;br /&gt;
&lt;br /&gt;
The current best resource is our pre-print, [https://doi.org/10.1101/2025.05.04.652045 &#039;&#039;cctbx.xfel: a suite for processing serial crystallographic data.&#039;&#039;].  This paper describes the algorithms and ideas behind the implementation and execution of the two main programs of &#039;&#039;cctbx.xfel&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;[[Dials.stills_process]]&#039;&#039;: this program runs through all the first steps of processing data using dials: import (reading image headers), spot finding, indexing, geometry refinement, and integration.  Serial images are independent from each other, so this program is optimized for massively parallel systems, but can be adapted to a variety of single and multi-processing modes.&lt;br /&gt;
* &#039;&#039;[[Cctbx.xfel.merge]]&#039;&#039;: this program runs through the remaining steps of processing: scaling and merging to produce a full dataset (.mtz file).  For documentation, see our [https://github.com/cctbx/cctbx_project/tree/master/xfel/merging Github project]&lt;br /&gt;
&lt;br /&gt;
Additional resources:&lt;br /&gt;
&lt;br /&gt;
* Our [http://cci.lbl.gov/publications/download/CCN_2019_p22_Brewster.pdf 2019 newsletter article] describes how to use the &#039;&#039;cctbx.xfel&#039;&#039; GUI, an interactive program for handling large XFEL datasets.&lt;br /&gt;
&lt;br /&gt;
* [[Overview]] to the system architecture at LCLS and real-time progress monitoring of data processing&lt;br /&gt;
* Installation: there are two ways to get &#039;&#039;cctbx.xfel&#039;&#039;:&lt;br /&gt;
** &#039;&#039;cctbx.xfel&#039;&#039; is installed for general use at SLAC.  To start using an existing installation, [[Using the pre-built cctbx at LCLS|simply source the current build]]. &lt;br /&gt;
** [https://dials.github.io/installation.html Download] a binary bundle of DIALS. Use this option if you will not be processing LCLS data because, for example, if you have serial crystallographic data from a synchrotron.&lt;br /&gt;
** Build a psana/cctbx.xfel build [https://github.com/cctbx/cctbx_project/tree/master/xfel/conda_envs from scratch]. Use this option if you want to process LCLS data outside of LCLS or want your own build.&lt;br /&gt;
* [[Tutorials]] on pre-processing, data reduction, and merging. &lt;br /&gt;
&lt;br /&gt;
Other related information:&lt;br /&gt;
&lt;br /&gt;
* [[Serial XFEL Crystallography References]]&lt;br /&gt;
&lt;br /&gt;
This project is under active development.  For any assistance, please contact the authors.&lt;/div&gt;</summary>
		<author><name>Aaron</name></author>
	</entry>
	<entry>
		<id>http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Cctbx.xfel.merge&amp;diff=1785</id>
		<title>Cctbx.xfel.merge</title>
		<link rel="alternate" type="text/html" href="http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Cctbx.xfel.merge&amp;diff=1785"/>
		<updated>2026-08-21T23:26:17Z</updated>

		<summary type="html">&lt;p&gt;Aaron: /* Basic usage */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= &#039;&#039;cctbx.xfel.merge&#039;&#039; =&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;cctbx.xfel.merge&#039;&#039;&#039;&#039;&#039; is the scaling, post-refinement and merging program of cctbx.xfel. It takes&lt;br /&gt;
the per-image integrated results produced by &#039;&#039;[[dials.stills_process]]&#039;&#039; — one crystal per still shot —&lt;br /&gt;
and reduces the whole ensemble to a single set of merged structure-factor intensities (an MTZ file)&lt;br /&gt;
suitable for structure solution and refinement, together with the crystallographic quality&lt;br /&gt;
statistics (completeness, multiplicity, ⟨I/σ⟩, CC½, CC&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt;, R-factors, etc.).&lt;br /&gt;
&lt;br /&gt;
Because serial datasets routinely contain tens of thousands to millions of still shots,&lt;br /&gt;
&amp;lt;code&amp;gt;cctbx.xfel.merge&amp;lt;/code&amp;gt; is built from the ground up to run under MPI across many nodes. It is&lt;br /&gt;
almost always launched with &amp;lt;code&amp;gt;mpirun&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;srun&amp;lt;/code&amp;gt;.  Note that MPI uses the term &#039;ranks&#039;&lt;br /&gt;
to distinguish independent processes that are running across one or more nodes.&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;cctbx.xfel.merge&amp;lt;/code&amp;gt; is organized as a sequence of &#039;&#039;&#039;workers&#039;&#039;&#039;. Each worker performs one&lt;br /&gt;
task — reading data, applying a correction, filtering, scaling, post-refining, computing a statistic,&lt;br /&gt;
or merging — and passes its (possibly modified) experiments and reflections on to the next worker.&lt;br /&gt;
The list of workers to run is the &amp;quot;step list&amp;quot;, and it is fully configurable: you can add, remove or&lt;br /&gt;
reorder steps with &amp;lt;code&amp;gt;dispatch.step_list&amp;lt;/code&amp;gt;. This is what makes the program flexible enough to&lt;br /&gt;
scale-and-merge in one pass, to scale subsets separately and merge later, or to run a reference-free&lt;br /&gt;
bootstrap.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;default&#039;&#039;&#039; step list is:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! # !! Worker !! Purpose&lt;br /&gt;
|-&lt;br /&gt;
| 1 || &amp;lt;code&amp;gt;input&amp;lt;/code&amp;gt; || Read integrated experiments (&amp;lt;code&amp;gt;.expt&amp;lt;/code&amp;gt;) and reflections (&amp;lt;code&amp;gt;.refl&amp;lt;/code&amp;gt;) from disk in DIALS format.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || &amp;lt;code&amp;gt;balance&amp;lt;/code&amp;gt; || Redistribute the input load evenly across MPI ranks (needed when there are fewer or more input files than ranks).&lt;br /&gt;
|-&lt;br /&gt;
| 3 || &amp;lt;code&amp;gt;model_scaling&amp;lt;/code&amp;gt; || Build the full Miller list, model intensities from the reference, and the resolution binner used for scaling and post-refinement.&lt;br /&gt;
|-&lt;br /&gt;
| 4 || &amp;lt;code&amp;gt;modify&amp;lt;/code&amp;gt; || Apply per-reflection modifications, e.g. polarization correction (and optionally re-indexing to resolve indexing ambiguity — see &amp;lt;code&amp;gt;modify.cosym&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;reindex_to_reference&amp;lt;/code&amp;gt;).&lt;br /&gt;
|-&lt;br /&gt;
| 5 || &amp;lt;code&amp;gt;filter&amp;lt;/code&amp;gt; || Reject whole experiments (or reflections) by resolution, unit cell, correlation to the reference, energy, etc.&lt;br /&gt;
|-&lt;br /&gt;
| 6 || &amp;lt;code&amp;gt;scale&amp;lt;/code&amp;gt; || Scale each lattice to the reference dataset (&amp;lt;code&amp;gt;mark0&amp;lt;/code&amp;gt;) or simply average (&amp;lt;code&amp;gt;mark1&amp;lt;/code&amp;gt;).&lt;br /&gt;
|-&lt;br /&gt;
| 7 || &amp;lt;code&amp;gt;postrefine&amp;lt;/code&amp;gt; || Post-refine per-image crystal parameters and partialities (Sauter 2015).&lt;br /&gt;
|-&lt;br /&gt;
| 8 || &amp;lt;code&amp;gt;statistics_unitcell&amp;lt;/code&amp;gt; || Determine and store the average unit cell.&lt;br /&gt;
|-&lt;br /&gt;
| 9 || &amp;lt;code&amp;gt;statistics_beam&amp;lt;/code&amp;gt; || Determine and store the average wavelength.&lt;br /&gt;
|-&lt;br /&gt;
| 10 || &amp;lt;code&amp;gt;model_statistics&amp;lt;/code&amp;gt; || Rebuild the Miller list / binner for statistics (may use the average unit cell).&lt;br /&gt;
|-&lt;br /&gt;
| 11 || &amp;lt;code&amp;gt;statistics_resolution&amp;lt;/code&amp;gt; || Per-crystal resolution statistics.&lt;br /&gt;
|-&lt;br /&gt;
| 12 || &amp;lt;code&amp;gt;group&amp;lt;/code&amp;gt; || Redistribute reflections across ranks so that every observation of a given HKL is gathered on the same rank prior to merging.&lt;br /&gt;
|-&lt;br /&gt;
| 13 || &amp;lt;code&amp;gt;errors_merge&amp;lt;/code&amp;gt; || Correct the merged error estimates with a per-HKL error model (e.g. Ev11, Brewster 2019b, or MM24 (the default), Mittan-Moreau (2025)).&lt;br /&gt;
|-&lt;br /&gt;
| 14 || &amp;lt;code&amp;gt;statistics_intensity&amp;lt;/code&amp;gt; || Intensity statistics by resolution.&lt;br /&gt;
|-&lt;br /&gt;
| 15 || &amp;lt;code&amp;gt;merge&amp;lt;/code&amp;gt; || Merge symmetry-equivalent intensities, gather all HKLs at rank 0, and write &amp;quot;odd&amp;quot;, &amp;quot;even&amp;quot; and &amp;quot;all&amp;quot; MTZ files.&lt;br /&gt;
|-&lt;br /&gt;
| 16 || &amp;lt;code&amp;gt;statistics_intensity_cxi&amp;lt;/code&amp;gt; || Correlation and R-factor statistics (ported from cxi.merge): the &amp;quot;Table of Scaling Results&amp;quot; — CC½ (half-dataset correlation, labelled &amp;quot;CC int&amp;quot;), CC&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt;, R&amp;lt;sub&amp;gt;int&amp;lt;/sub&amp;gt;, R&amp;lt;sub&amp;gt;split&amp;lt;/sub&amp;gt;, R&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Additional, non-default workers are available and can be&lt;br /&gt;
inserted into the step list, including &amp;lt;code&amp;gt;tdata&amp;lt;/code&amp;gt; (write out unit cells for clustering),&lt;br /&gt;
&amp;lt;code&amp;gt;export&amp;lt;/code&amp;gt; (batch MTZ for &#039;&#039;Careless&#039;&#039;), &amp;lt;code&amp;gt;publish&amp;lt;/code&amp;gt; (upload merged files to a&lt;br /&gt;
Google Drive folder), &amp;lt;code&amp;gt;monitor&amp;lt;/code&amp;gt; (resource-usage logging), &amp;lt;code&amp;gt;integrate&amp;lt;/code&amp;gt;&lt;br /&gt;
(on-the-fly integration), &amp;lt;code&amp;gt;prepare&amp;lt;/code&amp;gt; (SpReAD energy binning), and&lt;br /&gt;
&amp;lt;code&amp;gt;lunus&amp;lt;/code&amp;gt; (diffuse-scattering deck). A &amp;lt;code&amp;gt;deltaccint&amp;lt;/code&amp;gt; worker (ΔCC½ lattice&lt;br /&gt;
filtering) can be added after &amp;lt;code&amp;gt;group&amp;lt;/code&amp;gt;. Custom workers can be supplied through the&lt;br /&gt;
&amp;lt;code&amp;gt;XFEL_CUSTOM_WORKER_PATH&amp;lt;/code&amp;gt; environment variable.&lt;br /&gt;
&lt;br /&gt;
== Basic usage ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;cctbx.xfel.merge&amp;lt;/code&amp;gt; is run under MPI:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mpirun cctbx.xfel.merge merge.phil&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A typical &amp;lt;code&amp;gt;merge.phil&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
input.path=&amp;lt;path to data&amp;gt;&lt;br /&gt;
input.experiments_suffix=.expt&lt;br /&gt;
input.reflections_suffix=.refl&lt;br /&gt;
&lt;br /&gt;
filter.algorithm=unit_cell&lt;br /&gt;
filter.unit_cell.value.relative_length_tolerance=0.03&lt;br /&gt;
filter.outlier.min_corr=0.1&lt;br /&gt;
&lt;br /&gt;
select.algorithm=significance_filter&lt;br /&gt;
select.significance_filter.sigma=0.1&lt;br /&gt;
select.significance_filter.min_ct=200&lt;br /&gt;
select.significance_filter.max_ct=300&lt;br /&gt;
&lt;br /&gt;
scaling.model=&amp;lt;model.pdb or model.mtz&amp;gt;&lt;br /&gt;
scaling.resolution_scalar=0.96&lt;br /&gt;
&lt;br /&gt;
merging.d_min=1.8&lt;br /&gt;
merging.error.model=mm24&lt;br /&gt;
merging.merge_anomalous=True&lt;br /&gt;
&lt;br /&gt;
postrefinement.enable=True&lt;br /&gt;
statistics.n_bins=20&lt;br /&gt;
&lt;br /&gt;
output.output_dir=&amp;lt;output folder&amp;gt;&lt;br /&gt;
output.prefix=&amp;lt;prefix for output files&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Explore the parameters with:&lt;br /&gt;
* &amp;lt;code&amp;gt;cctbx.xfel.merge -c&amp;lt;/code&amp;gt; — show configurable parameters&lt;br /&gt;
* &amp;lt;code&amp;gt;cctbx.xfel.merge -c -e 10 -a 2&amp;lt;/code&amp;gt; — show all parameters (expert level 10) with full help text&lt;br /&gt;
&lt;br /&gt;
== Two-stage scaling and merging ==&lt;br /&gt;
&lt;br /&gt;
For large, growing datasets (the mode used by the [[cctbx.xfel GUI]]), it is more efficient to scale&lt;br /&gt;
and post-refine each subset of data &#039;&#039;&#039;once&#039;&#039;&#039;, then merge repeatedly as more data arrive. This is&lt;br /&gt;
done by running the program twice with different step lists.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Stage 1 — scale each subset&#039;&#039;&#039; (stops after per-image work and writes intermediate DIALS files):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dispatch.step_list=input balance model_scaling modify filter scale postrefine \&lt;br /&gt;
    statistics_unitcell statistics_beam model_statistics statistics_resolution&lt;br /&gt;
output.save_experiments_and_reflections=True&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;output.save_experiments_and_reflections=True&amp;lt;/code&amp;gt; dumps the scaled/post-refined data as&lt;br /&gt;
experiment lists and reflection tables that the merge stage can read back in.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Stage 2 — merge the scaled subsets&#039;&#039;&#039; (add an &amp;lt;code&amp;gt;input.path&amp;lt;/code&amp;gt; for each finished subset):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dispatch.step_list=input model_scaling statistics_unitcell statistics_beam \&lt;br /&gt;
    model_statistics statistics_resolution group errors_merge statistics_intensity \&lt;br /&gt;
    merge statistics_intensity_cxi&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Merging without a reference (bootstrap / mark1) ==&lt;br /&gt;
&lt;br /&gt;
If no scaling/merging reference is available, use a bootstrap procedure. First run the&lt;br /&gt;
&amp;lt;code&amp;gt;mark1&amp;lt;/code&amp;gt; algorithm, which simply averages the data (all per-image scale factors = 1, no&lt;br /&gt;
post-refinement), specifying the target cell and symmetry explicitly:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
scaling.algorithm=mark1&lt;br /&gt;
scaling.unit_cell=&amp;lt;unit cell&amp;gt;&lt;br /&gt;
scaling.space_group=&amp;lt;space group&amp;gt;&lt;br /&gt;
merging.error.model=errors_from_sample_residuals&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The resulting MTZ is then used as the reference (&amp;lt;code&amp;gt;scaling.model=&amp;lt;/code&amp;gt;) for subsequent regular&lt;br /&gt;
merges. Iterate a few cycles; CC½ typically improves and converges over the first few rounds.&lt;br /&gt;
&lt;br /&gt;
== Important parameters ==&lt;br /&gt;
&lt;br /&gt;
Parameters are given by their full PHIL path with defaults in parentheses. The program exposes many&lt;br /&gt;
more parameters (see &amp;lt;code&amp;gt;-c -e 10 -a 2&amp;lt;/code&amp;gt;); those below are the ones most commonly set.&lt;br /&gt;
&lt;br /&gt;
=== Input ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.path&amp;lt;/code&amp;gt; || None || Path(s) to the integrated data — a folder, several folders, or individual files; wildcards allowed; may be repeated. Matching &amp;lt;code&amp;gt;.expt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;.refl&amp;lt;/code&amp;gt; files must both be present.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.experiments_suffix&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;_integrated.expt&amp;lt;/code&amp;gt; || Only load experiment files ending with this suffix.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.reflections_suffix&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;_integrated.refl&amp;lt;/code&amp;gt; || Only load reflection files ending with this suffix.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.parallel_file_load.method&amp;lt;/code&amp;gt; || uniform || &amp;lt;code&amp;gt;uniform&amp;lt;/code&amp;gt; spreads input files evenly over all ranks; &amp;lt;code&amp;gt;node_memory&amp;lt;/code&amp;gt; distributes so per-node memory limits are respected.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.alist.file&amp;lt;/code&amp;gt; || None || Path to a text file of experiment tags or filenames; combined with &amp;lt;code&amp;gt;input.alist.op=keep|reject&amp;lt;/code&amp;gt; to merge only (or exclude) a specified subset.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.persistent_refl_cols&amp;lt;/code&amp;gt; || None || Reflection-table columns to preserve through the pruning steps (and into saved tables).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Filtering whole experiments (&amp;lt;code&amp;gt;filter&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;filter&amp;lt;/code&amp;gt; section accepts or rejects &#039;&#039;&#039;entire experiments&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.algorithm&amp;lt;/code&amp;gt; || (none) || One or more of &amp;lt;code&amp;gt;n_obs&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;resolution&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;unit_cell&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;energy&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bootstrap&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;experiment_prefix&amp;lt;/code&amp;gt;. Nothing is filtered unless listed.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.unit_cell.algorithm&amp;lt;/code&amp;gt; || value || How to restrict unit cells: &amp;lt;code&amp;gt;value&amp;lt;/code&amp;gt; (compare to a target), &amp;lt;code&amp;gt;range&amp;lt;/code&amp;gt;, or &amp;lt;code&amp;gt;cluster&amp;lt;/code&amp;gt; (use a precomputed covariance clustering).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.unit_cell.value.relative_length_tolerance&amp;lt;/code&amp;gt; || 0.1 || Fractional deviation of cell edge lengths allowed vs. the target cell. Often tightened (e.g. 0.03).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.unit_cell.value.absolute_angle_tolerance&amp;lt;/code&amp;gt; || 2.0 || Allowed cell-angle deviation (degrees) vs. the target.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.unit_cell.value.target_unit_cell&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;target_space_group&amp;lt;/code&amp;gt; || Auto || Target cell/symmetry; &amp;lt;code&amp;gt;Auto&amp;lt;/code&amp;gt; uses the scaling model.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.outlier.min_corr&amp;lt;/code&amp;gt; || 0.1 || Minimum correlation of an image&#039;s intensities to the reference model; images below this are rejected. Only applied when a scaling model is present. Use &amp;lt;code&amp;gt;-1&amp;lt;/code&amp;gt; to accept all images regardless of correlation.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.resolution.d_min&amp;lt;/code&amp;gt; || None || Reject an experiment unless some of its reflections extend beyond this resolution.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Selecting individual reflections (&amp;lt;code&amp;gt;select&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;select&amp;lt;/code&amp;gt; section accepts or rejects &#039;&#039;&#039;individual reflections&#039;&#039;&#039; (contrast with&lt;br /&gt;
&amp;lt;code&amp;gt;filter&amp;lt;/code&amp;gt;, which acts on whole experiments).&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;select.algorithm&amp;lt;/code&amp;gt; || (none) || One or more of &amp;lt;code&amp;gt;significance_filter&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;panel&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cspad_sensor&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;isolation_forest&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;target_energy&amp;lt;/code&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;select.significance_filter.sigma&amp;lt;/code&amp;gt; || 0.5 || Trim each lattice at the resolution where the binned ⟨I/σ⟩ drops below this value.  Often reduced to 0.1.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;select.significance_filter.min_ct&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;max_ct&amp;lt;/code&amp;gt; || 10 / 50 || Target minimum/maximum mean reflections per resolution bin when choosing the number of bins. For large unit cells these are often raised (e.g. 200/300); for small cells, use the defaults.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Modifying intensities (&amp;lt;code&amp;gt;modify&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;modify.algorithm&amp;lt;/code&amp;gt; || polarization || Per-reflection corrections to apply (default applies the polarization correction).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;modify.cosym&amp;lt;/code&amp;gt; || — || Resolve an indexing ambiguity across the ensemble using the Gildea/Winter (Brehm/Diederichs) cosym method, optionally anchored to &amp;lt;code&amp;gt;scaling.model&amp;lt;/code&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;modify.reindex_to_reference&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;reindex_to_abc&amp;lt;/code&amp;gt; || — || Alternative re-indexing operators (to a reference model, or an explicit operator).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Scaling (&amp;lt;code&amp;gt;scaling&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;scaling.model&amp;lt;/code&amp;gt; || None || Reference dataset: a PDB file (uses the CRYST1 cell and computes model intensities, including bulk solvent) or an MTZ from a previous cycle. Required for &amp;lt;code&amp;gt;mark0&amp;lt;/code&amp;gt; scaling.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;scaling.algorithm&amp;lt;/code&amp;gt; || mark0 || &amp;lt;code&amp;gt;mark0&amp;lt;/code&amp;gt;: per-image scaling against the reference. &amp;lt;code&amp;gt;mark1&amp;lt;/code&amp;gt;: no scaling, just Monte-Carlo averaging (all scale factors = 1) — used for reference-free bootstrap.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;scaling.unit_cell&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;scaling.space_group&amp;lt;/code&amp;gt; || None || Cell/symmetry to use when no model is provided (i.e. &amp;lt;code&amp;gt;mark1&amp;lt;/code&amp;gt;).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;scaling.resolution_scalar&amp;lt;/code&amp;gt; || 0.969 || &amp;lt;code&amp;gt;merging.d_min&amp;lt;/code&amp;gt; is multiplied by this when deciding which reflections fall within the resolution limit, generating a few extra reference reflections to account for per-shot cell variation (e.g. set 0.96 for a few more).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;scaling.mtz.mtz_column_F&amp;lt;/code&amp;gt; || fobs || Column name in the reference MTZ containing the reference structure factors (intensities or amplitudes).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Post-refinement (&amp;lt;code&amp;gt;postrefinement&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;postrefinement.enable&amp;lt;/code&amp;gt; || True || Enable post-refinement of per-image parameters/partialities (Sauter 2015).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;postrefinement.algorithm&amp;lt;/code&amp;gt; || rs || Post-refinement protocol: &amp;lt;code&amp;gt;rs&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;rs2&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;rs_hybrid&amp;lt;/code&amp;gt;, or &amp;lt;code&amp;gt;eta_deff&amp;lt;/code&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Merging and error model (&amp;lt;code&amp;gt;merging&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;merging.d_min&amp;lt;/code&amp;gt; || None || High-resolution limit for scaling and merging.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;merging.d_max&amp;lt;/code&amp;gt; || None || Low-resolution limit (currently affects only CCiso).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;merging.merge_anomalous&amp;lt;/code&amp;gt; || False || &amp;lt;code&amp;gt;True&amp;lt;/code&amp;gt; merges Bijvoet mates together (higher multiplicity); &amp;lt;code&amp;gt;False&amp;lt;/code&amp;gt; keeps them separate to preserve the anomalous signal.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;merging.minimum_multiplicity&amp;lt;/code&amp;gt; || 2 || Do not produce a merged structure factor for HKLs measured fewer than this many times.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;merging.error.model&amp;lt;/code&amp;gt; || mm24 || Merged-sigma error model: &amp;lt;code&amp;gt;mm24&amp;lt;/code&amp;gt; (Mittan-Moreau 2025, current default), &amp;lt;code&amp;gt;ev11&amp;lt;/code&amp;gt; (Evans 2011 / sdfac-refine), &amp;lt;code&amp;gt;ha14&amp;lt;/code&amp;gt;, or &amp;lt;code&amp;gt;errors_from_sample_residuals&amp;lt;/code&amp;gt; (no refined error terms — used with &amp;lt;code&amp;gt;mark1&amp;lt;/code&amp;gt; bootstrap).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;merging.set_average_unit_cell&amp;lt;/code&amp;gt; || True || Output MTZ adopts the average unit cell of the data rather than the reference model&#039;s cell.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Statistics (&amp;lt;code&amp;gt;statistics&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;statistics.n_bins&amp;lt;/code&amp;gt; || 10 || Number of resolution bins in the statistics tables.  Often raised to 20.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;statistics.cciso.mtz_file&amp;lt;/code&amp;gt; || None || Isomorphous reference structure factors for R&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt; / CC&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;statistics.report_ML&amp;lt;/code&amp;gt; || True || Report per-frame max-likelihood attributes (domain size, mosaicity).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Output (&amp;lt;code&amp;gt;output&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.output_dir&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;.&amp;lt;/code&amp;gt; || Directory for output files (created if it does not exist).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.prefix&amp;lt;/code&amp;gt; || iobs || Prefix prepended to all output file names.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.save_experiments_and_reflections&amp;lt;/code&amp;gt; || False || Dump the final experiments/reflections from the last worker as DIALS files — used for the two-stage scale-then-merge workflow.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.do_timing&amp;lt;/code&amp;gt; || False || Log elapsed time per execution step.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.expanded_bookkeeping&amp;lt;/code&amp;gt; || False || Store extra provenance columns (input file/reflection indices, odd/even flag, original id) in the saved reflection tables.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Multiprocessing (&amp;lt;code&amp;gt;mp&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mp.method&amp;lt;/code&amp;gt; || mpi || Multiprocessing method (only &amp;lt;code&amp;gt;mpi&amp;lt;/code&amp;gt; is currently supported).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mp.debug.cProfile&amp;lt;/code&amp;gt; || False || Enable code profiling; a &amp;lt;code&amp;gt;.prof&amp;lt;/code&amp;gt; file is written per rank.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Output files ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;merge&amp;lt;/code&amp;gt; worker gathers all HKLs at rank 0 and writes three MTZ files, prefixed with&lt;br /&gt;
&amp;lt;code&amp;gt;output.prefix&amp;lt;/code&amp;gt; (default &amp;lt;code&amp;gt;iobs&amp;lt;/code&amp;gt;):&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;amp;lt;prefix&amp;amp;gt;_all.mtz&amp;lt;/code&amp;gt; — the merged dataset using all observations (the main result for structure solution)&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;amp;lt;prefix&amp;amp;gt;_odd.mtz&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;&amp;amp;lt;prefix&amp;amp;gt;_even.mtz&amp;lt;/code&amp;gt; — the two half-datasets used for CC½ and related half-dataset statistics&lt;br /&gt;
&lt;br /&gt;
A main log records the per-step progress and the merging statistics tables by resolution bin:&lt;br /&gt;
completeness, multiplicity and ⟨I/σ⟩, plus the &amp;quot;Table of Scaling Results&amp;quot; reporting CC½ (the&lt;br /&gt;
half-dataset correlation, labelled &amp;quot;CC int&amp;quot;), CC&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt;, R&amp;lt;sub&amp;gt;int&amp;lt;/sub&amp;gt;, R&amp;lt;sub&amp;gt;split&amp;lt;/sub&amp;gt;&lt;br /&gt;
and R&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt;.  The merged MTZ can optionally be&lt;br /&gt;
uploaded to a shared [https://github.com/cctbx/cctbx_project/tree/master/xfel/merging/application/publish Google Drive folder] by adding the &amp;lt;code&amp;gt;publish&amp;lt;/code&amp;gt; worker.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
* Sauter NK (2015). &#039;&#039;J Synchrotron Radiat&#039;&#039; &#039;&#039;&#039;22&#039;&#039;&#039;, 239–48. (post-refinement)&lt;br /&gt;
* Uervirojnangkoorn M, &#039;&#039;et al.&#039;&#039; (2015). &#039;&#039;eLife&#039;&#039; 10.7554/eLife.05421. (PRIME / bootstrap)&lt;br /&gt;
* Brewster AS, &#039;&#039;et al.&#039;&#039; (2018). &#039;&#039;Acta Cryst.&#039;&#039; D &#039;&#039;&#039;74&#039;&#039;&#039;, 877–894.&lt;br /&gt;
* Brewster AS, &#039;&#039;et al.&#039;&#039; (2019a). &#039;&#039;Computational Crystallography Newsletter&#039;&#039; &#039;&#039;&#039;10&#039;&#039;&#039;, 22–39. (XFEL GUI)&lt;br /&gt;
* Brewster AS, &#039;&#039;et al.&#039;&#039; (2019b). &#039;&#039;Acta Cryst.&#039;&#039; D &#039;&#039;&#039;75&#039;&#039;&#039;, 959–968. (error models)&lt;br /&gt;
* Mittan-Moreau (2025). (mm24 error model)&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
* [[dials.stills_process]] — produces the integrated data that &amp;lt;code&amp;gt;cctbx.xfel.merge&amp;lt;/code&amp;gt; consumes&lt;br /&gt;
* [[cctbx.xfel GUI]] — orchestrates separate scaling and repeated merging as data are collected&lt;br /&gt;
* The program README at &amp;lt;code&amp;gt;xfel/merging/README.md&amp;lt;/code&amp;gt; in cctbx_project&lt;/div&gt;</summary>
		<author><name>Aaron</name></author>
	</entry>
	<entry>
		<id>http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Cctbx.xfel.merge&amp;diff=1784</id>
		<title>Cctbx.xfel.merge</title>
		<link rel="alternate" type="text/html" href="http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Cctbx.xfel.merge&amp;diff=1784"/>
		<updated>2026-08-21T23:25:39Z</updated>

		<summary type="html">&lt;p&gt;Aaron: /* Statistics (statistics) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= &#039;&#039;cctbx.xfel.merge&#039;&#039; =&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;cctbx.xfel.merge&#039;&#039;&#039;&#039;&#039; is the scaling, post-refinement and merging program of cctbx.xfel. It takes&lt;br /&gt;
the per-image integrated results produced by &#039;&#039;[[dials.stills_process]]&#039;&#039; — one crystal per still shot —&lt;br /&gt;
and reduces the whole ensemble to a single set of merged structure-factor intensities (an MTZ file)&lt;br /&gt;
suitable for structure solution and refinement, together with the crystallographic quality&lt;br /&gt;
statistics (completeness, multiplicity, ⟨I/σ⟩, CC½, CC&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt;, R-factors, etc.).&lt;br /&gt;
&lt;br /&gt;
Because serial datasets routinely contain tens of thousands to millions of still shots,&lt;br /&gt;
&amp;lt;code&amp;gt;cctbx.xfel.merge&amp;lt;/code&amp;gt; is built from the ground up to run under MPI across many nodes. It is&lt;br /&gt;
almost always launched with &amp;lt;code&amp;gt;mpirun&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;srun&amp;lt;/code&amp;gt;.  Note that MPI uses the term &#039;ranks&#039;&lt;br /&gt;
to distinguish independent processes that are running across one or more nodes.&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;cctbx.xfel.merge&amp;lt;/code&amp;gt; is organized as a sequence of &#039;&#039;&#039;workers&#039;&#039;&#039;. Each worker performs one&lt;br /&gt;
task — reading data, applying a correction, filtering, scaling, post-refining, computing a statistic,&lt;br /&gt;
or merging — and passes its (possibly modified) experiments and reflections on to the next worker.&lt;br /&gt;
The list of workers to run is the &amp;quot;step list&amp;quot;, and it is fully configurable: you can add, remove or&lt;br /&gt;
reorder steps with &amp;lt;code&amp;gt;dispatch.step_list&amp;lt;/code&amp;gt;. This is what makes the program flexible enough to&lt;br /&gt;
scale-and-merge in one pass, to scale subsets separately and merge later, or to run a reference-free&lt;br /&gt;
bootstrap.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;default&#039;&#039;&#039; step list is:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! # !! Worker !! Purpose&lt;br /&gt;
|-&lt;br /&gt;
| 1 || &amp;lt;code&amp;gt;input&amp;lt;/code&amp;gt; || Read integrated experiments (&amp;lt;code&amp;gt;.expt&amp;lt;/code&amp;gt;) and reflections (&amp;lt;code&amp;gt;.refl&amp;lt;/code&amp;gt;) from disk in DIALS format.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || &amp;lt;code&amp;gt;balance&amp;lt;/code&amp;gt; || Redistribute the input load evenly across MPI ranks (needed when there are fewer or more input files than ranks).&lt;br /&gt;
|-&lt;br /&gt;
| 3 || &amp;lt;code&amp;gt;model_scaling&amp;lt;/code&amp;gt; || Build the full Miller list, model intensities from the reference, and the resolution binner used for scaling and post-refinement.&lt;br /&gt;
|-&lt;br /&gt;
| 4 || &amp;lt;code&amp;gt;modify&amp;lt;/code&amp;gt; || Apply per-reflection modifications, e.g. polarization correction (and optionally re-indexing to resolve indexing ambiguity — see &amp;lt;code&amp;gt;modify.cosym&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;reindex_to_reference&amp;lt;/code&amp;gt;).&lt;br /&gt;
|-&lt;br /&gt;
| 5 || &amp;lt;code&amp;gt;filter&amp;lt;/code&amp;gt; || Reject whole experiments (or reflections) by resolution, unit cell, correlation to the reference, energy, etc.&lt;br /&gt;
|-&lt;br /&gt;
| 6 || &amp;lt;code&amp;gt;scale&amp;lt;/code&amp;gt; || Scale each lattice to the reference dataset (&amp;lt;code&amp;gt;mark0&amp;lt;/code&amp;gt;) or simply average (&amp;lt;code&amp;gt;mark1&amp;lt;/code&amp;gt;).&lt;br /&gt;
|-&lt;br /&gt;
| 7 || &amp;lt;code&amp;gt;postrefine&amp;lt;/code&amp;gt; || Post-refine per-image crystal parameters and partialities (Sauter 2015).&lt;br /&gt;
|-&lt;br /&gt;
| 8 || &amp;lt;code&amp;gt;statistics_unitcell&amp;lt;/code&amp;gt; || Determine and store the average unit cell.&lt;br /&gt;
|-&lt;br /&gt;
| 9 || &amp;lt;code&amp;gt;statistics_beam&amp;lt;/code&amp;gt; || Determine and store the average wavelength.&lt;br /&gt;
|-&lt;br /&gt;
| 10 || &amp;lt;code&amp;gt;model_statistics&amp;lt;/code&amp;gt; || Rebuild the Miller list / binner for statistics (may use the average unit cell).&lt;br /&gt;
|-&lt;br /&gt;
| 11 || &amp;lt;code&amp;gt;statistics_resolution&amp;lt;/code&amp;gt; || Per-crystal resolution statistics.&lt;br /&gt;
|-&lt;br /&gt;
| 12 || &amp;lt;code&amp;gt;group&amp;lt;/code&amp;gt; || Redistribute reflections across ranks so that every observation of a given HKL is gathered on the same rank prior to merging.&lt;br /&gt;
|-&lt;br /&gt;
| 13 || &amp;lt;code&amp;gt;errors_merge&amp;lt;/code&amp;gt; || Correct the merged error estimates with a per-HKL error model (e.g. Ev11, Brewster 2019b, or MM24 (the default), Mittan-Moreau (2025)).&lt;br /&gt;
|-&lt;br /&gt;
| 14 || &amp;lt;code&amp;gt;statistics_intensity&amp;lt;/code&amp;gt; || Intensity statistics by resolution.&lt;br /&gt;
|-&lt;br /&gt;
| 15 || &amp;lt;code&amp;gt;merge&amp;lt;/code&amp;gt; || Merge symmetry-equivalent intensities, gather all HKLs at rank 0, and write &amp;quot;odd&amp;quot;, &amp;quot;even&amp;quot; and &amp;quot;all&amp;quot; MTZ files.&lt;br /&gt;
|-&lt;br /&gt;
| 16 || &amp;lt;code&amp;gt;statistics_intensity_cxi&amp;lt;/code&amp;gt; || Correlation and R-factor statistics (ported from cxi.merge): the &amp;quot;Table of Scaling Results&amp;quot; — CC½ (half-dataset correlation, labelled &amp;quot;CC int&amp;quot;), CC&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt;, R&amp;lt;sub&amp;gt;int&amp;lt;/sub&amp;gt;, R&amp;lt;sub&amp;gt;split&amp;lt;/sub&amp;gt;, R&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Additional, non-default workers are available and can be&lt;br /&gt;
inserted into the step list, including &amp;lt;code&amp;gt;tdata&amp;lt;/code&amp;gt; (write out unit cells for clustering),&lt;br /&gt;
&amp;lt;code&amp;gt;export&amp;lt;/code&amp;gt; (batch MTZ for &#039;&#039;Careless&#039;&#039;), &amp;lt;code&amp;gt;publish&amp;lt;/code&amp;gt; (upload merged files to a&lt;br /&gt;
Google Drive folder), &amp;lt;code&amp;gt;monitor&amp;lt;/code&amp;gt; (resource-usage logging), &amp;lt;code&amp;gt;integrate&amp;lt;/code&amp;gt;&lt;br /&gt;
(on-the-fly integration), &amp;lt;code&amp;gt;prepare&amp;lt;/code&amp;gt; (SpReAD energy binning), and&lt;br /&gt;
&amp;lt;code&amp;gt;lunus&amp;lt;/code&amp;gt; (diffuse-scattering deck). A &amp;lt;code&amp;gt;deltaccint&amp;lt;/code&amp;gt; worker (ΔCC½ lattice&lt;br /&gt;
filtering) can be added after &amp;lt;code&amp;gt;group&amp;lt;/code&amp;gt;. Custom workers can be supplied through the&lt;br /&gt;
&amp;lt;code&amp;gt;XFEL_CUSTOM_WORKER_PATH&amp;lt;/code&amp;gt; environment variable.&lt;br /&gt;
&lt;br /&gt;
== Basic usage ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;cctbx.xfel.merge&amp;lt;/code&amp;gt; is run under MPI:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mpirun cctbx.xfel.merge merge.phil&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A typical &amp;lt;code&amp;gt;merge.phil&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
input.path=&amp;lt;path to data&amp;gt;&lt;br /&gt;
input.experiments_suffix=.expt&lt;br /&gt;
input.reflections_suffix=.refl&lt;br /&gt;
&lt;br /&gt;
filter.algorithm=unit_cell&lt;br /&gt;
filter.unit_cell.value.relative_length_tolerance=0.03&lt;br /&gt;
filter.outlier.min_corr=0.1&lt;br /&gt;
&lt;br /&gt;
select.algorithm=significance_filter&lt;br /&gt;
select.significance_filter.sigma=0.1&lt;br /&gt;
select.significance_filter.min_ct=200&lt;br /&gt;
select.significance_filter.max_ct=300&lt;br /&gt;
&lt;br /&gt;
scaling.model=&amp;lt;model.pdb or model.mtz&amp;gt;&lt;br /&gt;
scaling.resolution_scalar=0.96&lt;br /&gt;
&lt;br /&gt;
merging.d_min=1.8&lt;br /&gt;
merging.error.model=mm24&lt;br /&gt;
merging.merge_anomalous=True&lt;br /&gt;
&lt;br /&gt;
postrefinement.enable=True&lt;br /&gt;
statistics.n_bins=20&lt;br /&gt;
&lt;br /&gt;
output.do_timing=True&lt;br /&gt;
output.output_dir=&amp;lt;output folder&amp;gt;&lt;br /&gt;
output.prefix=&amp;lt;prefix for output files&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Explore the parameters with:&lt;br /&gt;
* &amp;lt;code&amp;gt;cctbx.xfel.merge -c&amp;lt;/code&amp;gt; — show configurable parameters&lt;br /&gt;
* &amp;lt;code&amp;gt;cctbx.xfel.merge -c -e 10 -a 2&amp;lt;/code&amp;gt; — show all parameters (expert level 10) with full help text&lt;br /&gt;
&lt;br /&gt;
== Two-stage scaling and merging ==&lt;br /&gt;
&lt;br /&gt;
For large, growing datasets (the mode used by the [[cctbx.xfel GUI]]), it is more efficient to scale&lt;br /&gt;
and post-refine each subset of data &#039;&#039;&#039;once&#039;&#039;&#039;, then merge repeatedly as more data arrive. This is&lt;br /&gt;
done by running the program twice with different step lists.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Stage 1 — scale each subset&#039;&#039;&#039; (stops after per-image work and writes intermediate DIALS files):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dispatch.step_list=input balance model_scaling modify filter scale postrefine \&lt;br /&gt;
    statistics_unitcell statistics_beam model_statistics statistics_resolution&lt;br /&gt;
output.save_experiments_and_reflections=True&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;output.save_experiments_and_reflections=True&amp;lt;/code&amp;gt; dumps the scaled/post-refined data as&lt;br /&gt;
experiment lists and reflection tables that the merge stage can read back in.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Stage 2 — merge the scaled subsets&#039;&#039;&#039; (add an &amp;lt;code&amp;gt;input.path&amp;lt;/code&amp;gt; for each finished subset):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dispatch.step_list=input model_scaling statistics_unitcell statistics_beam \&lt;br /&gt;
    model_statistics statistics_resolution group errors_merge statistics_intensity \&lt;br /&gt;
    merge statistics_intensity_cxi&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Merging without a reference (bootstrap / mark1) ==&lt;br /&gt;
&lt;br /&gt;
If no scaling/merging reference is available, use a bootstrap procedure. First run the&lt;br /&gt;
&amp;lt;code&amp;gt;mark1&amp;lt;/code&amp;gt; algorithm, which simply averages the data (all per-image scale factors = 1, no&lt;br /&gt;
post-refinement), specifying the target cell and symmetry explicitly:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
scaling.algorithm=mark1&lt;br /&gt;
scaling.unit_cell=&amp;lt;unit cell&amp;gt;&lt;br /&gt;
scaling.space_group=&amp;lt;space group&amp;gt;&lt;br /&gt;
merging.error.model=errors_from_sample_residuals&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The resulting MTZ is then used as the reference (&amp;lt;code&amp;gt;scaling.model=&amp;lt;/code&amp;gt;) for subsequent regular&lt;br /&gt;
merges. Iterate a few cycles; CC½ typically improves and converges over the first few rounds.&lt;br /&gt;
&lt;br /&gt;
== Important parameters ==&lt;br /&gt;
&lt;br /&gt;
Parameters are given by their full PHIL path with defaults in parentheses. The program exposes many&lt;br /&gt;
more parameters (see &amp;lt;code&amp;gt;-c -e 10 -a 2&amp;lt;/code&amp;gt;); those below are the ones most commonly set.&lt;br /&gt;
&lt;br /&gt;
=== Input ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.path&amp;lt;/code&amp;gt; || None || Path(s) to the integrated data — a folder, several folders, or individual files; wildcards allowed; may be repeated. Matching &amp;lt;code&amp;gt;.expt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;.refl&amp;lt;/code&amp;gt; files must both be present.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.experiments_suffix&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;_integrated.expt&amp;lt;/code&amp;gt; || Only load experiment files ending with this suffix.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.reflections_suffix&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;_integrated.refl&amp;lt;/code&amp;gt; || Only load reflection files ending with this suffix.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.parallel_file_load.method&amp;lt;/code&amp;gt; || uniform || &amp;lt;code&amp;gt;uniform&amp;lt;/code&amp;gt; spreads input files evenly over all ranks; &amp;lt;code&amp;gt;node_memory&amp;lt;/code&amp;gt; distributes so per-node memory limits are respected.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.alist.file&amp;lt;/code&amp;gt; || None || Path to a text file of experiment tags or filenames; combined with &amp;lt;code&amp;gt;input.alist.op=keep|reject&amp;lt;/code&amp;gt; to merge only (or exclude) a specified subset.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.persistent_refl_cols&amp;lt;/code&amp;gt; || None || Reflection-table columns to preserve through the pruning steps (and into saved tables).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Filtering whole experiments (&amp;lt;code&amp;gt;filter&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;filter&amp;lt;/code&amp;gt; section accepts or rejects &#039;&#039;&#039;entire experiments&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.algorithm&amp;lt;/code&amp;gt; || (none) || One or more of &amp;lt;code&amp;gt;n_obs&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;resolution&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;unit_cell&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;energy&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bootstrap&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;experiment_prefix&amp;lt;/code&amp;gt;. Nothing is filtered unless listed.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.unit_cell.algorithm&amp;lt;/code&amp;gt; || value || How to restrict unit cells: &amp;lt;code&amp;gt;value&amp;lt;/code&amp;gt; (compare to a target), &amp;lt;code&amp;gt;range&amp;lt;/code&amp;gt;, or &amp;lt;code&amp;gt;cluster&amp;lt;/code&amp;gt; (use a precomputed covariance clustering).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.unit_cell.value.relative_length_tolerance&amp;lt;/code&amp;gt; || 0.1 || Fractional deviation of cell edge lengths allowed vs. the target cell. Often tightened (e.g. 0.03).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.unit_cell.value.absolute_angle_tolerance&amp;lt;/code&amp;gt; || 2.0 || Allowed cell-angle deviation (degrees) vs. the target.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.unit_cell.value.target_unit_cell&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;target_space_group&amp;lt;/code&amp;gt; || Auto || Target cell/symmetry; &amp;lt;code&amp;gt;Auto&amp;lt;/code&amp;gt; uses the scaling model.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.outlier.min_corr&amp;lt;/code&amp;gt; || 0.1 || Minimum correlation of an image&#039;s intensities to the reference model; images below this are rejected. Only applied when a scaling model is present. Use &amp;lt;code&amp;gt;-1&amp;lt;/code&amp;gt; to accept all images regardless of correlation.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.resolution.d_min&amp;lt;/code&amp;gt; || None || Reject an experiment unless some of its reflections extend beyond this resolution.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Selecting individual reflections (&amp;lt;code&amp;gt;select&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;select&amp;lt;/code&amp;gt; section accepts or rejects &#039;&#039;&#039;individual reflections&#039;&#039;&#039; (contrast with&lt;br /&gt;
&amp;lt;code&amp;gt;filter&amp;lt;/code&amp;gt;, which acts on whole experiments).&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;select.algorithm&amp;lt;/code&amp;gt; || (none) || One or more of &amp;lt;code&amp;gt;significance_filter&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;panel&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cspad_sensor&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;isolation_forest&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;target_energy&amp;lt;/code&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;select.significance_filter.sigma&amp;lt;/code&amp;gt; || 0.5 || Trim each lattice at the resolution where the binned ⟨I/σ⟩ drops below this value.  Often reduced to 0.1.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;select.significance_filter.min_ct&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;max_ct&amp;lt;/code&amp;gt; || 10 / 50 || Target minimum/maximum mean reflections per resolution bin when choosing the number of bins. For large unit cells these are often raised (e.g. 200/300); for small cells, use the defaults.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Modifying intensities (&amp;lt;code&amp;gt;modify&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;modify.algorithm&amp;lt;/code&amp;gt; || polarization || Per-reflection corrections to apply (default applies the polarization correction).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;modify.cosym&amp;lt;/code&amp;gt; || — || Resolve an indexing ambiguity across the ensemble using the Gildea/Winter (Brehm/Diederichs) cosym method, optionally anchored to &amp;lt;code&amp;gt;scaling.model&amp;lt;/code&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;modify.reindex_to_reference&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;reindex_to_abc&amp;lt;/code&amp;gt; || — || Alternative re-indexing operators (to a reference model, or an explicit operator).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Scaling (&amp;lt;code&amp;gt;scaling&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;scaling.model&amp;lt;/code&amp;gt; || None || Reference dataset: a PDB file (uses the CRYST1 cell and computes model intensities, including bulk solvent) or an MTZ from a previous cycle. Required for &amp;lt;code&amp;gt;mark0&amp;lt;/code&amp;gt; scaling.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;scaling.algorithm&amp;lt;/code&amp;gt; || mark0 || &amp;lt;code&amp;gt;mark0&amp;lt;/code&amp;gt;: per-image scaling against the reference. &amp;lt;code&amp;gt;mark1&amp;lt;/code&amp;gt;: no scaling, just Monte-Carlo averaging (all scale factors = 1) — used for reference-free bootstrap.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;scaling.unit_cell&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;scaling.space_group&amp;lt;/code&amp;gt; || None || Cell/symmetry to use when no model is provided (i.e. &amp;lt;code&amp;gt;mark1&amp;lt;/code&amp;gt;).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;scaling.resolution_scalar&amp;lt;/code&amp;gt; || 0.969 || &amp;lt;code&amp;gt;merging.d_min&amp;lt;/code&amp;gt; is multiplied by this when deciding which reflections fall within the resolution limit, generating a few extra reference reflections to account for per-shot cell variation (e.g. set 0.96 for a few more).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;scaling.mtz.mtz_column_F&amp;lt;/code&amp;gt; || fobs || Column name in the reference MTZ containing the reference structure factors (intensities or amplitudes).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Post-refinement (&amp;lt;code&amp;gt;postrefinement&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;postrefinement.enable&amp;lt;/code&amp;gt; || True || Enable post-refinement of per-image parameters/partialities (Sauter 2015).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;postrefinement.algorithm&amp;lt;/code&amp;gt; || rs || Post-refinement protocol: &amp;lt;code&amp;gt;rs&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;rs2&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;rs_hybrid&amp;lt;/code&amp;gt;, or &amp;lt;code&amp;gt;eta_deff&amp;lt;/code&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Merging and error model (&amp;lt;code&amp;gt;merging&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;merging.d_min&amp;lt;/code&amp;gt; || None || High-resolution limit for scaling and merging.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;merging.d_max&amp;lt;/code&amp;gt; || None || Low-resolution limit (currently affects only CCiso).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;merging.merge_anomalous&amp;lt;/code&amp;gt; || False || &amp;lt;code&amp;gt;True&amp;lt;/code&amp;gt; merges Bijvoet mates together (higher multiplicity); &amp;lt;code&amp;gt;False&amp;lt;/code&amp;gt; keeps them separate to preserve the anomalous signal.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;merging.minimum_multiplicity&amp;lt;/code&amp;gt; || 2 || Do not produce a merged structure factor for HKLs measured fewer than this many times.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;merging.error.model&amp;lt;/code&amp;gt; || mm24 || Merged-sigma error model: &amp;lt;code&amp;gt;mm24&amp;lt;/code&amp;gt; (Mittan-Moreau 2025, current default), &amp;lt;code&amp;gt;ev11&amp;lt;/code&amp;gt; (Evans 2011 / sdfac-refine), &amp;lt;code&amp;gt;ha14&amp;lt;/code&amp;gt;, or &amp;lt;code&amp;gt;errors_from_sample_residuals&amp;lt;/code&amp;gt; (no refined error terms — used with &amp;lt;code&amp;gt;mark1&amp;lt;/code&amp;gt; bootstrap).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;merging.set_average_unit_cell&amp;lt;/code&amp;gt; || True || Output MTZ adopts the average unit cell of the data rather than the reference model&#039;s cell.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Statistics (&amp;lt;code&amp;gt;statistics&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;statistics.n_bins&amp;lt;/code&amp;gt; || 10 || Number of resolution bins in the statistics tables.  Often raised to 20.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;statistics.cciso.mtz_file&amp;lt;/code&amp;gt; || None || Isomorphous reference structure factors for R&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt; / CC&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;statistics.report_ML&amp;lt;/code&amp;gt; || True || Report per-frame max-likelihood attributes (domain size, mosaicity).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Output (&amp;lt;code&amp;gt;output&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.output_dir&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;.&amp;lt;/code&amp;gt; || Directory for output files (created if it does not exist).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.prefix&amp;lt;/code&amp;gt; || iobs || Prefix prepended to all output file names.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.save_experiments_and_reflections&amp;lt;/code&amp;gt; || False || Dump the final experiments/reflections from the last worker as DIALS files — used for the two-stage scale-then-merge workflow.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.do_timing&amp;lt;/code&amp;gt; || False || Log elapsed time per execution step.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.expanded_bookkeeping&amp;lt;/code&amp;gt; || False || Store extra provenance columns (input file/reflection indices, odd/even flag, original id) in the saved reflection tables.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Multiprocessing (&amp;lt;code&amp;gt;mp&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mp.method&amp;lt;/code&amp;gt; || mpi || Multiprocessing method (only &amp;lt;code&amp;gt;mpi&amp;lt;/code&amp;gt; is currently supported).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mp.debug.cProfile&amp;lt;/code&amp;gt; || False || Enable code profiling; a &amp;lt;code&amp;gt;.prof&amp;lt;/code&amp;gt; file is written per rank.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Output files ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;merge&amp;lt;/code&amp;gt; worker gathers all HKLs at rank 0 and writes three MTZ files, prefixed with&lt;br /&gt;
&amp;lt;code&amp;gt;output.prefix&amp;lt;/code&amp;gt; (default &amp;lt;code&amp;gt;iobs&amp;lt;/code&amp;gt;):&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;amp;lt;prefix&amp;amp;gt;_all.mtz&amp;lt;/code&amp;gt; — the merged dataset using all observations (the main result for structure solution)&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;amp;lt;prefix&amp;amp;gt;_odd.mtz&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;&amp;amp;lt;prefix&amp;amp;gt;_even.mtz&amp;lt;/code&amp;gt; — the two half-datasets used for CC½ and related half-dataset statistics&lt;br /&gt;
&lt;br /&gt;
A main log records the per-step progress and the merging statistics tables by resolution bin:&lt;br /&gt;
completeness, multiplicity and ⟨I/σ⟩, plus the &amp;quot;Table of Scaling Results&amp;quot; reporting CC½ (the&lt;br /&gt;
half-dataset correlation, labelled &amp;quot;CC int&amp;quot;), CC&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt;, R&amp;lt;sub&amp;gt;int&amp;lt;/sub&amp;gt;, R&amp;lt;sub&amp;gt;split&amp;lt;/sub&amp;gt;&lt;br /&gt;
and R&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt;.  The merged MTZ can optionally be&lt;br /&gt;
uploaded to a shared [https://github.com/cctbx/cctbx_project/tree/master/xfel/merging/application/publish Google Drive folder] by adding the &amp;lt;code&amp;gt;publish&amp;lt;/code&amp;gt; worker.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
* Sauter NK (2015). &#039;&#039;J Synchrotron Radiat&#039;&#039; &#039;&#039;&#039;22&#039;&#039;&#039;, 239–48. (post-refinement)&lt;br /&gt;
* Uervirojnangkoorn M, &#039;&#039;et al.&#039;&#039; (2015). &#039;&#039;eLife&#039;&#039; 10.7554/eLife.05421. (PRIME / bootstrap)&lt;br /&gt;
* Brewster AS, &#039;&#039;et al.&#039;&#039; (2018). &#039;&#039;Acta Cryst.&#039;&#039; D &#039;&#039;&#039;74&#039;&#039;&#039;, 877–894.&lt;br /&gt;
* Brewster AS, &#039;&#039;et al.&#039;&#039; (2019a). &#039;&#039;Computational Crystallography Newsletter&#039;&#039; &#039;&#039;&#039;10&#039;&#039;&#039;, 22–39. (XFEL GUI)&lt;br /&gt;
* Brewster AS, &#039;&#039;et al.&#039;&#039; (2019b). &#039;&#039;Acta Cryst.&#039;&#039; D &#039;&#039;&#039;75&#039;&#039;&#039;, 959–968. (error models)&lt;br /&gt;
* Mittan-Moreau (2025). (mm24 error model)&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
* [[dials.stills_process]] — produces the integrated data that &amp;lt;code&amp;gt;cctbx.xfel.merge&amp;lt;/code&amp;gt; consumes&lt;br /&gt;
* [[cctbx.xfel GUI]] — orchestrates separate scaling and repeated merging as data are collected&lt;br /&gt;
* The program README at &amp;lt;code&amp;gt;xfel/merging/README.md&amp;lt;/code&amp;gt; in cctbx_project&lt;/div&gt;</summary>
		<author><name>Aaron</name></author>
	</entry>
	<entry>
		<id>http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Cctbx.xfel.merge&amp;diff=1783</id>
		<title>Cctbx.xfel.merge</title>
		<link rel="alternate" type="text/html" href="http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Cctbx.xfel.merge&amp;diff=1783"/>
		<updated>2026-08-21T23:24:52Z</updated>

		<summary type="html">&lt;p&gt;Aaron: /* Merging and error model (merging) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= &#039;&#039;cctbx.xfel.merge&#039;&#039; =&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;cctbx.xfel.merge&#039;&#039;&#039;&#039;&#039; is the scaling, post-refinement and merging program of cctbx.xfel. It takes&lt;br /&gt;
the per-image integrated results produced by &#039;&#039;[[dials.stills_process]]&#039;&#039; — one crystal per still shot —&lt;br /&gt;
and reduces the whole ensemble to a single set of merged structure-factor intensities (an MTZ file)&lt;br /&gt;
suitable for structure solution and refinement, together with the crystallographic quality&lt;br /&gt;
statistics (completeness, multiplicity, ⟨I/σ⟩, CC½, CC&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt;, R-factors, etc.).&lt;br /&gt;
&lt;br /&gt;
Because serial datasets routinely contain tens of thousands to millions of still shots,&lt;br /&gt;
&amp;lt;code&amp;gt;cctbx.xfel.merge&amp;lt;/code&amp;gt; is built from the ground up to run under MPI across many nodes. It is&lt;br /&gt;
almost always launched with &amp;lt;code&amp;gt;mpirun&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;srun&amp;lt;/code&amp;gt;.  Note that MPI uses the term &#039;ranks&#039;&lt;br /&gt;
to distinguish independent processes that are running across one or more nodes.&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;cctbx.xfel.merge&amp;lt;/code&amp;gt; is organized as a sequence of &#039;&#039;&#039;workers&#039;&#039;&#039;. Each worker performs one&lt;br /&gt;
task — reading data, applying a correction, filtering, scaling, post-refining, computing a statistic,&lt;br /&gt;
or merging — and passes its (possibly modified) experiments and reflections on to the next worker.&lt;br /&gt;
The list of workers to run is the &amp;quot;step list&amp;quot;, and it is fully configurable: you can add, remove or&lt;br /&gt;
reorder steps with &amp;lt;code&amp;gt;dispatch.step_list&amp;lt;/code&amp;gt;. This is what makes the program flexible enough to&lt;br /&gt;
scale-and-merge in one pass, to scale subsets separately and merge later, or to run a reference-free&lt;br /&gt;
bootstrap.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;default&#039;&#039;&#039; step list is:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! # !! Worker !! Purpose&lt;br /&gt;
|-&lt;br /&gt;
| 1 || &amp;lt;code&amp;gt;input&amp;lt;/code&amp;gt; || Read integrated experiments (&amp;lt;code&amp;gt;.expt&amp;lt;/code&amp;gt;) and reflections (&amp;lt;code&amp;gt;.refl&amp;lt;/code&amp;gt;) from disk in DIALS format.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || &amp;lt;code&amp;gt;balance&amp;lt;/code&amp;gt; || Redistribute the input load evenly across MPI ranks (needed when there are fewer or more input files than ranks).&lt;br /&gt;
|-&lt;br /&gt;
| 3 || &amp;lt;code&amp;gt;model_scaling&amp;lt;/code&amp;gt; || Build the full Miller list, model intensities from the reference, and the resolution binner used for scaling and post-refinement.&lt;br /&gt;
|-&lt;br /&gt;
| 4 || &amp;lt;code&amp;gt;modify&amp;lt;/code&amp;gt; || Apply per-reflection modifications, e.g. polarization correction (and optionally re-indexing to resolve indexing ambiguity — see &amp;lt;code&amp;gt;modify.cosym&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;reindex_to_reference&amp;lt;/code&amp;gt;).&lt;br /&gt;
|-&lt;br /&gt;
| 5 || &amp;lt;code&amp;gt;filter&amp;lt;/code&amp;gt; || Reject whole experiments (or reflections) by resolution, unit cell, correlation to the reference, energy, etc.&lt;br /&gt;
|-&lt;br /&gt;
| 6 || &amp;lt;code&amp;gt;scale&amp;lt;/code&amp;gt; || Scale each lattice to the reference dataset (&amp;lt;code&amp;gt;mark0&amp;lt;/code&amp;gt;) or simply average (&amp;lt;code&amp;gt;mark1&amp;lt;/code&amp;gt;).&lt;br /&gt;
|-&lt;br /&gt;
| 7 || &amp;lt;code&amp;gt;postrefine&amp;lt;/code&amp;gt; || Post-refine per-image crystal parameters and partialities (Sauter 2015).&lt;br /&gt;
|-&lt;br /&gt;
| 8 || &amp;lt;code&amp;gt;statistics_unitcell&amp;lt;/code&amp;gt; || Determine and store the average unit cell.&lt;br /&gt;
|-&lt;br /&gt;
| 9 || &amp;lt;code&amp;gt;statistics_beam&amp;lt;/code&amp;gt; || Determine and store the average wavelength.&lt;br /&gt;
|-&lt;br /&gt;
| 10 || &amp;lt;code&amp;gt;model_statistics&amp;lt;/code&amp;gt; || Rebuild the Miller list / binner for statistics (may use the average unit cell).&lt;br /&gt;
|-&lt;br /&gt;
| 11 || &amp;lt;code&amp;gt;statistics_resolution&amp;lt;/code&amp;gt; || Per-crystal resolution statistics.&lt;br /&gt;
|-&lt;br /&gt;
| 12 || &amp;lt;code&amp;gt;group&amp;lt;/code&amp;gt; || Redistribute reflections across ranks so that every observation of a given HKL is gathered on the same rank prior to merging.&lt;br /&gt;
|-&lt;br /&gt;
| 13 || &amp;lt;code&amp;gt;errors_merge&amp;lt;/code&amp;gt; || Correct the merged error estimates with a per-HKL error model (e.g. Ev11, Brewster 2019b, or MM24 (the default), Mittan-Moreau (2025)).&lt;br /&gt;
|-&lt;br /&gt;
| 14 || &amp;lt;code&amp;gt;statistics_intensity&amp;lt;/code&amp;gt; || Intensity statistics by resolution.&lt;br /&gt;
|-&lt;br /&gt;
| 15 || &amp;lt;code&amp;gt;merge&amp;lt;/code&amp;gt; || Merge symmetry-equivalent intensities, gather all HKLs at rank 0, and write &amp;quot;odd&amp;quot;, &amp;quot;even&amp;quot; and &amp;quot;all&amp;quot; MTZ files.&lt;br /&gt;
|-&lt;br /&gt;
| 16 || &amp;lt;code&amp;gt;statistics_intensity_cxi&amp;lt;/code&amp;gt; || Correlation and R-factor statistics (ported from cxi.merge): the &amp;quot;Table of Scaling Results&amp;quot; — CC½ (half-dataset correlation, labelled &amp;quot;CC int&amp;quot;), CC&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt;, R&amp;lt;sub&amp;gt;int&amp;lt;/sub&amp;gt;, R&amp;lt;sub&amp;gt;split&amp;lt;/sub&amp;gt;, R&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Additional, non-default workers are available and can be&lt;br /&gt;
inserted into the step list, including &amp;lt;code&amp;gt;tdata&amp;lt;/code&amp;gt; (write out unit cells for clustering),&lt;br /&gt;
&amp;lt;code&amp;gt;export&amp;lt;/code&amp;gt; (batch MTZ for &#039;&#039;Careless&#039;&#039;), &amp;lt;code&amp;gt;publish&amp;lt;/code&amp;gt; (upload merged files to a&lt;br /&gt;
Google Drive folder), &amp;lt;code&amp;gt;monitor&amp;lt;/code&amp;gt; (resource-usage logging), &amp;lt;code&amp;gt;integrate&amp;lt;/code&amp;gt;&lt;br /&gt;
(on-the-fly integration), &amp;lt;code&amp;gt;prepare&amp;lt;/code&amp;gt; (SpReAD energy binning), and&lt;br /&gt;
&amp;lt;code&amp;gt;lunus&amp;lt;/code&amp;gt; (diffuse-scattering deck). A &amp;lt;code&amp;gt;deltaccint&amp;lt;/code&amp;gt; worker (ΔCC½ lattice&lt;br /&gt;
filtering) can be added after &amp;lt;code&amp;gt;group&amp;lt;/code&amp;gt;. Custom workers can be supplied through the&lt;br /&gt;
&amp;lt;code&amp;gt;XFEL_CUSTOM_WORKER_PATH&amp;lt;/code&amp;gt; environment variable.&lt;br /&gt;
&lt;br /&gt;
== Basic usage ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;cctbx.xfel.merge&amp;lt;/code&amp;gt; is run under MPI:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mpirun cctbx.xfel.merge merge.phil&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A typical &amp;lt;code&amp;gt;merge.phil&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
input.path=&amp;lt;path to data&amp;gt;&lt;br /&gt;
input.experiments_suffix=.expt&lt;br /&gt;
input.reflections_suffix=.refl&lt;br /&gt;
&lt;br /&gt;
filter.algorithm=unit_cell&lt;br /&gt;
filter.unit_cell.value.relative_length_tolerance=0.03&lt;br /&gt;
filter.outlier.min_corr=0.1&lt;br /&gt;
&lt;br /&gt;
select.algorithm=significance_filter&lt;br /&gt;
select.significance_filter.sigma=0.1&lt;br /&gt;
select.significance_filter.min_ct=200&lt;br /&gt;
select.significance_filter.max_ct=300&lt;br /&gt;
&lt;br /&gt;
scaling.model=&amp;lt;model.pdb or model.mtz&amp;gt;&lt;br /&gt;
scaling.resolution_scalar=0.96&lt;br /&gt;
&lt;br /&gt;
merging.d_min=1.8&lt;br /&gt;
merging.error.model=mm24&lt;br /&gt;
merging.merge_anomalous=True&lt;br /&gt;
&lt;br /&gt;
postrefinement.enable=True&lt;br /&gt;
statistics.n_bins=20&lt;br /&gt;
&lt;br /&gt;
output.do_timing=True&lt;br /&gt;
output.output_dir=&amp;lt;output folder&amp;gt;&lt;br /&gt;
output.prefix=&amp;lt;prefix for output files&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Explore the parameters with:&lt;br /&gt;
* &amp;lt;code&amp;gt;cctbx.xfel.merge -c&amp;lt;/code&amp;gt; — show configurable parameters&lt;br /&gt;
* &amp;lt;code&amp;gt;cctbx.xfel.merge -c -e 10 -a 2&amp;lt;/code&amp;gt; — show all parameters (expert level 10) with full help text&lt;br /&gt;
&lt;br /&gt;
== Two-stage scaling and merging ==&lt;br /&gt;
&lt;br /&gt;
For large, growing datasets (the mode used by the [[cctbx.xfel GUI]]), it is more efficient to scale&lt;br /&gt;
and post-refine each subset of data &#039;&#039;&#039;once&#039;&#039;&#039;, then merge repeatedly as more data arrive. This is&lt;br /&gt;
done by running the program twice with different step lists.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Stage 1 — scale each subset&#039;&#039;&#039; (stops after per-image work and writes intermediate DIALS files):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dispatch.step_list=input balance model_scaling modify filter scale postrefine \&lt;br /&gt;
    statistics_unitcell statistics_beam model_statistics statistics_resolution&lt;br /&gt;
output.save_experiments_and_reflections=True&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;output.save_experiments_and_reflections=True&amp;lt;/code&amp;gt; dumps the scaled/post-refined data as&lt;br /&gt;
experiment lists and reflection tables that the merge stage can read back in.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Stage 2 — merge the scaled subsets&#039;&#039;&#039; (add an &amp;lt;code&amp;gt;input.path&amp;lt;/code&amp;gt; for each finished subset):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dispatch.step_list=input model_scaling statistics_unitcell statistics_beam \&lt;br /&gt;
    model_statistics statistics_resolution group errors_merge statistics_intensity \&lt;br /&gt;
    merge statistics_intensity_cxi&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Merging without a reference (bootstrap / mark1) ==&lt;br /&gt;
&lt;br /&gt;
If no scaling/merging reference is available, use a bootstrap procedure. First run the&lt;br /&gt;
&amp;lt;code&amp;gt;mark1&amp;lt;/code&amp;gt; algorithm, which simply averages the data (all per-image scale factors = 1, no&lt;br /&gt;
post-refinement), specifying the target cell and symmetry explicitly:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
scaling.algorithm=mark1&lt;br /&gt;
scaling.unit_cell=&amp;lt;unit cell&amp;gt;&lt;br /&gt;
scaling.space_group=&amp;lt;space group&amp;gt;&lt;br /&gt;
merging.error.model=errors_from_sample_residuals&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The resulting MTZ is then used as the reference (&amp;lt;code&amp;gt;scaling.model=&amp;lt;/code&amp;gt;) for subsequent regular&lt;br /&gt;
merges. Iterate a few cycles; CC½ typically improves and converges over the first few rounds.&lt;br /&gt;
&lt;br /&gt;
== Important parameters ==&lt;br /&gt;
&lt;br /&gt;
Parameters are given by their full PHIL path with defaults in parentheses. The program exposes many&lt;br /&gt;
more parameters (see &amp;lt;code&amp;gt;-c -e 10 -a 2&amp;lt;/code&amp;gt;); those below are the ones most commonly set.&lt;br /&gt;
&lt;br /&gt;
=== Input ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.path&amp;lt;/code&amp;gt; || None || Path(s) to the integrated data — a folder, several folders, or individual files; wildcards allowed; may be repeated. Matching &amp;lt;code&amp;gt;.expt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;.refl&amp;lt;/code&amp;gt; files must both be present.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.experiments_suffix&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;_integrated.expt&amp;lt;/code&amp;gt; || Only load experiment files ending with this suffix.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.reflections_suffix&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;_integrated.refl&amp;lt;/code&amp;gt; || Only load reflection files ending with this suffix.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.parallel_file_load.method&amp;lt;/code&amp;gt; || uniform || &amp;lt;code&amp;gt;uniform&amp;lt;/code&amp;gt; spreads input files evenly over all ranks; &amp;lt;code&amp;gt;node_memory&amp;lt;/code&amp;gt; distributes so per-node memory limits are respected.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.alist.file&amp;lt;/code&amp;gt; || None || Path to a text file of experiment tags or filenames; combined with &amp;lt;code&amp;gt;input.alist.op=keep|reject&amp;lt;/code&amp;gt; to merge only (or exclude) a specified subset.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.persistent_refl_cols&amp;lt;/code&amp;gt; || None || Reflection-table columns to preserve through the pruning steps (and into saved tables).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Filtering whole experiments (&amp;lt;code&amp;gt;filter&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;filter&amp;lt;/code&amp;gt; section accepts or rejects &#039;&#039;&#039;entire experiments&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.algorithm&amp;lt;/code&amp;gt; || (none) || One or more of &amp;lt;code&amp;gt;n_obs&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;resolution&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;unit_cell&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;energy&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bootstrap&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;experiment_prefix&amp;lt;/code&amp;gt;. Nothing is filtered unless listed.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.unit_cell.algorithm&amp;lt;/code&amp;gt; || value || How to restrict unit cells: &amp;lt;code&amp;gt;value&amp;lt;/code&amp;gt; (compare to a target), &amp;lt;code&amp;gt;range&amp;lt;/code&amp;gt;, or &amp;lt;code&amp;gt;cluster&amp;lt;/code&amp;gt; (use a precomputed covariance clustering).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.unit_cell.value.relative_length_tolerance&amp;lt;/code&amp;gt; || 0.1 || Fractional deviation of cell edge lengths allowed vs. the target cell. Often tightened (e.g. 0.03).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.unit_cell.value.absolute_angle_tolerance&amp;lt;/code&amp;gt; || 2.0 || Allowed cell-angle deviation (degrees) vs. the target.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.unit_cell.value.target_unit_cell&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;target_space_group&amp;lt;/code&amp;gt; || Auto || Target cell/symmetry; &amp;lt;code&amp;gt;Auto&amp;lt;/code&amp;gt; uses the scaling model.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.outlier.min_corr&amp;lt;/code&amp;gt; || 0.1 || Minimum correlation of an image&#039;s intensities to the reference model; images below this are rejected. Only applied when a scaling model is present. Use &amp;lt;code&amp;gt;-1&amp;lt;/code&amp;gt; to accept all images regardless of correlation.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.resolution.d_min&amp;lt;/code&amp;gt; || None || Reject an experiment unless some of its reflections extend beyond this resolution.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Selecting individual reflections (&amp;lt;code&amp;gt;select&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;select&amp;lt;/code&amp;gt; section accepts or rejects &#039;&#039;&#039;individual reflections&#039;&#039;&#039; (contrast with&lt;br /&gt;
&amp;lt;code&amp;gt;filter&amp;lt;/code&amp;gt;, which acts on whole experiments).&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;select.algorithm&amp;lt;/code&amp;gt; || (none) || One or more of &amp;lt;code&amp;gt;significance_filter&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;panel&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cspad_sensor&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;isolation_forest&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;target_energy&amp;lt;/code&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;select.significance_filter.sigma&amp;lt;/code&amp;gt; || 0.5 || Trim each lattice at the resolution where the binned ⟨I/σ⟩ drops below this value.  Often reduced to 0.1.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;select.significance_filter.min_ct&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;max_ct&amp;lt;/code&amp;gt; || 10 / 50 || Target minimum/maximum mean reflections per resolution bin when choosing the number of bins. For large unit cells these are often raised (e.g. 200/300); for small cells, use the defaults.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Modifying intensities (&amp;lt;code&amp;gt;modify&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;modify.algorithm&amp;lt;/code&amp;gt; || polarization || Per-reflection corrections to apply (default applies the polarization correction).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;modify.cosym&amp;lt;/code&amp;gt; || — || Resolve an indexing ambiguity across the ensemble using the Gildea/Winter (Brehm/Diederichs) cosym method, optionally anchored to &amp;lt;code&amp;gt;scaling.model&amp;lt;/code&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;modify.reindex_to_reference&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;reindex_to_abc&amp;lt;/code&amp;gt; || — || Alternative re-indexing operators (to a reference model, or an explicit operator).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Scaling (&amp;lt;code&amp;gt;scaling&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;scaling.model&amp;lt;/code&amp;gt; || None || Reference dataset: a PDB file (uses the CRYST1 cell and computes model intensities, including bulk solvent) or an MTZ from a previous cycle. Required for &amp;lt;code&amp;gt;mark0&amp;lt;/code&amp;gt; scaling.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;scaling.algorithm&amp;lt;/code&amp;gt; || mark0 || &amp;lt;code&amp;gt;mark0&amp;lt;/code&amp;gt;: per-image scaling against the reference. &amp;lt;code&amp;gt;mark1&amp;lt;/code&amp;gt;: no scaling, just Monte-Carlo averaging (all scale factors = 1) — used for reference-free bootstrap.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;scaling.unit_cell&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;scaling.space_group&amp;lt;/code&amp;gt; || None || Cell/symmetry to use when no model is provided (i.e. &amp;lt;code&amp;gt;mark1&amp;lt;/code&amp;gt;).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;scaling.resolution_scalar&amp;lt;/code&amp;gt; || 0.969 || &amp;lt;code&amp;gt;merging.d_min&amp;lt;/code&amp;gt; is multiplied by this when deciding which reflections fall within the resolution limit, generating a few extra reference reflections to account for per-shot cell variation (e.g. set 0.96 for a few more).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;scaling.mtz.mtz_column_F&amp;lt;/code&amp;gt; || fobs || Column name in the reference MTZ containing the reference structure factors (intensities or amplitudes).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Post-refinement (&amp;lt;code&amp;gt;postrefinement&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;postrefinement.enable&amp;lt;/code&amp;gt; || True || Enable post-refinement of per-image parameters/partialities (Sauter 2015).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;postrefinement.algorithm&amp;lt;/code&amp;gt; || rs || Post-refinement protocol: &amp;lt;code&amp;gt;rs&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;rs2&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;rs_hybrid&amp;lt;/code&amp;gt;, or &amp;lt;code&amp;gt;eta_deff&amp;lt;/code&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Merging and error model (&amp;lt;code&amp;gt;merging&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;merging.d_min&amp;lt;/code&amp;gt; || None || High-resolution limit for scaling and merging.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;merging.d_max&amp;lt;/code&amp;gt; || None || Low-resolution limit (currently affects only CCiso).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;merging.merge_anomalous&amp;lt;/code&amp;gt; || False || &amp;lt;code&amp;gt;True&amp;lt;/code&amp;gt; merges Bijvoet mates together (higher multiplicity); &amp;lt;code&amp;gt;False&amp;lt;/code&amp;gt; keeps them separate to preserve the anomalous signal.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;merging.minimum_multiplicity&amp;lt;/code&amp;gt; || 2 || Do not produce a merged structure factor for HKLs measured fewer than this many times.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;merging.error.model&amp;lt;/code&amp;gt; || mm24 || Merged-sigma error model: &amp;lt;code&amp;gt;mm24&amp;lt;/code&amp;gt; (Mittan-Moreau 2025, current default), &amp;lt;code&amp;gt;ev11&amp;lt;/code&amp;gt; (Evans 2011 / sdfac-refine), &amp;lt;code&amp;gt;ha14&amp;lt;/code&amp;gt;, or &amp;lt;code&amp;gt;errors_from_sample_residuals&amp;lt;/code&amp;gt; (no refined error terms — used with &amp;lt;code&amp;gt;mark1&amp;lt;/code&amp;gt; bootstrap).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;merging.set_average_unit_cell&amp;lt;/code&amp;gt; || True || Output MTZ adopts the average unit cell of the data rather than the reference model&#039;s cell.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Statistics (&amp;lt;code&amp;gt;statistics&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;statistics.n_bins&amp;lt;/code&amp;gt; || 10 || Number of resolution bins in the statistics tables.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;statistics.cciso.mtz_file&amp;lt;/code&amp;gt; || None || Isomorphous reference structure factors for R&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt; / CC&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;statistics.report_ML&amp;lt;/code&amp;gt; || True || Report per-frame max-likelihood attributes (domain size, mosaicity).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Output (&amp;lt;code&amp;gt;output&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.output_dir&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;.&amp;lt;/code&amp;gt; || Directory for output files (created if it does not exist).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.prefix&amp;lt;/code&amp;gt; || iobs || Prefix prepended to all output file names.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.save_experiments_and_reflections&amp;lt;/code&amp;gt; || False || Dump the final experiments/reflections from the last worker as DIALS files — used for the two-stage scale-then-merge workflow.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.do_timing&amp;lt;/code&amp;gt; || False || Log elapsed time per execution step.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.expanded_bookkeeping&amp;lt;/code&amp;gt; || False || Store extra provenance columns (input file/reflection indices, odd/even flag, original id) in the saved reflection tables.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Multiprocessing (&amp;lt;code&amp;gt;mp&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mp.method&amp;lt;/code&amp;gt; || mpi || Multiprocessing method (only &amp;lt;code&amp;gt;mpi&amp;lt;/code&amp;gt; is currently supported).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mp.debug.cProfile&amp;lt;/code&amp;gt; || False || Enable code profiling; a &amp;lt;code&amp;gt;.prof&amp;lt;/code&amp;gt; file is written per rank.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Output files ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;merge&amp;lt;/code&amp;gt; worker gathers all HKLs at rank 0 and writes three MTZ files, prefixed with&lt;br /&gt;
&amp;lt;code&amp;gt;output.prefix&amp;lt;/code&amp;gt; (default &amp;lt;code&amp;gt;iobs&amp;lt;/code&amp;gt;):&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;amp;lt;prefix&amp;amp;gt;_all.mtz&amp;lt;/code&amp;gt; — the merged dataset using all observations (the main result for structure solution)&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;amp;lt;prefix&amp;amp;gt;_odd.mtz&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;&amp;amp;lt;prefix&amp;amp;gt;_even.mtz&amp;lt;/code&amp;gt; — the two half-datasets used for CC½ and related half-dataset statistics&lt;br /&gt;
&lt;br /&gt;
A main log records the per-step progress and the merging statistics tables by resolution bin:&lt;br /&gt;
completeness, multiplicity and ⟨I/σ⟩, plus the &amp;quot;Table of Scaling Results&amp;quot; reporting CC½ (the&lt;br /&gt;
half-dataset correlation, labelled &amp;quot;CC int&amp;quot;), CC&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt;, R&amp;lt;sub&amp;gt;int&amp;lt;/sub&amp;gt;, R&amp;lt;sub&amp;gt;split&amp;lt;/sub&amp;gt;&lt;br /&gt;
and R&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt;.  The merged MTZ can optionally be&lt;br /&gt;
uploaded to a shared [https://github.com/cctbx/cctbx_project/tree/master/xfel/merging/application/publish Google Drive folder] by adding the &amp;lt;code&amp;gt;publish&amp;lt;/code&amp;gt; worker.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
* Sauter NK (2015). &#039;&#039;J Synchrotron Radiat&#039;&#039; &#039;&#039;&#039;22&#039;&#039;&#039;, 239–48. (post-refinement)&lt;br /&gt;
* Uervirojnangkoorn M, &#039;&#039;et al.&#039;&#039; (2015). &#039;&#039;eLife&#039;&#039; 10.7554/eLife.05421. (PRIME / bootstrap)&lt;br /&gt;
* Brewster AS, &#039;&#039;et al.&#039;&#039; (2018). &#039;&#039;Acta Cryst.&#039;&#039; D &#039;&#039;&#039;74&#039;&#039;&#039;, 877–894.&lt;br /&gt;
* Brewster AS, &#039;&#039;et al.&#039;&#039; (2019a). &#039;&#039;Computational Crystallography Newsletter&#039;&#039; &#039;&#039;&#039;10&#039;&#039;&#039;, 22–39. (XFEL GUI)&lt;br /&gt;
* Brewster AS, &#039;&#039;et al.&#039;&#039; (2019b). &#039;&#039;Acta Cryst.&#039;&#039; D &#039;&#039;&#039;75&#039;&#039;&#039;, 959–968. (error models)&lt;br /&gt;
* Mittan-Moreau (2025). (mm24 error model)&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
* [[dials.stills_process]] — produces the integrated data that &amp;lt;code&amp;gt;cctbx.xfel.merge&amp;lt;/code&amp;gt; consumes&lt;br /&gt;
* [[cctbx.xfel GUI]] — orchestrates separate scaling and repeated merging as data are collected&lt;br /&gt;
* The program README at &amp;lt;code&amp;gt;xfel/merging/README.md&amp;lt;/code&amp;gt; in cctbx_project&lt;/div&gt;</summary>
		<author><name>Aaron</name></author>
	</entry>
	<entry>
		<id>http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Cctbx.xfel.merge&amp;diff=1782</id>
		<title>Cctbx.xfel.merge</title>
		<link rel="alternate" type="text/html" href="http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Cctbx.xfel.merge&amp;diff=1782"/>
		<updated>2026-08-21T23:24:39Z</updated>

		<summary type="html">&lt;p&gt;Aaron: /* Merging and error model (merging) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= &#039;&#039;cctbx.xfel.merge&#039;&#039; =&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;cctbx.xfel.merge&#039;&#039;&#039;&#039;&#039; is the scaling, post-refinement and merging program of cctbx.xfel. It takes&lt;br /&gt;
the per-image integrated results produced by &#039;&#039;[[dials.stills_process]]&#039;&#039; — one crystal per still shot —&lt;br /&gt;
and reduces the whole ensemble to a single set of merged structure-factor intensities (an MTZ file)&lt;br /&gt;
suitable for structure solution and refinement, together with the crystallographic quality&lt;br /&gt;
statistics (completeness, multiplicity, ⟨I/σ⟩, CC½, CC&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt;, R-factors, etc.).&lt;br /&gt;
&lt;br /&gt;
Because serial datasets routinely contain tens of thousands to millions of still shots,&lt;br /&gt;
&amp;lt;code&amp;gt;cctbx.xfel.merge&amp;lt;/code&amp;gt; is built from the ground up to run under MPI across many nodes. It is&lt;br /&gt;
almost always launched with &amp;lt;code&amp;gt;mpirun&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;srun&amp;lt;/code&amp;gt;.  Note that MPI uses the term &#039;ranks&#039;&lt;br /&gt;
to distinguish independent processes that are running across one or more nodes.&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;cctbx.xfel.merge&amp;lt;/code&amp;gt; is organized as a sequence of &#039;&#039;&#039;workers&#039;&#039;&#039;. Each worker performs one&lt;br /&gt;
task — reading data, applying a correction, filtering, scaling, post-refining, computing a statistic,&lt;br /&gt;
or merging — and passes its (possibly modified) experiments and reflections on to the next worker.&lt;br /&gt;
The list of workers to run is the &amp;quot;step list&amp;quot;, and it is fully configurable: you can add, remove or&lt;br /&gt;
reorder steps with &amp;lt;code&amp;gt;dispatch.step_list&amp;lt;/code&amp;gt;. This is what makes the program flexible enough to&lt;br /&gt;
scale-and-merge in one pass, to scale subsets separately and merge later, or to run a reference-free&lt;br /&gt;
bootstrap.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;default&#039;&#039;&#039; step list is:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! # !! Worker !! Purpose&lt;br /&gt;
|-&lt;br /&gt;
| 1 || &amp;lt;code&amp;gt;input&amp;lt;/code&amp;gt; || Read integrated experiments (&amp;lt;code&amp;gt;.expt&amp;lt;/code&amp;gt;) and reflections (&amp;lt;code&amp;gt;.refl&amp;lt;/code&amp;gt;) from disk in DIALS format.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || &amp;lt;code&amp;gt;balance&amp;lt;/code&amp;gt; || Redistribute the input load evenly across MPI ranks (needed when there are fewer or more input files than ranks).&lt;br /&gt;
|-&lt;br /&gt;
| 3 || &amp;lt;code&amp;gt;model_scaling&amp;lt;/code&amp;gt; || Build the full Miller list, model intensities from the reference, and the resolution binner used for scaling and post-refinement.&lt;br /&gt;
|-&lt;br /&gt;
| 4 || &amp;lt;code&amp;gt;modify&amp;lt;/code&amp;gt; || Apply per-reflection modifications, e.g. polarization correction (and optionally re-indexing to resolve indexing ambiguity — see &amp;lt;code&amp;gt;modify.cosym&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;reindex_to_reference&amp;lt;/code&amp;gt;).&lt;br /&gt;
|-&lt;br /&gt;
| 5 || &amp;lt;code&amp;gt;filter&amp;lt;/code&amp;gt; || Reject whole experiments (or reflections) by resolution, unit cell, correlation to the reference, energy, etc.&lt;br /&gt;
|-&lt;br /&gt;
| 6 || &amp;lt;code&amp;gt;scale&amp;lt;/code&amp;gt; || Scale each lattice to the reference dataset (&amp;lt;code&amp;gt;mark0&amp;lt;/code&amp;gt;) or simply average (&amp;lt;code&amp;gt;mark1&amp;lt;/code&amp;gt;).&lt;br /&gt;
|-&lt;br /&gt;
| 7 || &amp;lt;code&amp;gt;postrefine&amp;lt;/code&amp;gt; || Post-refine per-image crystal parameters and partialities (Sauter 2015).&lt;br /&gt;
|-&lt;br /&gt;
| 8 || &amp;lt;code&amp;gt;statistics_unitcell&amp;lt;/code&amp;gt; || Determine and store the average unit cell.&lt;br /&gt;
|-&lt;br /&gt;
| 9 || &amp;lt;code&amp;gt;statistics_beam&amp;lt;/code&amp;gt; || Determine and store the average wavelength.&lt;br /&gt;
|-&lt;br /&gt;
| 10 || &amp;lt;code&amp;gt;model_statistics&amp;lt;/code&amp;gt; || Rebuild the Miller list / binner for statistics (may use the average unit cell).&lt;br /&gt;
|-&lt;br /&gt;
| 11 || &amp;lt;code&amp;gt;statistics_resolution&amp;lt;/code&amp;gt; || Per-crystal resolution statistics.&lt;br /&gt;
|-&lt;br /&gt;
| 12 || &amp;lt;code&amp;gt;group&amp;lt;/code&amp;gt; || Redistribute reflections across ranks so that every observation of a given HKL is gathered on the same rank prior to merging.&lt;br /&gt;
|-&lt;br /&gt;
| 13 || &amp;lt;code&amp;gt;errors_merge&amp;lt;/code&amp;gt; || Correct the merged error estimates with a per-HKL error model (e.g. Ev11, Brewster 2019b, or MM24 (the default), Mittan-Moreau (2025)).&lt;br /&gt;
|-&lt;br /&gt;
| 14 || &amp;lt;code&amp;gt;statistics_intensity&amp;lt;/code&amp;gt; || Intensity statistics by resolution.&lt;br /&gt;
|-&lt;br /&gt;
| 15 || &amp;lt;code&amp;gt;merge&amp;lt;/code&amp;gt; || Merge symmetry-equivalent intensities, gather all HKLs at rank 0, and write &amp;quot;odd&amp;quot;, &amp;quot;even&amp;quot; and &amp;quot;all&amp;quot; MTZ files.&lt;br /&gt;
|-&lt;br /&gt;
| 16 || &amp;lt;code&amp;gt;statistics_intensity_cxi&amp;lt;/code&amp;gt; || Correlation and R-factor statistics (ported from cxi.merge): the &amp;quot;Table of Scaling Results&amp;quot; — CC½ (half-dataset correlation, labelled &amp;quot;CC int&amp;quot;), CC&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt;, R&amp;lt;sub&amp;gt;int&amp;lt;/sub&amp;gt;, R&amp;lt;sub&amp;gt;split&amp;lt;/sub&amp;gt;, R&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Additional, non-default workers are available and can be&lt;br /&gt;
inserted into the step list, including &amp;lt;code&amp;gt;tdata&amp;lt;/code&amp;gt; (write out unit cells for clustering),&lt;br /&gt;
&amp;lt;code&amp;gt;export&amp;lt;/code&amp;gt; (batch MTZ for &#039;&#039;Careless&#039;&#039;), &amp;lt;code&amp;gt;publish&amp;lt;/code&amp;gt; (upload merged files to a&lt;br /&gt;
Google Drive folder), &amp;lt;code&amp;gt;monitor&amp;lt;/code&amp;gt; (resource-usage logging), &amp;lt;code&amp;gt;integrate&amp;lt;/code&amp;gt;&lt;br /&gt;
(on-the-fly integration), &amp;lt;code&amp;gt;prepare&amp;lt;/code&amp;gt; (SpReAD energy binning), and&lt;br /&gt;
&amp;lt;code&amp;gt;lunus&amp;lt;/code&amp;gt; (diffuse-scattering deck). A &amp;lt;code&amp;gt;deltaccint&amp;lt;/code&amp;gt; worker (ΔCC½ lattice&lt;br /&gt;
filtering) can be added after &amp;lt;code&amp;gt;group&amp;lt;/code&amp;gt;. Custom workers can be supplied through the&lt;br /&gt;
&amp;lt;code&amp;gt;XFEL_CUSTOM_WORKER_PATH&amp;lt;/code&amp;gt; environment variable.&lt;br /&gt;
&lt;br /&gt;
== Basic usage ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;cctbx.xfel.merge&amp;lt;/code&amp;gt; is run under MPI:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mpirun cctbx.xfel.merge merge.phil&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A typical &amp;lt;code&amp;gt;merge.phil&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
input.path=&amp;lt;path to data&amp;gt;&lt;br /&gt;
input.experiments_suffix=.expt&lt;br /&gt;
input.reflections_suffix=.refl&lt;br /&gt;
&lt;br /&gt;
filter.algorithm=unit_cell&lt;br /&gt;
filter.unit_cell.value.relative_length_tolerance=0.03&lt;br /&gt;
filter.outlier.min_corr=0.1&lt;br /&gt;
&lt;br /&gt;
select.algorithm=significance_filter&lt;br /&gt;
select.significance_filter.sigma=0.1&lt;br /&gt;
select.significance_filter.min_ct=200&lt;br /&gt;
select.significance_filter.max_ct=300&lt;br /&gt;
&lt;br /&gt;
scaling.model=&amp;lt;model.pdb or model.mtz&amp;gt;&lt;br /&gt;
scaling.resolution_scalar=0.96&lt;br /&gt;
&lt;br /&gt;
merging.d_min=1.8&lt;br /&gt;
merging.error.model=mm24&lt;br /&gt;
merging.merge_anomalous=True&lt;br /&gt;
&lt;br /&gt;
postrefinement.enable=True&lt;br /&gt;
statistics.n_bins=20&lt;br /&gt;
&lt;br /&gt;
output.do_timing=True&lt;br /&gt;
output.output_dir=&amp;lt;output folder&amp;gt;&lt;br /&gt;
output.prefix=&amp;lt;prefix for output files&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Explore the parameters with:&lt;br /&gt;
* &amp;lt;code&amp;gt;cctbx.xfel.merge -c&amp;lt;/code&amp;gt; — show configurable parameters&lt;br /&gt;
* &amp;lt;code&amp;gt;cctbx.xfel.merge -c -e 10 -a 2&amp;lt;/code&amp;gt; — show all parameters (expert level 10) with full help text&lt;br /&gt;
&lt;br /&gt;
== Two-stage scaling and merging ==&lt;br /&gt;
&lt;br /&gt;
For large, growing datasets (the mode used by the [[cctbx.xfel GUI]]), it is more efficient to scale&lt;br /&gt;
and post-refine each subset of data &#039;&#039;&#039;once&#039;&#039;&#039;, then merge repeatedly as more data arrive. This is&lt;br /&gt;
done by running the program twice with different step lists.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Stage 1 — scale each subset&#039;&#039;&#039; (stops after per-image work and writes intermediate DIALS files):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dispatch.step_list=input balance model_scaling modify filter scale postrefine \&lt;br /&gt;
    statistics_unitcell statistics_beam model_statistics statistics_resolution&lt;br /&gt;
output.save_experiments_and_reflections=True&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;output.save_experiments_and_reflections=True&amp;lt;/code&amp;gt; dumps the scaled/post-refined data as&lt;br /&gt;
experiment lists and reflection tables that the merge stage can read back in.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Stage 2 — merge the scaled subsets&#039;&#039;&#039; (add an &amp;lt;code&amp;gt;input.path&amp;lt;/code&amp;gt; for each finished subset):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dispatch.step_list=input model_scaling statistics_unitcell statistics_beam \&lt;br /&gt;
    model_statistics statistics_resolution group errors_merge statistics_intensity \&lt;br /&gt;
    merge statistics_intensity_cxi&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Merging without a reference (bootstrap / mark1) ==&lt;br /&gt;
&lt;br /&gt;
If no scaling/merging reference is available, use a bootstrap procedure. First run the&lt;br /&gt;
&amp;lt;code&amp;gt;mark1&amp;lt;/code&amp;gt; algorithm, which simply averages the data (all per-image scale factors = 1, no&lt;br /&gt;
post-refinement), specifying the target cell and symmetry explicitly:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
scaling.algorithm=mark1&lt;br /&gt;
scaling.unit_cell=&amp;lt;unit cell&amp;gt;&lt;br /&gt;
scaling.space_group=&amp;lt;space group&amp;gt;&lt;br /&gt;
merging.error.model=errors_from_sample_residuals&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The resulting MTZ is then used as the reference (&amp;lt;code&amp;gt;scaling.model=&amp;lt;/code&amp;gt;) for subsequent regular&lt;br /&gt;
merges. Iterate a few cycles; CC½ typically improves and converges over the first few rounds.&lt;br /&gt;
&lt;br /&gt;
== Important parameters ==&lt;br /&gt;
&lt;br /&gt;
Parameters are given by their full PHIL path with defaults in parentheses. The program exposes many&lt;br /&gt;
more parameters (see &amp;lt;code&amp;gt;-c -e 10 -a 2&amp;lt;/code&amp;gt;); those below are the ones most commonly set.&lt;br /&gt;
&lt;br /&gt;
=== Input ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.path&amp;lt;/code&amp;gt; || None || Path(s) to the integrated data — a folder, several folders, or individual files; wildcards allowed; may be repeated. Matching &amp;lt;code&amp;gt;.expt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;.refl&amp;lt;/code&amp;gt; files must both be present.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.experiments_suffix&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;_integrated.expt&amp;lt;/code&amp;gt; || Only load experiment files ending with this suffix.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.reflections_suffix&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;_integrated.refl&amp;lt;/code&amp;gt; || Only load reflection files ending with this suffix.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.parallel_file_load.method&amp;lt;/code&amp;gt; || uniform || &amp;lt;code&amp;gt;uniform&amp;lt;/code&amp;gt; spreads input files evenly over all ranks; &amp;lt;code&amp;gt;node_memory&amp;lt;/code&amp;gt; distributes so per-node memory limits are respected.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.alist.file&amp;lt;/code&amp;gt; || None || Path to a text file of experiment tags or filenames; combined with &amp;lt;code&amp;gt;input.alist.op=keep|reject&amp;lt;/code&amp;gt; to merge only (or exclude) a specified subset.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.persistent_refl_cols&amp;lt;/code&amp;gt; || None || Reflection-table columns to preserve through the pruning steps (and into saved tables).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Filtering whole experiments (&amp;lt;code&amp;gt;filter&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;filter&amp;lt;/code&amp;gt; section accepts or rejects &#039;&#039;&#039;entire experiments&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.algorithm&amp;lt;/code&amp;gt; || (none) || One or more of &amp;lt;code&amp;gt;n_obs&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;resolution&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;unit_cell&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;energy&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bootstrap&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;experiment_prefix&amp;lt;/code&amp;gt;. Nothing is filtered unless listed.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.unit_cell.algorithm&amp;lt;/code&amp;gt; || value || How to restrict unit cells: &amp;lt;code&amp;gt;value&amp;lt;/code&amp;gt; (compare to a target), &amp;lt;code&amp;gt;range&amp;lt;/code&amp;gt;, or &amp;lt;code&amp;gt;cluster&amp;lt;/code&amp;gt; (use a precomputed covariance clustering).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.unit_cell.value.relative_length_tolerance&amp;lt;/code&amp;gt; || 0.1 || Fractional deviation of cell edge lengths allowed vs. the target cell. Often tightened (e.g. 0.03).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.unit_cell.value.absolute_angle_tolerance&amp;lt;/code&amp;gt; || 2.0 || Allowed cell-angle deviation (degrees) vs. the target.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.unit_cell.value.target_unit_cell&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;target_space_group&amp;lt;/code&amp;gt; || Auto || Target cell/symmetry; &amp;lt;code&amp;gt;Auto&amp;lt;/code&amp;gt; uses the scaling model.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.outlier.min_corr&amp;lt;/code&amp;gt; || 0.1 || Minimum correlation of an image&#039;s intensities to the reference model; images below this are rejected. Only applied when a scaling model is present. Use &amp;lt;code&amp;gt;-1&amp;lt;/code&amp;gt; to accept all images regardless of correlation.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.resolution.d_min&amp;lt;/code&amp;gt; || None || Reject an experiment unless some of its reflections extend beyond this resolution.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Selecting individual reflections (&amp;lt;code&amp;gt;select&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;select&amp;lt;/code&amp;gt; section accepts or rejects &#039;&#039;&#039;individual reflections&#039;&#039;&#039; (contrast with&lt;br /&gt;
&amp;lt;code&amp;gt;filter&amp;lt;/code&amp;gt;, which acts on whole experiments).&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;select.algorithm&amp;lt;/code&amp;gt; || (none) || One or more of &amp;lt;code&amp;gt;significance_filter&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;panel&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cspad_sensor&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;isolation_forest&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;target_energy&amp;lt;/code&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;select.significance_filter.sigma&amp;lt;/code&amp;gt; || 0.5 || Trim each lattice at the resolution where the binned ⟨I/σ⟩ drops below this value.  Often reduced to 0.1.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;select.significance_filter.min_ct&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;max_ct&amp;lt;/code&amp;gt; || 10 / 50 || Target minimum/maximum mean reflections per resolution bin when choosing the number of bins. For large unit cells these are often raised (e.g. 200/300); for small cells, use the defaults.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Modifying intensities (&amp;lt;code&amp;gt;modify&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;modify.algorithm&amp;lt;/code&amp;gt; || polarization || Per-reflection corrections to apply (default applies the polarization correction).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;modify.cosym&amp;lt;/code&amp;gt; || — || Resolve an indexing ambiguity across the ensemble using the Gildea/Winter (Brehm/Diederichs) cosym method, optionally anchored to &amp;lt;code&amp;gt;scaling.model&amp;lt;/code&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;modify.reindex_to_reference&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;reindex_to_abc&amp;lt;/code&amp;gt; || — || Alternative re-indexing operators (to a reference model, or an explicit operator).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Scaling (&amp;lt;code&amp;gt;scaling&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;scaling.model&amp;lt;/code&amp;gt; || None || Reference dataset: a PDB file (uses the CRYST1 cell and computes model intensities, including bulk solvent) or an MTZ from a previous cycle. Required for &amp;lt;code&amp;gt;mark0&amp;lt;/code&amp;gt; scaling.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;scaling.algorithm&amp;lt;/code&amp;gt; || mark0 || &amp;lt;code&amp;gt;mark0&amp;lt;/code&amp;gt;: per-image scaling against the reference. &amp;lt;code&amp;gt;mark1&amp;lt;/code&amp;gt;: no scaling, just Monte-Carlo averaging (all scale factors = 1) — used for reference-free bootstrap.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;scaling.unit_cell&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;scaling.space_group&amp;lt;/code&amp;gt; || None || Cell/symmetry to use when no model is provided (i.e. &amp;lt;code&amp;gt;mark1&amp;lt;/code&amp;gt;).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;scaling.resolution_scalar&amp;lt;/code&amp;gt; || 0.969 || &amp;lt;code&amp;gt;merging.d_min&amp;lt;/code&amp;gt; is multiplied by this when deciding which reflections fall within the resolution limit, generating a few extra reference reflections to account for per-shot cell variation (e.g. set 0.96 for a few more).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;scaling.mtz.mtz_column_F&amp;lt;/code&amp;gt; || fobs || Column name in the reference MTZ containing the reference structure factors (intensities or amplitudes).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Post-refinement (&amp;lt;code&amp;gt;postrefinement&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;postrefinement.enable&amp;lt;/code&amp;gt; || True || Enable post-refinement of per-image parameters/partialities (Sauter 2015).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;postrefinement.algorithm&amp;lt;/code&amp;gt; || rs || Post-refinement protocol: &amp;lt;code&amp;gt;rs&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;rs2&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;rs_hybrid&amp;lt;/code&amp;gt;, or &amp;lt;code&amp;gt;eta_deff&amp;lt;/code&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Merging and error model (&amp;lt;code&amp;gt;merging&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;merging.d_min&amp;lt;/code&amp;gt; || None || High-resolution limit for scaling and merging.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;merging.d_max&amp;lt;/code&amp;gt; || None || Low-resolution limit (currently affects only CCiso).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;merging.merge_anomalous&amp;lt;/code&amp;gt; || False || &amp;lt;code&amp;gt;True&amp;lt;/code&amp;gt; merges Bijvoet mates together (higher multiplicity); &amp;lt;code&amp;gt;False&amp;lt;/code&amp;gt; keeps them separate to preserve the anomalous signal.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;merging.minimum_multiplicity&amp;lt;/code&amp;gt; || 2 || Do not produce a merged structure factor for HKLs measured fewer than this many times.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;merging.error.model&amp;lt;/code&amp;gt; || mm24 || Merged-sigma error model: &amp;lt;code&amp;gt;mm24&amp;lt;/code&amp;gt; (Mittan-Moreau 2025, current default), &amp;lt;code&amp;gt;ev11&amp;lt;/code&amp;gt; (Evans 2011 / sdfac-refine), &amp;lt;code&amp;gt;ha14&amp;lt;/code&amp;gt;, or &amp;lt;code&amp;gt;errors_from_sample_residuals&amp;lt;/code&amp;gt; (no refined error terms — used with &amp;lt;code&amp;gt;mark1&amp;lt;/code&amp;gt; bootstrap).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;merging.set_average_unit_cell&amp;lt;/code&amp;gt; || True || Output MTZ adopts the (cluster-derived) average unit cell of the data rather than the reference model&#039;s cell.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Statistics (&amp;lt;code&amp;gt;statistics&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;statistics.n_bins&amp;lt;/code&amp;gt; || 10 || Number of resolution bins in the statistics tables.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;statistics.cciso.mtz_file&amp;lt;/code&amp;gt; || None || Isomorphous reference structure factors for R&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt; / CC&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;statistics.report_ML&amp;lt;/code&amp;gt; || True || Report per-frame max-likelihood attributes (domain size, mosaicity).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Output (&amp;lt;code&amp;gt;output&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.output_dir&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;.&amp;lt;/code&amp;gt; || Directory for output files (created if it does not exist).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.prefix&amp;lt;/code&amp;gt; || iobs || Prefix prepended to all output file names.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.save_experiments_and_reflections&amp;lt;/code&amp;gt; || False || Dump the final experiments/reflections from the last worker as DIALS files — used for the two-stage scale-then-merge workflow.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.do_timing&amp;lt;/code&amp;gt; || False || Log elapsed time per execution step.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.expanded_bookkeeping&amp;lt;/code&amp;gt; || False || Store extra provenance columns (input file/reflection indices, odd/even flag, original id) in the saved reflection tables.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Multiprocessing (&amp;lt;code&amp;gt;mp&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mp.method&amp;lt;/code&amp;gt; || mpi || Multiprocessing method (only &amp;lt;code&amp;gt;mpi&amp;lt;/code&amp;gt; is currently supported).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mp.debug.cProfile&amp;lt;/code&amp;gt; || False || Enable code profiling; a &amp;lt;code&amp;gt;.prof&amp;lt;/code&amp;gt; file is written per rank.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Output files ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;merge&amp;lt;/code&amp;gt; worker gathers all HKLs at rank 0 and writes three MTZ files, prefixed with&lt;br /&gt;
&amp;lt;code&amp;gt;output.prefix&amp;lt;/code&amp;gt; (default &amp;lt;code&amp;gt;iobs&amp;lt;/code&amp;gt;):&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;amp;lt;prefix&amp;amp;gt;_all.mtz&amp;lt;/code&amp;gt; — the merged dataset using all observations (the main result for structure solution)&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;amp;lt;prefix&amp;amp;gt;_odd.mtz&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;&amp;amp;lt;prefix&amp;amp;gt;_even.mtz&amp;lt;/code&amp;gt; — the two half-datasets used for CC½ and related half-dataset statistics&lt;br /&gt;
&lt;br /&gt;
A main log records the per-step progress and the merging statistics tables by resolution bin:&lt;br /&gt;
completeness, multiplicity and ⟨I/σ⟩, plus the &amp;quot;Table of Scaling Results&amp;quot; reporting CC½ (the&lt;br /&gt;
half-dataset correlation, labelled &amp;quot;CC int&amp;quot;), CC&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt;, R&amp;lt;sub&amp;gt;int&amp;lt;/sub&amp;gt;, R&amp;lt;sub&amp;gt;split&amp;lt;/sub&amp;gt;&lt;br /&gt;
and R&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt;.  The merged MTZ can optionally be&lt;br /&gt;
uploaded to a shared [https://github.com/cctbx/cctbx_project/tree/master/xfel/merging/application/publish Google Drive folder] by adding the &amp;lt;code&amp;gt;publish&amp;lt;/code&amp;gt; worker.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
* Sauter NK (2015). &#039;&#039;J Synchrotron Radiat&#039;&#039; &#039;&#039;&#039;22&#039;&#039;&#039;, 239–48. (post-refinement)&lt;br /&gt;
* Uervirojnangkoorn M, &#039;&#039;et al.&#039;&#039; (2015). &#039;&#039;eLife&#039;&#039; 10.7554/eLife.05421. (PRIME / bootstrap)&lt;br /&gt;
* Brewster AS, &#039;&#039;et al.&#039;&#039; (2018). &#039;&#039;Acta Cryst.&#039;&#039; D &#039;&#039;&#039;74&#039;&#039;&#039;, 877–894.&lt;br /&gt;
* Brewster AS, &#039;&#039;et al.&#039;&#039; (2019a). &#039;&#039;Computational Crystallography Newsletter&#039;&#039; &#039;&#039;&#039;10&#039;&#039;&#039;, 22–39. (XFEL GUI)&lt;br /&gt;
* Brewster AS, &#039;&#039;et al.&#039;&#039; (2019b). &#039;&#039;Acta Cryst.&#039;&#039; D &#039;&#039;&#039;75&#039;&#039;&#039;, 959–968. (error models)&lt;br /&gt;
* Mittan-Moreau (2025). (mm24 error model)&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
* [[dials.stills_process]] — produces the integrated data that &amp;lt;code&amp;gt;cctbx.xfel.merge&amp;lt;/code&amp;gt; consumes&lt;br /&gt;
* [[cctbx.xfel GUI]] — orchestrates separate scaling and repeated merging as data are collected&lt;br /&gt;
* The program README at &amp;lt;code&amp;gt;xfel/merging/README.md&amp;lt;/code&amp;gt; in cctbx_project&lt;/div&gt;</summary>
		<author><name>Aaron</name></author>
	</entry>
	<entry>
		<id>http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Cctbx.xfel.merge&amp;diff=1781</id>
		<title>Cctbx.xfel.merge</title>
		<link rel="alternate" type="text/html" href="http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Cctbx.xfel.merge&amp;diff=1781"/>
		<updated>2026-08-21T23:22:00Z</updated>

		<summary type="html">&lt;p&gt;Aaron: /* Selecting individual reflections (select) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= &#039;&#039;cctbx.xfel.merge&#039;&#039; =&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;cctbx.xfel.merge&#039;&#039;&#039;&#039;&#039; is the scaling, post-refinement and merging program of cctbx.xfel. It takes&lt;br /&gt;
the per-image integrated results produced by &#039;&#039;[[dials.stills_process]]&#039;&#039; — one crystal per still shot —&lt;br /&gt;
and reduces the whole ensemble to a single set of merged structure-factor intensities (an MTZ file)&lt;br /&gt;
suitable for structure solution and refinement, together with the crystallographic quality&lt;br /&gt;
statistics (completeness, multiplicity, ⟨I/σ⟩, CC½, CC&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt;, R-factors, etc.).&lt;br /&gt;
&lt;br /&gt;
Because serial datasets routinely contain tens of thousands to millions of still shots,&lt;br /&gt;
&amp;lt;code&amp;gt;cctbx.xfel.merge&amp;lt;/code&amp;gt; is built from the ground up to run under MPI across many nodes. It is&lt;br /&gt;
almost always launched with &amp;lt;code&amp;gt;mpirun&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;srun&amp;lt;/code&amp;gt;.  Note that MPI uses the term &#039;ranks&#039;&lt;br /&gt;
to distinguish independent processes that are running across one or more nodes.&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;cctbx.xfel.merge&amp;lt;/code&amp;gt; is organized as a sequence of &#039;&#039;&#039;workers&#039;&#039;&#039;. Each worker performs one&lt;br /&gt;
task — reading data, applying a correction, filtering, scaling, post-refining, computing a statistic,&lt;br /&gt;
or merging — and passes its (possibly modified) experiments and reflections on to the next worker.&lt;br /&gt;
The list of workers to run is the &amp;quot;step list&amp;quot;, and it is fully configurable: you can add, remove or&lt;br /&gt;
reorder steps with &amp;lt;code&amp;gt;dispatch.step_list&amp;lt;/code&amp;gt;. This is what makes the program flexible enough to&lt;br /&gt;
scale-and-merge in one pass, to scale subsets separately and merge later, or to run a reference-free&lt;br /&gt;
bootstrap.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;default&#039;&#039;&#039; step list is:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! # !! Worker !! Purpose&lt;br /&gt;
|-&lt;br /&gt;
| 1 || &amp;lt;code&amp;gt;input&amp;lt;/code&amp;gt; || Read integrated experiments (&amp;lt;code&amp;gt;.expt&amp;lt;/code&amp;gt;) and reflections (&amp;lt;code&amp;gt;.refl&amp;lt;/code&amp;gt;) from disk in DIALS format.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || &amp;lt;code&amp;gt;balance&amp;lt;/code&amp;gt; || Redistribute the input load evenly across MPI ranks (needed when there are fewer or more input files than ranks).&lt;br /&gt;
|-&lt;br /&gt;
| 3 || &amp;lt;code&amp;gt;model_scaling&amp;lt;/code&amp;gt; || Build the full Miller list, model intensities from the reference, and the resolution binner used for scaling and post-refinement.&lt;br /&gt;
|-&lt;br /&gt;
| 4 || &amp;lt;code&amp;gt;modify&amp;lt;/code&amp;gt; || Apply per-reflection modifications, e.g. polarization correction (and optionally re-indexing to resolve indexing ambiguity — see &amp;lt;code&amp;gt;modify.cosym&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;reindex_to_reference&amp;lt;/code&amp;gt;).&lt;br /&gt;
|-&lt;br /&gt;
| 5 || &amp;lt;code&amp;gt;filter&amp;lt;/code&amp;gt; || Reject whole experiments (or reflections) by resolution, unit cell, correlation to the reference, energy, etc.&lt;br /&gt;
|-&lt;br /&gt;
| 6 || &amp;lt;code&amp;gt;scale&amp;lt;/code&amp;gt; || Scale each lattice to the reference dataset (&amp;lt;code&amp;gt;mark0&amp;lt;/code&amp;gt;) or simply average (&amp;lt;code&amp;gt;mark1&amp;lt;/code&amp;gt;).&lt;br /&gt;
|-&lt;br /&gt;
| 7 || &amp;lt;code&amp;gt;postrefine&amp;lt;/code&amp;gt; || Post-refine per-image crystal parameters and partialities (Sauter 2015).&lt;br /&gt;
|-&lt;br /&gt;
| 8 || &amp;lt;code&amp;gt;statistics_unitcell&amp;lt;/code&amp;gt; || Determine and store the average unit cell.&lt;br /&gt;
|-&lt;br /&gt;
| 9 || &amp;lt;code&amp;gt;statistics_beam&amp;lt;/code&amp;gt; || Determine and store the average wavelength.&lt;br /&gt;
|-&lt;br /&gt;
| 10 || &amp;lt;code&amp;gt;model_statistics&amp;lt;/code&amp;gt; || Rebuild the Miller list / binner for statistics (may use the average unit cell).&lt;br /&gt;
|-&lt;br /&gt;
| 11 || &amp;lt;code&amp;gt;statistics_resolution&amp;lt;/code&amp;gt; || Per-crystal resolution statistics.&lt;br /&gt;
|-&lt;br /&gt;
| 12 || &amp;lt;code&amp;gt;group&amp;lt;/code&amp;gt; || Redistribute reflections across ranks so that every observation of a given HKL is gathered on the same rank prior to merging.&lt;br /&gt;
|-&lt;br /&gt;
| 13 || &amp;lt;code&amp;gt;errors_merge&amp;lt;/code&amp;gt; || Correct the merged error estimates with a per-HKL error model (e.g. Ev11, Brewster 2019b, or MM24 (the default), Mittan-Moreau (2025)).&lt;br /&gt;
|-&lt;br /&gt;
| 14 || &amp;lt;code&amp;gt;statistics_intensity&amp;lt;/code&amp;gt; || Intensity statistics by resolution.&lt;br /&gt;
|-&lt;br /&gt;
| 15 || &amp;lt;code&amp;gt;merge&amp;lt;/code&amp;gt; || Merge symmetry-equivalent intensities, gather all HKLs at rank 0, and write &amp;quot;odd&amp;quot;, &amp;quot;even&amp;quot; and &amp;quot;all&amp;quot; MTZ files.&lt;br /&gt;
|-&lt;br /&gt;
| 16 || &amp;lt;code&amp;gt;statistics_intensity_cxi&amp;lt;/code&amp;gt; || Correlation and R-factor statistics (ported from cxi.merge): the &amp;quot;Table of Scaling Results&amp;quot; — CC½ (half-dataset correlation, labelled &amp;quot;CC int&amp;quot;), CC&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt;, R&amp;lt;sub&amp;gt;int&amp;lt;/sub&amp;gt;, R&amp;lt;sub&amp;gt;split&amp;lt;/sub&amp;gt;, R&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Additional, non-default workers are available and can be&lt;br /&gt;
inserted into the step list, including &amp;lt;code&amp;gt;tdata&amp;lt;/code&amp;gt; (write out unit cells for clustering),&lt;br /&gt;
&amp;lt;code&amp;gt;export&amp;lt;/code&amp;gt; (batch MTZ for &#039;&#039;Careless&#039;&#039;), &amp;lt;code&amp;gt;publish&amp;lt;/code&amp;gt; (upload merged files to a&lt;br /&gt;
Google Drive folder), &amp;lt;code&amp;gt;monitor&amp;lt;/code&amp;gt; (resource-usage logging), &amp;lt;code&amp;gt;integrate&amp;lt;/code&amp;gt;&lt;br /&gt;
(on-the-fly integration), &amp;lt;code&amp;gt;prepare&amp;lt;/code&amp;gt; (SpReAD energy binning), and&lt;br /&gt;
&amp;lt;code&amp;gt;lunus&amp;lt;/code&amp;gt; (diffuse-scattering deck). A &amp;lt;code&amp;gt;deltaccint&amp;lt;/code&amp;gt; worker (ΔCC½ lattice&lt;br /&gt;
filtering) can be added after &amp;lt;code&amp;gt;group&amp;lt;/code&amp;gt;. Custom workers can be supplied through the&lt;br /&gt;
&amp;lt;code&amp;gt;XFEL_CUSTOM_WORKER_PATH&amp;lt;/code&amp;gt; environment variable.&lt;br /&gt;
&lt;br /&gt;
== Basic usage ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;cctbx.xfel.merge&amp;lt;/code&amp;gt; is run under MPI:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mpirun cctbx.xfel.merge merge.phil&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A typical &amp;lt;code&amp;gt;merge.phil&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
input.path=&amp;lt;path to data&amp;gt;&lt;br /&gt;
input.experiments_suffix=.expt&lt;br /&gt;
input.reflections_suffix=.refl&lt;br /&gt;
&lt;br /&gt;
filter.algorithm=unit_cell&lt;br /&gt;
filter.unit_cell.value.relative_length_tolerance=0.03&lt;br /&gt;
filter.outlier.min_corr=0.1&lt;br /&gt;
&lt;br /&gt;
select.algorithm=significance_filter&lt;br /&gt;
select.significance_filter.sigma=0.1&lt;br /&gt;
select.significance_filter.min_ct=200&lt;br /&gt;
select.significance_filter.max_ct=300&lt;br /&gt;
&lt;br /&gt;
scaling.model=&amp;lt;model.pdb or model.mtz&amp;gt;&lt;br /&gt;
scaling.resolution_scalar=0.96&lt;br /&gt;
&lt;br /&gt;
merging.d_min=1.8&lt;br /&gt;
merging.error.model=mm24&lt;br /&gt;
merging.merge_anomalous=True&lt;br /&gt;
&lt;br /&gt;
postrefinement.enable=True&lt;br /&gt;
statistics.n_bins=20&lt;br /&gt;
&lt;br /&gt;
output.do_timing=True&lt;br /&gt;
output.output_dir=&amp;lt;output folder&amp;gt;&lt;br /&gt;
output.prefix=&amp;lt;prefix for output files&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Explore the parameters with:&lt;br /&gt;
* &amp;lt;code&amp;gt;cctbx.xfel.merge -c&amp;lt;/code&amp;gt; — show configurable parameters&lt;br /&gt;
* &amp;lt;code&amp;gt;cctbx.xfel.merge -c -e 10 -a 2&amp;lt;/code&amp;gt; — show all parameters (expert level 10) with full help text&lt;br /&gt;
&lt;br /&gt;
== Two-stage scaling and merging ==&lt;br /&gt;
&lt;br /&gt;
For large, growing datasets (the mode used by the [[cctbx.xfel GUI]]), it is more efficient to scale&lt;br /&gt;
and post-refine each subset of data &#039;&#039;&#039;once&#039;&#039;&#039;, then merge repeatedly as more data arrive. This is&lt;br /&gt;
done by running the program twice with different step lists.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Stage 1 — scale each subset&#039;&#039;&#039; (stops after per-image work and writes intermediate DIALS files):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dispatch.step_list=input balance model_scaling modify filter scale postrefine \&lt;br /&gt;
    statistics_unitcell statistics_beam model_statistics statistics_resolution&lt;br /&gt;
output.save_experiments_and_reflections=True&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;output.save_experiments_and_reflections=True&amp;lt;/code&amp;gt; dumps the scaled/post-refined data as&lt;br /&gt;
experiment lists and reflection tables that the merge stage can read back in.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Stage 2 — merge the scaled subsets&#039;&#039;&#039; (add an &amp;lt;code&amp;gt;input.path&amp;lt;/code&amp;gt; for each finished subset):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dispatch.step_list=input model_scaling statistics_unitcell statistics_beam \&lt;br /&gt;
    model_statistics statistics_resolution group errors_merge statistics_intensity \&lt;br /&gt;
    merge statistics_intensity_cxi&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Merging without a reference (bootstrap / mark1) ==&lt;br /&gt;
&lt;br /&gt;
If no scaling/merging reference is available, use a bootstrap procedure. First run the&lt;br /&gt;
&amp;lt;code&amp;gt;mark1&amp;lt;/code&amp;gt; algorithm, which simply averages the data (all per-image scale factors = 1, no&lt;br /&gt;
post-refinement), specifying the target cell and symmetry explicitly:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
scaling.algorithm=mark1&lt;br /&gt;
scaling.unit_cell=&amp;lt;unit cell&amp;gt;&lt;br /&gt;
scaling.space_group=&amp;lt;space group&amp;gt;&lt;br /&gt;
merging.error.model=errors_from_sample_residuals&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The resulting MTZ is then used as the reference (&amp;lt;code&amp;gt;scaling.model=&amp;lt;/code&amp;gt;) for subsequent regular&lt;br /&gt;
merges. Iterate a few cycles; CC½ typically improves and converges over the first few rounds.&lt;br /&gt;
&lt;br /&gt;
== Important parameters ==&lt;br /&gt;
&lt;br /&gt;
Parameters are given by their full PHIL path with defaults in parentheses. The program exposes many&lt;br /&gt;
more parameters (see &amp;lt;code&amp;gt;-c -e 10 -a 2&amp;lt;/code&amp;gt;); those below are the ones most commonly set.&lt;br /&gt;
&lt;br /&gt;
=== Input ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.path&amp;lt;/code&amp;gt; || None || Path(s) to the integrated data — a folder, several folders, or individual files; wildcards allowed; may be repeated. Matching &amp;lt;code&amp;gt;.expt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;.refl&amp;lt;/code&amp;gt; files must both be present.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.experiments_suffix&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;_integrated.expt&amp;lt;/code&amp;gt; || Only load experiment files ending with this suffix.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.reflections_suffix&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;_integrated.refl&amp;lt;/code&amp;gt; || Only load reflection files ending with this suffix.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.parallel_file_load.method&amp;lt;/code&amp;gt; || uniform || &amp;lt;code&amp;gt;uniform&amp;lt;/code&amp;gt; spreads input files evenly over all ranks; &amp;lt;code&amp;gt;node_memory&amp;lt;/code&amp;gt; distributes so per-node memory limits are respected.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.alist.file&amp;lt;/code&amp;gt; || None || Path to a text file of experiment tags or filenames; combined with &amp;lt;code&amp;gt;input.alist.op=keep|reject&amp;lt;/code&amp;gt; to merge only (or exclude) a specified subset.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.persistent_refl_cols&amp;lt;/code&amp;gt; || None || Reflection-table columns to preserve through the pruning steps (and into saved tables).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Filtering whole experiments (&amp;lt;code&amp;gt;filter&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;filter&amp;lt;/code&amp;gt; section accepts or rejects &#039;&#039;&#039;entire experiments&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.algorithm&amp;lt;/code&amp;gt; || (none) || One or more of &amp;lt;code&amp;gt;n_obs&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;resolution&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;unit_cell&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;energy&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bootstrap&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;experiment_prefix&amp;lt;/code&amp;gt;. Nothing is filtered unless listed.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.unit_cell.algorithm&amp;lt;/code&amp;gt; || value || How to restrict unit cells: &amp;lt;code&amp;gt;value&amp;lt;/code&amp;gt; (compare to a target), &amp;lt;code&amp;gt;range&amp;lt;/code&amp;gt;, or &amp;lt;code&amp;gt;cluster&amp;lt;/code&amp;gt; (use a precomputed covariance clustering).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.unit_cell.value.relative_length_tolerance&amp;lt;/code&amp;gt; || 0.1 || Fractional deviation of cell edge lengths allowed vs. the target cell. Often tightened (e.g. 0.03).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.unit_cell.value.absolute_angle_tolerance&amp;lt;/code&amp;gt; || 2.0 || Allowed cell-angle deviation (degrees) vs. the target.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.unit_cell.value.target_unit_cell&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;target_space_group&amp;lt;/code&amp;gt; || Auto || Target cell/symmetry; &amp;lt;code&amp;gt;Auto&amp;lt;/code&amp;gt; uses the scaling model.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.outlier.min_corr&amp;lt;/code&amp;gt; || 0.1 || Minimum correlation of an image&#039;s intensities to the reference model; images below this are rejected. Only applied when a scaling model is present. Use &amp;lt;code&amp;gt;-1&amp;lt;/code&amp;gt; to accept all images regardless of correlation.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.resolution.d_min&amp;lt;/code&amp;gt; || None || Reject an experiment unless some of its reflections extend beyond this resolution.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Selecting individual reflections (&amp;lt;code&amp;gt;select&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;select&amp;lt;/code&amp;gt; section accepts or rejects &#039;&#039;&#039;individual reflections&#039;&#039;&#039; (contrast with&lt;br /&gt;
&amp;lt;code&amp;gt;filter&amp;lt;/code&amp;gt;, which acts on whole experiments).&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;select.algorithm&amp;lt;/code&amp;gt; || (none) || One or more of &amp;lt;code&amp;gt;significance_filter&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;panel&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cspad_sensor&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;isolation_forest&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;target_energy&amp;lt;/code&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;select.significance_filter.sigma&amp;lt;/code&amp;gt; || 0.5 || Trim each lattice at the resolution where the binned ⟨I/σ⟩ drops below this value.  Often reduced to 0.1.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;select.significance_filter.min_ct&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;max_ct&amp;lt;/code&amp;gt; || 10 / 50 || Target minimum/maximum mean reflections per resolution bin when choosing the number of bins. For large unit cells these are often raised (e.g. 200/300); for small cells, use the defaults.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Modifying intensities (&amp;lt;code&amp;gt;modify&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;modify.algorithm&amp;lt;/code&amp;gt; || polarization || Per-reflection corrections to apply (default applies the polarization correction).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;modify.cosym&amp;lt;/code&amp;gt; || — || Resolve an indexing ambiguity across the ensemble using the Gildea/Winter (Brehm/Diederichs) cosym method, optionally anchored to &amp;lt;code&amp;gt;scaling.model&amp;lt;/code&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;modify.reindex_to_reference&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;reindex_to_abc&amp;lt;/code&amp;gt; || — || Alternative re-indexing operators (to a reference model, or an explicit operator).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Scaling (&amp;lt;code&amp;gt;scaling&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;scaling.model&amp;lt;/code&amp;gt; || None || Reference dataset: a PDB file (uses the CRYST1 cell and computes model intensities, including bulk solvent) or an MTZ from a previous cycle. Required for &amp;lt;code&amp;gt;mark0&amp;lt;/code&amp;gt; scaling.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;scaling.algorithm&amp;lt;/code&amp;gt; || mark0 || &amp;lt;code&amp;gt;mark0&amp;lt;/code&amp;gt;: per-image scaling against the reference. &amp;lt;code&amp;gt;mark1&amp;lt;/code&amp;gt;: no scaling, just Monte-Carlo averaging (all scale factors = 1) — used for reference-free bootstrap.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;scaling.unit_cell&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;scaling.space_group&amp;lt;/code&amp;gt; || None || Cell/symmetry to use when no model is provided (i.e. &amp;lt;code&amp;gt;mark1&amp;lt;/code&amp;gt;).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;scaling.resolution_scalar&amp;lt;/code&amp;gt; || 0.969 || &amp;lt;code&amp;gt;merging.d_min&amp;lt;/code&amp;gt; is multiplied by this when deciding which reflections fall within the resolution limit, generating a few extra reference reflections to account for per-shot cell variation (e.g. set 0.96 for a few more).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;scaling.mtz.mtz_column_F&amp;lt;/code&amp;gt; || fobs || Column name in the reference MTZ containing the reference structure factors (intensities or amplitudes).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Post-refinement (&amp;lt;code&amp;gt;postrefinement&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;postrefinement.enable&amp;lt;/code&amp;gt; || True || Enable post-refinement of per-image parameters/partialities (Sauter 2015).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;postrefinement.algorithm&amp;lt;/code&amp;gt; || rs || Post-refinement protocol: &amp;lt;code&amp;gt;rs&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;rs2&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;rs_hybrid&amp;lt;/code&amp;gt;, or &amp;lt;code&amp;gt;eta_deff&amp;lt;/code&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Merging and error model (&amp;lt;code&amp;gt;merging&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;merging.d_min&amp;lt;/code&amp;gt; || None || High-resolution limit for scaling and merging.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;merging.d_max&amp;lt;/code&amp;gt; || None || Low-resolution limit (currently affects only CCiso).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;merging.merge_anomalous&amp;lt;/code&amp;gt; || False || &amp;lt;code&amp;gt;True&amp;lt;/code&amp;gt; merges Bijvoet mates together (higher multiplicity); &amp;lt;code&amp;gt;False&amp;lt;/code&amp;gt; keeps them separate to preserve the anomalous signal.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;merging.minimum_multiplicity&amp;lt;/code&amp;gt; || 2 || Do not produce a merged structure factor for HKLs measured fewer than this many times.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;merging.error.model&amp;lt;/code&amp;gt; || mm24 || Merged-sigma error model: &amp;lt;code&amp;gt;mm24&amp;lt;/code&amp;gt; (Mittan-Moreau 2025, current default), &amp;lt;code&amp;gt;ev11&amp;lt;/code&amp;gt; (Evans 2011 / sdfac-refine, recommended in the README), &amp;lt;code&amp;gt;ha14&amp;lt;/code&amp;gt;, or &amp;lt;code&amp;gt;errors_from_sample_residuals&amp;lt;/code&amp;gt; (no refined error terms — used with &amp;lt;code&amp;gt;mark1&amp;lt;/code&amp;gt; bootstrap).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;merging.set_average_unit_cell&amp;lt;/code&amp;gt; || True || Output MTZ adopts the (cluster-derived) average unit cell of the data rather than the reference model&#039;s cell.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Statistics (&amp;lt;code&amp;gt;statistics&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;statistics.n_bins&amp;lt;/code&amp;gt; || 10 || Number of resolution bins in the statistics tables.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;statistics.cciso.mtz_file&amp;lt;/code&amp;gt; || None || Isomorphous reference structure factors for R&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt; / CC&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;statistics.report_ML&amp;lt;/code&amp;gt; || True || Report per-frame max-likelihood attributes (domain size, mosaicity).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Output (&amp;lt;code&amp;gt;output&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.output_dir&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;.&amp;lt;/code&amp;gt; || Directory for output files (created if it does not exist).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.prefix&amp;lt;/code&amp;gt; || iobs || Prefix prepended to all output file names.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.save_experiments_and_reflections&amp;lt;/code&amp;gt; || False || Dump the final experiments/reflections from the last worker as DIALS files — used for the two-stage scale-then-merge workflow.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.do_timing&amp;lt;/code&amp;gt; || False || Log elapsed time per execution step.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.expanded_bookkeeping&amp;lt;/code&amp;gt; || False || Store extra provenance columns (input file/reflection indices, odd/even flag, original id) in the saved reflection tables.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Multiprocessing (&amp;lt;code&amp;gt;mp&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mp.method&amp;lt;/code&amp;gt; || mpi || Multiprocessing method (only &amp;lt;code&amp;gt;mpi&amp;lt;/code&amp;gt; is currently supported).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mp.debug.cProfile&amp;lt;/code&amp;gt; || False || Enable code profiling; a &amp;lt;code&amp;gt;.prof&amp;lt;/code&amp;gt; file is written per rank.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Output files ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;merge&amp;lt;/code&amp;gt; worker gathers all HKLs at rank 0 and writes three MTZ files, prefixed with&lt;br /&gt;
&amp;lt;code&amp;gt;output.prefix&amp;lt;/code&amp;gt; (default &amp;lt;code&amp;gt;iobs&amp;lt;/code&amp;gt;):&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;amp;lt;prefix&amp;amp;gt;_all.mtz&amp;lt;/code&amp;gt; — the merged dataset using all observations (the main result for structure solution)&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;amp;lt;prefix&amp;amp;gt;_odd.mtz&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;&amp;amp;lt;prefix&amp;amp;gt;_even.mtz&amp;lt;/code&amp;gt; — the two half-datasets used for CC½ and related half-dataset statistics&lt;br /&gt;
&lt;br /&gt;
A main log records the per-step progress and the merging statistics tables by resolution bin:&lt;br /&gt;
completeness, multiplicity and ⟨I/σ⟩, plus the &amp;quot;Table of Scaling Results&amp;quot; reporting CC½ (the&lt;br /&gt;
half-dataset correlation, labelled &amp;quot;CC int&amp;quot;), CC&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt;, R&amp;lt;sub&amp;gt;int&amp;lt;/sub&amp;gt;, R&amp;lt;sub&amp;gt;split&amp;lt;/sub&amp;gt;&lt;br /&gt;
and R&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt;.  The merged MTZ can optionally be&lt;br /&gt;
uploaded to a shared [https://github.com/cctbx/cctbx_project/tree/master/xfel/merging/application/publish Google Drive folder] by adding the &amp;lt;code&amp;gt;publish&amp;lt;/code&amp;gt; worker.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
* Sauter NK (2015). &#039;&#039;J Synchrotron Radiat&#039;&#039; &#039;&#039;&#039;22&#039;&#039;&#039;, 239–48. (post-refinement)&lt;br /&gt;
* Uervirojnangkoorn M, &#039;&#039;et al.&#039;&#039; (2015). &#039;&#039;eLife&#039;&#039; 10.7554/eLife.05421. (PRIME / bootstrap)&lt;br /&gt;
* Brewster AS, &#039;&#039;et al.&#039;&#039; (2018). &#039;&#039;Acta Cryst.&#039;&#039; D &#039;&#039;&#039;74&#039;&#039;&#039;, 877–894.&lt;br /&gt;
* Brewster AS, &#039;&#039;et al.&#039;&#039; (2019a). &#039;&#039;Computational Crystallography Newsletter&#039;&#039; &#039;&#039;&#039;10&#039;&#039;&#039;, 22–39. (XFEL GUI)&lt;br /&gt;
* Brewster AS, &#039;&#039;et al.&#039;&#039; (2019b). &#039;&#039;Acta Cryst.&#039;&#039; D &#039;&#039;&#039;75&#039;&#039;&#039;, 959–968. (error models)&lt;br /&gt;
* Mittan-Moreau (2025). (mm24 error model)&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
* [[dials.stills_process]] — produces the integrated data that &amp;lt;code&amp;gt;cctbx.xfel.merge&amp;lt;/code&amp;gt; consumes&lt;br /&gt;
* [[cctbx.xfel GUI]] — orchestrates separate scaling and repeated merging as data are collected&lt;br /&gt;
* The program README at &amp;lt;code&amp;gt;xfel/merging/README.md&amp;lt;/code&amp;gt; in cctbx_project&lt;/div&gt;</summary>
		<author><name>Aaron</name></author>
	</entry>
	<entry>
		<id>http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Cctbx.xfel.merge&amp;diff=1780</id>
		<title>Cctbx.xfel.merge</title>
		<link rel="alternate" type="text/html" href="http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Cctbx.xfel.merge&amp;diff=1780"/>
		<updated>2026-08-21T23:18:48Z</updated>

		<summary type="html">&lt;p&gt;Aaron: /* Two-stage scaling and merging */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= &#039;&#039;cctbx.xfel.merge&#039;&#039; =&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;cctbx.xfel.merge&#039;&#039;&#039;&#039;&#039; is the scaling, post-refinement and merging program of cctbx.xfel. It takes&lt;br /&gt;
the per-image integrated results produced by &#039;&#039;[[dials.stills_process]]&#039;&#039; — one crystal per still shot —&lt;br /&gt;
and reduces the whole ensemble to a single set of merged structure-factor intensities (an MTZ file)&lt;br /&gt;
suitable for structure solution and refinement, together with the crystallographic quality&lt;br /&gt;
statistics (completeness, multiplicity, ⟨I/σ⟩, CC½, CC&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt;, R-factors, etc.).&lt;br /&gt;
&lt;br /&gt;
Because serial datasets routinely contain tens of thousands to millions of still shots,&lt;br /&gt;
&amp;lt;code&amp;gt;cctbx.xfel.merge&amp;lt;/code&amp;gt; is built from the ground up to run under MPI across many nodes. It is&lt;br /&gt;
almost always launched with &amp;lt;code&amp;gt;mpirun&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;srun&amp;lt;/code&amp;gt;.  Note that MPI uses the term &#039;ranks&#039;&lt;br /&gt;
to distinguish independent processes that are running across one or more nodes.&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;cctbx.xfel.merge&amp;lt;/code&amp;gt; is organized as a sequence of &#039;&#039;&#039;workers&#039;&#039;&#039;. Each worker performs one&lt;br /&gt;
task — reading data, applying a correction, filtering, scaling, post-refining, computing a statistic,&lt;br /&gt;
or merging — and passes its (possibly modified) experiments and reflections on to the next worker.&lt;br /&gt;
The list of workers to run is the &amp;quot;step list&amp;quot;, and it is fully configurable: you can add, remove or&lt;br /&gt;
reorder steps with &amp;lt;code&amp;gt;dispatch.step_list&amp;lt;/code&amp;gt;. This is what makes the program flexible enough to&lt;br /&gt;
scale-and-merge in one pass, to scale subsets separately and merge later, or to run a reference-free&lt;br /&gt;
bootstrap.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;default&#039;&#039;&#039; step list is:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! # !! Worker !! Purpose&lt;br /&gt;
|-&lt;br /&gt;
| 1 || &amp;lt;code&amp;gt;input&amp;lt;/code&amp;gt; || Read integrated experiments (&amp;lt;code&amp;gt;.expt&amp;lt;/code&amp;gt;) and reflections (&amp;lt;code&amp;gt;.refl&amp;lt;/code&amp;gt;) from disk in DIALS format.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || &amp;lt;code&amp;gt;balance&amp;lt;/code&amp;gt; || Redistribute the input load evenly across MPI ranks (needed when there are fewer or more input files than ranks).&lt;br /&gt;
|-&lt;br /&gt;
| 3 || &amp;lt;code&amp;gt;model_scaling&amp;lt;/code&amp;gt; || Build the full Miller list, model intensities from the reference, and the resolution binner used for scaling and post-refinement.&lt;br /&gt;
|-&lt;br /&gt;
| 4 || &amp;lt;code&amp;gt;modify&amp;lt;/code&amp;gt; || Apply per-reflection modifications, e.g. polarization correction (and optionally re-indexing to resolve indexing ambiguity — see &amp;lt;code&amp;gt;modify.cosym&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;reindex_to_reference&amp;lt;/code&amp;gt;).&lt;br /&gt;
|-&lt;br /&gt;
| 5 || &amp;lt;code&amp;gt;filter&amp;lt;/code&amp;gt; || Reject whole experiments (or reflections) by resolution, unit cell, correlation to the reference, energy, etc.&lt;br /&gt;
|-&lt;br /&gt;
| 6 || &amp;lt;code&amp;gt;scale&amp;lt;/code&amp;gt; || Scale each lattice to the reference dataset (&amp;lt;code&amp;gt;mark0&amp;lt;/code&amp;gt;) or simply average (&amp;lt;code&amp;gt;mark1&amp;lt;/code&amp;gt;).&lt;br /&gt;
|-&lt;br /&gt;
| 7 || &amp;lt;code&amp;gt;postrefine&amp;lt;/code&amp;gt; || Post-refine per-image crystal parameters and partialities (Sauter 2015).&lt;br /&gt;
|-&lt;br /&gt;
| 8 || &amp;lt;code&amp;gt;statistics_unitcell&amp;lt;/code&amp;gt; || Determine and store the average unit cell.&lt;br /&gt;
|-&lt;br /&gt;
| 9 || &amp;lt;code&amp;gt;statistics_beam&amp;lt;/code&amp;gt; || Determine and store the average wavelength.&lt;br /&gt;
|-&lt;br /&gt;
| 10 || &amp;lt;code&amp;gt;model_statistics&amp;lt;/code&amp;gt; || Rebuild the Miller list / binner for statistics (may use the average unit cell).&lt;br /&gt;
|-&lt;br /&gt;
| 11 || &amp;lt;code&amp;gt;statistics_resolution&amp;lt;/code&amp;gt; || Per-crystal resolution statistics.&lt;br /&gt;
|-&lt;br /&gt;
| 12 || &amp;lt;code&amp;gt;group&amp;lt;/code&amp;gt; || Redistribute reflections across ranks so that every observation of a given HKL is gathered on the same rank prior to merging.&lt;br /&gt;
|-&lt;br /&gt;
| 13 || &amp;lt;code&amp;gt;errors_merge&amp;lt;/code&amp;gt; || Correct the merged error estimates with a per-HKL error model (e.g. Ev11, Brewster 2019b, or MM24 (the default), Mittan-Moreau (2025)).&lt;br /&gt;
|-&lt;br /&gt;
| 14 || &amp;lt;code&amp;gt;statistics_intensity&amp;lt;/code&amp;gt; || Intensity statistics by resolution.&lt;br /&gt;
|-&lt;br /&gt;
| 15 || &amp;lt;code&amp;gt;merge&amp;lt;/code&amp;gt; || Merge symmetry-equivalent intensities, gather all HKLs at rank 0, and write &amp;quot;odd&amp;quot;, &amp;quot;even&amp;quot; and &amp;quot;all&amp;quot; MTZ files.&lt;br /&gt;
|-&lt;br /&gt;
| 16 || &amp;lt;code&amp;gt;statistics_intensity_cxi&amp;lt;/code&amp;gt; || Correlation and R-factor statistics (ported from cxi.merge): the &amp;quot;Table of Scaling Results&amp;quot; — CC½ (half-dataset correlation, labelled &amp;quot;CC int&amp;quot;), CC&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt;, R&amp;lt;sub&amp;gt;int&amp;lt;/sub&amp;gt;, R&amp;lt;sub&amp;gt;split&amp;lt;/sub&amp;gt;, R&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Additional, non-default workers are available and can be&lt;br /&gt;
inserted into the step list, including &amp;lt;code&amp;gt;tdata&amp;lt;/code&amp;gt; (write out unit cells for clustering),&lt;br /&gt;
&amp;lt;code&amp;gt;export&amp;lt;/code&amp;gt; (batch MTZ for &#039;&#039;Careless&#039;&#039;), &amp;lt;code&amp;gt;publish&amp;lt;/code&amp;gt; (upload merged files to a&lt;br /&gt;
Google Drive folder), &amp;lt;code&amp;gt;monitor&amp;lt;/code&amp;gt; (resource-usage logging), &amp;lt;code&amp;gt;integrate&amp;lt;/code&amp;gt;&lt;br /&gt;
(on-the-fly integration), &amp;lt;code&amp;gt;prepare&amp;lt;/code&amp;gt; (SpReAD energy binning), and&lt;br /&gt;
&amp;lt;code&amp;gt;lunus&amp;lt;/code&amp;gt; (diffuse-scattering deck). A &amp;lt;code&amp;gt;deltaccint&amp;lt;/code&amp;gt; worker (ΔCC½ lattice&lt;br /&gt;
filtering) can be added after &amp;lt;code&amp;gt;group&amp;lt;/code&amp;gt;. Custom workers can be supplied through the&lt;br /&gt;
&amp;lt;code&amp;gt;XFEL_CUSTOM_WORKER_PATH&amp;lt;/code&amp;gt; environment variable.&lt;br /&gt;
&lt;br /&gt;
== Basic usage ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;cctbx.xfel.merge&amp;lt;/code&amp;gt; is run under MPI:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mpirun cctbx.xfel.merge merge.phil&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A typical &amp;lt;code&amp;gt;merge.phil&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
input.path=&amp;lt;path to data&amp;gt;&lt;br /&gt;
input.experiments_suffix=.expt&lt;br /&gt;
input.reflections_suffix=.refl&lt;br /&gt;
&lt;br /&gt;
filter.algorithm=unit_cell&lt;br /&gt;
filter.unit_cell.value.relative_length_tolerance=0.03&lt;br /&gt;
filter.outlier.min_corr=0.1&lt;br /&gt;
&lt;br /&gt;
select.algorithm=significance_filter&lt;br /&gt;
select.significance_filter.sigma=0.1&lt;br /&gt;
select.significance_filter.min_ct=200&lt;br /&gt;
select.significance_filter.max_ct=300&lt;br /&gt;
&lt;br /&gt;
scaling.model=&amp;lt;model.pdb or model.mtz&amp;gt;&lt;br /&gt;
scaling.resolution_scalar=0.96&lt;br /&gt;
&lt;br /&gt;
merging.d_min=1.8&lt;br /&gt;
merging.error.model=mm24&lt;br /&gt;
merging.merge_anomalous=True&lt;br /&gt;
&lt;br /&gt;
postrefinement.enable=True&lt;br /&gt;
statistics.n_bins=20&lt;br /&gt;
&lt;br /&gt;
output.do_timing=True&lt;br /&gt;
output.output_dir=&amp;lt;output folder&amp;gt;&lt;br /&gt;
output.prefix=&amp;lt;prefix for output files&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Explore the parameters with:&lt;br /&gt;
* &amp;lt;code&amp;gt;cctbx.xfel.merge -c&amp;lt;/code&amp;gt; — show configurable parameters&lt;br /&gt;
* &amp;lt;code&amp;gt;cctbx.xfel.merge -c -e 10 -a 2&amp;lt;/code&amp;gt; — show all parameters (expert level 10) with full help text&lt;br /&gt;
&lt;br /&gt;
== Two-stage scaling and merging ==&lt;br /&gt;
&lt;br /&gt;
For large, growing datasets (the mode used by the [[cctbx.xfel GUI]]), it is more efficient to scale&lt;br /&gt;
and post-refine each subset of data &#039;&#039;&#039;once&#039;&#039;&#039;, then merge repeatedly as more data arrive. This is&lt;br /&gt;
done by running the program twice with different step lists.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Stage 1 — scale each subset&#039;&#039;&#039; (stops after per-image work and writes intermediate DIALS files):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dispatch.step_list=input balance model_scaling modify filter scale postrefine \&lt;br /&gt;
    statistics_unitcell statistics_beam model_statistics statistics_resolution&lt;br /&gt;
output.save_experiments_and_reflections=True&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;output.save_experiments_and_reflections=True&amp;lt;/code&amp;gt; dumps the scaled/post-refined data as&lt;br /&gt;
experiment lists and reflection tables that the merge stage can read back in.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Stage 2 — merge the scaled subsets&#039;&#039;&#039; (add an &amp;lt;code&amp;gt;input.path&amp;lt;/code&amp;gt; for each finished subset):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dispatch.step_list=input model_scaling statistics_unitcell statistics_beam \&lt;br /&gt;
    model_statistics statistics_resolution group errors_merge statistics_intensity \&lt;br /&gt;
    merge statistics_intensity_cxi&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Merging without a reference (bootstrap / mark1) ==&lt;br /&gt;
&lt;br /&gt;
If no scaling/merging reference is available, use a bootstrap procedure. First run the&lt;br /&gt;
&amp;lt;code&amp;gt;mark1&amp;lt;/code&amp;gt; algorithm, which simply averages the data (all per-image scale factors = 1, no&lt;br /&gt;
post-refinement), specifying the target cell and symmetry explicitly:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
scaling.algorithm=mark1&lt;br /&gt;
scaling.unit_cell=&amp;lt;unit cell&amp;gt;&lt;br /&gt;
scaling.space_group=&amp;lt;space group&amp;gt;&lt;br /&gt;
merging.error.model=errors_from_sample_residuals&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The resulting MTZ is then used as the reference (&amp;lt;code&amp;gt;scaling.model=&amp;lt;/code&amp;gt;) for subsequent regular&lt;br /&gt;
merges. Iterate a few cycles; CC½ typically improves and converges over the first few rounds.&lt;br /&gt;
&lt;br /&gt;
== Important parameters ==&lt;br /&gt;
&lt;br /&gt;
Parameters are given by their full PHIL path with defaults in parentheses. The program exposes many&lt;br /&gt;
more parameters (see &amp;lt;code&amp;gt;-c -e 10 -a 2&amp;lt;/code&amp;gt;); those below are the ones most commonly set.&lt;br /&gt;
&lt;br /&gt;
=== Input ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.path&amp;lt;/code&amp;gt; || None || Path(s) to the integrated data — a folder, several folders, or individual files; wildcards allowed; may be repeated. Matching &amp;lt;code&amp;gt;.expt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;.refl&amp;lt;/code&amp;gt; files must both be present.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.experiments_suffix&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;_integrated.expt&amp;lt;/code&amp;gt; || Only load experiment files ending with this suffix.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.reflections_suffix&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;_integrated.refl&amp;lt;/code&amp;gt; || Only load reflection files ending with this suffix.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.parallel_file_load.method&amp;lt;/code&amp;gt; || uniform || &amp;lt;code&amp;gt;uniform&amp;lt;/code&amp;gt; spreads input files evenly over all ranks; &amp;lt;code&amp;gt;node_memory&amp;lt;/code&amp;gt; distributes so per-node memory limits are respected.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.alist.file&amp;lt;/code&amp;gt; || None || Path to a text file of experiment tags or filenames; combined with &amp;lt;code&amp;gt;input.alist.op=keep|reject&amp;lt;/code&amp;gt; to merge only (or exclude) a specified subset.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.persistent_refl_cols&amp;lt;/code&amp;gt; || None || Reflection-table columns to preserve through the pruning steps (and into saved tables).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Filtering whole experiments (&amp;lt;code&amp;gt;filter&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;filter&amp;lt;/code&amp;gt; section accepts or rejects &#039;&#039;&#039;entire experiments&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.algorithm&amp;lt;/code&amp;gt; || (none) || One or more of &amp;lt;code&amp;gt;n_obs&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;resolution&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;unit_cell&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;energy&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bootstrap&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;experiment_prefix&amp;lt;/code&amp;gt;. Nothing is filtered unless listed.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.unit_cell.algorithm&amp;lt;/code&amp;gt; || value || How to restrict unit cells: &amp;lt;code&amp;gt;value&amp;lt;/code&amp;gt; (compare to a target), &amp;lt;code&amp;gt;range&amp;lt;/code&amp;gt;, or &amp;lt;code&amp;gt;cluster&amp;lt;/code&amp;gt; (use a precomputed covariance clustering).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.unit_cell.value.relative_length_tolerance&amp;lt;/code&amp;gt; || 0.1 || Fractional deviation of cell edge lengths allowed vs. the target cell. Often tightened (e.g. 0.03).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.unit_cell.value.absolute_angle_tolerance&amp;lt;/code&amp;gt; || 2.0 || Allowed cell-angle deviation (degrees) vs. the target.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.unit_cell.value.target_unit_cell&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;target_space_group&amp;lt;/code&amp;gt; || Auto || Target cell/symmetry; &amp;lt;code&amp;gt;Auto&amp;lt;/code&amp;gt; uses the scaling model.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.outlier.min_corr&amp;lt;/code&amp;gt; || 0.1 || Minimum correlation of an image&#039;s intensities to the reference model; images below this are rejected. Only applied when a scaling model is present. Use &amp;lt;code&amp;gt;-1&amp;lt;/code&amp;gt; to accept all images regardless of correlation.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.resolution.d_min&amp;lt;/code&amp;gt; || None || Reject an experiment unless some of its reflections extend beyond this resolution.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Selecting individual reflections (&amp;lt;code&amp;gt;select&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;select&amp;lt;/code&amp;gt; section accepts or rejects &#039;&#039;&#039;individual reflections&#039;&#039;&#039; (contrast with&lt;br /&gt;
&amp;lt;code&amp;gt;filter&amp;lt;/code&amp;gt;, which acts on whole experiments).&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;select.algorithm&amp;lt;/code&amp;gt; || (none) || One or more of &amp;lt;code&amp;gt;significance_filter&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;panel&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cspad_sensor&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;isolation_forest&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;target_energy&amp;lt;/code&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;select.significance_filter.sigma&amp;lt;/code&amp;gt; || 0.5 || Trim each lattice at the resolution where the binned ⟨I/σ⟩ drops below this value.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;select.significance_filter.min_ct&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;max_ct&amp;lt;/code&amp;gt; || 10 / 50 || Target minimum/maximum mean reflections per resolution bin when choosing the number of bins. For large unit cells these are often raised (e.g. 200/300); for small cells, use the defaults.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Modifying intensities (&amp;lt;code&amp;gt;modify&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;modify.algorithm&amp;lt;/code&amp;gt; || polarization || Per-reflection corrections to apply (default applies the polarization correction).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;modify.cosym&amp;lt;/code&amp;gt; || — || Resolve an indexing ambiguity across the ensemble using the Gildea/Winter (Brehm/Diederichs) cosym method, optionally anchored to &amp;lt;code&amp;gt;scaling.model&amp;lt;/code&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;modify.reindex_to_reference&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;reindex_to_abc&amp;lt;/code&amp;gt; || — || Alternative re-indexing operators (to a reference model, or an explicit operator).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Scaling (&amp;lt;code&amp;gt;scaling&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;scaling.model&amp;lt;/code&amp;gt; || None || Reference dataset: a PDB file (uses the CRYST1 cell and computes model intensities, including bulk solvent) or an MTZ from a previous cycle. Required for &amp;lt;code&amp;gt;mark0&amp;lt;/code&amp;gt; scaling.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;scaling.algorithm&amp;lt;/code&amp;gt; || mark0 || &amp;lt;code&amp;gt;mark0&amp;lt;/code&amp;gt;: per-image scaling against the reference. &amp;lt;code&amp;gt;mark1&amp;lt;/code&amp;gt;: no scaling, just Monte-Carlo averaging (all scale factors = 1) — used for reference-free bootstrap.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;scaling.unit_cell&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;scaling.space_group&amp;lt;/code&amp;gt; || None || Cell/symmetry to use when no model is provided (i.e. &amp;lt;code&amp;gt;mark1&amp;lt;/code&amp;gt;).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;scaling.resolution_scalar&amp;lt;/code&amp;gt; || 0.969 || &amp;lt;code&amp;gt;merging.d_min&amp;lt;/code&amp;gt; is multiplied by this when deciding which reflections fall within the resolution limit, generating a few extra reference reflections to account for per-shot cell variation (e.g. set 0.96 for a few more).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;scaling.mtz.mtz_column_F&amp;lt;/code&amp;gt; || fobs || Column name in the reference MTZ containing the reference structure factors (intensities or amplitudes).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Post-refinement (&amp;lt;code&amp;gt;postrefinement&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;postrefinement.enable&amp;lt;/code&amp;gt; || True || Enable post-refinement of per-image parameters/partialities (Sauter 2015).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;postrefinement.algorithm&amp;lt;/code&amp;gt; || rs || Post-refinement protocol: &amp;lt;code&amp;gt;rs&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;rs2&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;rs_hybrid&amp;lt;/code&amp;gt;, or &amp;lt;code&amp;gt;eta_deff&amp;lt;/code&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Merging and error model (&amp;lt;code&amp;gt;merging&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;merging.d_min&amp;lt;/code&amp;gt; || None || High-resolution limit for scaling and merging.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;merging.d_max&amp;lt;/code&amp;gt; || None || Low-resolution limit (currently affects only CCiso).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;merging.merge_anomalous&amp;lt;/code&amp;gt; || False || &amp;lt;code&amp;gt;True&amp;lt;/code&amp;gt; merges Bijvoet mates together (higher multiplicity); &amp;lt;code&amp;gt;False&amp;lt;/code&amp;gt; keeps them separate to preserve the anomalous signal.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;merging.minimum_multiplicity&amp;lt;/code&amp;gt; || 2 || Do not produce a merged structure factor for HKLs measured fewer than this many times.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;merging.error.model&amp;lt;/code&amp;gt; || mm24 || Merged-sigma error model: &amp;lt;code&amp;gt;mm24&amp;lt;/code&amp;gt; (Mittan-Moreau 2025, current default), &amp;lt;code&amp;gt;ev11&amp;lt;/code&amp;gt; (Evans 2011 / sdfac-refine, recommended in the README), &amp;lt;code&amp;gt;ha14&amp;lt;/code&amp;gt;, or &amp;lt;code&amp;gt;errors_from_sample_residuals&amp;lt;/code&amp;gt; (no refined error terms — used with &amp;lt;code&amp;gt;mark1&amp;lt;/code&amp;gt; bootstrap).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;merging.set_average_unit_cell&amp;lt;/code&amp;gt; || True || Output MTZ adopts the (cluster-derived) average unit cell of the data rather than the reference model&#039;s cell.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Statistics (&amp;lt;code&amp;gt;statistics&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;statistics.n_bins&amp;lt;/code&amp;gt; || 10 || Number of resolution bins in the statistics tables.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;statistics.cciso.mtz_file&amp;lt;/code&amp;gt; || None || Isomorphous reference structure factors for R&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt; / CC&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;statistics.report_ML&amp;lt;/code&amp;gt; || True || Report per-frame max-likelihood attributes (domain size, mosaicity).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Output (&amp;lt;code&amp;gt;output&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.output_dir&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;.&amp;lt;/code&amp;gt; || Directory for output files (created if it does not exist).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.prefix&amp;lt;/code&amp;gt; || iobs || Prefix prepended to all output file names.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.save_experiments_and_reflections&amp;lt;/code&amp;gt; || False || Dump the final experiments/reflections from the last worker as DIALS files — used for the two-stage scale-then-merge workflow.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.do_timing&amp;lt;/code&amp;gt; || False || Log elapsed time per execution step.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.expanded_bookkeeping&amp;lt;/code&amp;gt; || False || Store extra provenance columns (input file/reflection indices, odd/even flag, original id) in the saved reflection tables.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Multiprocessing (&amp;lt;code&amp;gt;mp&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mp.method&amp;lt;/code&amp;gt; || mpi || Multiprocessing method (only &amp;lt;code&amp;gt;mpi&amp;lt;/code&amp;gt; is currently supported).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mp.debug.cProfile&amp;lt;/code&amp;gt; || False || Enable code profiling; a &amp;lt;code&amp;gt;.prof&amp;lt;/code&amp;gt; file is written per rank.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Output files ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;merge&amp;lt;/code&amp;gt; worker gathers all HKLs at rank 0 and writes three MTZ files, prefixed with&lt;br /&gt;
&amp;lt;code&amp;gt;output.prefix&amp;lt;/code&amp;gt; (default &amp;lt;code&amp;gt;iobs&amp;lt;/code&amp;gt;):&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;amp;lt;prefix&amp;amp;gt;_all.mtz&amp;lt;/code&amp;gt; — the merged dataset using all observations (the main result for structure solution)&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;amp;lt;prefix&amp;amp;gt;_odd.mtz&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;&amp;amp;lt;prefix&amp;amp;gt;_even.mtz&amp;lt;/code&amp;gt; — the two half-datasets used for CC½ and related half-dataset statistics&lt;br /&gt;
&lt;br /&gt;
A main log records the per-step progress and the merging statistics tables by resolution bin:&lt;br /&gt;
completeness, multiplicity and ⟨I/σ⟩, plus the &amp;quot;Table of Scaling Results&amp;quot; reporting CC½ (the&lt;br /&gt;
half-dataset correlation, labelled &amp;quot;CC int&amp;quot;), CC&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt;, R&amp;lt;sub&amp;gt;int&amp;lt;/sub&amp;gt;, R&amp;lt;sub&amp;gt;split&amp;lt;/sub&amp;gt;&lt;br /&gt;
and R&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt;.  The merged MTZ can optionally be&lt;br /&gt;
uploaded to a shared [https://github.com/cctbx/cctbx_project/tree/master/xfel/merging/application/publish Google Drive folder] by adding the &amp;lt;code&amp;gt;publish&amp;lt;/code&amp;gt; worker.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
* Sauter NK (2015). &#039;&#039;J Synchrotron Radiat&#039;&#039; &#039;&#039;&#039;22&#039;&#039;&#039;, 239–48. (post-refinement)&lt;br /&gt;
* Uervirojnangkoorn M, &#039;&#039;et al.&#039;&#039; (2015). &#039;&#039;eLife&#039;&#039; 10.7554/eLife.05421. (PRIME / bootstrap)&lt;br /&gt;
* Brewster AS, &#039;&#039;et al.&#039;&#039; (2018). &#039;&#039;Acta Cryst.&#039;&#039; D &#039;&#039;&#039;74&#039;&#039;&#039;, 877–894.&lt;br /&gt;
* Brewster AS, &#039;&#039;et al.&#039;&#039; (2019a). &#039;&#039;Computational Crystallography Newsletter&#039;&#039; &#039;&#039;&#039;10&#039;&#039;&#039;, 22–39. (XFEL GUI)&lt;br /&gt;
* Brewster AS, &#039;&#039;et al.&#039;&#039; (2019b). &#039;&#039;Acta Cryst.&#039;&#039; D &#039;&#039;&#039;75&#039;&#039;&#039;, 959–968. (error models)&lt;br /&gt;
* Mittan-Moreau (2025). (mm24 error model)&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
* [[dials.stills_process]] — produces the integrated data that &amp;lt;code&amp;gt;cctbx.xfel.merge&amp;lt;/code&amp;gt; consumes&lt;br /&gt;
* [[cctbx.xfel GUI]] — orchestrates separate scaling and repeated merging as data are collected&lt;br /&gt;
* The program README at &amp;lt;code&amp;gt;xfel/merging/README.md&amp;lt;/code&amp;gt; in cctbx_project&lt;/div&gt;</summary>
		<author><name>Aaron</name></author>
	</entry>
	<entry>
		<id>http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Cctbx.xfel.merge&amp;diff=1779</id>
		<title>Cctbx.xfel.merge</title>
		<link rel="alternate" type="text/html" href="http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Cctbx.xfel.merge&amp;diff=1779"/>
		<updated>2026-08-21T23:17:17Z</updated>

		<summary type="html">&lt;p&gt;Aaron: /* Basic usage */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= &#039;&#039;cctbx.xfel.merge&#039;&#039; =&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;cctbx.xfel.merge&#039;&#039;&#039;&#039;&#039; is the scaling, post-refinement and merging program of cctbx.xfel. It takes&lt;br /&gt;
the per-image integrated results produced by &#039;&#039;[[dials.stills_process]]&#039;&#039; — one crystal per still shot —&lt;br /&gt;
and reduces the whole ensemble to a single set of merged structure-factor intensities (an MTZ file)&lt;br /&gt;
suitable for structure solution and refinement, together with the crystallographic quality&lt;br /&gt;
statistics (completeness, multiplicity, ⟨I/σ⟩, CC½, CC&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt;, R-factors, etc.).&lt;br /&gt;
&lt;br /&gt;
Because serial datasets routinely contain tens of thousands to millions of still shots,&lt;br /&gt;
&amp;lt;code&amp;gt;cctbx.xfel.merge&amp;lt;/code&amp;gt; is built from the ground up to run under MPI across many nodes. It is&lt;br /&gt;
almost always launched with &amp;lt;code&amp;gt;mpirun&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;srun&amp;lt;/code&amp;gt;.  Note that MPI uses the term &#039;ranks&#039;&lt;br /&gt;
to distinguish independent processes that are running across one or more nodes.&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;cctbx.xfel.merge&amp;lt;/code&amp;gt; is organized as a sequence of &#039;&#039;&#039;workers&#039;&#039;&#039;. Each worker performs one&lt;br /&gt;
task — reading data, applying a correction, filtering, scaling, post-refining, computing a statistic,&lt;br /&gt;
or merging — and passes its (possibly modified) experiments and reflections on to the next worker.&lt;br /&gt;
The list of workers to run is the &amp;quot;step list&amp;quot;, and it is fully configurable: you can add, remove or&lt;br /&gt;
reorder steps with &amp;lt;code&amp;gt;dispatch.step_list&amp;lt;/code&amp;gt;. This is what makes the program flexible enough to&lt;br /&gt;
scale-and-merge in one pass, to scale subsets separately and merge later, or to run a reference-free&lt;br /&gt;
bootstrap.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;default&#039;&#039;&#039; step list is:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! # !! Worker !! Purpose&lt;br /&gt;
|-&lt;br /&gt;
| 1 || &amp;lt;code&amp;gt;input&amp;lt;/code&amp;gt; || Read integrated experiments (&amp;lt;code&amp;gt;.expt&amp;lt;/code&amp;gt;) and reflections (&amp;lt;code&amp;gt;.refl&amp;lt;/code&amp;gt;) from disk in DIALS format.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || &amp;lt;code&amp;gt;balance&amp;lt;/code&amp;gt; || Redistribute the input load evenly across MPI ranks (needed when there are fewer or more input files than ranks).&lt;br /&gt;
|-&lt;br /&gt;
| 3 || &amp;lt;code&amp;gt;model_scaling&amp;lt;/code&amp;gt; || Build the full Miller list, model intensities from the reference, and the resolution binner used for scaling and post-refinement.&lt;br /&gt;
|-&lt;br /&gt;
| 4 || &amp;lt;code&amp;gt;modify&amp;lt;/code&amp;gt; || Apply per-reflection modifications, e.g. polarization correction (and optionally re-indexing to resolve indexing ambiguity — see &amp;lt;code&amp;gt;modify.cosym&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;reindex_to_reference&amp;lt;/code&amp;gt;).&lt;br /&gt;
|-&lt;br /&gt;
| 5 || &amp;lt;code&amp;gt;filter&amp;lt;/code&amp;gt; || Reject whole experiments (or reflections) by resolution, unit cell, correlation to the reference, energy, etc.&lt;br /&gt;
|-&lt;br /&gt;
| 6 || &amp;lt;code&amp;gt;scale&amp;lt;/code&amp;gt; || Scale each lattice to the reference dataset (&amp;lt;code&amp;gt;mark0&amp;lt;/code&amp;gt;) or simply average (&amp;lt;code&amp;gt;mark1&amp;lt;/code&amp;gt;).&lt;br /&gt;
|-&lt;br /&gt;
| 7 || &amp;lt;code&amp;gt;postrefine&amp;lt;/code&amp;gt; || Post-refine per-image crystal parameters and partialities (Sauter 2015).&lt;br /&gt;
|-&lt;br /&gt;
| 8 || &amp;lt;code&amp;gt;statistics_unitcell&amp;lt;/code&amp;gt; || Determine and store the average unit cell.&lt;br /&gt;
|-&lt;br /&gt;
| 9 || &amp;lt;code&amp;gt;statistics_beam&amp;lt;/code&amp;gt; || Determine and store the average wavelength.&lt;br /&gt;
|-&lt;br /&gt;
| 10 || &amp;lt;code&amp;gt;model_statistics&amp;lt;/code&amp;gt; || Rebuild the Miller list / binner for statistics (may use the average unit cell).&lt;br /&gt;
|-&lt;br /&gt;
| 11 || &amp;lt;code&amp;gt;statistics_resolution&amp;lt;/code&amp;gt; || Per-crystal resolution statistics.&lt;br /&gt;
|-&lt;br /&gt;
| 12 || &amp;lt;code&amp;gt;group&amp;lt;/code&amp;gt; || Redistribute reflections across ranks so that every observation of a given HKL is gathered on the same rank prior to merging.&lt;br /&gt;
|-&lt;br /&gt;
| 13 || &amp;lt;code&amp;gt;errors_merge&amp;lt;/code&amp;gt; || Correct the merged error estimates with a per-HKL error model (e.g. Ev11, Brewster 2019b, or MM24 (the default), Mittan-Moreau (2025)).&lt;br /&gt;
|-&lt;br /&gt;
| 14 || &amp;lt;code&amp;gt;statistics_intensity&amp;lt;/code&amp;gt; || Intensity statistics by resolution.&lt;br /&gt;
|-&lt;br /&gt;
| 15 || &amp;lt;code&amp;gt;merge&amp;lt;/code&amp;gt; || Merge symmetry-equivalent intensities, gather all HKLs at rank 0, and write &amp;quot;odd&amp;quot;, &amp;quot;even&amp;quot; and &amp;quot;all&amp;quot; MTZ files.&lt;br /&gt;
|-&lt;br /&gt;
| 16 || &amp;lt;code&amp;gt;statistics_intensity_cxi&amp;lt;/code&amp;gt; || Correlation and R-factor statistics (ported from cxi.merge): the &amp;quot;Table of Scaling Results&amp;quot; — CC½ (half-dataset correlation, labelled &amp;quot;CC int&amp;quot;), CC&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt;, R&amp;lt;sub&amp;gt;int&amp;lt;/sub&amp;gt;, R&amp;lt;sub&amp;gt;split&amp;lt;/sub&amp;gt;, R&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Additional, non-default workers are available and can be&lt;br /&gt;
inserted into the step list, including &amp;lt;code&amp;gt;tdata&amp;lt;/code&amp;gt; (write out unit cells for clustering),&lt;br /&gt;
&amp;lt;code&amp;gt;export&amp;lt;/code&amp;gt; (batch MTZ for &#039;&#039;Careless&#039;&#039;), &amp;lt;code&amp;gt;publish&amp;lt;/code&amp;gt; (upload merged files to a&lt;br /&gt;
Google Drive folder), &amp;lt;code&amp;gt;monitor&amp;lt;/code&amp;gt; (resource-usage logging), &amp;lt;code&amp;gt;integrate&amp;lt;/code&amp;gt;&lt;br /&gt;
(on-the-fly integration), &amp;lt;code&amp;gt;prepare&amp;lt;/code&amp;gt; (SpReAD energy binning), and&lt;br /&gt;
&amp;lt;code&amp;gt;lunus&amp;lt;/code&amp;gt; (diffuse-scattering deck). A &amp;lt;code&amp;gt;deltaccint&amp;lt;/code&amp;gt; worker (ΔCC½ lattice&lt;br /&gt;
filtering) can be added after &amp;lt;code&amp;gt;group&amp;lt;/code&amp;gt;. Custom workers can be supplied through the&lt;br /&gt;
&amp;lt;code&amp;gt;XFEL_CUSTOM_WORKER_PATH&amp;lt;/code&amp;gt; environment variable.&lt;br /&gt;
&lt;br /&gt;
== Basic usage ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;cctbx.xfel.merge&amp;lt;/code&amp;gt; is run under MPI:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mpirun cctbx.xfel.merge merge.phil&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A typical &amp;lt;code&amp;gt;merge.phil&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
input.path=&amp;lt;path to data&amp;gt;&lt;br /&gt;
input.experiments_suffix=.expt&lt;br /&gt;
input.reflections_suffix=.refl&lt;br /&gt;
&lt;br /&gt;
filter.algorithm=unit_cell&lt;br /&gt;
filter.unit_cell.value.relative_length_tolerance=0.03&lt;br /&gt;
filter.outlier.min_corr=0.1&lt;br /&gt;
&lt;br /&gt;
select.algorithm=significance_filter&lt;br /&gt;
select.significance_filter.sigma=0.1&lt;br /&gt;
select.significance_filter.min_ct=200&lt;br /&gt;
select.significance_filter.max_ct=300&lt;br /&gt;
&lt;br /&gt;
scaling.model=&amp;lt;model.pdb or model.mtz&amp;gt;&lt;br /&gt;
scaling.resolution_scalar=0.96&lt;br /&gt;
&lt;br /&gt;
merging.d_min=1.8&lt;br /&gt;
merging.error.model=mm24&lt;br /&gt;
merging.merge_anomalous=True&lt;br /&gt;
&lt;br /&gt;
postrefinement.enable=True&lt;br /&gt;
statistics.n_bins=20&lt;br /&gt;
&lt;br /&gt;
output.do_timing=True&lt;br /&gt;
output.output_dir=&amp;lt;output folder&amp;gt;&lt;br /&gt;
output.prefix=&amp;lt;prefix for output files&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Explore the parameters with:&lt;br /&gt;
* &amp;lt;code&amp;gt;cctbx.xfel.merge -c&amp;lt;/code&amp;gt; — show configurable parameters&lt;br /&gt;
* &amp;lt;code&amp;gt;cctbx.xfel.merge -c -e 10 -a 2&amp;lt;/code&amp;gt; — show all parameters (expert level 10) with full help text&lt;br /&gt;
&lt;br /&gt;
== Two-stage scaling and merging ==&lt;br /&gt;
&lt;br /&gt;
For large, growing datasets (the mode used by the [[cctbx.xfel GUI]]), it is more efficient to scale&lt;br /&gt;
and post-refine each subset of data &#039;&#039;&#039;once&#039;&#039;&#039;, then merge repeatedly as more data arrive. This is&lt;br /&gt;
done by running the program twice with different step lists.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Stage 1 — scale each subset&#039;&#039;&#039; (stops after per-image work and writes intermediate DIALS files):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dispatch.step_list=input balance model_scaling modify filter scale postrefine \&lt;br /&gt;
    statistics_unitcell statistics_beam model_statistics statistics_resolution&lt;br /&gt;
input.parallel_file_load.method=uniform&lt;br /&gt;
output.save_experiments_and_reflections=True&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;output.save_experiments_and_reflections=True&amp;lt;/code&amp;gt; dumps the scaled/post-refined data as&lt;br /&gt;
experiment lists and reflection tables that the merge stage can read back in.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Stage 2 — merge the scaled subsets&#039;&#039;&#039; (add an &amp;lt;code&amp;gt;input.path&amp;lt;/code&amp;gt; for each finished subset):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dispatch.step_list=input model_scaling statistics_unitcell statistics_beam \&lt;br /&gt;
    model_statistics statistics_resolution group errors_merge statistics_intensity \&lt;br /&gt;
    merge statistics_intensity_cxi&lt;br /&gt;
input.parallel_file_load.method=uniform&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Merging without a reference (bootstrap / mark1) ==&lt;br /&gt;
&lt;br /&gt;
If no scaling/merging reference is available, use a bootstrap procedure. First run the&lt;br /&gt;
&amp;lt;code&amp;gt;mark1&amp;lt;/code&amp;gt; algorithm, which simply averages the data (all per-image scale factors = 1, no&lt;br /&gt;
post-refinement), specifying the target cell and symmetry explicitly:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
scaling.algorithm=mark1&lt;br /&gt;
scaling.unit_cell=&amp;lt;unit cell&amp;gt;&lt;br /&gt;
scaling.space_group=&amp;lt;space group&amp;gt;&lt;br /&gt;
merging.error.model=errors_from_sample_residuals&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The resulting MTZ is then used as the reference (&amp;lt;code&amp;gt;scaling.model=&amp;lt;/code&amp;gt;) for subsequent regular&lt;br /&gt;
merges. Iterate a few cycles; CC½ typically improves and converges over the first few rounds.&lt;br /&gt;
&lt;br /&gt;
== Important parameters ==&lt;br /&gt;
&lt;br /&gt;
Parameters are given by their full PHIL path with defaults in parentheses. The program exposes many&lt;br /&gt;
more parameters (see &amp;lt;code&amp;gt;-c -e 10 -a 2&amp;lt;/code&amp;gt;); those below are the ones most commonly set.&lt;br /&gt;
&lt;br /&gt;
=== Input ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.path&amp;lt;/code&amp;gt; || None || Path(s) to the integrated data — a folder, several folders, or individual files; wildcards allowed; may be repeated. Matching &amp;lt;code&amp;gt;.expt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;.refl&amp;lt;/code&amp;gt; files must both be present.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.experiments_suffix&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;_integrated.expt&amp;lt;/code&amp;gt; || Only load experiment files ending with this suffix.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.reflections_suffix&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;_integrated.refl&amp;lt;/code&amp;gt; || Only load reflection files ending with this suffix.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.parallel_file_load.method&amp;lt;/code&amp;gt; || uniform || &amp;lt;code&amp;gt;uniform&amp;lt;/code&amp;gt; spreads input files evenly over all ranks; &amp;lt;code&amp;gt;node_memory&amp;lt;/code&amp;gt; distributes so per-node memory limits are respected.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.alist.file&amp;lt;/code&amp;gt; || None || Path to a text file of experiment tags or filenames; combined with &amp;lt;code&amp;gt;input.alist.op=keep|reject&amp;lt;/code&amp;gt; to merge only (or exclude) a specified subset.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.persistent_refl_cols&amp;lt;/code&amp;gt; || None || Reflection-table columns to preserve through the pruning steps (and into saved tables).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Filtering whole experiments (&amp;lt;code&amp;gt;filter&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;filter&amp;lt;/code&amp;gt; section accepts or rejects &#039;&#039;&#039;entire experiments&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.algorithm&amp;lt;/code&amp;gt; || (none) || One or more of &amp;lt;code&amp;gt;n_obs&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;resolution&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;unit_cell&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;energy&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bootstrap&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;experiment_prefix&amp;lt;/code&amp;gt;. Nothing is filtered unless listed.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.unit_cell.algorithm&amp;lt;/code&amp;gt; || value || How to restrict unit cells: &amp;lt;code&amp;gt;value&amp;lt;/code&amp;gt; (compare to a target), &amp;lt;code&amp;gt;range&amp;lt;/code&amp;gt;, or &amp;lt;code&amp;gt;cluster&amp;lt;/code&amp;gt; (use a precomputed covariance clustering).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.unit_cell.value.relative_length_tolerance&amp;lt;/code&amp;gt; || 0.1 || Fractional deviation of cell edge lengths allowed vs. the target cell. Often tightened (e.g. 0.03).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.unit_cell.value.absolute_angle_tolerance&amp;lt;/code&amp;gt; || 2.0 || Allowed cell-angle deviation (degrees) vs. the target.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.unit_cell.value.target_unit_cell&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;target_space_group&amp;lt;/code&amp;gt; || Auto || Target cell/symmetry; &amp;lt;code&amp;gt;Auto&amp;lt;/code&amp;gt; uses the scaling model.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.outlier.min_corr&amp;lt;/code&amp;gt; || 0.1 || Minimum correlation of an image&#039;s intensities to the reference model; images below this are rejected. Only applied when a scaling model is present. Use &amp;lt;code&amp;gt;-1&amp;lt;/code&amp;gt; to accept all images regardless of correlation.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.resolution.d_min&amp;lt;/code&amp;gt; || None || Reject an experiment unless some of its reflections extend beyond this resolution.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Selecting individual reflections (&amp;lt;code&amp;gt;select&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;select&amp;lt;/code&amp;gt; section accepts or rejects &#039;&#039;&#039;individual reflections&#039;&#039;&#039; (contrast with&lt;br /&gt;
&amp;lt;code&amp;gt;filter&amp;lt;/code&amp;gt;, which acts on whole experiments).&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;select.algorithm&amp;lt;/code&amp;gt; || (none) || One or more of &amp;lt;code&amp;gt;significance_filter&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;panel&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cspad_sensor&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;isolation_forest&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;target_energy&amp;lt;/code&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;select.significance_filter.sigma&amp;lt;/code&amp;gt; || 0.5 || Trim each lattice at the resolution where the binned ⟨I/σ⟩ drops below this value.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;select.significance_filter.min_ct&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;max_ct&amp;lt;/code&amp;gt; || 10 / 50 || Target minimum/maximum mean reflections per resolution bin when choosing the number of bins. For large unit cells these are often raised (e.g. 200/300); for small cells, use the defaults.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Modifying intensities (&amp;lt;code&amp;gt;modify&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;modify.algorithm&amp;lt;/code&amp;gt; || polarization || Per-reflection corrections to apply (default applies the polarization correction).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;modify.cosym&amp;lt;/code&amp;gt; || — || Resolve an indexing ambiguity across the ensemble using the Gildea/Winter (Brehm/Diederichs) cosym method, optionally anchored to &amp;lt;code&amp;gt;scaling.model&amp;lt;/code&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;modify.reindex_to_reference&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;reindex_to_abc&amp;lt;/code&amp;gt; || — || Alternative re-indexing operators (to a reference model, or an explicit operator).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Scaling (&amp;lt;code&amp;gt;scaling&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;scaling.model&amp;lt;/code&amp;gt; || None || Reference dataset: a PDB file (uses the CRYST1 cell and computes model intensities, including bulk solvent) or an MTZ from a previous cycle. Required for &amp;lt;code&amp;gt;mark0&amp;lt;/code&amp;gt; scaling.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;scaling.algorithm&amp;lt;/code&amp;gt; || mark0 || &amp;lt;code&amp;gt;mark0&amp;lt;/code&amp;gt;: per-image scaling against the reference. &amp;lt;code&amp;gt;mark1&amp;lt;/code&amp;gt;: no scaling, just Monte-Carlo averaging (all scale factors = 1) — used for reference-free bootstrap.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;scaling.unit_cell&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;scaling.space_group&amp;lt;/code&amp;gt; || None || Cell/symmetry to use when no model is provided (i.e. &amp;lt;code&amp;gt;mark1&amp;lt;/code&amp;gt;).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;scaling.resolution_scalar&amp;lt;/code&amp;gt; || 0.969 || &amp;lt;code&amp;gt;merging.d_min&amp;lt;/code&amp;gt; is multiplied by this when deciding which reflections fall within the resolution limit, generating a few extra reference reflections to account for per-shot cell variation (e.g. set 0.96 for a few more).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;scaling.mtz.mtz_column_F&amp;lt;/code&amp;gt; || fobs || Column name in the reference MTZ containing the reference structure factors (intensities or amplitudes).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Post-refinement (&amp;lt;code&amp;gt;postrefinement&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;postrefinement.enable&amp;lt;/code&amp;gt; || True || Enable post-refinement of per-image parameters/partialities (Sauter 2015).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;postrefinement.algorithm&amp;lt;/code&amp;gt; || rs || Post-refinement protocol: &amp;lt;code&amp;gt;rs&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;rs2&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;rs_hybrid&amp;lt;/code&amp;gt;, or &amp;lt;code&amp;gt;eta_deff&amp;lt;/code&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Merging and error model (&amp;lt;code&amp;gt;merging&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;merging.d_min&amp;lt;/code&amp;gt; || None || High-resolution limit for scaling and merging.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;merging.d_max&amp;lt;/code&amp;gt; || None || Low-resolution limit (currently affects only CCiso).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;merging.merge_anomalous&amp;lt;/code&amp;gt; || False || &amp;lt;code&amp;gt;True&amp;lt;/code&amp;gt; merges Bijvoet mates together (higher multiplicity); &amp;lt;code&amp;gt;False&amp;lt;/code&amp;gt; keeps them separate to preserve the anomalous signal.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;merging.minimum_multiplicity&amp;lt;/code&amp;gt; || 2 || Do not produce a merged structure factor for HKLs measured fewer than this many times.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;merging.error.model&amp;lt;/code&amp;gt; || mm24 || Merged-sigma error model: &amp;lt;code&amp;gt;mm24&amp;lt;/code&amp;gt; (Mittan-Moreau 2025, current default), &amp;lt;code&amp;gt;ev11&amp;lt;/code&amp;gt; (Evans 2011 / sdfac-refine, recommended in the README), &amp;lt;code&amp;gt;ha14&amp;lt;/code&amp;gt;, or &amp;lt;code&amp;gt;errors_from_sample_residuals&amp;lt;/code&amp;gt; (no refined error terms — used with &amp;lt;code&amp;gt;mark1&amp;lt;/code&amp;gt; bootstrap).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;merging.set_average_unit_cell&amp;lt;/code&amp;gt; || True || Output MTZ adopts the (cluster-derived) average unit cell of the data rather than the reference model&#039;s cell.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Statistics (&amp;lt;code&amp;gt;statistics&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;statistics.n_bins&amp;lt;/code&amp;gt; || 10 || Number of resolution bins in the statistics tables.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;statistics.cciso.mtz_file&amp;lt;/code&amp;gt; || None || Isomorphous reference structure factors for R&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt; / CC&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;statistics.report_ML&amp;lt;/code&amp;gt; || True || Report per-frame max-likelihood attributes (domain size, mosaicity).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Output (&amp;lt;code&amp;gt;output&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.output_dir&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;.&amp;lt;/code&amp;gt; || Directory for output files (created if it does not exist).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.prefix&amp;lt;/code&amp;gt; || iobs || Prefix prepended to all output file names.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.save_experiments_and_reflections&amp;lt;/code&amp;gt; || False || Dump the final experiments/reflections from the last worker as DIALS files — used for the two-stage scale-then-merge workflow.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.do_timing&amp;lt;/code&amp;gt; || False || Log elapsed time per execution step.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.expanded_bookkeeping&amp;lt;/code&amp;gt; || False || Store extra provenance columns (input file/reflection indices, odd/even flag, original id) in the saved reflection tables.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Multiprocessing (&amp;lt;code&amp;gt;mp&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mp.method&amp;lt;/code&amp;gt; || mpi || Multiprocessing method (only &amp;lt;code&amp;gt;mpi&amp;lt;/code&amp;gt; is currently supported).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mp.debug.cProfile&amp;lt;/code&amp;gt; || False || Enable code profiling; a &amp;lt;code&amp;gt;.prof&amp;lt;/code&amp;gt; file is written per rank.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Output files ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;merge&amp;lt;/code&amp;gt; worker gathers all HKLs at rank 0 and writes three MTZ files, prefixed with&lt;br /&gt;
&amp;lt;code&amp;gt;output.prefix&amp;lt;/code&amp;gt; (default &amp;lt;code&amp;gt;iobs&amp;lt;/code&amp;gt;):&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;amp;lt;prefix&amp;amp;gt;_all.mtz&amp;lt;/code&amp;gt; — the merged dataset using all observations (the main result for structure solution)&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;amp;lt;prefix&amp;amp;gt;_odd.mtz&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;&amp;amp;lt;prefix&amp;amp;gt;_even.mtz&amp;lt;/code&amp;gt; — the two half-datasets used for CC½ and related half-dataset statistics&lt;br /&gt;
&lt;br /&gt;
A main log records the per-step progress and the merging statistics tables by resolution bin:&lt;br /&gt;
completeness, multiplicity and ⟨I/σ⟩, plus the &amp;quot;Table of Scaling Results&amp;quot; reporting CC½ (the&lt;br /&gt;
half-dataset correlation, labelled &amp;quot;CC int&amp;quot;), CC&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt;, R&amp;lt;sub&amp;gt;int&amp;lt;/sub&amp;gt;, R&amp;lt;sub&amp;gt;split&amp;lt;/sub&amp;gt;&lt;br /&gt;
and R&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt;.  The merged MTZ can optionally be&lt;br /&gt;
uploaded to a shared [https://github.com/cctbx/cctbx_project/tree/master/xfel/merging/application/publish Google Drive folder] by adding the &amp;lt;code&amp;gt;publish&amp;lt;/code&amp;gt; worker.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
* Sauter NK (2015). &#039;&#039;J Synchrotron Radiat&#039;&#039; &#039;&#039;&#039;22&#039;&#039;&#039;, 239–48. (post-refinement)&lt;br /&gt;
* Uervirojnangkoorn M, &#039;&#039;et al.&#039;&#039; (2015). &#039;&#039;eLife&#039;&#039; 10.7554/eLife.05421. (PRIME / bootstrap)&lt;br /&gt;
* Brewster AS, &#039;&#039;et al.&#039;&#039; (2018). &#039;&#039;Acta Cryst.&#039;&#039; D &#039;&#039;&#039;74&#039;&#039;&#039;, 877–894.&lt;br /&gt;
* Brewster AS, &#039;&#039;et al.&#039;&#039; (2019a). &#039;&#039;Computational Crystallography Newsletter&#039;&#039; &#039;&#039;&#039;10&#039;&#039;&#039;, 22–39. (XFEL GUI)&lt;br /&gt;
* Brewster AS, &#039;&#039;et al.&#039;&#039; (2019b). &#039;&#039;Acta Cryst.&#039;&#039; D &#039;&#039;&#039;75&#039;&#039;&#039;, 959–968. (error models)&lt;br /&gt;
* Mittan-Moreau (2025). (mm24 error model)&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
* [[dials.stills_process]] — produces the integrated data that &amp;lt;code&amp;gt;cctbx.xfel.merge&amp;lt;/code&amp;gt; consumes&lt;br /&gt;
* [[cctbx.xfel GUI]] — orchestrates separate scaling and repeated merging as data are collected&lt;br /&gt;
* The program README at &amp;lt;code&amp;gt;xfel/merging/README.md&amp;lt;/code&amp;gt; in cctbx_project&lt;/div&gt;</summary>
		<author><name>Aaron</name></author>
	</entry>
	<entry>
		<id>http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Cctbx.xfel.merge&amp;diff=1778</id>
		<title>Cctbx.xfel.merge</title>
		<link rel="alternate" type="text/html" href="http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Cctbx.xfel.merge&amp;diff=1778"/>
		<updated>2026-08-21T23:15:21Z</updated>

		<summary type="html">&lt;p&gt;Aaron: /* Merging and error model (merging) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= &#039;&#039;cctbx.xfel.merge&#039;&#039; =&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;cctbx.xfel.merge&#039;&#039;&#039;&#039;&#039; is the scaling, post-refinement and merging program of cctbx.xfel. It takes&lt;br /&gt;
the per-image integrated results produced by &#039;&#039;[[dials.stills_process]]&#039;&#039; — one crystal per still shot —&lt;br /&gt;
and reduces the whole ensemble to a single set of merged structure-factor intensities (an MTZ file)&lt;br /&gt;
suitable for structure solution and refinement, together with the crystallographic quality&lt;br /&gt;
statistics (completeness, multiplicity, ⟨I/σ⟩, CC½, CC&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt;, R-factors, etc.).&lt;br /&gt;
&lt;br /&gt;
Because serial datasets routinely contain tens of thousands to millions of still shots,&lt;br /&gt;
&amp;lt;code&amp;gt;cctbx.xfel.merge&amp;lt;/code&amp;gt; is built from the ground up to run under MPI across many nodes. It is&lt;br /&gt;
almost always launched with &amp;lt;code&amp;gt;mpirun&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;srun&amp;lt;/code&amp;gt;.  Note that MPI uses the term &#039;ranks&#039;&lt;br /&gt;
to distinguish independent processes that are running across one or more nodes.&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;cctbx.xfel.merge&amp;lt;/code&amp;gt; is organized as a sequence of &#039;&#039;&#039;workers&#039;&#039;&#039;. Each worker performs one&lt;br /&gt;
task — reading data, applying a correction, filtering, scaling, post-refining, computing a statistic,&lt;br /&gt;
or merging — and passes its (possibly modified) experiments and reflections on to the next worker.&lt;br /&gt;
The list of workers to run is the &amp;quot;step list&amp;quot;, and it is fully configurable: you can add, remove or&lt;br /&gt;
reorder steps with &amp;lt;code&amp;gt;dispatch.step_list&amp;lt;/code&amp;gt;. This is what makes the program flexible enough to&lt;br /&gt;
scale-and-merge in one pass, to scale subsets separately and merge later, or to run a reference-free&lt;br /&gt;
bootstrap.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;default&#039;&#039;&#039; step list is:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! # !! Worker !! Purpose&lt;br /&gt;
|-&lt;br /&gt;
| 1 || &amp;lt;code&amp;gt;input&amp;lt;/code&amp;gt; || Read integrated experiments (&amp;lt;code&amp;gt;.expt&amp;lt;/code&amp;gt;) and reflections (&amp;lt;code&amp;gt;.refl&amp;lt;/code&amp;gt;) from disk in DIALS format.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || &amp;lt;code&amp;gt;balance&amp;lt;/code&amp;gt; || Redistribute the input load evenly across MPI ranks (needed when there are fewer or more input files than ranks).&lt;br /&gt;
|-&lt;br /&gt;
| 3 || &amp;lt;code&amp;gt;model_scaling&amp;lt;/code&amp;gt; || Build the full Miller list, model intensities from the reference, and the resolution binner used for scaling and post-refinement.&lt;br /&gt;
|-&lt;br /&gt;
| 4 || &amp;lt;code&amp;gt;modify&amp;lt;/code&amp;gt; || Apply per-reflection modifications, e.g. polarization correction (and optionally re-indexing to resolve indexing ambiguity — see &amp;lt;code&amp;gt;modify.cosym&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;reindex_to_reference&amp;lt;/code&amp;gt;).&lt;br /&gt;
|-&lt;br /&gt;
| 5 || &amp;lt;code&amp;gt;filter&amp;lt;/code&amp;gt; || Reject whole experiments (or reflections) by resolution, unit cell, correlation to the reference, energy, etc.&lt;br /&gt;
|-&lt;br /&gt;
| 6 || &amp;lt;code&amp;gt;scale&amp;lt;/code&amp;gt; || Scale each lattice to the reference dataset (&amp;lt;code&amp;gt;mark0&amp;lt;/code&amp;gt;) or simply average (&amp;lt;code&amp;gt;mark1&amp;lt;/code&amp;gt;).&lt;br /&gt;
|-&lt;br /&gt;
| 7 || &amp;lt;code&amp;gt;postrefine&amp;lt;/code&amp;gt; || Post-refine per-image crystal parameters and partialities (Sauter 2015).&lt;br /&gt;
|-&lt;br /&gt;
| 8 || &amp;lt;code&amp;gt;statistics_unitcell&amp;lt;/code&amp;gt; || Determine and store the average unit cell.&lt;br /&gt;
|-&lt;br /&gt;
| 9 || &amp;lt;code&amp;gt;statistics_beam&amp;lt;/code&amp;gt; || Determine and store the average wavelength.&lt;br /&gt;
|-&lt;br /&gt;
| 10 || &amp;lt;code&amp;gt;model_statistics&amp;lt;/code&amp;gt; || Rebuild the Miller list / binner for statistics (may use the average unit cell).&lt;br /&gt;
|-&lt;br /&gt;
| 11 || &amp;lt;code&amp;gt;statistics_resolution&amp;lt;/code&amp;gt; || Per-crystal resolution statistics.&lt;br /&gt;
|-&lt;br /&gt;
| 12 || &amp;lt;code&amp;gt;group&amp;lt;/code&amp;gt; || Redistribute reflections across ranks so that every observation of a given HKL is gathered on the same rank prior to merging.&lt;br /&gt;
|-&lt;br /&gt;
| 13 || &amp;lt;code&amp;gt;errors_merge&amp;lt;/code&amp;gt; || Correct the merged error estimates with a per-HKL error model (e.g. Ev11, Brewster 2019b, or MM24 (the default), Mittan-Moreau (2025)).&lt;br /&gt;
|-&lt;br /&gt;
| 14 || &amp;lt;code&amp;gt;statistics_intensity&amp;lt;/code&amp;gt; || Intensity statistics by resolution.&lt;br /&gt;
|-&lt;br /&gt;
| 15 || &amp;lt;code&amp;gt;merge&amp;lt;/code&amp;gt; || Merge symmetry-equivalent intensities, gather all HKLs at rank 0, and write &amp;quot;odd&amp;quot;, &amp;quot;even&amp;quot; and &amp;quot;all&amp;quot; MTZ files.&lt;br /&gt;
|-&lt;br /&gt;
| 16 || &amp;lt;code&amp;gt;statistics_intensity_cxi&amp;lt;/code&amp;gt; || Correlation and R-factor statistics (ported from cxi.merge): the &amp;quot;Table of Scaling Results&amp;quot; — CC½ (half-dataset correlation, labelled &amp;quot;CC int&amp;quot;), CC&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt;, R&amp;lt;sub&amp;gt;int&amp;lt;/sub&amp;gt;, R&amp;lt;sub&amp;gt;split&amp;lt;/sub&amp;gt;, R&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Additional, non-default workers are available and can be&lt;br /&gt;
inserted into the step list, including &amp;lt;code&amp;gt;tdata&amp;lt;/code&amp;gt; (write out unit cells for clustering),&lt;br /&gt;
&amp;lt;code&amp;gt;export&amp;lt;/code&amp;gt; (batch MTZ for &#039;&#039;Careless&#039;&#039;), &amp;lt;code&amp;gt;publish&amp;lt;/code&amp;gt; (upload merged files to a&lt;br /&gt;
Google Drive folder), &amp;lt;code&amp;gt;monitor&amp;lt;/code&amp;gt; (resource-usage logging), &amp;lt;code&amp;gt;integrate&amp;lt;/code&amp;gt;&lt;br /&gt;
(on-the-fly integration), &amp;lt;code&amp;gt;prepare&amp;lt;/code&amp;gt; (SpReAD energy binning), and&lt;br /&gt;
&amp;lt;code&amp;gt;lunus&amp;lt;/code&amp;gt; (diffuse-scattering deck). A &amp;lt;code&amp;gt;deltaccint&amp;lt;/code&amp;gt; worker (ΔCC½ lattice&lt;br /&gt;
filtering) can be added after &amp;lt;code&amp;gt;group&amp;lt;/code&amp;gt;. Custom workers can be supplied through the&lt;br /&gt;
&amp;lt;code&amp;gt;XFEL_CUSTOM_WORKER_PATH&amp;lt;/code&amp;gt; environment variable.&lt;br /&gt;
&lt;br /&gt;
== Basic usage ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;cctbx.xfel.merge&amp;lt;/code&amp;gt; is run under MPI:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mpirun cctbx.xfel.merge merge.phil&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A typical &amp;lt;code&amp;gt;merge.phil&amp;lt;/code&amp;gt; (from the program README):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
input.path=&amp;lt;path to data&amp;gt;&lt;br /&gt;
input.experiments_suffix=.expt&lt;br /&gt;
input.reflections_suffix=.refl&lt;br /&gt;
&lt;br /&gt;
filter.algorithm=unit_cell&lt;br /&gt;
filter.unit_cell.value.relative_length_tolerance=0.03&lt;br /&gt;
filter.outlier.min_corr=0.1&lt;br /&gt;
&lt;br /&gt;
select.algorithm=significance_filter&lt;br /&gt;
select.significance_filter.sigma=0.1&lt;br /&gt;
select.significance_filter.min_ct=200&lt;br /&gt;
select.significance_filter.max_ct=300&lt;br /&gt;
&lt;br /&gt;
scaling.model=&amp;lt;model.pdb or model.mtz&amp;gt;&lt;br /&gt;
scaling.resolution_scalar=0.96&lt;br /&gt;
&lt;br /&gt;
merging.d_min=1.8&lt;br /&gt;
merging.error.model=ev11&lt;br /&gt;
merging.merge_anomalous=True&lt;br /&gt;
&lt;br /&gt;
postrefinement.enable=True&lt;br /&gt;
statistics.n_bins=20&lt;br /&gt;
&lt;br /&gt;
output.do_timing=True&lt;br /&gt;
output.output_dir=&amp;lt;output folder&amp;gt;&lt;br /&gt;
output.prefix=&amp;lt;prefix for output files&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Explore the parameters with:&lt;br /&gt;
* &amp;lt;code&amp;gt;cctbx.xfel.merge -c&amp;lt;/code&amp;gt; — show configurable parameters&lt;br /&gt;
* &amp;lt;code&amp;gt;cctbx.xfel.merge -c -e 10 -a 2&amp;lt;/code&amp;gt; — show all parameters (expert level 10) with full help text&lt;br /&gt;
&lt;br /&gt;
== Two-stage scaling and merging ==&lt;br /&gt;
&lt;br /&gt;
For large, growing datasets (the mode used by the [[cctbx.xfel GUI]]), it is more efficient to scale&lt;br /&gt;
and post-refine each subset of data &#039;&#039;&#039;once&#039;&#039;&#039;, then merge repeatedly as more data arrive. This is&lt;br /&gt;
done by running the program twice with different step lists.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Stage 1 — scale each subset&#039;&#039;&#039; (stops after per-image work and writes intermediate DIALS files):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dispatch.step_list=input balance model_scaling modify filter scale postrefine \&lt;br /&gt;
    statistics_unitcell statistics_beam model_statistics statistics_resolution&lt;br /&gt;
input.parallel_file_load.method=uniform&lt;br /&gt;
output.save_experiments_and_reflections=True&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;output.save_experiments_and_reflections=True&amp;lt;/code&amp;gt; dumps the scaled/post-refined data as&lt;br /&gt;
experiment lists and reflection tables that the merge stage can read back in.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Stage 2 — merge the scaled subsets&#039;&#039;&#039; (add an &amp;lt;code&amp;gt;input.path&amp;lt;/code&amp;gt; for each finished subset):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dispatch.step_list=input model_scaling statistics_unitcell statistics_beam \&lt;br /&gt;
    model_statistics statistics_resolution group errors_merge statistics_intensity \&lt;br /&gt;
    merge statistics_intensity_cxi&lt;br /&gt;
input.parallel_file_load.method=uniform&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Merging without a reference (bootstrap / mark1) ==&lt;br /&gt;
&lt;br /&gt;
If no scaling/merging reference is available, use a bootstrap procedure. First run the&lt;br /&gt;
&amp;lt;code&amp;gt;mark1&amp;lt;/code&amp;gt; algorithm, which simply averages the data (all per-image scale factors = 1, no&lt;br /&gt;
post-refinement), specifying the target cell and symmetry explicitly:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
scaling.algorithm=mark1&lt;br /&gt;
scaling.unit_cell=&amp;lt;unit cell&amp;gt;&lt;br /&gt;
scaling.space_group=&amp;lt;space group&amp;gt;&lt;br /&gt;
merging.error.model=errors_from_sample_residuals&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The resulting MTZ is then used as the reference (&amp;lt;code&amp;gt;scaling.model=&amp;lt;/code&amp;gt;) for subsequent regular&lt;br /&gt;
merges. Iterate a few cycles; CC½ typically improves and converges over the first few rounds.&lt;br /&gt;
&lt;br /&gt;
== Important parameters ==&lt;br /&gt;
&lt;br /&gt;
Parameters are given by their full PHIL path with defaults in parentheses. The program exposes many&lt;br /&gt;
more parameters (see &amp;lt;code&amp;gt;-c -e 10 -a 2&amp;lt;/code&amp;gt;); those below are the ones most commonly set.&lt;br /&gt;
&lt;br /&gt;
=== Input ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.path&amp;lt;/code&amp;gt; || None || Path(s) to the integrated data — a folder, several folders, or individual files; wildcards allowed; may be repeated. Matching &amp;lt;code&amp;gt;.expt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;.refl&amp;lt;/code&amp;gt; files must both be present.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.experiments_suffix&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;_integrated.expt&amp;lt;/code&amp;gt; || Only load experiment files ending with this suffix.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.reflections_suffix&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;_integrated.refl&amp;lt;/code&amp;gt; || Only load reflection files ending with this suffix.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.parallel_file_load.method&amp;lt;/code&amp;gt; || uniform || &amp;lt;code&amp;gt;uniform&amp;lt;/code&amp;gt; spreads input files evenly over all ranks; &amp;lt;code&amp;gt;node_memory&amp;lt;/code&amp;gt; distributes so per-node memory limits are respected.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.alist.file&amp;lt;/code&amp;gt; || None || Path to a text file of experiment tags or filenames; combined with &amp;lt;code&amp;gt;input.alist.op=keep|reject&amp;lt;/code&amp;gt; to merge only (or exclude) a specified subset.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.persistent_refl_cols&amp;lt;/code&amp;gt; || None || Reflection-table columns to preserve through the pruning steps (and into saved tables).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Filtering whole experiments (&amp;lt;code&amp;gt;filter&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;filter&amp;lt;/code&amp;gt; section accepts or rejects &#039;&#039;&#039;entire experiments&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.algorithm&amp;lt;/code&amp;gt; || (none) || One or more of &amp;lt;code&amp;gt;n_obs&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;resolution&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;unit_cell&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;energy&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bootstrap&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;experiment_prefix&amp;lt;/code&amp;gt;. Nothing is filtered unless listed.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.unit_cell.algorithm&amp;lt;/code&amp;gt; || value || How to restrict unit cells: &amp;lt;code&amp;gt;value&amp;lt;/code&amp;gt; (compare to a target), &amp;lt;code&amp;gt;range&amp;lt;/code&amp;gt;, or &amp;lt;code&amp;gt;cluster&amp;lt;/code&amp;gt; (use a precomputed covariance clustering).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.unit_cell.value.relative_length_tolerance&amp;lt;/code&amp;gt; || 0.1 || Fractional deviation of cell edge lengths allowed vs. the target cell. Often tightened (e.g. 0.03).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.unit_cell.value.absolute_angle_tolerance&amp;lt;/code&amp;gt; || 2.0 || Allowed cell-angle deviation (degrees) vs. the target.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.unit_cell.value.target_unit_cell&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;target_space_group&amp;lt;/code&amp;gt; || Auto || Target cell/symmetry; &amp;lt;code&amp;gt;Auto&amp;lt;/code&amp;gt; uses the scaling model.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.outlier.min_corr&amp;lt;/code&amp;gt; || 0.1 || Minimum correlation of an image&#039;s intensities to the reference model; images below this are rejected. Only applied when a scaling model is present. Use &amp;lt;code&amp;gt;-1&amp;lt;/code&amp;gt; to accept all images regardless of correlation.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.resolution.d_min&amp;lt;/code&amp;gt; || None || Reject an experiment unless some of its reflections extend beyond this resolution.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Selecting individual reflections (&amp;lt;code&amp;gt;select&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;select&amp;lt;/code&amp;gt; section accepts or rejects &#039;&#039;&#039;individual reflections&#039;&#039;&#039; (contrast with&lt;br /&gt;
&amp;lt;code&amp;gt;filter&amp;lt;/code&amp;gt;, which acts on whole experiments).&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;select.algorithm&amp;lt;/code&amp;gt; || (none) || One or more of &amp;lt;code&amp;gt;significance_filter&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;panel&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cspad_sensor&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;isolation_forest&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;target_energy&amp;lt;/code&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;select.significance_filter.sigma&amp;lt;/code&amp;gt; || 0.5 || Trim each lattice at the resolution where the binned ⟨I/σ⟩ drops below this value.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;select.significance_filter.min_ct&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;max_ct&amp;lt;/code&amp;gt; || 10 / 50 || Target minimum/maximum mean reflections per resolution bin when choosing the number of bins. For large unit cells these are often raised (e.g. 200/300); for small cells, use the defaults.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Modifying intensities (&amp;lt;code&amp;gt;modify&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;modify.algorithm&amp;lt;/code&amp;gt; || polarization || Per-reflection corrections to apply (default applies the polarization correction).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;modify.cosym&amp;lt;/code&amp;gt; || — || Resolve an indexing ambiguity across the ensemble using the Gildea/Winter (Brehm/Diederichs) cosym method, optionally anchored to &amp;lt;code&amp;gt;scaling.model&amp;lt;/code&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;modify.reindex_to_reference&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;reindex_to_abc&amp;lt;/code&amp;gt; || — || Alternative re-indexing operators (to a reference model, or an explicit operator).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Scaling (&amp;lt;code&amp;gt;scaling&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;scaling.model&amp;lt;/code&amp;gt; || None || Reference dataset: a PDB file (uses the CRYST1 cell and computes model intensities, including bulk solvent) or an MTZ from a previous cycle. Required for &amp;lt;code&amp;gt;mark0&amp;lt;/code&amp;gt; scaling.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;scaling.algorithm&amp;lt;/code&amp;gt; || mark0 || &amp;lt;code&amp;gt;mark0&amp;lt;/code&amp;gt;: per-image scaling against the reference. &amp;lt;code&amp;gt;mark1&amp;lt;/code&amp;gt;: no scaling, just Monte-Carlo averaging (all scale factors = 1) — used for reference-free bootstrap.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;scaling.unit_cell&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;scaling.space_group&amp;lt;/code&amp;gt; || None || Cell/symmetry to use when no model is provided (i.e. &amp;lt;code&amp;gt;mark1&amp;lt;/code&amp;gt;).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;scaling.resolution_scalar&amp;lt;/code&amp;gt; || 0.969 || &amp;lt;code&amp;gt;merging.d_min&amp;lt;/code&amp;gt; is multiplied by this when deciding which reflections fall within the resolution limit, generating a few extra reference reflections to account for per-shot cell variation (e.g. set 0.96 for a few more).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;scaling.mtz.mtz_column_F&amp;lt;/code&amp;gt; || fobs || Column name in the reference MTZ containing the reference structure factors (intensities or amplitudes).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Post-refinement (&amp;lt;code&amp;gt;postrefinement&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;postrefinement.enable&amp;lt;/code&amp;gt; || True || Enable post-refinement of per-image parameters/partialities (Sauter 2015).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;postrefinement.algorithm&amp;lt;/code&amp;gt; || rs || Post-refinement protocol: &amp;lt;code&amp;gt;rs&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;rs2&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;rs_hybrid&amp;lt;/code&amp;gt;, or &amp;lt;code&amp;gt;eta_deff&amp;lt;/code&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Merging and error model (&amp;lt;code&amp;gt;merging&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;merging.d_min&amp;lt;/code&amp;gt; || None || High-resolution limit for scaling and merging.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;merging.d_max&amp;lt;/code&amp;gt; || None || Low-resolution limit (currently affects only CCiso).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;merging.merge_anomalous&amp;lt;/code&amp;gt; || False || &amp;lt;code&amp;gt;True&amp;lt;/code&amp;gt; merges Bijvoet mates together (higher multiplicity); &amp;lt;code&amp;gt;False&amp;lt;/code&amp;gt; keeps them separate to preserve the anomalous signal.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;merging.minimum_multiplicity&amp;lt;/code&amp;gt; || 2 || Do not produce a merged structure factor for HKLs measured fewer than this many times.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;merging.error.model&amp;lt;/code&amp;gt; || mm24 || Merged-sigma error model: &amp;lt;code&amp;gt;mm24&amp;lt;/code&amp;gt; (Mittan-Moreau 2025, current default), &amp;lt;code&amp;gt;ev11&amp;lt;/code&amp;gt; (Evans 2011 / sdfac-refine, recommended in the README), &amp;lt;code&amp;gt;ha14&amp;lt;/code&amp;gt;, or &amp;lt;code&amp;gt;errors_from_sample_residuals&amp;lt;/code&amp;gt; (no refined error terms — used with &amp;lt;code&amp;gt;mark1&amp;lt;/code&amp;gt; bootstrap).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;merging.set_average_unit_cell&amp;lt;/code&amp;gt; || True || Output MTZ adopts the (cluster-derived) average unit cell of the data rather than the reference model&#039;s cell.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Statistics (&amp;lt;code&amp;gt;statistics&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;statistics.n_bins&amp;lt;/code&amp;gt; || 10 || Number of resolution bins in the statistics tables.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;statistics.cciso.mtz_file&amp;lt;/code&amp;gt; || None || Isomorphous reference structure factors for R&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt; / CC&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;statistics.report_ML&amp;lt;/code&amp;gt; || True || Report per-frame max-likelihood attributes (domain size, mosaicity).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Output (&amp;lt;code&amp;gt;output&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.output_dir&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;.&amp;lt;/code&amp;gt; || Directory for output files (created if it does not exist).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.prefix&amp;lt;/code&amp;gt; || iobs || Prefix prepended to all output file names.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.save_experiments_and_reflections&amp;lt;/code&amp;gt; || False || Dump the final experiments/reflections from the last worker as DIALS files — used for the two-stage scale-then-merge workflow.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.do_timing&amp;lt;/code&amp;gt; || False || Log elapsed time per execution step.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.expanded_bookkeeping&amp;lt;/code&amp;gt; || False || Store extra provenance columns (input file/reflection indices, odd/even flag, original id) in the saved reflection tables.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Multiprocessing (&amp;lt;code&amp;gt;mp&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mp.method&amp;lt;/code&amp;gt; || mpi || Multiprocessing method (only &amp;lt;code&amp;gt;mpi&amp;lt;/code&amp;gt; is currently supported).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mp.debug.cProfile&amp;lt;/code&amp;gt; || False || Enable code profiling; a &amp;lt;code&amp;gt;.prof&amp;lt;/code&amp;gt; file is written per rank.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Output files ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;merge&amp;lt;/code&amp;gt; worker gathers all HKLs at rank 0 and writes three MTZ files, prefixed with&lt;br /&gt;
&amp;lt;code&amp;gt;output.prefix&amp;lt;/code&amp;gt; (default &amp;lt;code&amp;gt;iobs&amp;lt;/code&amp;gt;):&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;amp;lt;prefix&amp;amp;gt;_all.mtz&amp;lt;/code&amp;gt; — the merged dataset using all observations (the main result for structure solution)&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;amp;lt;prefix&amp;amp;gt;_odd.mtz&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;&amp;amp;lt;prefix&amp;amp;gt;_even.mtz&amp;lt;/code&amp;gt; — the two half-datasets used for CC½ and related half-dataset statistics&lt;br /&gt;
&lt;br /&gt;
A main log records the per-step progress and the merging statistics tables by resolution bin:&lt;br /&gt;
completeness, multiplicity and ⟨I/σ⟩, plus the &amp;quot;Table of Scaling Results&amp;quot; reporting CC½ (the&lt;br /&gt;
half-dataset correlation, labelled &amp;quot;CC int&amp;quot;), CC&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt;, R&amp;lt;sub&amp;gt;int&amp;lt;/sub&amp;gt;, R&amp;lt;sub&amp;gt;split&amp;lt;/sub&amp;gt;&lt;br /&gt;
and R&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt;.  The merged MTZ can optionally be&lt;br /&gt;
uploaded to a shared [https://github.com/cctbx/cctbx_project/tree/master/xfel/merging/application/publish Google Drive folder] by adding the &amp;lt;code&amp;gt;publish&amp;lt;/code&amp;gt; worker.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
* Sauter NK (2015). &#039;&#039;J Synchrotron Radiat&#039;&#039; &#039;&#039;&#039;22&#039;&#039;&#039;, 239–48. (post-refinement)&lt;br /&gt;
* Uervirojnangkoorn M, &#039;&#039;et al.&#039;&#039; (2015). &#039;&#039;eLife&#039;&#039; 10.7554/eLife.05421. (PRIME / bootstrap)&lt;br /&gt;
* Brewster AS, &#039;&#039;et al.&#039;&#039; (2018). &#039;&#039;Acta Cryst.&#039;&#039; D &#039;&#039;&#039;74&#039;&#039;&#039;, 877–894.&lt;br /&gt;
* Brewster AS, &#039;&#039;et al.&#039;&#039; (2019a). &#039;&#039;Computational Crystallography Newsletter&#039;&#039; &#039;&#039;&#039;10&#039;&#039;&#039;, 22–39. (XFEL GUI)&lt;br /&gt;
* Brewster AS, &#039;&#039;et al.&#039;&#039; (2019b). &#039;&#039;Acta Cryst.&#039;&#039; D &#039;&#039;&#039;75&#039;&#039;&#039;, 959–968. (error models)&lt;br /&gt;
* Mittan-Moreau (2025). (mm24 error model)&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
* [[dials.stills_process]] — produces the integrated data that &amp;lt;code&amp;gt;cctbx.xfel.merge&amp;lt;/code&amp;gt; consumes&lt;br /&gt;
* [[cctbx.xfel GUI]] — orchestrates separate scaling and repeated merging as data are collected&lt;br /&gt;
* The program README at &amp;lt;code&amp;gt;xfel/merging/README.md&amp;lt;/code&amp;gt; in cctbx_project&lt;/div&gt;</summary>
		<author><name>Aaron</name></author>
	</entry>
	<entry>
		<id>http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Cctbx.xfel.merge&amp;diff=1777</id>
		<title>Cctbx.xfel.merge</title>
		<link rel="alternate" type="text/html" href="http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Cctbx.xfel.merge&amp;diff=1777"/>
		<updated>2026-08-21T23:14:53Z</updated>

		<summary type="html">&lt;p&gt;Aaron: /* References */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= &#039;&#039;cctbx.xfel.merge&#039;&#039; =&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;cctbx.xfel.merge&#039;&#039;&#039;&#039;&#039; is the scaling, post-refinement and merging program of cctbx.xfel. It takes&lt;br /&gt;
the per-image integrated results produced by &#039;&#039;[[dials.stills_process]]&#039;&#039; — one crystal per still shot —&lt;br /&gt;
and reduces the whole ensemble to a single set of merged structure-factor intensities (an MTZ file)&lt;br /&gt;
suitable for structure solution and refinement, together with the crystallographic quality&lt;br /&gt;
statistics (completeness, multiplicity, ⟨I/σ⟩, CC½, CC&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt;, R-factors, etc.).&lt;br /&gt;
&lt;br /&gt;
Because serial datasets routinely contain tens of thousands to millions of still shots,&lt;br /&gt;
&amp;lt;code&amp;gt;cctbx.xfel.merge&amp;lt;/code&amp;gt; is built from the ground up to run under MPI across many nodes. It is&lt;br /&gt;
almost always launched with &amp;lt;code&amp;gt;mpirun&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;srun&amp;lt;/code&amp;gt;.  Note that MPI uses the term &#039;ranks&#039;&lt;br /&gt;
to distinguish independent processes that are running across one or more nodes.&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;cctbx.xfel.merge&amp;lt;/code&amp;gt; is organized as a sequence of &#039;&#039;&#039;workers&#039;&#039;&#039;. Each worker performs one&lt;br /&gt;
task — reading data, applying a correction, filtering, scaling, post-refining, computing a statistic,&lt;br /&gt;
or merging — and passes its (possibly modified) experiments and reflections on to the next worker.&lt;br /&gt;
The list of workers to run is the &amp;quot;step list&amp;quot;, and it is fully configurable: you can add, remove or&lt;br /&gt;
reorder steps with &amp;lt;code&amp;gt;dispatch.step_list&amp;lt;/code&amp;gt;. This is what makes the program flexible enough to&lt;br /&gt;
scale-and-merge in one pass, to scale subsets separately and merge later, or to run a reference-free&lt;br /&gt;
bootstrap.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;default&#039;&#039;&#039; step list is:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! # !! Worker !! Purpose&lt;br /&gt;
|-&lt;br /&gt;
| 1 || &amp;lt;code&amp;gt;input&amp;lt;/code&amp;gt; || Read integrated experiments (&amp;lt;code&amp;gt;.expt&amp;lt;/code&amp;gt;) and reflections (&amp;lt;code&amp;gt;.refl&amp;lt;/code&amp;gt;) from disk in DIALS format.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || &amp;lt;code&amp;gt;balance&amp;lt;/code&amp;gt; || Redistribute the input load evenly across MPI ranks (needed when there are fewer or more input files than ranks).&lt;br /&gt;
|-&lt;br /&gt;
| 3 || &amp;lt;code&amp;gt;model_scaling&amp;lt;/code&amp;gt; || Build the full Miller list, model intensities from the reference, and the resolution binner used for scaling and post-refinement.&lt;br /&gt;
|-&lt;br /&gt;
| 4 || &amp;lt;code&amp;gt;modify&amp;lt;/code&amp;gt; || Apply per-reflection modifications, e.g. polarization correction (and optionally re-indexing to resolve indexing ambiguity — see &amp;lt;code&amp;gt;modify.cosym&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;reindex_to_reference&amp;lt;/code&amp;gt;).&lt;br /&gt;
|-&lt;br /&gt;
| 5 || &amp;lt;code&amp;gt;filter&amp;lt;/code&amp;gt; || Reject whole experiments (or reflections) by resolution, unit cell, correlation to the reference, energy, etc.&lt;br /&gt;
|-&lt;br /&gt;
| 6 || &amp;lt;code&amp;gt;scale&amp;lt;/code&amp;gt; || Scale each lattice to the reference dataset (&amp;lt;code&amp;gt;mark0&amp;lt;/code&amp;gt;) or simply average (&amp;lt;code&amp;gt;mark1&amp;lt;/code&amp;gt;).&lt;br /&gt;
|-&lt;br /&gt;
| 7 || &amp;lt;code&amp;gt;postrefine&amp;lt;/code&amp;gt; || Post-refine per-image crystal parameters and partialities (Sauter 2015).&lt;br /&gt;
|-&lt;br /&gt;
| 8 || &amp;lt;code&amp;gt;statistics_unitcell&amp;lt;/code&amp;gt; || Determine and store the average unit cell.&lt;br /&gt;
|-&lt;br /&gt;
| 9 || &amp;lt;code&amp;gt;statistics_beam&amp;lt;/code&amp;gt; || Determine and store the average wavelength.&lt;br /&gt;
|-&lt;br /&gt;
| 10 || &amp;lt;code&amp;gt;model_statistics&amp;lt;/code&amp;gt; || Rebuild the Miller list / binner for statistics (may use the average unit cell).&lt;br /&gt;
|-&lt;br /&gt;
| 11 || &amp;lt;code&amp;gt;statistics_resolution&amp;lt;/code&amp;gt; || Per-crystal resolution statistics.&lt;br /&gt;
|-&lt;br /&gt;
| 12 || &amp;lt;code&amp;gt;group&amp;lt;/code&amp;gt; || Redistribute reflections across ranks so that every observation of a given HKL is gathered on the same rank prior to merging.&lt;br /&gt;
|-&lt;br /&gt;
| 13 || &amp;lt;code&amp;gt;errors_merge&amp;lt;/code&amp;gt; || Correct the merged error estimates with a per-HKL error model (e.g. Ev11, Brewster 2019b, or MM24 (the default), Mittan-Moreau (2025)).&lt;br /&gt;
|-&lt;br /&gt;
| 14 || &amp;lt;code&amp;gt;statistics_intensity&amp;lt;/code&amp;gt; || Intensity statistics by resolution.&lt;br /&gt;
|-&lt;br /&gt;
| 15 || &amp;lt;code&amp;gt;merge&amp;lt;/code&amp;gt; || Merge symmetry-equivalent intensities, gather all HKLs at rank 0, and write &amp;quot;odd&amp;quot;, &amp;quot;even&amp;quot; and &amp;quot;all&amp;quot; MTZ files.&lt;br /&gt;
|-&lt;br /&gt;
| 16 || &amp;lt;code&amp;gt;statistics_intensity_cxi&amp;lt;/code&amp;gt; || Correlation and R-factor statistics (ported from cxi.merge): the &amp;quot;Table of Scaling Results&amp;quot; — CC½ (half-dataset correlation, labelled &amp;quot;CC int&amp;quot;), CC&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt;, R&amp;lt;sub&amp;gt;int&amp;lt;/sub&amp;gt;, R&amp;lt;sub&amp;gt;split&amp;lt;/sub&amp;gt;, R&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Additional, non-default workers are available and can be&lt;br /&gt;
inserted into the step list, including &amp;lt;code&amp;gt;tdata&amp;lt;/code&amp;gt; (write out unit cells for clustering),&lt;br /&gt;
&amp;lt;code&amp;gt;export&amp;lt;/code&amp;gt; (batch MTZ for &#039;&#039;Careless&#039;&#039;), &amp;lt;code&amp;gt;publish&amp;lt;/code&amp;gt; (upload merged files to a&lt;br /&gt;
Google Drive folder), &amp;lt;code&amp;gt;monitor&amp;lt;/code&amp;gt; (resource-usage logging), &amp;lt;code&amp;gt;integrate&amp;lt;/code&amp;gt;&lt;br /&gt;
(on-the-fly integration), &amp;lt;code&amp;gt;prepare&amp;lt;/code&amp;gt; (SpReAD energy binning), and&lt;br /&gt;
&amp;lt;code&amp;gt;lunus&amp;lt;/code&amp;gt; (diffuse-scattering deck). A &amp;lt;code&amp;gt;deltaccint&amp;lt;/code&amp;gt; worker (ΔCC½ lattice&lt;br /&gt;
filtering) can be added after &amp;lt;code&amp;gt;group&amp;lt;/code&amp;gt;. Custom workers can be supplied through the&lt;br /&gt;
&amp;lt;code&amp;gt;XFEL_CUSTOM_WORKER_PATH&amp;lt;/code&amp;gt; environment variable.&lt;br /&gt;
&lt;br /&gt;
== Basic usage ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;cctbx.xfel.merge&amp;lt;/code&amp;gt; is run under MPI:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mpirun cctbx.xfel.merge merge.phil&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A typical &amp;lt;code&amp;gt;merge.phil&amp;lt;/code&amp;gt; (from the program README):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
input.path=&amp;lt;path to data&amp;gt;&lt;br /&gt;
input.experiments_suffix=.expt&lt;br /&gt;
input.reflections_suffix=.refl&lt;br /&gt;
&lt;br /&gt;
filter.algorithm=unit_cell&lt;br /&gt;
filter.unit_cell.value.relative_length_tolerance=0.03&lt;br /&gt;
filter.outlier.min_corr=0.1&lt;br /&gt;
&lt;br /&gt;
select.algorithm=significance_filter&lt;br /&gt;
select.significance_filter.sigma=0.1&lt;br /&gt;
select.significance_filter.min_ct=200&lt;br /&gt;
select.significance_filter.max_ct=300&lt;br /&gt;
&lt;br /&gt;
scaling.model=&amp;lt;model.pdb or model.mtz&amp;gt;&lt;br /&gt;
scaling.resolution_scalar=0.96&lt;br /&gt;
&lt;br /&gt;
merging.d_min=1.8&lt;br /&gt;
merging.error.model=ev11&lt;br /&gt;
merging.merge_anomalous=True&lt;br /&gt;
&lt;br /&gt;
postrefinement.enable=True&lt;br /&gt;
statistics.n_bins=20&lt;br /&gt;
&lt;br /&gt;
output.do_timing=True&lt;br /&gt;
output.output_dir=&amp;lt;output folder&amp;gt;&lt;br /&gt;
output.prefix=&amp;lt;prefix for output files&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Explore the parameters with:&lt;br /&gt;
* &amp;lt;code&amp;gt;cctbx.xfel.merge -c&amp;lt;/code&amp;gt; — show configurable parameters&lt;br /&gt;
* &amp;lt;code&amp;gt;cctbx.xfel.merge -c -e 10 -a 2&amp;lt;/code&amp;gt; — show all parameters (expert level 10) with full help text&lt;br /&gt;
&lt;br /&gt;
== Two-stage scaling and merging ==&lt;br /&gt;
&lt;br /&gt;
For large, growing datasets (the mode used by the [[cctbx.xfel GUI]]), it is more efficient to scale&lt;br /&gt;
and post-refine each subset of data &#039;&#039;&#039;once&#039;&#039;&#039;, then merge repeatedly as more data arrive. This is&lt;br /&gt;
done by running the program twice with different step lists.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Stage 1 — scale each subset&#039;&#039;&#039; (stops after per-image work and writes intermediate DIALS files):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dispatch.step_list=input balance model_scaling modify filter scale postrefine \&lt;br /&gt;
    statistics_unitcell statistics_beam model_statistics statistics_resolution&lt;br /&gt;
input.parallel_file_load.method=uniform&lt;br /&gt;
output.save_experiments_and_reflections=True&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;output.save_experiments_and_reflections=True&amp;lt;/code&amp;gt; dumps the scaled/post-refined data as&lt;br /&gt;
experiment lists and reflection tables that the merge stage can read back in.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Stage 2 — merge the scaled subsets&#039;&#039;&#039; (add an &amp;lt;code&amp;gt;input.path&amp;lt;/code&amp;gt; for each finished subset):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dispatch.step_list=input model_scaling statistics_unitcell statistics_beam \&lt;br /&gt;
    model_statistics statistics_resolution group errors_merge statistics_intensity \&lt;br /&gt;
    merge statistics_intensity_cxi&lt;br /&gt;
input.parallel_file_load.method=uniform&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Merging without a reference (bootstrap / mark1) ==&lt;br /&gt;
&lt;br /&gt;
If no scaling/merging reference is available, use a bootstrap procedure. First run the&lt;br /&gt;
&amp;lt;code&amp;gt;mark1&amp;lt;/code&amp;gt; algorithm, which simply averages the data (all per-image scale factors = 1, no&lt;br /&gt;
post-refinement), specifying the target cell and symmetry explicitly:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
scaling.algorithm=mark1&lt;br /&gt;
scaling.unit_cell=&amp;lt;unit cell&amp;gt;&lt;br /&gt;
scaling.space_group=&amp;lt;space group&amp;gt;&lt;br /&gt;
merging.error.model=errors_from_sample_residuals&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The resulting MTZ is then used as the reference (&amp;lt;code&amp;gt;scaling.model=&amp;lt;/code&amp;gt;) for subsequent regular&lt;br /&gt;
merges. Iterate a few cycles; CC½ typically improves and converges over the first few rounds.&lt;br /&gt;
&lt;br /&gt;
== Important parameters ==&lt;br /&gt;
&lt;br /&gt;
Parameters are given by their full PHIL path with defaults in parentheses. The program exposes many&lt;br /&gt;
more parameters (see &amp;lt;code&amp;gt;-c -e 10 -a 2&amp;lt;/code&amp;gt;); those below are the ones most commonly set.&lt;br /&gt;
&lt;br /&gt;
=== Input ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.path&amp;lt;/code&amp;gt; || None || Path(s) to the integrated data — a folder, several folders, or individual files; wildcards allowed; may be repeated. Matching &amp;lt;code&amp;gt;.expt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;.refl&amp;lt;/code&amp;gt; files must both be present.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.experiments_suffix&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;_integrated.expt&amp;lt;/code&amp;gt; || Only load experiment files ending with this suffix.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.reflections_suffix&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;_integrated.refl&amp;lt;/code&amp;gt; || Only load reflection files ending with this suffix.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.parallel_file_load.method&amp;lt;/code&amp;gt; || uniform || &amp;lt;code&amp;gt;uniform&amp;lt;/code&amp;gt; spreads input files evenly over all ranks; &amp;lt;code&amp;gt;node_memory&amp;lt;/code&amp;gt; distributes so per-node memory limits are respected.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.alist.file&amp;lt;/code&amp;gt; || None || Path to a text file of experiment tags or filenames; combined with &amp;lt;code&amp;gt;input.alist.op=keep|reject&amp;lt;/code&amp;gt; to merge only (or exclude) a specified subset.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.persistent_refl_cols&amp;lt;/code&amp;gt; || None || Reflection-table columns to preserve through the pruning steps (and into saved tables).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Filtering whole experiments (&amp;lt;code&amp;gt;filter&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;filter&amp;lt;/code&amp;gt; section accepts or rejects &#039;&#039;&#039;entire experiments&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.algorithm&amp;lt;/code&amp;gt; || (none) || One or more of &amp;lt;code&amp;gt;n_obs&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;resolution&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;unit_cell&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;energy&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bootstrap&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;experiment_prefix&amp;lt;/code&amp;gt;. Nothing is filtered unless listed.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.unit_cell.algorithm&amp;lt;/code&amp;gt; || value || How to restrict unit cells: &amp;lt;code&amp;gt;value&amp;lt;/code&amp;gt; (compare to a target), &amp;lt;code&amp;gt;range&amp;lt;/code&amp;gt;, or &amp;lt;code&amp;gt;cluster&amp;lt;/code&amp;gt; (use a precomputed covariance clustering).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.unit_cell.value.relative_length_tolerance&amp;lt;/code&amp;gt; || 0.1 || Fractional deviation of cell edge lengths allowed vs. the target cell. Often tightened (e.g. 0.03).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.unit_cell.value.absolute_angle_tolerance&amp;lt;/code&amp;gt; || 2.0 || Allowed cell-angle deviation (degrees) vs. the target.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.unit_cell.value.target_unit_cell&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;target_space_group&amp;lt;/code&amp;gt; || Auto || Target cell/symmetry; &amp;lt;code&amp;gt;Auto&amp;lt;/code&amp;gt; uses the scaling model.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.outlier.min_corr&amp;lt;/code&amp;gt; || 0.1 || Minimum correlation of an image&#039;s intensities to the reference model; images below this are rejected. Only applied when a scaling model is present. Use &amp;lt;code&amp;gt;-1&amp;lt;/code&amp;gt; to accept all images regardless of correlation.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.resolution.d_min&amp;lt;/code&amp;gt; || None || Reject an experiment unless some of its reflections extend beyond this resolution.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Selecting individual reflections (&amp;lt;code&amp;gt;select&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;select&amp;lt;/code&amp;gt; section accepts or rejects &#039;&#039;&#039;individual reflections&#039;&#039;&#039; (contrast with&lt;br /&gt;
&amp;lt;code&amp;gt;filter&amp;lt;/code&amp;gt;, which acts on whole experiments).&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;select.algorithm&amp;lt;/code&amp;gt; || (none) || One or more of &amp;lt;code&amp;gt;significance_filter&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;panel&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cspad_sensor&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;isolation_forest&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;target_energy&amp;lt;/code&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;select.significance_filter.sigma&amp;lt;/code&amp;gt; || 0.5 || Trim each lattice at the resolution where the binned ⟨I/σ⟩ drops below this value.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;select.significance_filter.min_ct&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;max_ct&amp;lt;/code&amp;gt; || 10 / 50 || Target minimum/maximum mean reflections per resolution bin when choosing the number of bins. For large unit cells these are often raised (e.g. 200/300); for small cells, use the defaults.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Modifying intensities (&amp;lt;code&amp;gt;modify&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;modify.algorithm&amp;lt;/code&amp;gt; || polarization || Per-reflection corrections to apply (default applies the polarization correction).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;modify.cosym&amp;lt;/code&amp;gt; || — || Resolve an indexing ambiguity across the ensemble using the Gildea/Winter (Brehm/Diederichs) cosym method, optionally anchored to &amp;lt;code&amp;gt;scaling.model&amp;lt;/code&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;modify.reindex_to_reference&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;reindex_to_abc&amp;lt;/code&amp;gt; || — || Alternative re-indexing operators (to a reference model, or an explicit operator).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Scaling (&amp;lt;code&amp;gt;scaling&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;scaling.model&amp;lt;/code&amp;gt; || None || Reference dataset: a PDB file (uses the CRYST1 cell and computes model intensities, including bulk solvent) or an MTZ from a previous cycle. Required for &amp;lt;code&amp;gt;mark0&amp;lt;/code&amp;gt; scaling.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;scaling.algorithm&amp;lt;/code&amp;gt; || mark0 || &amp;lt;code&amp;gt;mark0&amp;lt;/code&amp;gt;: per-image scaling against the reference. &amp;lt;code&amp;gt;mark1&amp;lt;/code&amp;gt;: no scaling, just Monte-Carlo averaging (all scale factors = 1) — used for reference-free bootstrap.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;scaling.unit_cell&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;scaling.space_group&amp;lt;/code&amp;gt; || None || Cell/symmetry to use when no model is provided (i.e. &amp;lt;code&amp;gt;mark1&amp;lt;/code&amp;gt;).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;scaling.resolution_scalar&amp;lt;/code&amp;gt; || 0.969 || &amp;lt;code&amp;gt;merging.d_min&amp;lt;/code&amp;gt; is multiplied by this when deciding which reflections fall within the resolution limit, generating a few extra reference reflections to account for per-shot cell variation (e.g. set 0.96 for a few more).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;scaling.mtz.mtz_column_F&amp;lt;/code&amp;gt; || fobs || Column name in the reference MTZ containing the reference structure factors (intensities or amplitudes).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Post-refinement (&amp;lt;code&amp;gt;postrefinement&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;postrefinement.enable&amp;lt;/code&amp;gt; || True || Enable post-refinement of per-image parameters/partialities (Sauter 2015).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;postrefinement.algorithm&amp;lt;/code&amp;gt; || rs || Post-refinement protocol: &amp;lt;code&amp;gt;rs&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;rs2&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;rs_hybrid&amp;lt;/code&amp;gt;, or &amp;lt;code&amp;gt;eta_deff&amp;lt;/code&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Merging and error model (&amp;lt;code&amp;gt;merging&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;merging.d_min&amp;lt;/code&amp;gt; || None || High-resolution limit for scaling and merging.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;merging.d_max&amp;lt;/code&amp;gt; || None || Low-resolution limit (currently affects only CCiso).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;merging.merge_anomalous&amp;lt;/code&amp;gt; || False || &amp;lt;code&amp;gt;True&amp;lt;/code&amp;gt; merges Bijvoet mates together (higher multiplicity); &amp;lt;code&amp;gt;False&amp;lt;/code&amp;gt; keeps them separate to preserve the anomalous signal.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;merging.minimum_multiplicity&amp;lt;/code&amp;gt; || 2 || Do not produce a merged structure factor for HKLs measured fewer than this many times.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;merging.error.model&amp;lt;/code&amp;gt; || mm24 || Merged-sigma error model: &amp;lt;code&amp;gt;mm24&amp;lt;/code&amp;gt; (Mittan-Moreau 2024, current default), &amp;lt;code&amp;gt;ev11&amp;lt;/code&amp;gt; (Evans 2011 / sdfac-refine, recommended in the README), &amp;lt;code&amp;gt;ha14&amp;lt;/code&amp;gt;, or &amp;lt;code&amp;gt;errors_from_sample_residuals&amp;lt;/code&amp;gt; (no refined error terms — used with &amp;lt;code&amp;gt;mark1&amp;lt;/code&amp;gt; bootstrap).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;merging.set_average_unit_cell&amp;lt;/code&amp;gt; || True || Output MTZ adopts the (cluster-derived) average unit cell of the data rather than the reference model&#039;s cell.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Statistics (&amp;lt;code&amp;gt;statistics&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;statistics.n_bins&amp;lt;/code&amp;gt; || 10 || Number of resolution bins in the statistics tables.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;statistics.cciso.mtz_file&amp;lt;/code&amp;gt; || None || Isomorphous reference structure factors for R&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt; / CC&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;statistics.report_ML&amp;lt;/code&amp;gt; || True || Report per-frame max-likelihood attributes (domain size, mosaicity).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Output (&amp;lt;code&amp;gt;output&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.output_dir&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;.&amp;lt;/code&amp;gt; || Directory for output files (created if it does not exist).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.prefix&amp;lt;/code&amp;gt; || iobs || Prefix prepended to all output file names.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.save_experiments_and_reflections&amp;lt;/code&amp;gt; || False || Dump the final experiments/reflections from the last worker as DIALS files — used for the two-stage scale-then-merge workflow.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.do_timing&amp;lt;/code&amp;gt; || False || Log elapsed time per execution step.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.expanded_bookkeeping&amp;lt;/code&amp;gt; || False || Store extra provenance columns (input file/reflection indices, odd/even flag, original id) in the saved reflection tables.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Multiprocessing (&amp;lt;code&amp;gt;mp&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mp.method&amp;lt;/code&amp;gt; || mpi || Multiprocessing method (only &amp;lt;code&amp;gt;mpi&amp;lt;/code&amp;gt; is currently supported).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mp.debug.cProfile&amp;lt;/code&amp;gt; || False || Enable code profiling; a &amp;lt;code&amp;gt;.prof&amp;lt;/code&amp;gt; file is written per rank.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Output files ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;merge&amp;lt;/code&amp;gt; worker gathers all HKLs at rank 0 and writes three MTZ files, prefixed with&lt;br /&gt;
&amp;lt;code&amp;gt;output.prefix&amp;lt;/code&amp;gt; (default &amp;lt;code&amp;gt;iobs&amp;lt;/code&amp;gt;):&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;amp;lt;prefix&amp;amp;gt;_all.mtz&amp;lt;/code&amp;gt; — the merged dataset using all observations (the main result for structure solution)&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;amp;lt;prefix&amp;amp;gt;_odd.mtz&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;&amp;amp;lt;prefix&amp;amp;gt;_even.mtz&amp;lt;/code&amp;gt; — the two half-datasets used for CC½ and related half-dataset statistics&lt;br /&gt;
&lt;br /&gt;
A main log records the per-step progress and the merging statistics tables by resolution bin:&lt;br /&gt;
completeness, multiplicity and ⟨I/σ⟩, plus the &amp;quot;Table of Scaling Results&amp;quot; reporting CC½ (the&lt;br /&gt;
half-dataset correlation, labelled &amp;quot;CC int&amp;quot;), CC&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt;, R&amp;lt;sub&amp;gt;int&amp;lt;/sub&amp;gt;, R&amp;lt;sub&amp;gt;split&amp;lt;/sub&amp;gt;&lt;br /&gt;
and R&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt;.  The merged MTZ can optionally be&lt;br /&gt;
uploaded to a shared [https://github.com/cctbx/cctbx_project/tree/master/xfel/merging/application/publish Google Drive folder] by adding the &amp;lt;code&amp;gt;publish&amp;lt;/code&amp;gt; worker.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
* Sauter NK (2015). &#039;&#039;J Synchrotron Radiat&#039;&#039; &#039;&#039;&#039;22&#039;&#039;&#039;, 239–48. (post-refinement)&lt;br /&gt;
* Uervirojnangkoorn M, &#039;&#039;et al.&#039;&#039; (2015). &#039;&#039;eLife&#039;&#039; 10.7554/eLife.05421. (PRIME / bootstrap)&lt;br /&gt;
* Brewster AS, &#039;&#039;et al.&#039;&#039; (2018). &#039;&#039;Acta Cryst.&#039;&#039; D &#039;&#039;&#039;74&#039;&#039;&#039;, 877–894.&lt;br /&gt;
* Brewster AS, &#039;&#039;et al.&#039;&#039; (2019a). &#039;&#039;Computational Crystallography Newsletter&#039;&#039; &#039;&#039;&#039;10&#039;&#039;&#039;, 22–39. (XFEL GUI)&lt;br /&gt;
* Brewster AS, &#039;&#039;et al.&#039;&#039; (2019b). &#039;&#039;Acta Cryst.&#039;&#039; D &#039;&#039;&#039;75&#039;&#039;&#039;, 959–968. (error models)&lt;br /&gt;
* Mittan-Moreau (2025). (mm24 error model)&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
* [[dials.stills_process]] — produces the integrated data that &amp;lt;code&amp;gt;cctbx.xfel.merge&amp;lt;/code&amp;gt; consumes&lt;br /&gt;
* [[cctbx.xfel GUI]] — orchestrates separate scaling and repeated merging as data are collected&lt;br /&gt;
* The program README at &amp;lt;code&amp;gt;xfel/merging/README.md&amp;lt;/code&amp;gt; in cctbx_project&lt;/div&gt;</summary>
		<author><name>Aaron</name></author>
	</entry>
	<entry>
		<id>http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Cctbx.xfel.merge&amp;diff=1776</id>
		<title>Cctbx.xfel.merge</title>
		<link rel="alternate" type="text/html" href="http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Cctbx.xfel.merge&amp;diff=1776"/>
		<updated>2026-08-21T23:14:17Z</updated>

		<summary type="html">&lt;p&gt;Aaron: /* Output files */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= &#039;&#039;cctbx.xfel.merge&#039;&#039; =&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;cctbx.xfel.merge&#039;&#039;&#039;&#039;&#039; is the scaling, post-refinement and merging program of cctbx.xfel. It takes&lt;br /&gt;
the per-image integrated results produced by &#039;&#039;[[dials.stills_process]]&#039;&#039; — one crystal per still shot —&lt;br /&gt;
and reduces the whole ensemble to a single set of merged structure-factor intensities (an MTZ file)&lt;br /&gt;
suitable for structure solution and refinement, together with the crystallographic quality&lt;br /&gt;
statistics (completeness, multiplicity, ⟨I/σ⟩, CC½, CC&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt;, R-factors, etc.).&lt;br /&gt;
&lt;br /&gt;
Because serial datasets routinely contain tens of thousands to millions of still shots,&lt;br /&gt;
&amp;lt;code&amp;gt;cctbx.xfel.merge&amp;lt;/code&amp;gt; is built from the ground up to run under MPI across many nodes. It is&lt;br /&gt;
almost always launched with &amp;lt;code&amp;gt;mpirun&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;srun&amp;lt;/code&amp;gt;.  Note that MPI uses the term &#039;ranks&#039;&lt;br /&gt;
to distinguish independent processes that are running across one or more nodes.&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;cctbx.xfel.merge&amp;lt;/code&amp;gt; is organized as a sequence of &#039;&#039;&#039;workers&#039;&#039;&#039;. Each worker performs one&lt;br /&gt;
task — reading data, applying a correction, filtering, scaling, post-refining, computing a statistic,&lt;br /&gt;
or merging — and passes its (possibly modified) experiments and reflections on to the next worker.&lt;br /&gt;
The list of workers to run is the &amp;quot;step list&amp;quot;, and it is fully configurable: you can add, remove or&lt;br /&gt;
reorder steps with &amp;lt;code&amp;gt;dispatch.step_list&amp;lt;/code&amp;gt;. This is what makes the program flexible enough to&lt;br /&gt;
scale-and-merge in one pass, to scale subsets separately and merge later, or to run a reference-free&lt;br /&gt;
bootstrap.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;default&#039;&#039;&#039; step list is:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! # !! Worker !! Purpose&lt;br /&gt;
|-&lt;br /&gt;
| 1 || &amp;lt;code&amp;gt;input&amp;lt;/code&amp;gt; || Read integrated experiments (&amp;lt;code&amp;gt;.expt&amp;lt;/code&amp;gt;) and reflections (&amp;lt;code&amp;gt;.refl&amp;lt;/code&amp;gt;) from disk in DIALS format.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || &amp;lt;code&amp;gt;balance&amp;lt;/code&amp;gt; || Redistribute the input load evenly across MPI ranks (needed when there are fewer or more input files than ranks).&lt;br /&gt;
|-&lt;br /&gt;
| 3 || &amp;lt;code&amp;gt;model_scaling&amp;lt;/code&amp;gt; || Build the full Miller list, model intensities from the reference, and the resolution binner used for scaling and post-refinement.&lt;br /&gt;
|-&lt;br /&gt;
| 4 || &amp;lt;code&amp;gt;modify&amp;lt;/code&amp;gt; || Apply per-reflection modifications, e.g. polarization correction (and optionally re-indexing to resolve indexing ambiguity — see &amp;lt;code&amp;gt;modify.cosym&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;reindex_to_reference&amp;lt;/code&amp;gt;).&lt;br /&gt;
|-&lt;br /&gt;
| 5 || &amp;lt;code&amp;gt;filter&amp;lt;/code&amp;gt; || Reject whole experiments (or reflections) by resolution, unit cell, correlation to the reference, energy, etc.&lt;br /&gt;
|-&lt;br /&gt;
| 6 || &amp;lt;code&amp;gt;scale&amp;lt;/code&amp;gt; || Scale each lattice to the reference dataset (&amp;lt;code&amp;gt;mark0&amp;lt;/code&amp;gt;) or simply average (&amp;lt;code&amp;gt;mark1&amp;lt;/code&amp;gt;).&lt;br /&gt;
|-&lt;br /&gt;
| 7 || &amp;lt;code&amp;gt;postrefine&amp;lt;/code&amp;gt; || Post-refine per-image crystal parameters and partialities (Sauter 2015).&lt;br /&gt;
|-&lt;br /&gt;
| 8 || &amp;lt;code&amp;gt;statistics_unitcell&amp;lt;/code&amp;gt; || Determine and store the average unit cell.&lt;br /&gt;
|-&lt;br /&gt;
| 9 || &amp;lt;code&amp;gt;statistics_beam&amp;lt;/code&amp;gt; || Determine and store the average wavelength.&lt;br /&gt;
|-&lt;br /&gt;
| 10 || &amp;lt;code&amp;gt;model_statistics&amp;lt;/code&amp;gt; || Rebuild the Miller list / binner for statistics (may use the average unit cell).&lt;br /&gt;
|-&lt;br /&gt;
| 11 || &amp;lt;code&amp;gt;statistics_resolution&amp;lt;/code&amp;gt; || Per-crystal resolution statistics.&lt;br /&gt;
|-&lt;br /&gt;
| 12 || &amp;lt;code&amp;gt;group&amp;lt;/code&amp;gt; || Redistribute reflections across ranks so that every observation of a given HKL is gathered on the same rank prior to merging.&lt;br /&gt;
|-&lt;br /&gt;
| 13 || &amp;lt;code&amp;gt;errors_merge&amp;lt;/code&amp;gt; || Correct the merged error estimates with a per-HKL error model (e.g. Ev11, Brewster 2019b, or MM24 (the default), Mittan-Moreau (2025)).&lt;br /&gt;
|-&lt;br /&gt;
| 14 || &amp;lt;code&amp;gt;statistics_intensity&amp;lt;/code&amp;gt; || Intensity statistics by resolution.&lt;br /&gt;
|-&lt;br /&gt;
| 15 || &amp;lt;code&amp;gt;merge&amp;lt;/code&amp;gt; || Merge symmetry-equivalent intensities, gather all HKLs at rank 0, and write &amp;quot;odd&amp;quot;, &amp;quot;even&amp;quot; and &amp;quot;all&amp;quot; MTZ files.&lt;br /&gt;
|-&lt;br /&gt;
| 16 || &amp;lt;code&amp;gt;statistics_intensity_cxi&amp;lt;/code&amp;gt; || Correlation and R-factor statistics (ported from cxi.merge): the &amp;quot;Table of Scaling Results&amp;quot; — CC½ (half-dataset correlation, labelled &amp;quot;CC int&amp;quot;), CC&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt;, R&amp;lt;sub&amp;gt;int&amp;lt;/sub&amp;gt;, R&amp;lt;sub&amp;gt;split&amp;lt;/sub&amp;gt;, R&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Additional, non-default workers are available and can be&lt;br /&gt;
inserted into the step list, including &amp;lt;code&amp;gt;tdata&amp;lt;/code&amp;gt; (write out unit cells for clustering),&lt;br /&gt;
&amp;lt;code&amp;gt;export&amp;lt;/code&amp;gt; (batch MTZ for &#039;&#039;Careless&#039;&#039;), &amp;lt;code&amp;gt;publish&amp;lt;/code&amp;gt; (upload merged files to a&lt;br /&gt;
Google Drive folder), &amp;lt;code&amp;gt;monitor&amp;lt;/code&amp;gt; (resource-usage logging), &amp;lt;code&amp;gt;integrate&amp;lt;/code&amp;gt;&lt;br /&gt;
(on-the-fly integration), &amp;lt;code&amp;gt;prepare&amp;lt;/code&amp;gt; (SpReAD energy binning), and&lt;br /&gt;
&amp;lt;code&amp;gt;lunus&amp;lt;/code&amp;gt; (diffuse-scattering deck). A &amp;lt;code&amp;gt;deltaccint&amp;lt;/code&amp;gt; worker (ΔCC½ lattice&lt;br /&gt;
filtering) can be added after &amp;lt;code&amp;gt;group&amp;lt;/code&amp;gt;. Custom workers can be supplied through the&lt;br /&gt;
&amp;lt;code&amp;gt;XFEL_CUSTOM_WORKER_PATH&amp;lt;/code&amp;gt; environment variable.&lt;br /&gt;
&lt;br /&gt;
== Basic usage ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;cctbx.xfel.merge&amp;lt;/code&amp;gt; is run under MPI:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mpirun cctbx.xfel.merge merge.phil&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A typical &amp;lt;code&amp;gt;merge.phil&amp;lt;/code&amp;gt; (from the program README):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
input.path=&amp;lt;path to data&amp;gt;&lt;br /&gt;
input.experiments_suffix=.expt&lt;br /&gt;
input.reflections_suffix=.refl&lt;br /&gt;
&lt;br /&gt;
filter.algorithm=unit_cell&lt;br /&gt;
filter.unit_cell.value.relative_length_tolerance=0.03&lt;br /&gt;
filter.outlier.min_corr=0.1&lt;br /&gt;
&lt;br /&gt;
select.algorithm=significance_filter&lt;br /&gt;
select.significance_filter.sigma=0.1&lt;br /&gt;
select.significance_filter.min_ct=200&lt;br /&gt;
select.significance_filter.max_ct=300&lt;br /&gt;
&lt;br /&gt;
scaling.model=&amp;lt;model.pdb or model.mtz&amp;gt;&lt;br /&gt;
scaling.resolution_scalar=0.96&lt;br /&gt;
&lt;br /&gt;
merging.d_min=1.8&lt;br /&gt;
merging.error.model=ev11&lt;br /&gt;
merging.merge_anomalous=True&lt;br /&gt;
&lt;br /&gt;
postrefinement.enable=True&lt;br /&gt;
statistics.n_bins=20&lt;br /&gt;
&lt;br /&gt;
output.do_timing=True&lt;br /&gt;
output.output_dir=&amp;lt;output folder&amp;gt;&lt;br /&gt;
output.prefix=&amp;lt;prefix for output files&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Explore the parameters with:&lt;br /&gt;
* &amp;lt;code&amp;gt;cctbx.xfel.merge -c&amp;lt;/code&amp;gt; — show configurable parameters&lt;br /&gt;
* &amp;lt;code&amp;gt;cctbx.xfel.merge -c -e 10 -a 2&amp;lt;/code&amp;gt; — show all parameters (expert level 10) with full help text&lt;br /&gt;
&lt;br /&gt;
== Two-stage scaling and merging ==&lt;br /&gt;
&lt;br /&gt;
For large, growing datasets (the mode used by the [[cctbx.xfel GUI]]), it is more efficient to scale&lt;br /&gt;
and post-refine each subset of data &#039;&#039;&#039;once&#039;&#039;&#039;, then merge repeatedly as more data arrive. This is&lt;br /&gt;
done by running the program twice with different step lists.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Stage 1 — scale each subset&#039;&#039;&#039; (stops after per-image work and writes intermediate DIALS files):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dispatch.step_list=input balance model_scaling modify filter scale postrefine \&lt;br /&gt;
    statistics_unitcell statistics_beam model_statistics statistics_resolution&lt;br /&gt;
input.parallel_file_load.method=uniform&lt;br /&gt;
output.save_experiments_and_reflections=True&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;output.save_experiments_and_reflections=True&amp;lt;/code&amp;gt; dumps the scaled/post-refined data as&lt;br /&gt;
experiment lists and reflection tables that the merge stage can read back in.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Stage 2 — merge the scaled subsets&#039;&#039;&#039; (add an &amp;lt;code&amp;gt;input.path&amp;lt;/code&amp;gt; for each finished subset):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dispatch.step_list=input model_scaling statistics_unitcell statistics_beam \&lt;br /&gt;
    model_statistics statistics_resolution group errors_merge statistics_intensity \&lt;br /&gt;
    merge statistics_intensity_cxi&lt;br /&gt;
input.parallel_file_load.method=uniform&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Merging without a reference (bootstrap / mark1) ==&lt;br /&gt;
&lt;br /&gt;
If no scaling/merging reference is available, use a bootstrap procedure. First run the&lt;br /&gt;
&amp;lt;code&amp;gt;mark1&amp;lt;/code&amp;gt; algorithm, which simply averages the data (all per-image scale factors = 1, no&lt;br /&gt;
post-refinement), specifying the target cell and symmetry explicitly:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
scaling.algorithm=mark1&lt;br /&gt;
scaling.unit_cell=&amp;lt;unit cell&amp;gt;&lt;br /&gt;
scaling.space_group=&amp;lt;space group&amp;gt;&lt;br /&gt;
merging.error.model=errors_from_sample_residuals&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The resulting MTZ is then used as the reference (&amp;lt;code&amp;gt;scaling.model=&amp;lt;/code&amp;gt;) for subsequent regular&lt;br /&gt;
merges. Iterate a few cycles; CC½ typically improves and converges over the first few rounds.&lt;br /&gt;
&lt;br /&gt;
== Important parameters ==&lt;br /&gt;
&lt;br /&gt;
Parameters are given by their full PHIL path with defaults in parentheses. The program exposes many&lt;br /&gt;
more parameters (see &amp;lt;code&amp;gt;-c -e 10 -a 2&amp;lt;/code&amp;gt;); those below are the ones most commonly set.&lt;br /&gt;
&lt;br /&gt;
=== Input ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.path&amp;lt;/code&amp;gt; || None || Path(s) to the integrated data — a folder, several folders, or individual files; wildcards allowed; may be repeated. Matching &amp;lt;code&amp;gt;.expt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;.refl&amp;lt;/code&amp;gt; files must both be present.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.experiments_suffix&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;_integrated.expt&amp;lt;/code&amp;gt; || Only load experiment files ending with this suffix.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.reflections_suffix&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;_integrated.refl&amp;lt;/code&amp;gt; || Only load reflection files ending with this suffix.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.parallel_file_load.method&amp;lt;/code&amp;gt; || uniform || &amp;lt;code&amp;gt;uniform&amp;lt;/code&amp;gt; spreads input files evenly over all ranks; &amp;lt;code&amp;gt;node_memory&amp;lt;/code&amp;gt; distributes so per-node memory limits are respected.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.alist.file&amp;lt;/code&amp;gt; || None || Path to a text file of experiment tags or filenames; combined with &amp;lt;code&amp;gt;input.alist.op=keep|reject&amp;lt;/code&amp;gt; to merge only (or exclude) a specified subset.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.persistent_refl_cols&amp;lt;/code&amp;gt; || None || Reflection-table columns to preserve through the pruning steps (and into saved tables).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Filtering whole experiments (&amp;lt;code&amp;gt;filter&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;filter&amp;lt;/code&amp;gt; section accepts or rejects &#039;&#039;&#039;entire experiments&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.algorithm&amp;lt;/code&amp;gt; || (none) || One or more of &amp;lt;code&amp;gt;n_obs&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;resolution&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;unit_cell&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;energy&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bootstrap&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;experiment_prefix&amp;lt;/code&amp;gt;. Nothing is filtered unless listed.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.unit_cell.algorithm&amp;lt;/code&amp;gt; || value || How to restrict unit cells: &amp;lt;code&amp;gt;value&amp;lt;/code&amp;gt; (compare to a target), &amp;lt;code&amp;gt;range&amp;lt;/code&amp;gt;, or &amp;lt;code&amp;gt;cluster&amp;lt;/code&amp;gt; (use a precomputed covariance clustering).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.unit_cell.value.relative_length_tolerance&amp;lt;/code&amp;gt; || 0.1 || Fractional deviation of cell edge lengths allowed vs. the target cell. Often tightened (e.g. 0.03).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.unit_cell.value.absolute_angle_tolerance&amp;lt;/code&amp;gt; || 2.0 || Allowed cell-angle deviation (degrees) vs. the target.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.unit_cell.value.target_unit_cell&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;target_space_group&amp;lt;/code&amp;gt; || Auto || Target cell/symmetry; &amp;lt;code&amp;gt;Auto&amp;lt;/code&amp;gt; uses the scaling model.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.outlier.min_corr&amp;lt;/code&amp;gt; || 0.1 || Minimum correlation of an image&#039;s intensities to the reference model; images below this are rejected. Only applied when a scaling model is present. Use &amp;lt;code&amp;gt;-1&amp;lt;/code&amp;gt; to accept all images regardless of correlation.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.resolution.d_min&amp;lt;/code&amp;gt; || None || Reject an experiment unless some of its reflections extend beyond this resolution.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Selecting individual reflections (&amp;lt;code&amp;gt;select&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;select&amp;lt;/code&amp;gt; section accepts or rejects &#039;&#039;&#039;individual reflections&#039;&#039;&#039; (contrast with&lt;br /&gt;
&amp;lt;code&amp;gt;filter&amp;lt;/code&amp;gt;, which acts on whole experiments).&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;select.algorithm&amp;lt;/code&amp;gt; || (none) || One or more of &amp;lt;code&amp;gt;significance_filter&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;panel&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cspad_sensor&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;isolation_forest&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;target_energy&amp;lt;/code&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;select.significance_filter.sigma&amp;lt;/code&amp;gt; || 0.5 || Trim each lattice at the resolution where the binned ⟨I/σ⟩ drops below this value.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;select.significance_filter.min_ct&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;max_ct&amp;lt;/code&amp;gt; || 10 / 50 || Target minimum/maximum mean reflections per resolution bin when choosing the number of bins. For large unit cells these are often raised (e.g. 200/300); for small cells, use the defaults.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Modifying intensities (&amp;lt;code&amp;gt;modify&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;modify.algorithm&amp;lt;/code&amp;gt; || polarization || Per-reflection corrections to apply (default applies the polarization correction).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;modify.cosym&amp;lt;/code&amp;gt; || — || Resolve an indexing ambiguity across the ensemble using the Gildea/Winter (Brehm/Diederichs) cosym method, optionally anchored to &amp;lt;code&amp;gt;scaling.model&amp;lt;/code&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;modify.reindex_to_reference&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;reindex_to_abc&amp;lt;/code&amp;gt; || — || Alternative re-indexing operators (to a reference model, or an explicit operator).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Scaling (&amp;lt;code&amp;gt;scaling&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;scaling.model&amp;lt;/code&amp;gt; || None || Reference dataset: a PDB file (uses the CRYST1 cell and computes model intensities, including bulk solvent) or an MTZ from a previous cycle. Required for &amp;lt;code&amp;gt;mark0&amp;lt;/code&amp;gt; scaling.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;scaling.algorithm&amp;lt;/code&amp;gt; || mark0 || &amp;lt;code&amp;gt;mark0&amp;lt;/code&amp;gt;: per-image scaling against the reference. &amp;lt;code&amp;gt;mark1&amp;lt;/code&amp;gt;: no scaling, just Monte-Carlo averaging (all scale factors = 1) — used for reference-free bootstrap.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;scaling.unit_cell&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;scaling.space_group&amp;lt;/code&amp;gt; || None || Cell/symmetry to use when no model is provided (i.e. &amp;lt;code&amp;gt;mark1&amp;lt;/code&amp;gt;).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;scaling.resolution_scalar&amp;lt;/code&amp;gt; || 0.969 || &amp;lt;code&amp;gt;merging.d_min&amp;lt;/code&amp;gt; is multiplied by this when deciding which reflections fall within the resolution limit, generating a few extra reference reflections to account for per-shot cell variation (e.g. set 0.96 for a few more).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;scaling.mtz.mtz_column_F&amp;lt;/code&amp;gt; || fobs || Column name in the reference MTZ containing the reference structure factors (intensities or amplitudes).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Post-refinement (&amp;lt;code&amp;gt;postrefinement&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;postrefinement.enable&amp;lt;/code&amp;gt; || True || Enable post-refinement of per-image parameters/partialities (Sauter 2015).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;postrefinement.algorithm&amp;lt;/code&amp;gt; || rs || Post-refinement protocol: &amp;lt;code&amp;gt;rs&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;rs2&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;rs_hybrid&amp;lt;/code&amp;gt;, or &amp;lt;code&amp;gt;eta_deff&amp;lt;/code&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Merging and error model (&amp;lt;code&amp;gt;merging&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;merging.d_min&amp;lt;/code&amp;gt; || None || High-resolution limit for scaling and merging.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;merging.d_max&amp;lt;/code&amp;gt; || None || Low-resolution limit (currently affects only CCiso).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;merging.merge_anomalous&amp;lt;/code&amp;gt; || False || &amp;lt;code&amp;gt;True&amp;lt;/code&amp;gt; merges Bijvoet mates together (higher multiplicity); &amp;lt;code&amp;gt;False&amp;lt;/code&amp;gt; keeps them separate to preserve the anomalous signal.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;merging.minimum_multiplicity&amp;lt;/code&amp;gt; || 2 || Do not produce a merged structure factor for HKLs measured fewer than this many times.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;merging.error.model&amp;lt;/code&amp;gt; || mm24 || Merged-sigma error model: &amp;lt;code&amp;gt;mm24&amp;lt;/code&amp;gt; (Mittan-Moreau 2024, current default), &amp;lt;code&amp;gt;ev11&amp;lt;/code&amp;gt; (Evans 2011 / sdfac-refine, recommended in the README), &amp;lt;code&amp;gt;ha14&amp;lt;/code&amp;gt;, or &amp;lt;code&amp;gt;errors_from_sample_residuals&amp;lt;/code&amp;gt; (no refined error terms — used with &amp;lt;code&amp;gt;mark1&amp;lt;/code&amp;gt; bootstrap).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;merging.set_average_unit_cell&amp;lt;/code&amp;gt; || True || Output MTZ adopts the (cluster-derived) average unit cell of the data rather than the reference model&#039;s cell.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Statistics (&amp;lt;code&amp;gt;statistics&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;statistics.n_bins&amp;lt;/code&amp;gt; || 10 || Number of resolution bins in the statistics tables.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;statistics.cciso.mtz_file&amp;lt;/code&amp;gt; || None || Isomorphous reference structure factors for R&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt; / CC&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;statistics.report_ML&amp;lt;/code&amp;gt; || True || Report per-frame max-likelihood attributes (domain size, mosaicity).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Output (&amp;lt;code&amp;gt;output&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.output_dir&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;.&amp;lt;/code&amp;gt; || Directory for output files (created if it does not exist).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.prefix&amp;lt;/code&amp;gt; || iobs || Prefix prepended to all output file names.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.save_experiments_and_reflections&amp;lt;/code&amp;gt; || False || Dump the final experiments/reflections from the last worker as DIALS files — used for the two-stage scale-then-merge workflow.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.do_timing&amp;lt;/code&amp;gt; || False || Log elapsed time per execution step.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.expanded_bookkeeping&amp;lt;/code&amp;gt; || False || Store extra provenance columns (input file/reflection indices, odd/even flag, original id) in the saved reflection tables.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Multiprocessing (&amp;lt;code&amp;gt;mp&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mp.method&amp;lt;/code&amp;gt; || mpi || Multiprocessing method (only &amp;lt;code&amp;gt;mpi&amp;lt;/code&amp;gt; is currently supported).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mp.debug.cProfile&amp;lt;/code&amp;gt; || False || Enable code profiling; a &amp;lt;code&amp;gt;.prof&amp;lt;/code&amp;gt; file is written per rank.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Output files ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;merge&amp;lt;/code&amp;gt; worker gathers all HKLs at rank 0 and writes three MTZ files, prefixed with&lt;br /&gt;
&amp;lt;code&amp;gt;output.prefix&amp;lt;/code&amp;gt; (default &amp;lt;code&amp;gt;iobs&amp;lt;/code&amp;gt;):&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;amp;lt;prefix&amp;amp;gt;_all.mtz&amp;lt;/code&amp;gt; — the merged dataset using all observations (the main result for structure solution)&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;amp;lt;prefix&amp;amp;gt;_odd.mtz&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;&amp;amp;lt;prefix&amp;amp;gt;_even.mtz&amp;lt;/code&amp;gt; — the two half-datasets used for CC½ and related half-dataset statistics&lt;br /&gt;
&lt;br /&gt;
A main log records the per-step progress and the merging statistics tables by resolution bin:&lt;br /&gt;
completeness, multiplicity and ⟨I/σ⟩, plus the &amp;quot;Table of Scaling Results&amp;quot; reporting CC½ (the&lt;br /&gt;
half-dataset correlation, labelled &amp;quot;CC int&amp;quot;), CC&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt;, R&amp;lt;sub&amp;gt;int&amp;lt;/sub&amp;gt;, R&amp;lt;sub&amp;gt;split&amp;lt;/sub&amp;gt;&lt;br /&gt;
and R&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt;.  The merged MTZ can optionally be&lt;br /&gt;
uploaded to a shared [https://github.com/cctbx/cctbx_project/tree/master/xfel/merging/application/publish Google Drive folder] by adding the &amp;lt;code&amp;gt;publish&amp;lt;/code&amp;gt; worker.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
* Sauter NK (2015). &#039;&#039;J Synchrotron Radiat&#039;&#039; &#039;&#039;&#039;22&#039;&#039;&#039;, 239–48. (post-refinement)&lt;br /&gt;
* Uervirojnangkoorn M, &#039;&#039;et al.&#039;&#039; (2015). &#039;&#039;eLife&#039;&#039; 10.7554/eLife.05421. (PRIME / bootstrap)&lt;br /&gt;
* Brewster AS, &#039;&#039;et al.&#039;&#039; (2018). &#039;&#039;Acta Cryst.&#039;&#039; D &#039;&#039;&#039;74&#039;&#039;&#039;, 877–894.&lt;br /&gt;
* Brewster AS, &#039;&#039;et al.&#039;&#039; (2019a). &#039;&#039;Computational Crystallography Newsletter&#039;&#039; &#039;&#039;&#039;10&#039;&#039;&#039;, 22–39. (XFEL GUI)&lt;br /&gt;
* Brewster AS, &#039;&#039;et al.&#039;&#039; (2019b). &#039;&#039;Acta Cryst.&#039;&#039; D &#039;&#039;&#039;75&#039;&#039;&#039;, 959–968. (error models)&lt;br /&gt;
* Mittan-Moreau (2024). (mm24 error model)&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
* [[dials.stills_process]] — produces the integrated data that &amp;lt;code&amp;gt;cctbx.xfel.merge&amp;lt;/code&amp;gt; consumes&lt;br /&gt;
* [[cctbx.xfel GUI]] — orchestrates separate scaling and repeated merging as data are collected&lt;br /&gt;
* The program README at &amp;lt;code&amp;gt;xfel/merging/README.md&amp;lt;/code&amp;gt; in cctbx_project&lt;/div&gt;</summary>
		<author><name>Aaron</name></author>
	</entry>
	<entry>
		<id>http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Cctbx.xfel.merge&amp;diff=1775</id>
		<title>Cctbx.xfel.merge</title>
		<link rel="alternate" type="text/html" href="http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Cctbx.xfel.merge&amp;diff=1775"/>
		<updated>2026-08-21T23:12:54Z</updated>

		<summary type="html">&lt;p&gt;Aaron: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= &#039;&#039;cctbx.xfel.merge&#039;&#039; =&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;cctbx.xfel.merge&#039;&#039;&#039;&#039;&#039; is the scaling, post-refinement and merging program of cctbx.xfel. It takes&lt;br /&gt;
the per-image integrated results produced by &#039;&#039;[[dials.stills_process]]&#039;&#039; — one crystal per still shot —&lt;br /&gt;
and reduces the whole ensemble to a single set of merged structure-factor intensities (an MTZ file)&lt;br /&gt;
suitable for structure solution and refinement, together with the crystallographic quality&lt;br /&gt;
statistics (completeness, multiplicity, ⟨I/σ⟩, CC½, CC&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt;, R-factors, etc.).&lt;br /&gt;
&lt;br /&gt;
Because serial datasets routinely contain tens of thousands to millions of still shots,&lt;br /&gt;
&amp;lt;code&amp;gt;cctbx.xfel.merge&amp;lt;/code&amp;gt; is built from the ground up to run under MPI across many nodes. It is&lt;br /&gt;
almost always launched with &amp;lt;code&amp;gt;mpirun&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;srun&amp;lt;/code&amp;gt;.  Note that MPI uses the term &#039;ranks&#039;&lt;br /&gt;
to distinguish independent processes that are running across one or more nodes.&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;cctbx.xfel.merge&amp;lt;/code&amp;gt; is organized as a sequence of &#039;&#039;&#039;workers&#039;&#039;&#039;. Each worker performs one&lt;br /&gt;
task — reading data, applying a correction, filtering, scaling, post-refining, computing a statistic,&lt;br /&gt;
or merging — and passes its (possibly modified) experiments and reflections on to the next worker.&lt;br /&gt;
The list of workers to run is the &amp;quot;step list&amp;quot;, and it is fully configurable: you can add, remove or&lt;br /&gt;
reorder steps with &amp;lt;code&amp;gt;dispatch.step_list&amp;lt;/code&amp;gt;. This is what makes the program flexible enough to&lt;br /&gt;
scale-and-merge in one pass, to scale subsets separately and merge later, or to run a reference-free&lt;br /&gt;
bootstrap.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;default&#039;&#039;&#039; step list is:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! # !! Worker !! Purpose&lt;br /&gt;
|-&lt;br /&gt;
| 1 || &amp;lt;code&amp;gt;input&amp;lt;/code&amp;gt; || Read integrated experiments (&amp;lt;code&amp;gt;.expt&amp;lt;/code&amp;gt;) and reflections (&amp;lt;code&amp;gt;.refl&amp;lt;/code&amp;gt;) from disk in DIALS format.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || &amp;lt;code&amp;gt;balance&amp;lt;/code&amp;gt; || Redistribute the input load evenly across MPI ranks (needed when there are fewer or more input files than ranks).&lt;br /&gt;
|-&lt;br /&gt;
| 3 || &amp;lt;code&amp;gt;model_scaling&amp;lt;/code&amp;gt; || Build the full Miller list, model intensities from the reference, and the resolution binner used for scaling and post-refinement.&lt;br /&gt;
|-&lt;br /&gt;
| 4 || &amp;lt;code&amp;gt;modify&amp;lt;/code&amp;gt; || Apply per-reflection modifications, e.g. polarization correction (and optionally re-indexing to resolve indexing ambiguity — see &amp;lt;code&amp;gt;modify.cosym&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;reindex_to_reference&amp;lt;/code&amp;gt;).&lt;br /&gt;
|-&lt;br /&gt;
| 5 || &amp;lt;code&amp;gt;filter&amp;lt;/code&amp;gt; || Reject whole experiments (or reflections) by resolution, unit cell, correlation to the reference, energy, etc.&lt;br /&gt;
|-&lt;br /&gt;
| 6 || &amp;lt;code&amp;gt;scale&amp;lt;/code&amp;gt; || Scale each lattice to the reference dataset (&amp;lt;code&amp;gt;mark0&amp;lt;/code&amp;gt;) or simply average (&amp;lt;code&amp;gt;mark1&amp;lt;/code&amp;gt;).&lt;br /&gt;
|-&lt;br /&gt;
| 7 || &amp;lt;code&amp;gt;postrefine&amp;lt;/code&amp;gt; || Post-refine per-image crystal parameters and partialities (Sauter 2015).&lt;br /&gt;
|-&lt;br /&gt;
| 8 || &amp;lt;code&amp;gt;statistics_unitcell&amp;lt;/code&amp;gt; || Determine and store the average unit cell.&lt;br /&gt;
|-&lt;br /&gt;
| 9 || &amp;lt;code&amp;gt;statistics_beam&amp;lt;/code&amp;gt; || Determine and store the average wavelength.&lt;br /&gt;
|-&lt;br /&gt;
| 10 || &amp;lt;code&amp;gt;model_statistics&amp;lt;/code&amp;gt; || Rebuild the Miller list / binner for statistics (may use the average unit cell).&lt;br /&gt;
|-&lt;br /&gt;
| 11 || &amp;lt;code&amp;gt;statistics_resolution&amp;lt;/code&amp;gt; || Per-crystal resolution statistics.&lt;br /&gt;
|-&lt;br /&gt;
| 12 || &amp;lt;code&amp;gt;group&amp;lt;/code&amp;gt; || Redistribute reflections across ranks so that every observation of a given HKL is gathered on the same rank prior to merging.&lt;br /&gt;
|-&lt;br /&gt;
| 13 || &amp;lt;code&amp;gt;errors_merge&amp;lt;/code&amp;gt; || Correct the merged error estimates with a per-HKL error model (e.g. Ev11, Brewster 2019b, or MM24 (the default), Mittan-Moreau (2025)).&lt;br /&gt;
|-&lt;br /&gt;
| 14 || &amp;lt;code&amp;gt;statistics_intensity&amp;lt;/code&amp;gt; || Intensity statistics by resolution.&lt;br /&gt;
|-&lt;br /&gt;
| 15 || &amp;lt;code&amp;gt;merge&amp;lt;/code&amp;gt; || Merge symmetry-equivalent intensities, gather all HKLs at rank 0, and write &amp;quot;odd&amp;quot;, &amp;quot;even&amp;quot; and &amp;quot;all&amp;quot; MTZ files.&lt;br /&gt;
|-&lt;br /&gt;
| 16 || &amp;lt;code&amp;gt;statistics_intensity_cxi&amp;lt;/code&amp;gt; || Correlation and R-factor statistics (ported from cxi.merge): the &amp;quot;Table of Scaling Results&amp;quot; — CC½ (half-dataset correlation, labelled &amp;quot;CC int&amp;quot;), CC&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt;, R&amp;lt;sub&amp;gt;int&amp;lt;/sub&amp;gt;, R&amp;lt;sub&amp;gt;split&amp;lt;/sub&amp;gt;, R&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Additional, non-default workers are available and can be&lt;br /&gt;
inserted into the step list, including &amp;lt;code&amp;gt;tdata&amp;lt;/code&amp;gt; (write out unit cells for clustering),&lt;br /&gt;
&amp;lt;code&amp;gt;export&amp;lt;/code&amp;gt; (batch MTZ for &#039;&#039;Careless&#039;&#039;), &amp;lt;code&amp;gt;publish&amp;lt;/code&amp;gt; (upload merged files to a&lt;br /&gt;
Google Drive folder), &amp;lt;code&amp;gt;monitor&amp;lt;/code&amp;gt; (resource-usage logging), &amp;lt;code&amp;gt;integrate&amp;lt;/code&amp;gt;&lt;br /&gt;
(on-the-fly integration), &amp;lt;code&amp;gt;prepare&amp;lt;/code&amp;gt; (SpReAD energy binning), and&lt;br /&gt;
&amp;lt;code&amp;gt;lunus&amp;lt;/code&amp;gt; (diffuse-scattering deck). A &amp;lt;code&amp;gt;deltaccint&amp;lt;/code&amp;gt; worker (ΔCC½ lattice&lt;br /&gt;
filtering) can be added after &amp;lt;code&amp;gt;group&amp;lt;/code&amp;gt;. Custom workers can be supplied through the&lt;br /&gt;
&amp;lt;code&amp;gt;XFEL_CUSTOM_WORKER_PATH&amp;lt;/code&amp;gt; environment variable.&lt;br /&gt;
&lt;br /&gt;
== Basic usage ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;cctbx.xfel.merge&amp;lt;/code&amp;gt; is run under MPI:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mpirun cctbx.xfel.merge merge.phil&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A typical &amp;lt;code&amp;gt;merge.phil&amp;lt;/code&amp;gt; (from the program README):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
input.path=&amp;lt;path to data&amp;gt;&lt;br /&gt;
input.experiments_suffix=.expt&lt;br /&gt;
input.reflections_suffix=.refl&lt;br /&gt;
&lt;br /&gt;
filter.algorithm=unit_cell&lt;br /&gt;
filter.unit_cell.value.relative_length_tolerance=0.03&lt;br /&gt;
filter.outlier.min_corr=0.1&lt;br /&gt;
&lt;br /&gt;
select.algorithm=significance_filter&lt;br /&gt;
select.significance_filter.sigma=0.1&lt;br /&gt;
select.significance_filter.min_ct=200&lt;br /&gt;
select.significance_filter.max_ct=300&lt;br /&gt;
&lt;br /&gt;
scaling.model=&amp;lt;model.pdb or model.mtz&amp;gt;&lt;br /&gt;
scaling.resolution_scalar=0.96&lt;br /&gt;
&lt;br /&gt;
merging.d_min=1.8&lt;br /&gt;
merging.error.model=ev11&lt;br /&gt;
merging.merge_anomalous=True&lt;br /&gt;
&lt;br /&gt;
postrefinement.enable=True&lt;br /&gt;
statistics.n_bins=20&lt;br /&gt;
&lt;br /&gt;
output.do_timing=True&lt;br /&gt;
output.output_dir=&amp;lt;output folder&amp;gt;&lt;br /&gt;
output.prefix=&amp;lt;prefix for output files&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Explore the parameters with:&lt;br /&gt;
* &amp;lt;code&amp;gt;cctbx.xfel.merge -c&amp;lt;/code&amp;gt; — show configurable parameters&lt;br /&gt;
* &amp;lt;code&amp;gt;cctbx.xfel.merge -c -e 10 -a 2&amp;lt;/code&amp;gt; — show all parameters (expert level 10) with full help text&lt;br /&gt;
&lt;br /&gt;
== Two-stage scaling and merging ==&lt;br /&gt;
&lt;br /&gt;
For large, growing datasets (the mode used by the [[cctbx.xfel GUI]]), it is more efficient to scale&lt;br /&gt;
and post-refine each subset of data &#039;&#039;&#039;once&#039;&#039;&#039;, then merge repeatedly as more data arrive. This is&lt;br /&gt;
done by running the program twice with different step lists.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Stage 1 — scale each subset&#039;&#039;&#039; (stops after per-image work and writes intermediate DIALS files):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dispatch.step_list=input balance model_scaling modify filter scale postrefine \&lt;br /&gt;
    statistics_unitcell statistics_beam model_statistics statistics_resolution&lt;br /&gt;
input.parallel_file_load.method=uniform&lt;br /&gt;
output.save_experiments_and_reflections=True&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;output.save_experiments_and_reflections=True&amp;lt;/code&amp;gt; dumps the scaled/post-refined data as&lt;br /&gt;
experiment lists and reflection tables that the merge stage can read back in.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Stage 2 — merge the scaled subsets&#039;&#039;&#039; (add an &amp;lt;code&amp;gt;input.path&amp;lt;/code&amp;gt; for each finished subset):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dispatch.step_list=input model_scaling statistics_unitcell statistics_beam \&lt;br /&gt;
    model_statistics statistics_resolution group errors_merge statistics_intensity \&lt;br /&gt;
    merge statistics_intensity_cxi&lt;br /&gt;
input.parallel_file_load.method=uniform&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Merging without a reference (bootstrap / mark1) ==&lt;br /&gt;
&lt;br /&gt;
If no scaling/merging reference is available, use a bootstrap procedure. First run the&lt;br /&gt;
&amp;lt;code&amp;gt;mark1&amp;lt;/code&amp;gt; algorithm, which simply averages the data (all per-image scale factors = 1, no&lt;br /&gt;
post-refinement), specifying the target cell and symmetry explicitly:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
scaling.algorithm=mark1&lt;br /&gt;
scaling.unit_cell=&amp;lt;unit cell&amp;gt;&lt;br /&gt;
scaling.space_group=&amp;lt;space group&amp;gt;&lt;br /&gt;
merging.error.model=errors_from_sample_residuals&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The resulting MTZ is then used as the reference (&amp;lt;code&amp;gt;scaling.model=&amp;lt;/code&amp;gt;) for subsequent regular&lt;br /&gt;
merges. Iterate a few cycles; CC½ typically improves and converges over the first few rounds.&lt;br /&gt;
&lt;br /&gt;
== Important parameters ==&lt;br /&gt;
&lt;br /&gt;
Parameters are given by their full PHIL path with defaults in parentheses. The program exposes many&lt;br /&gt;
more parameters (see &amp;lt;code&amp;gt;-c -e 10 -a 2&amp;lt;/code&amp;gt;); those below are the ones most commonly set.&lt;br /&gt;
&lt;br /&gt;
=== Input ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.path&amp;lt;/code&amp;gt; || None || Path(s) to the integrated data — a folder, several folders, or individual files; wildcards allowed; may be repeated. Matching &amp;lt;code&amp;gt;.expt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;.refl&amp;lt;/code&amp;gt; files must both be present.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.experiments_suffix&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;_integrated.expt&amp;lt;/code&amp;gt; || Only load experiment files ending with this suffix.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.reflections_suffix&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;_integrated.refl&amp;lt;/code&amp;gt; || Only load reflection files ending with this suffix.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.parallel_file_load.method&amp;lt;/code&amp;gt; || uniform || &amp;lt;code&amp;gt;uniform&amp;lt;/code&amp;gt; spreads input files evenly over all ranks; &amp;lt;code&amp;gt;node_memory&amp;lt;/code&amp;gt; distributes so per-node memory limits are respected.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.alist.file&amp;lt;/code&amp;gt; || None || Path to a text file of experiment tags or filenames; combined with &amp;lt;code&amp;gt;input.alist.op=keep|reject&amp;lt;/code&amp;gt; to merge only (or exclude) a specified subset.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.persistent_refl_cols&amp;lt;/code&amp;gt; || None || Reflection-table columns to preserve through the pruning steps (and into saved tables).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Filtering whole experiments (&amp;lt;code&amp;gt;filter&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;filter&amp;lt;/code&amp;gt; section accepts or rejects &#039;&#039;&#039;entire experiments&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.algorithm&amp;lt;/code&amp;gt; || (none) || One or more of &amp;lt;code&amp;gt;n_obs&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;resolution&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;unit_cell&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;energy&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bootstrap&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;experiment_prefix&amp;lt;/code&amp;gt;. Nothing is filtered unless listed.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.unit_cell.algorithm&amp;lt;/code&amp;gt; || value || How to restrict unit cells: &amp;lt;code&amp;gt;value&amp;lt;/code&amp;gt; (compare to a target), &amp;lt;code&amp;gt;range&amp;lt;/code&amp;gt;, or &amp;lt;code&amp;gt;cluster&amp;lt;/code&amp;gt; (use a precomputed covariance clustering).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.unit_cell.value.relative_length_tolerance&amp;lt;/code&amp;gt; || 0.1 || Fractional deviation of cell edge lengths allowed vs. the target cell. Often tightened (e.g. 0.03).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.unit_cell.value.absolute_angle_tolerance&amp;lt;/code&amp;gt; || 2.0 || Allowed cell-angle deviation (degrees) vs. the target.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.unit_cell.value.target_unit_cell&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;target_space_group&amp;lt;/code&amp;gt; || Auto || Target cell/symmetry; &amp;lt;code&amp;gt;Auto&amp;lt;/code&amp;gt; uses the scaling model.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.outlier.min_corr&amp;lt;/code&amp;gt; || 0.1 || Minimum correlation of an image&#039;s intensities to the reference model; images below this are rejected. Only applied when a scaling model is present. Use &amp;lt;code&amp;gt;-1&amp;lt;/code&amp;gt; to accept all images regardless of correlation.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.resolution.d_min&amp;lt;/code&amp;gt; || None || Reject an experiment unless some of its reflections extend beyond this resolution.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Selecting individual reflections (&amp;lt;code&amp;gt;select&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;select&amp;lt;/code&amp;gt; section accepts or rejects &#039;&#039;&#039;individual reflections&#039;&#039;&#039; (contrast with&lt;br /&gt;
&amp;lt;code&amp;gt;filter&amp;lt;/code&amp;gt;, which acts on whole experiments).&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;select.algorithm&amp;lt;/code&amp;gt; || (none) || One or more of &amp;lt;code&amp;gt;significance_filter&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;panel&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cspad_sensor&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;isolation_forest&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;target_energy&amp;lt;/code&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;select.significance_filter.sigma&amp;lt;/code&amp;gt; || 0.5 || Trim each lattice at the resolution where the binned ⟨I/σ⟩ drops below this value.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;select.significance_filter.min_ct&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;max_ct&amp;lt;/code&amp;gt; || 10 / 50 || Target minimum/maximum mean reflections per resolution bin when choosing the number of bins. For large unit cells these are often raised (e.g. 200/300); for small cells, use the defaults.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Modifying intensities (&amp;lt;code&amp;gt;modify&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;modify.algorithm&amp;lt;/code&amp;gt; || polarization || Per-reflection corrections to apply (default applies the polarization correction).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;modify.cosym&amp;lt;/code&amp;gt; || — || Resolve an indexing ambiguity across the ensemble using the Gildea/Winter (Brehm/Diederichs) cosym method, optionally anchored to &amp;lt;code&amp;gt;scaling.model&amp;lt;/code&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;modify.reindex_to_reference&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;reindex_to_abc&amp;lt;/code&amp;gt; || — || Alternative re-indexing operators (to a reference model, or an explicit operator).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Scaling (&amp;lt;code&amp;gt;scaling&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;scaling.model&amp;lt;/code&amp;gt; || None || Reference dataset: a PDB file (uses the CRYST1 cell and computes model intensities, including bulk solvent) or an MTZ from a previous cycle. Required for &amp;lt;code&amp;gt;mark0&amp;lt;/code&amp;gt; scaling.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;scaling.algorithm&amp;lt;/code&amp;gt; || mark0 || &amp;lt;code&amp;gt;mark0&amp;lt;/code&amp;gt;: per-image scaling against the reference. &amp;lt;code&amp;gt;mark1&amp;lt;/code&amp;gt;: no scaling, just Monte-Carlo averaging (all scale factors = 1) — used for reference-free bootstrap.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;scaling.unit_cell&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;scaling.space_group&amp;lt;/code&amp;gt; || None || Cell/symmetry to use when no model is provided (i.e. &amp;lt;code&amp;gt;mark1&amp;lt;/code&amp;gt;).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;scaling.resolution_scalar&amp;lt;/code&amp;gt; || 0.969 || &amp;lt;code&amp;gt;merging.d_min&amp;lt;/code&amp;gt; is multiplied by this when deciding which reflections fall within the resolution limit, generating a few extra reference reflections to account for per-shot cell variation (e.g. set 0.96 for a few more).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;scaling.mtz.mtz_column_F&amp;lt;/code&amp;gt; || fobs || Column name in the reference MTZ containing the reference structure factors (intensities or amplitudes).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Post-refinement (&amp;lt;code&amp;gt;postrefinement&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;postrefinement.enable&amp;lt;/code&amp;gt; || True || Enable post-refinement of per-image parameters/partialities (Sauter 2015).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;postrefinement.algorithm&amp;lt;/code&amp;gt; || rs || Post-refinement protocol: &amp;lt;code&amp;gt;rs&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;rs2&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;rs_hybrid&amp;lt;/code&amp;gt;, or &amp;lt;code&amp;gt;eta_deff&amp;lt;/code&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Merging and error model (&amp;lt;code&amp;gt;merging&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;merging.d_min&amp;lt;/code&amp;gt; || None || High-resolution limit for scaling and merging.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;merging.d_max&amp;lt;/code&amp;gt; || None || Low-resolution limit (currently affects only CCiso).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;merging.merge_anomalous&amp;lt;/code&amp;gt; || False || &amp;lt;code&amp;gt;True&amp;lt;/code&amp;gt; merges Bijvoet mates together (higher multiplicity); &amp;lt;code&amp;gt;False&amp;lt;/code&amp;gt; keeps them separate to preserve the anomalous signal.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;merging.minimum_multiplicity&amp;lt;/code&amp;gt; || 2 || Do not produce a merged structure factor for HKLs measured fewer than this many times.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;merging.error.model&amp;lt;/code&amp;gt; || mm24 || Merged-sigma error model: &amp;lt;code&amp;gt;mm24&amp;lt;/code&amp;gt; (Mittan-Moreau 2024, current default), &amp;lt;code&amp;gt;ev11&amp;lt;/code&amp;gt; (Evans 2011 / sdfac-refine, recommended in the README), &amp;lt;code&amp;gt;ha14&amp;lt;/code&amp;gt;, or &amp;lt;code&amp;gt;errors_from_sample_residuals&amp;lt;/code&amp;gt; (no refined error terms — used with &amp;lt;code&amp;gt;mark1&amp;lt;/code&amp;gt; bootstrap).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;merging.set_average_unit_cell&amp;lt;/code&amp;gt; || True || Output MTZ adopts the (cluster-derived) average unit cell of the data rather than the reference model&#039;s cell.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Statistics (&amp;lt;code&amp;gt;statistics&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;statistics.n_bins&amp;lt;/code&amp;gt; || 10 || Number of resolution bins in the statistics tables.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;statistics.cciso.mtz_file&amp;lt;/code&amp;gt; || None || Isomorphous reference structure factors for R&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt; / CC&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;statistics.report_ML&amp;lt;/code&amp;gt; || True || Report per-frame max-likelihood attributes (domain size, mosaicity).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Output (&amp;lt;code&amp;gt;output&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.output_dir&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;.&amp;lt;/code&amp;gt; || Directory for output files (created if it does not exist).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.prefix&amp;lt;/code&amp;gt; || iobs || Prefix prepended to all output file names.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.save_experiments_and_reflections&amp;lt;/code&amp;gt; || False || Dump the final experiments/reflections from the last worker as DIALS files — used for the two-stage scale-then-merge workflow.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.do_timing&amp;lt;/code&amp;gt; || False || Log elapsed time per execution step.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.expanded_bookkeeping&amp;lt;/code&amp;gt; || False || Store extra provenance columns (input file/reflection indices, odd/even flag, original id) in the saved reflection tables.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Multiprocessing (&amp;lt;code&amp;gt;mp&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mp.method&amp;lt;/code&amp;gt; || mpi || Multiprocessing method (only &amp;lt;code&amp;gt;mpi&amp;lt;/code&amp;gt; is currently supported).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mp.debug.cProfile&amp;lt;/code&amp;gt; || False || Enable code profiling; a &amp;lt;code&amp;gt;.prof&amp;lt;/code&amp;gt; file is written per rank.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Output files ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;merge&amp;lt;/code&amp;gt; worker gathers all HKLs at rank 0 and writes three MTZ files, prefixed with&lt;br /&gt;
&amp;lt;code&amp;gt;output.prefix&amp;lt;/code&amp;gt; (default &amp;lt;code&amp;gt;iobs&amp;lt;/code&amp;gt;):&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;amp;lt;prefix&amp;amp;gt;_all.mtz&amp;lt;/code&amp;gt; — the merged dataset using all observations (the main result for structure solution)&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;amp;lt;prefix&amp;amp;gt;_odd.mtz&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;&amp;amp;lt;prefix&amp;amp;gt;_even.mtz&amp;lt;/code&amp;gt; — the two half-datasets used for CC½ and related half-dataset statistics&lt;br /&gt;
&lt;br /&gt;
A main log records the per-step progress and the merging statistics tables (completeness,&lt;br /&gt;
multiplicity, ⟨I/σ⟩, CC½, CC*, R-factors) by resolution bin. The merged MTZ can optionally be&lt;br /&gt;
uploaded to a shared [https://github.com/cctbx/cctbx_project/tree/master/xfel/merging/application/publish Google Drive folder] by adding the &amp;lt;code&amp;gt;publish&amp;lt;/code&amp;gt; worker.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
* Sauter NK (2015). &#039;&#039;J Synchrotron Radiat&#039;&#039; &#039;&#039;&#039;22&#039;&#039;&#039;, 239–48. (post-refinement)&lt;br /&gt;
* Uervirojnangkoorn M, &#039;&#039;et al.&#039;&#039; (2015). &#039;&#039;eLife&#039;&#039; 10.7554/eLife.05421. (PRIME / bootstrap)&lt;br /&gt;
* Brewster AS, &#039;&#039;et al.&#039;&#039; (2018). &#039;&#039;Acta Cryst.&#039;&#039; D &#039;&#039;&#039;74&#039;&#039;&#039;, 877–894.&lt;br /&gt;
* Brewster AS, &#039;&#039;et al.&#039;&#039; (2019a). &#039;&#039;Computational Crystallography Newsletter&#039;&#039; &#039;&#039;&#039;10&#039;&#039;&#039;, 22–39. (XFEL GUI)&lt;br /&gt;
* Brewster AS, &#039;&#039;et al.&#039;&#039; (2019b). &#039;&#039;Acta Cryst.&#039;&#039; D &#039;&#039;&#039;75&#039;&#039;&#039;, 959–968. (error models)&lt;br /&gt;
* Mittan-Moreau (2024). (mm24 error model)&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
* [[dials.stills_process]] — produces the integrated data that &amp;lt;code&amp;gt;cctbx.xfel.merge&amp;lt;/code&amp;gt; consumes&lt;br /&gt;
* [[cctbx.xfel GUI]] — orchestrates separate scaling and repeated merging as data are collected&lt;br /&gt;
* The program README at &amp;lt;code&amp;gt;xfel/merging/README.md&amp;lt;/code&amp;gt; in cctbx_project&lt;/div&gt;</summary>
		<author><name>Aaron</name></author>
	</entry>
	<entry>
		<id>http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Cctbx.xfel.merge&amp;diff=1774</id>
		<title>Cctbx.xfel.merge</title>
		<link rel="alternate" type="text/html" href="http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Cctbx.xfel.merge&amp;diff=1774"/>
		<updated>2026-08-21T23:12:15Z</updated>

		<summary type="html">&lt;p&gt;Aaron: /* Overview */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= &#039;&#039;cctbx.xfel.merge&#039;&#039; =&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;cctbx.xfel.merge&#039;&#039;&#039;&#039;&#039; is the scaling, post-refinement and merging program of cctbx.xfel. It takes&lt;br /&gt;
the per-image integrated results produced by &#039;&#039;[[dials.stills_process]]&#039;&#039; — one crystal per still shot —&lt;br /&gt;
and reduces the whole ensemble to a single set of merged structure-factor intensities (an MTZ file)&lt;br /&gt;
suitable for structure solution and refinement, together with the crystallographic quality&lt;br /&gt;
statistics (completeness, multiplicity, CC½, R-factors, etc.).&lt;br /&gt;
&lt;br /&gt;
Because serial datasets routinely contain tens of thousands to millions of still shots,&lt;br /&gt;
&amp;lt;code&amp;gt;cctbx.xfel.merge&amp;lt;/code&amp;gt; is built from the ground up to run under MPI across many nodes. It is&lt;br /&gt;
almost always launched with &amp;lt;code&amp;gt;mpirun&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;srun&amp;lt;/code&amp;gt;.  Note that MPI uses the term &#039;ranks&#039;&lt;br /&gt;
to distinguish independent processes that are running across one or more nodes.&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;cctbx.xfel.merge&amp;lt;/code&amp;gt; is organized as a sequence of &#039;&#039;&#039;workers&#039;&#039;&#039;. Each worker performs one&lt;br /&gt;
task — reading data, applying a correction, filtering, scaling, post-refining, computing a statistic,&lt;br /&gt;
or merging — and passes its (possibly modified) experiments and reflections on to the next worker.&lt;br /&gt;
The list of workers to run is the &amp;quot;step list&amp;quot;, and it is fully configurable: you can add, remove or&lt;br /&gt;
reorder steps with &amp;lt;code&amp;gt;dispatch.step_list&amp;lt;/code&amp;gt;. This is what makes the program flexible enough to&lt;br /&gt;
scale-and-merge in one pass, to scale subsets separately and merge later, or to run a reference-free&lt;br /&gt;
bootstrap.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;default&#039;&#039;&#039; step list is:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! # !! Worker !! Purpose&lt;br /&gt;
|-&lt;br /&gt;
| 1 || &amp;lt;code&amp;gt;input&amp;lt;/code&amp;gt; || Read integrated experiments (&amp;lt;code&amp;gt;.expt&amp;lt;/code&amp;gt;) and reflections (&amp;lt;code&amp;gt;.refl&amp;lt;/code&amp;gt;) from disk in DIALS format.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || &amp;lt;code&amp;gt;balance&amp;lt;/code&amp;gt; || Redistribute the input load evenly across MPI ranks (needed when there are fewer or more input files than ranks).&lt;br /&gt;
|-&lt;br /&gt;
| 3 || &amp;lt;code&amp;gt;model_scaling&amp;lt;/code&amp;gt; || Build the full Miller list, model intensities from the reference, and the resolution binner used for scaling and post-refinement.&lt;br /&gt;
|-&lt;br /&gt;
| 4 || &amp;lt;code&amp;gt;modify&amp;lt;/code&amp;gt; || Apply per-reflection modifications, e.g. polarization correction (and optionally re-indexing to resolve indexing ambiguity — see &amp;lt;code&amp;gt;modify.cosym&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;reindex_to_reference&amp;lt;/code&amp;gt;).&lt;br /&gt;
|-&lt;br /&gt;
| 5 || &amp;lt;code&amp;gt;filter&amp;lt;/code&amp;gt; || Reject whole experiments (or reflections) by resolution, unit cell, correlation to the reference, energy, etc.&lt;br /&gt;
|-&lt;br /&gt;
| 6 || &amp;lt;code&amp;gt;scale&amp;lt;/code&amp;gt; || Scale each lattice to the reference dataset (&amp;lt;code&amp;gt;mark0&amp;lt;/code&amp;gt;) or simply average (&amp;lt;code&amp;gt;mark1&amp;lt;/code&amp;gt;).&lt;br /&gt;
|-&lt;br /&gt;
| 7 || &amp;lt;code&amp;gt;postrefine&amp;lt;/code&amp;gt; || Post-refine per-image crystal parameters and partialities (Sauter 2015).&lt;br /&gt;
|-&lt;br /&gt;
| 8 || &amp;lt;code&amp;gt;statistics_unitcell&amp;lt;/code&amp;gt; || Determine and store the average unit cell.&lt;br /&gt;
|-&lt;br /&gt;
| 9 || &amp;lt;code&amp;gt;statistics_beam&amp;lt;/code&amp;gt; || Determine and store the average wavelength.&lt;br /&gt;
|-&lt;br /&gt;
| 10 || &amp;lt;code&amp;gt;model_statistics&amp;lt;/code&amp;gt; || Rebuild the Miller list / binner for statistics (may use the average unit cell).&lt;br /&gt;
|-&lt;br /&gt;
| 11 || &amp;lt;code&amp;gt;statistics_resolution&amp;lt;/code&amp;gt; || Per-crystal resolution statistics.&lt;br /&gt;
|-&lt;br /&gt;
| 12 || &amp;lt;code&amp;gt;group&amp;lt;/code&amp;gt; || Redistribute reflections across ranks so that every observation of a given HKL is gathered on the same rank prior to merging.&lt;br /&gt;
|-&lt;br /&gt;
| 13 || &amp;lt;code&amp;gt;errors_merge&amp;lt;/code&amp;gt; || Correct the merged error estimates with a per-HKL error model (e.g. Ev11, Brewster 2019b, or MM24 (the default), Mittan-Moreau (2025)).&lt;br /&gt;
|-&lt;br /&gt;
| 14 || &amp;lt;code&amp;gt;statistics_intensity&amp;lt;/code&amp;gt; || Intensity statistics by resolution.&lt;br /&gt;
|-&lt;br /&gt;
| 15 || &amp;lt;code&amp;gt;merge&amp;lt;/code&amp;gt; || Merge symmetry-equivalent intensities, gather all HKLs at rank 0, and write &amp;quot;odd&amp;quot;, &amp;quot;even&amp;quot; and &amp;quot;all&amp;quot; MTZ files.&lt;br /&gt;
|-&lt;br /&gt;
| 16 || &amp;lt;code&amp;gt;statistics_intensity_cxi&amp;lt;/code&amp;gt; || Correlation and R-factor statistics (ported from cxi.merge): the &amp;quot;Table of Scaling Results&amp;quot; — CC½ (half-dataset correlation, labelled &amp;quot;CC int&amp;quot;), CC&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt;, R&amp;lt;sub&amp;gt;int&amp;lt;/sub&amp;gt;, R&amp;lt;sub&amp;gt;split&amp;lt;/sub&amp;gt;, R&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Additional, non-default workers are available and can be&lt;br /&gt;
inserted into the step list, including &amp;lt;code&amp;gt;tdata&amp;lt;/code&amp;gt; (write out unit cells for clustering),&lt;br /&gt;
&amp;lt;code&amp;gt;export&amp;lt;/code&amp;gt; (batch MTZ for &#039;&#039;Careless&#039;&#039;), &amp;lt;code&amp;gt;publish&amp;lt;/code&amp;gt; (upload merged files to a&lt;br /&gt;
Google Drive folder), &amp;lt;code&amp;gt;monitor&amp;lt;/code&amp;gt; (resource-usage logging), &amp;lt;code&amp;gt;integrate&amp;lt;/code&amp;gt;&lt;br /&gt;
(on-the-fly integration), &amp;lt;code&amp;gt;prepare&amp;lt;/code&amp;gt; (SpReAD energy binning), and&lt;br /&gt;
&amp;lt;code&amp;gt;lunus&amp;lt;/code&amp;gt; (diffuse-scattering deck). A &amp;lt;code&amp;gt;deltaccint&amp;lt;/code&amp;gt; worker (ΔCC½ lattice&lt;br /&gt;
filtering) can be added after &amp;lt;code&amp;gt;group&amp;lt;/code&amp;gt;. Custom workers can be supplied through the&lt;br /&gt;
&amp;lt;code&amp;gt;XFEL_CUSTOM_WORKER_PATH&amp;lt;/code&amp;gt; environment variable.&lt;br /&gt;
&lt;br /&gt;
== Basic usage ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;cctbx.xfel.merge&amp;lt;/code&amp;gt; is run under MPI:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mpirun cctbx.xfel.merge merge.phil&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A typical &amp;lt;code&amp;gt;merge.phil&amp;lt;/code&amp;gt; (from the program README):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
input.path=&amp;lt;path to data&amp;gt;&lt;br /&gt;
input.experiments_suffix=.expt&lt;br /&gt;
input.reflections_suffix=.refl&lt;br /&gt;
&lt;br /&gt;
filter.algorithm=unit_cell&lt;br /&gt;
filter.unit_cell.value.relative_length_tolerance=0.03&lt;br /&gt;
filter.outlier.min_corr=0.1&lt;br /&gt;
&lt;br /&gt;
select.algorithm=significance_filter&lt;br /&gt;
select.significance_filter.sigma=0.1&lt;br /&gt;
select.significance_filter.min_ct=200&lt;br /&gt;
select.significance_filter.max_ct=300&lt;br /&gt;
&lt;br /&gt;
scaling.model=&amp;lt;model.pdb or model.mtz&amp;gt;&lt;br /&gt;
scaling.resolution_scalar=0.96&lt;br /&gt;
&lt;br /&gt;
merging.d_min=1.8&lt;br /&gt;
merging.error.model=ev11&lt;br /&gt;
merging.merge_anomalous=True&lt;br /&gt;
&lt;br /&gt;
postrefinement.enable=True&lt;br /&gt;
statistics.n_bins=20&lt;br /&gt;
&lt;br /&gt;
output.do_timing=True&lt;br /&gt;
output.output_dir=&amp;lt;output folder&amp;gt;&lt;br /&gt;
output.prefix=&amp;lt;prefix for output files&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Explore the parameters with:&lt;br /&gt;
* &amp;lt;code&amp;gt;cctbx.xfel.merge -c&amp;lt;/code&amp;gt; — show configurable parameters&lt;br /&gt;
* &amp;lt;code&amp;gt;cctbx.xfel.merge -c -e 10 -a 2&amp;lt;/code&amp;gt; — show all parameters (expert level 10) with full help text&lt;br /&gt;
&lt;br /&gt;
== Two-stage scaling and merging ==&lt;br /&gt;
&lt;br /&gt;
For large, growing datasets (the mode used by the [[cctbx.xfel GUI]]), it is more efficient to scale&lt;br /&gt;
and post-refine each subset of data &#039;&#039;&#039;once&#039;&#039;&#039;, then merge repeatedly as more data arrive. This is&lt;br /&gt;
done by running the program twice with different step lists.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Stage 1 — scale each subset&#039;&#039;&#039; (stops after per-image work and writes intermediate DIALS files):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dispatch.step_list=input balance model_scaling modify filter scale postrefine \&lt;br /&gt;
    statistics_unitcell statistics_beam model_statistics statistics_resolution&lt;br /&gt;
input.parallel_file_load.method=uniform&lt;br /&gt;
output.save_experiments_and_reflections=True&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;output.save_experiments_and_reflections=True&amp;lt;/code&amp;gt; dumps the scaled/post-refined data as&lt;br /&gt;
experiment lists and reflection tables that the merge stage can read back in.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Stage 2 — merge the scaled subsets&#039;&#039;&#039; (add an &amp;lt;code&amp;gt;input.path&amp;lt;/code&amp;gt; for each finished subset):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dispatch.step_list=input model_scaling statistics_unitcell statistics_beam \&lt;br /&gt;
    model_statistics statistics_resolution group errors_merge statistics_intensity \&lt;br /&gt;
    merge statistics_intensity_cxi&lt;br /&gt;
input.parallel_file_load.method=uniform&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Merging without a reference (bootstrap / mark1) ==&lt;br /&gt;
&lt;br /&gt;
If no scaling/merging reference is available, use a bootstrap procedure. First run the&lt;br /&gt;
&amp;lt;code&amp;gt;mark1&amp;lt;/code&amp;gt; algorithm, which simply averages the data (all per-image scale factors = 1, no&lt;br /&gt;
post-refinement), specifying the target cell and symmetry explicitly:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
scaling.algorithm=mark1&lt;br /&gt;
scaling.unit_cell=&amp;lt;unit cell&amp;gt;&lt;br /&gt;
scaling.space_group=&amp;lt;space group&amp;gt;&lt;br /&gt;
merging.error.model=errors_from_sample_residuals&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The resulting MTZ is then used as the reference (&amp;lt;code&amp;gt;scaling.model=&amp;lt;/code&amp;gt;) for subsequent regular&lt;br /&gt;
merges. Iterate a few cycles; CC½ typically improves and converges over the first few rounds.&lt;br /&gt;
&lt;br /&gt;
== Important parameters ==&lt;br /&gt;
&lt;br /&gt;
Parameters are given by their full PHIL path with defaults in parentheses. The program exposes many&lt;br /&gt;
more parameters (see &amp;lt;code&amp;gt;-c -e 10 -a 2&amp;lt;/code&amp;gt;); those below are the ones most commonly set.&lt;br /&gt;
&lt;br /&gt;
=== Input ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.path&amp;lt;/code&amp;gt; || None || Path(s) to the integrated data — a folder, several folders, or individual files; wildcards allowed; may be repeated. Matching &amp;lt;code&amp;gt;.expt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;.refl&amp;lt;/code&amp;gt; files must both be present.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.experiments_suffix&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;_integrated.expt&amp;lt;/code&amp;gt; || Only load experiment files ending with this suffix.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.reflections_suffix&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;_integrated.refl&amp;lt;/code&amp;gt; || Only load reflection files ending with this suffix.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.parallel_file_load.method&amp;lt;/code&amp;gt; || uniform || &amp;lt;code&amp;gt;uniform&amp;lt;/code&amp;gt; spreads input files evenly over all ranks; &amp;lt;code&amp;gt;node_memory&amp;lt;/code&amp;gt; distributes so per-node memory limits are respected.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.alist.file&amp;lt;/code&amp;gt; || None || Path to a text file of experiment tags or filenames; combined with &amp;lt;code&amp;gt;input.alist.op=keep|reject&amp;lt;/code&amp;gt; to merge only (or exclude) a specified subset.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.persistent_refl_cols&amp;lt;/code&amp;gt; || None || Reflection-table columns to preserve through the pruning steps (and into saved tables).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Filtering whole experiments (&amp;lt;code&amp;gt;filter&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;filter&amp;lt;/code&amp;gt; section accepts or rejects &#039;&#039;&#039;entire experiments&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.algorithm&amp;lt;/code&amp;gt; || (none) || One or more of &amp;lt;code&amp;gt;n_obs&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;resolution&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;unit_cell&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;energy&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bootstrap&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;experiment_prefix&amp;lt;/code&amp;gt;. Nothing is filtered unless listed.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.unit_cell.algorithm&amp;lt;/code&amp;gt; || value || How to restrict unit cells: &amp;lt;code&amp;gt;value&amp;lt;/code&amp;gt; (compare to a target), &amp;lt;code&amp;gt;range&amp;lt;/code&amp;gt;, or &amp;lt;code&amp;gt;cluster&amp;lt;/code&amp;gt; (use a precomputed covariance clustering).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.unit_cell.value.relative_length_tolerance&amp;lt;/code&amp;gt; || 0.1 || Fractional deviation of cell edge lengths allowed vs. the target cell. Often tightened (e.g. 0.03).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.unit_cell.value.absolute_angle_tolerance&amp;lt;/code&amp;gt; || 2.0 || Allowed cell-angle deviation (degrees) vs. the target.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.unit_cell.value.target_unit_cell&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;target_space_group&amp;lt;/code&amp;gt; || Auto || Target cell/symmetry; &amp;lt;code&amp;gt;Auto&amp;lt;/code&amp;gt; uses the scaling model.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.outlier.min_corr&amp;lt;/code&amp;gt; || 0.1 || Minimum correlation of an image&#039;s intensities to the reference model; images below this are rejected. Only applied when a scaling model is present. Use &amp;lt;code&amp;gt;-1&amp;lt;/code&amp;gt; to accept all images regardless of correlation.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.resolution.d_min&amp;lt;/code&amp;gt; || None || Reject an experiment unless some of its reflections extend beyond this resolution.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Selecting individual reflections (&amp;lt;code&amp;gt;select&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;select&amp;lt;/code&amp;gt; section accepts or rejects &#039;&#039;&#039;individual reflections&#039;&#039;&#039; (contrast with&lt;br /&gt;
&amp;lt;code&amp;gt;filter&amp;lt;/code&amp;gt;, which acts on whole experiments).&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;select.algorithm&amp;lt;/code&amp;gt; || (none) || One or more of &amp;lt;code&amp;gt;significance_filter&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;panel&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cspad_sensor&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;isolation_forest&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;target_energy&amp;lt;/code&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;select.significance_filter.sigma&amp;lt;/code&amp;gt; || 0.5 || Trim each lattice at the resolution where the binned ⟨I/σ⟩ drops below this value.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;select.significance_filter.min_ct&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;max_ct&amp;lt;/code&amp;gt; || 10 / 50 || Target minimum/maximum mean reflections per resolution bin when choosing the number of bins. For large unit cells these are often raised (e.g. 200/300); for small cells, use the defaults.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Modifying intensities (&amp;lt;code&amp;gt;modify&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;modify.algorithm&amp;lt;/code&amp;gt; || polarization || Per-reflection corrections to apply (default applies the polarization correction).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;modify.cosym&amp;lt;/code&amp;gt; || — || Resolve an indexing ambiguity across the ensemble using the Gildea/Winter (Brehm/Diederichs) cosym method, optionally anchored to &amp;lt;code&amp;gt;scaling.model&amp;lt;/code&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;modify.reindex_to_reference&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;reindex_to_abc&amp;lt;/code&amp;gt; || — || Alternative re-indexing operators (to a reference model, or an explicit operator).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Scaling (&amp;lt;code&amp;gt;scaling&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;scaling.model&amp;lt;/code&amp;gt; || None || Reference dataset: a PDB file (uses the CRYST1 cell and computes model intensities, including bulk solvent) or an MTZ from a previous cycle. Required for &amp;lt;code&amp;gt;mark0&amp;lt;/code&amp;gt; scaling.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;scaling.algorithm&amp;lt;/code&amp;gt; || mark0 || &amp;lt;code&amp;gt;mark0&amp;lt;/code&amp;gt;: per-image scaling against the reference. &amp;lt;code&amp;gt;mark1&amp;lt;/code&amp;gt;: no scaling, just Monte-Carlo averaging (all scale factors = 1) — used for reference-free bootstrap.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;scaling.unit_cell&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;scaling.space_group&amp;lt;/code&amp;gt; || None || Cell/symmetry to use when no model is provided (i.e. &amp;lt;code&amp;gt;mark1&amp;lt;/code&amp;gt;).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;scaling.resolution_scalar&amp;lt;/code&amp;gt; || 0.969 || &amp;lt;code&amp;gt;merging.d_min&amp;lt;/code&amp;gt; is multiplied by this when deciding which reflections fall within the resolution limit, generating a few extra reference reflections to account for per-shot cell variation (e.g. set 0.96 for a few more).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;scaling.mtz.mtz_column_F&amp;lt;/code&amp;gt; || fobs || Column name in the reference MTZ containing the reference structure factors (intensities or amplitudes).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Post-refinement (&amp;lt;code&amp;gt;postrefinement&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;postrefinement.enable&amp;lt;/code&amp;gt; || True || Enable post-refinement of per-image parameters/partialities (Sauter 2015).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;postrefinement.algorithm&amp;lt;/code&amp;gt; || rs || Post-refinement protocol: &amp;lt;code&amp;gt;rs&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;rs2&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;rs_hybrid&amp;lt;/code&amp;gt;, or &amp;lt;code&amp;gt;eta_deff&amp;lt;/code&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Merging and error model (&amp;lt;code&amp;gt;merging&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;merging.d_min&amp;lt;/code&amp;gt; || None || High-resolution limit for scaling and merging.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;merging.d_max&amp;lt;/code&amp;gt; || None || Low-resolution limit (currently affects only CCiso).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;merging.merge_anomalous&amp;lt;/code&amp;gt; || False || &amp;lt;code&amp;gt;True&amp;lt;/code&amp;gt; merges Bijvoet mates together (higher multiplicity); &amp;lt;code&amp;gt;False&amp;lt;/code&amp;gt; keeps them separate to preserve the anomalous signal.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;merging.minimum_multiplicity&amp;lt;/code&amp;gt; || 2 || Do not produce a merged structure factor for HKLs measured fewer than this many times.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;merging.error.model&amp;lt;/code&amp;gt; || mm24 || Merged-sigma error model: &amp;lt;code&amp;gt;mm24&amp;lt;/code&amp;gt; (Mittan-Moreau 2024, current default), &amp;lt;code&amp;gt;ev11&amp;lt;/code&amp;gt; (Evans 2011 / sdfac-refine, recommended in the README), &amp;lt;code&amp;gt;ha14&amp;lt;/code&amp;gt;, or &amp;lt;code&amp;gt;errors_from_sample_residuals&amp;lt;/code&amp;gt; (no refined error terms — used with &amp;lt;code&amp;gt;mark1&amp;lt;/code&amp;gt; bootstrap).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;merging.set_average_unit_cell&amp;lt;/code&amp;gt; || True || Output MTZ adopts the (cluster-derived) average unit cell of the data rather than the reference model&#039;s cell.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Statistics (&amp;lt;code&amp;gt;statistics&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;statistics.n_bins&amp;lt;/code&amp;gt; || 10 || Number of resolution bins in the statistics tables.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;statistics.cciso.mtz_file&amp;lt;/code&amp;gt; || None || Isomorphous reference structure factors for R&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt; / CC&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;statistics.report_ML&amp;lt;/code&amp;gt; || True || Report per-frame max-likelihood attributes (domain size, mosaicity).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Output (&amp;lt;code&amp;gt;output&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.output_dir&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;.&amp;lt;/code&amp;gt; || Directory for output files (created if it does not exist).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.prefix&amp;lt;/code&amp;gt; || iobs || Prefix prepended to all output file names.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.save_experiments_and_reflections&amp;lt;/code&amp;gt; || False || Dump the final experiments/reflections from the last worker as DIALS files — used for the two-stage scale-then-merge workflow.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.do_timing&amp;lt;/code&amp;gt; || False || Log elapsed time per execution step.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.expanded_bookkeeping&amp;lt;/code&amp;gt; || False || Store extra provenance columns (input file/reflection indices, odd/even flag, original id) in the saved reflection tables.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Multiprocessing (&amp;lt;code&amp;gt;mp&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mp.method&amp;lt;/code&amp;gt; || mpi || Multiprocessing method (only &amp;lt;code&amp;gt;mpi&amp;lt;/code&amp;gt; is currently supported).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mp.debug.cProfile&amp;lt;/code&amp;gt; || False || Enable code profiling; a &amp;lt;code&amp;gt;.prof&amp;lt;/code&amp;gt; file is written per rank.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Output files ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;merge&amp;lt;/code&amp;gt; worker gathers all HKLs at rank 0 and writes three MTZ files, prefixed with&lt;br /&gt;
&amp;lt;code&amp;gt;output.prefix&amp;lt;/code&amp;gt; (default &amp;lt;code&amp;gt;iobs&amp;lt;/code&amp;gt;):&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;amp;lt;prefix&amp;amp;gt;_all.mtz&amp;lt;/code&amp;gt; — the merged dataset using all observations (the main result for structure solution)&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;amp;lt;prefix&amp;amp;gt;_odd.mtz&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;&amp;amp;lt;prefix&amp;amp;gt;_even.mtz&amp;lt;/code&amp;gt; — the two half-datasets used for CC½ and related half-dataset statistics&lt;br /&gt;
&lt;br /&gt;
A main log records the per-step progress and the merging statistics tables (completeness,&lt;br /&gt;
multiplicity, ⟨I/σ⟩, CC½, CC*, R-factors) by resolution bin. The merged MTZ can optionally be&lt;br /&gt;
uploaded to a shared [https://github.com/cctbx/cctbx_project/tree/master/xfel/merging/application/publish Google Drive folder] by adding the &amp;lt;code&amp;gt;publish&amp;lt;/code&amp;gt; worker.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
* Sauter NK (2015). &#039;&#039;J Synchrotron Radiat&#039;&#039; &#039;&#039;&#039;22&#039;&#039;&#039;, 239–48. (post-refinement)&lt;br /&gt;
* Uervirojnangkoorn M, &#039;&#039;et al.&#039;&#039; (2015). &#039;&#039;eLife&#039;&#039; 10.7554/eLife.05421. (PRIME / bootstrap)&lt;br /&gt;
* Brewster AS, &#039;&#039;et al.&#039;&#039; (2018). &#039;&#039;Acta Cryst.&#039;&#039; D &#039;&#039;&#039;74&#039;&#039;&#039;, 877–894.&lt;br /&gt;
* Brewster AS, &#039;&#039;et al.&#039;&#039; (2019a). &#039;&#039;Computational Crystallography Newsletter&#039;&#039; &#039;&#039;&#039;10&#039;&#039;&#039;, 22–39. (XFEL GUI)&lt;br /&gt;
* Brewster AS, &#039;&#039;et al.&#039;&#039; (2019b). &#039;&#039;Acta Cryst.&#039;&#039; D &#039;&#039;&#039;75&#039;&#039;&#039;, 959–968. (error models)&lt;br /&gt;
* Mittan-Moreau (2024). (mm24 error model)&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
* [[dials.stills_process]] — produces the integrated data that &amp;lt;code&amp;gt;cctbx.xfel.merge&amp;lt;/code&amp;gt; consumes&lt;br /&gt;
* [[cctbx.xfel GUI]] — orchestrates separate scaling and repeated merging as data are collected&lt;br /&gt;
* The program README at &amp;lt;code&amp;gt;xfel/merging/README.md&amp;lt;/code&amp;gt; in cctbx_project&lt;/div&gt;</summary>
		<author><name>Aaron</name></author>
	</entry>
	<entry>
		<id>http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Cctbx.xfel.merge&amp;diff=1773</id>
		<title>Cctbx.xfel.merge</title>
		<link rel="alternate" type="text/html" href="http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Cctbx.xfel.merge&amp;diff=1773"/>
		<updated>2026-08-21T23:01:36Z</updated>

		<summary type="html">&lt;p&gt;Aaron: /* cctbx.xfel.merge */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= &#039;&#039;cctbx.xfel.merge&#039;&#039; =&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;cctbx.xfel.merge&#039;&#039;&#039;&#039;&#039; is the scaling, post-refinement and merging program of cctbx.xfel. It takes&lt;br /&gt;
the per-image integrated results produced by &#039;&#039;[[dials.stills_process]]&#039;&#039; — one crystal per still shot —&lt;br /&gt;
and reduces the whole ensemble to a single set of merged structure-factor intensities (an MTZ file)&lt;br /&gt;
suitable for structure solution and refinement, together with the crystallographic quality&lt;br /&gt;
statistics (completeness, multiplicity, CC½, R-factors, etc.).&lt;br /&gt;
&lt;br /&gt;
Because serial datasets routinely contain tens of thousands to millions of still shots,&lt;br /&gt;
&amp;lt;code&amp;gt;cctbx.xfel.merge&amp;lt;/code&amp;gt; is built from the ground up to run under MPI across many nodes. It is&lt;br /&gt;
almost always launched with &amp;lt;code&amp;gt;mpirun&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;srun&amp;lt;/code&amp;gt;.  Note that MPI uses the term &#039;ranks&#039;&lt;br /&gt;
to distinguish independent processes that are running across one or more nodes.&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;cctbx.xfel.merge&amp;lt;/code&amp;gt; is organized as a sequence of &#039;&#039;&#039;workers&#039;&#039;&#039;. Each worker performs one&lt;br /&gt;
task — reading data, applying a correction, filtering, scaling, post-refining, computing a statistic,&lt;br /&gt;
or merging — and passes its (possibly modified) experiments and reflections on to the next worker.&lt;br /&gt;
The list of workers to run is the &amp;quot;step list&amp;quot;, and it is fully configurable: you can add, remove or&lt;br /&gt;
reorder steps with &amp;lt;code&amp;gt;dispatch.step_list&amp;lt;/code&amp;gt;. This is what makes the program flexible enough to&lt;br /&gt;
scale-and-merge in one pass, to scale subsets separately and merge later, or to run a reference-free&lt;br /&gt;
bootstrap.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;default&#039;&#039;&#039; step list is:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! # !! Worker !! Purpose&lt;br /&gt;
|-&lt;br /&gt;
| 1 || &amp;lt;code&amp;gt;input&amp;lt;/code&amp;gt; || Read integrated experiments (&amp;lt;code&amp;gt;.expt&amp;lt;/code&amp;gt;) and reflections (&amp;lt;code&amp;gt;.refl&amp;lt;/code&amp;gt;) from disk in DIALS format.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || &amp;lt;code&amp;gt;balance&amp;lt;/code&amp;gt; || Redistribute the input load evenly across MPI ranks (needed when there are fewer or more input files than ranks).&lt;br /&gt;
|-&lt;br /&gt;
| 3 || &amp;lt;code&amp;gt;model_scaling&amp;lt;/code&amp;gt; || Build the full Miller list, model intensities from the reference, and the resolution binner used for scaling and post-refinement.&lt;br /&gt;
|-&lt;br /&gt;
| 4 || &amp;lt;code&amp;gt;modify&amp;lt;/code&amp;gt; || Apply per-reflection modifications, e.g. polarization correction (and optionally re-indexing to resolve indexing ambiguity — see &amp;lt;code&amp;gt;modify.cosym&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;reindex_to_reference&amp;lt;/code&amp;gt;).&lt;br /&gt;
|-&lt;br /&gt;
| 5 || &amp;lt;code&amp;gt;filter&amp;lt;/code&amp;gt; || Reject whole experiments (or reflections) by resolution, unit cell, correlation to the reference, energy, etc.&lt;br /&gt;
|-&lt;br /&gt;
| 6 || &amp;lt;code&amp;gt;scale&amp;lt;/code&amp;gt; || Scale each lattice to the reference dataset (&amp;lt;code&amp;gt;mark0&amp;lt;/code&amp;gt;) or simply average (&amp;lt;code&amp;gt;mark1&amp;lt;/code&amp;gt;).&lt;br /&gt;
|-&lt;br /&gt;
| 7 || &amp;lt;code&amp;gt;postrefine&amp;lt;/code&amp;gt; || Post-refine per-image crystal parameters and partialities (Sauter 2015).&lt;br /&gt;
|-&lt;br /&gt;
| 8 || &amp;lt;code&amp;gt;statistics_unitcell&amp;lt;/code&amp;gt; || Determine and store the average unit cell.&lt;br /&gt;
|-&lt;br /&gt;
| 9 || &amp;lt;code&amp;gt;statistics_beam&amp;lt;/code&amp;gt; || Determine and store the average wavelength.&lt;br /&gt;
|-&lt;br /&gt;
| 10 || &amp;lt;code&amp;gt;model_statistics&amp;lt;/code&amp;gt; || Rebuild the Miller list / binner for statistics (may use the average unit cell).&lt;br /&gt;
|-&lt;br /&gt;
| 11 || &amp;lt;code&amp;gt;statistics_resolution&amp;lt;/code&amp;gt; || Per-crystal resolution statistics.&lt;br /&gt;
|-&lt;br /&gt;
| 12 || &amp;lt;code&amp;gt;group&amp;lt;/code&amp;gt; || Redistribute reflections across ranks so that every observation of a given HKL is gathered on the same rank prior to merging.&lt;br /&gt;
|-&lt;br /&gt;
| 13 || &amp;lt;code&amp;gt;errors_merge&amp;lt;/code&amp;gt; || Correct the merged error estimates with a per-HKL error model (e.g. Ev11, Brewster 2019b).&lt;br /&gt;
|-&lt;br /&gt;
| 14 || &amp;lt;code&amp;gt;statistics_intensity&amp;lt;/code&amp;gt; || Intensity statistics by resolution.&lt;br /&gt;
|-&lt;br /&gt;
| 15 || &amp;lt;code&amp;gt;merge&amp;lt;/code&amp;gt; || Merge symmetry-equivalent intensities, gather all HKLs at rank 0, and write &amp;quot;odd&amp;quot;, &amp;quot;even&amp;quot; and &amp;quot;all&amp;quot; MTZ files.&lt;br /&gt;
|-&lt;br /&gt;
| 16 || &amp;lt;code&amp;gt;statistics_intensity_cxi&amp;lt;/code&amp;gt; || CC½ / CC* and related statistics (ported from cxi.merge).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Additional, non-default workers are available in &amp;lt;code&amp;gt;xfel/merging/application/&amp;lt;/code&amp;gt; and can be&lt;br /&gt;
inserted into the step list, including &amp;lt;code&amp;gt;tdata&amp;lt;/code&amp;gt; (write out unit cells for clustering),&lt;br /&gt;
&amp;lt;code&amp;gt;export&amp;lt;/code&amp;gt; (batch MTZ for &#039;&#039;Careless&#039;&#039;), &amp;lt;code&amp;gt;publish&amp;lt;/code&amp;gt; (upload merged files to a&lt;br /&gt;
Google Drive folder), &amp;lt;code&amp;gt;monitor&amp;lt;/code&amp;gt; (resource-usage logging), &amp;lt;code&amp;gt;integrate&amp;lt;/code&amp;gt;&lt;br /&gt;
(on-the-fly integration from psana2/XTC2), &amp;lt;code&amp;gt;prepare&amp;lt;/code&amp;gt; (SpReAD energy binning), and&lt;br /&gt;
&amp;lt;code&amp;gt;lunus&amp;lt;/code&amp;gt; (diffuse-scattering deck). A &amp;lt;code&amp;gt;deltaccint&amp;lt;/code&amp;gt; worker (ΔCC½ lattice&lt;br /&gt;
filtering) can be added after &amp;lt;code&amp;gt;group&amp;lt;/code&amp;gt;. Custom workers can be supplied through the&lt;br /&gt;
&amp;lt;code&amp;gt;XFEL_CUSTOM_WORKER_PATH&amp;lt;/code&amp;gt; environment variable.&lt;br /&gt;
&lt;br /&gt;
== Basic usage ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;cctbx.xfel.merge&amp;lt;/code&amp;gt; is run under MPI:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mpirun cctbx.xfel.merge merge.phil&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A typical &amp;lt;code&amp;gt;merge.phil&amp;lt;/code&amp;gt; (from the program README):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
input.path=&amp;lt;path to data&amp;gt;&lt;br /&gt;
input.experiments_suffix=.expt&lt;br /&gt;
input.reflections_suffix=.refl&lt;br /&gt;
&lt;br /&gt;
filter.algorithm=unit_cell&lt;br /&gt;
filter.unit_cell.value.relative_length_tolerance=0.03&lt;br /&gt;
filter.outlier.min_corr=0.1&lt;br /&gt;
&lt;br /&gt;
select.algorithm=significance_filter&lt;br /&gt;
select.significance_filter.sigma=0.1&lt;br /&gt;
select.significance_filter.min_ct=200&lt;br /&gt;
select.significance_filter.max_ct=300&lt;br /&gt;
&lt;br /&gt;
scaling.model=&amp;lt;model.pdb or model.mtz&amp;gt;&lt;br /&gt;
scaling.resolution_scalar=0.96&lt;br /&gt;
&lt;br /&gt;
merging.d_min=1.8&lt;br /&gt;
merging.error.model=ev11&lt;br /&gt;
merging.merge_anomalous=True&lt;br /&gt;
&lt;br /&gt;
postrefinement.enable=True&lt;br /&gt;
statistics.n_bins=20&lt;br /&gt;
&lt;br /&gt;
output.do_timing=True&lt;br /&gt;
output.output_dir=&amp;lt;output folder&amp;gt;&lt;br /&gt;
output.prefix=&amp;lt;prefix for output files&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Explore the parameters with:&lt;br /&gt;
* &amp;lt;code&amp;gt;cctbx.xfel.merge -c&amp;lt;/code&amp;gt; — show configurable parameters&lt;br /&gt;
* &amp;lt;code&amp;gt;cctbx.xfel.merge -c -e 10 -a 2&amp;lt;/code&amp;gt; — show all parameters (expert level 10) with full help text&lt;br /&gt;
&lt;br /&gt;
== Two-stage scaling and merging ==&lt;br /&gt;
&lt;br /&gt;
For large, growing datasets (the mode used by the [[cctbx.xfel GUI]]), it is more efficient to scale&lt;br /&gt;
and post-refine each subset of data &#039;&#039;&#039;once&#039;&#039;&#039;, then merge repeatedly as more data arrive. This is&lt;br /&gt;
done by running the program twice with different step lists.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Stage 1 — scale each subset&#039;&#039;&#039; (stops after per-image work and writes intermediate DIALS files):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dispatch.step_list=input balance model_scaling modify filter scale postrefine \&lt;br /&gt;
    statistics_unitcell statistics_beam model_statistics statistics_resolution&lt;br /&gt;
input.parallel_file_load.method=uniform&lt;br /&gt;
output.save_experiments_and_reflections=True&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;output.save_experiments_and_reflections=True&amp;lt;/code&amp;gt; dumps the scaled/post-refined data as&lt;br /&gt;
experiment lists and reflection tables that the merge stage can read back in.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Stage 2 — merge the scaled subsets&#039;&#039;&#039; (add an &amp;lt;code&amp;gt;input.path&amp;lt;/code&amp;gt; for each finished subset):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dispatch.step_list=input model_scaling statistics_unitcell statistics_beam \&lt;br /&gt;
    model_statistics statistics_resolution group errors_merge statistics_intensity \&lt;br /&gt;
    merge statistics_intensity_cxi&lt;br /&gt;
input.parallel_file_load.method=uniform&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Merging without a reference (bootstrap / mark1) ==&lt;br /&gt;
&lt;br /&gt;
If no scaling/merging reference is available, use a bootstrap procedure. First run the&lt;br /&gt;
&amp;lt;code&amp;gt;mark1&amp;lt;/code&amp;gt; algorithm, which simply averages the data (all per-image scale factors = 1, no&lt;br /&gt;
post-refinement), specifying the target cell and symmetry explicitly:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
scaling.algorithm=mark1&lt;br /&gt;
scaling.unit_cell=&amp;lt;unit cell&amp;gt;&lt;br /&gt;
scaling.space_group=&amp;lt;space group&amp;gt;&lt;br /&gt;
merging.error.model=errors_from_sample_residuals&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The resulting MTZ is then used as the reference (&amp;lt;code&amp;gt;scaling.model=&amp;lt;/code&amp;gt;) for subsequent regular&lt;br /&gt;
merges. Iterate a few cycles; CC½ typically improves and converges over the first few rounds.&lt;br /&gt;
&lt;br /&gt;
== Important parameters ==&lt;br /&gt;
&lt;br /&gt;
Parameters are given by their full PHIL path with defaults in parentheses. The program exposes many&lt;br /&gt;
more parameters (see &amp;lt;code&amp;gt;-c -e 10 -a 2&amp;lt;/code&amp;gt;); those below are the ones most commonly set.&lt;br /&gt;
&lt;br /&gt;
=== Input ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.path&amp;lt;/code&amp;gt; || None || Path(s) to the integrated data — a folder, several folders, or individual files; wildcards allowed; may be repeated. Matching &amp;lt;code&amp;gt;.expt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;.refl&amp;lt;/code&amp;gt; files must both be present.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.experiments_suffix&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;_integrated.expt&amp;lt;/code&amp;gt; || Only load experiment files ending with this suffix.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.reflections_suffix&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;_integrated.refl&amp;lt;/code&amp;gt; || Only load reflection files ending with this suffix.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.parallel_file_load.method&amp;lt;/code&amp;gt; || uniform || &amp;lt;code&amp;gt;uniform&amp;lt;/code&amp;gt; spreads input files evenly over all ranks; &amp;lt;code&amp;gt;node_memory&amp;lt;/code&amp;gt; distributes so per-node memory limits are respected.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.alist.file&amp;lt;/code&amp;gt; || None || Path to a text file of experiment tags or filenames; combined with &amp;lt;code&amp;gt;input.alist.op=keep|reject&amp;lt;/code&amp;gt; to merge only (or exclude) a specified subset.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.persistent_refl_cols&amp;lt;/code&amp;gt; || None || Reflection-table columns to preserve through the pruning steps (and into saved tables).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Filtering whole experiments (&amp;lt;code&amp;gt;filter&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;filter&amp;lt;/code&amp;gt; section accepts or rejects &#039;&#039;&#039;entire experiments&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.algorithm&amp;lt;/code&amp;gt; || (none) || One or more of &amp;lt;code&amp;gt;n_obs&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;resolution&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;unit_cell&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;energy&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bootstrap&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;experiment_prefix&amp;lt;/code&amp;gt;. Nothing is filtered unless listed.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.unit_cell.algorithm&amp;lt;/code&amp;gt; || value || How to restrict unit cells: &amp;lt;code&amp;gt;value&amp;lt;/code&amp;gt; (compare to a target), &amp;lt;code&amp;gt;range&amp;lt;/code&amp;gt;, or &amp;lt;code&amp;gt;cluster&amp;lt;/code&amp;gt; (use a precomputed covariance clustering).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.unit_cell.value.relative_length_tolerance&amp;lt;/code&amp;gt; || 0.1 || Fractional deviation of cell edge lengths allowed vs. the target cell. Often tightened (e.g. 0.03).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.unit_cell.value.absolute_angle_tolerance&amp;lt;/code&amp;gt; || 2.0 || Allowed cell-angle deviation (degrees) vs. the target.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.unit_cell.value.target_unit_cell&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;target_space_group&amp;lt;/code&amp;gt; || Auto || Target cell/symmetry; &amp;lt;code&amp;gt;Auto&amp;lt;/code&amp;gt; uses the scaling model.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.outlier.min_corr&amp;lt;/code&amp;gt; || 0.1 || Minimum correlation of an image&#039;s intensities to the reference model; images below this are rejected. Only applied when a scaling model is present. Use &amp;lt;code&amp;gt;-1&amp;lt;/code&amp;gt; to accept all images regardless of correlation.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.resolution.d_min&amp;lt;/code&amp;gt; || None || Reject an experiment unless some of its reflections extend beyond this resolution.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Selecting individual reflections (&amp;lt;code&amp;gt;select&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;select&amp;lt;/code&amp;gt; section accepts or rejects &#039;&#039;&#039;individual reflections&#039;&#039;&#039; (contrast with&lt;br /&gt;
&amp;lt;code&amp;gt;filter&amp;lt;/code&amp;gt;, which acts on whole experiments).&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;select.algorithm&amp;lt;/code&amp;gt; || (none) || One or more of &amp;lt;code&amp;gt;significance_filter&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;panel&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cspad_sensor&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;isolation_forest&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;target_energy&amp;lt;/code&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;select.significance_filter.sigma&amp;lt;/code&amp;gt; || 0.5 || Trim each lattice at the resolution where the binned ⟨I/σ⟩ drops below this value.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;select.significance_filter.min_ct&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;max_ct&amp;lt;/code&amp;gt; || 10 / 50 || Target minimum/maximum mean reflections per resolution bin when choosing the number of bins. For large unit cells these are often raised (e.g. 200/300); for small cells, use the defaults.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Modifying intensities (&amp;lt;code&amp;gt;modify&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;modify.algorithm&amp;lt;/code&amp;gt; || polarization || Per-reflection corrections to apply (default applies the polarization correction).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;modify.cosym&amp;lt;/code&amp;gt; || — || Resolve an indexing ambiguity across the ensemble using the Gildea/Winter (Brehm/Diederichs) cosym method, optionally anchored to &amp;lt;code&amp;gt;scaling.model&amp;lt;/code&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;modify.reindex_to_reference&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;reindex_to_abc&amp;lt;/code&amp;gt; || — || Alternative re-indexing operators (to a reference model, or an explicit operator).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Scaling (&amp;lt;code&amp;gt;scaling&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;scaling.model&amp;lt;/code&amp;gt; || None || Reference dataset: a PDB file (uses the CRYST1 cell and computes model intensities, including bulk solvent) or an MTZ from a previous cycle. Required for &amp;lt;code&amp;gt;mark0&amp;lt;/code&amp;gt; scaling.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;scaling.algorithm&amp;lt;/code&amp;gt; || mark0 || &amp;lt;code&amp;gt;mark0&amp;lt;/code&amp;gt;: per-image scaling against the reference. &amp;lt;code&amp;gt;mark1&amp;lt;/code&amp;gt;: no scaling, just Monte-Carlo averaging (all scale factors = 1) — used for reference-free bootstrap.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;scaling.unit_cell&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;scaling.space_group&amp;lt;/code&amp;gt; || None || Cell/symmetry to use when no model is provided (i.e. &amp;lt;code&amp;gt;mark1&amp;lt;/code&amp;gt;).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;scaling.resolution_scalar&amp;lt;/code&amp;gt; || 0.969 || &amp;lt;code&amp;gt;merging.d_min&amp;lt;/code&amp;gt; is multiplied by this when deciding which reflections fall within the resolution limit, generating a few extra reference reflections to account for per-shot cell variation (e.g. set 0.96 for a few more).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;scaling.mtz.mtz_column_F&amp;lt;/code&amp;gt; || fobs || Column name in the reference MTZ containing the reference structure factors (intensities or amplitudes).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Post-refinement (&amp;lt;code&amp;gt;postrefinement&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;postrefinement.enable&amp;lt;/code&amp;gt; || True || Enable post-refinement of per-image parameters/partialities (Sauter 2015).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;postrefinement.algorithm&amp;lt;/code&amp;gt; || rs || Post-refinement protocol: &amp;lt;code&amp;gt;rs&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;rs2&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;rs_hybrid&amp;lt;/code&amp;gt;, or &amp;lt;code&amp;gt;eta_deff&amp;lt;/code&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Merging and error model (&amp;lt;code&amp;gt;merging&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;merging.d_min&amp;lt;/code&amp;gt; || None || High-resolution limit for scaling and merging.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;merging.d_max&amp;lt;/code&amp;gt; || None || Low-resolution limit (currently affects only CCiso).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;merging.merge_anomalous&amp;lt;/code&amp;gt; || False || &amp;lt;code&amp;gt;True&amp;lt;/code&amp;gt; merges Bijvoet mates together (higher multiplicity); &amp;lt;code&amp;gt;False&amp;lt;/code&amp;gt; keeps them separate to preserve the anomalous signal.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;merging.minimum_multiplicity&amp;lt;/code&amp;gt; || 2 || Do not produce a merged structure factor for HKLs measured fewer than this many times.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;merging.error.model&amp;lt;/code&amp;gt; || mm24 || Merged-sigma error model: &amp;lt;code&amp;gt;mm24&amp;lt;/code&amp;gt; (Mittan-Moreau 2024, current default), &amp;lt;code&amp;gt;ev11&amp;lt;/code&amp;gt; (Evans 2011 / sdfac-refine, recommended in the README), &amp;lt;code&amp;gt;ha14&amp;lt;/code&amp;gt;, or &amp;lt;code&amp;gt;errors_from_sample_residuals&amp;lt;/code&amp;gt; (no refined error terms — used with &amp;lt;code&amp;gt;mark1&amp;lt;/code&amp;gt; bootstrap).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;merging.set_average_unit_cell&amp;lt;/code&amp;gt; || True || Output MTZ adopts the (cluster-derived) average unit cell of the data rather than the reference model&#039;s cell.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Statistics (&amp;lt;code&amp;gt;statistics&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;statistics.n_bins&amp;lt;/code&amp;gt; || 10 || Number of resolution bins in the statistics tables.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;statistics.cciso.mtz_file&amp;lt;/code&amp;gt; || None || Isomorphous reference structure factors for R&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt; / CC&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;statistics.report_ML&amp;lt;/code&amp;gt; || True || Report per-frame max-likelihood attributes (domain size, mosaicity).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Output (&amp;lt;code&amp;gt;output&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.output_dir&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;.&amp;lt;/code&amp;gt; || Directory for output files (created if it does not exist).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.prefix&amp;lt;/code&amp;gt; || iobs || Prefix prepended to all output file names.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.save_experiments_and_reflections&amp;lt;/code&amp;gt; || False || Dump the final experiments/reflections from the last worker as DIALS files — used for the two-stage scale-then-merge workflow.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.do_timing&amp;lt;/code&amp;gt; || False || Log elapsed time per execution step.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.expanded_bookkeeping&amp;lt;/code&amp;gt; || False || Store extra provenance columns (input file/reflection indices, odd/even flag, original id) in the saved reflection tables.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Multiprocessing (&amp;lt;code&amp;gt;mp&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mp.method&amp;lt;/code&amp;gt; || mpi || Multiprocessing method (only &amp;lt;code&amp;gt;mpi&amp;lt;/code&amp;gt; is currently supported).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mp.debug.cProfile&amp;lt;/code&amp;gt; || False || Enable code profiling; a &amp;lt;code&amp;gt;.prof&amp;lt;/code&amp;gt; file is written per rank.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Output files ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;merge&amp;lt;/code&amp;gt; worker gathers all HKLs at rank 0 and writes three MTZ files, prefixed with&lt;br /&gt;
&amp;lt;code&amp;gt;output.prefix&amp;lt;/code&amp;gt; (default &amp;lt;code&amp;gt;iobs&amp;lt;/code&amp;gt;):&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;amp;lt;prefix&amp;amp;gt;_all.mtz&amp;lt;/code&amp;gt; — the merged dataset using all observations (the main result for structure solution)&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;amp;lt;prefix&amp;amp;gt;_odd.mtz&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;&amp;amp;lt;prefix&amp;amp;gt;_even.mtz&amp;lt;/code&amp;gt; — the two half-datasets used for CC½ and related half-dataset statistics&lt;br /&gt;
&lt;br /&gt;
A main log records the per-step progress and the merging statistics tables (completeness,&lt;br /&gt;
multiplicity, ⟨I/σ⟩, CC½, CC*, R-factors) by resolution bin. The merged MTZ can optionally be&lt;br /&gt;
uploaded to a shared [https://github.com/cctbx/cctbx_project/tree/master/xfel/merging/application/publish Google Drive folder] by adding the &amp;lt;code&amp;gt;publish&amp;lt;/code&amp;gt; worker.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
* Sauter NK (2015). &#039;&#039;J Synchrotron Radiat&#039;&#039; &#039;&#039;&#039;22&#039;&#039;&#039;, 239–48. (post-refinement)&lt;br /&gt;
* Uervirojnangkoorn M, &#039;&#039;et al.&#039;&#039; (2015). &#039;&#039;eLife&#039;&#039; 10.7554/eLife.05421. (PRIME / bootstrap)&lt;br /&gt;
* Brewster AS, &#039;&#039;et al.&#039;&#039; (2018). &#039;&#039;Acta Cryst.&#039;&#039; D &#039;&#039;&#039;74&#039;&#039;&#039;, 877–894.&lt;br /&gt;
* Brewster AS, &#039;&#039;et al.&#039;&#039; (2019a). &#039;&#039;Computational Crystallography Newsletter&#039;&#039; &#039;&#039;&#039;10&#039;&#039;&#039;, 22–39. (XFEL GUI)&lt;br /&gt;
* Brewster AS, &#039;&#039;et al.&#039;&#039; (2019b). &#039;&#039;Acta Cryst.&#039;&#039; D &#039;&#039;&#039;75&#039;&#039;&#039;, 959–968. (error models)&lt;br /&gt;
* Mittan-Moreau (2024). (mm24 error model)&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
* [[dials.stills_process]] — produces the integrated data that &amp;lt;code&amp;gt;cctbx.xfel.merge&amp;lt;/code&amp;gt; consumes&lt;br /&gt;
* [[cctbx.xfel GUI]] — orchestrates separate scaling and repeated merging as data are collected&lt;br /&gt;
* The program README at &amp;lt;code&amp;gt;xfel/merging/README.md&amp;lt;/code&amp;gt; in cctbx_project&lt;/div&gt;</summary>
		<author><name>Aaron</name></author>
	</entry>
	<entry>
		<id>http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Cctbx.xfel.merge&amp;diff=1772</id>
		<title>Cctbx.xfel.merge</title>
		<link rel="alternate" type="text/html" href="http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Cctbx.xfel.merge&amp;diff=1772"/>
		<updated>2026-08-21T23:00:59Z</updated>

		<summary type="html">&lt;p&gt;Aaron: /* cctbx.xfel.merge */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= &#039;&#039;cctbx.xfel.merge&#039;&#039; =&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;cctbx.xfel.merge&#039;&#039;&#039;&#039;&#039; is the scaling, post-refinement and merging program of cctbx.xfel. It takes&lt;br /&gt;
the per-image integrated results produced by &#039;&#039;[[dials.stills_process]]&#039;&#039; — one crystal per still shot —&lt;br /&gt;
and reduces the whole ensemble to a single set of merged structure-factor intensities (an MTZ file)&lt;br /&gt;
suitable for structure solution and refinement, together with the crystallographic quality&lt;br /&gt;
statistics (completeness, multiplicity, CC½, R-factors, etc.).&lt;br /&gt;
&lt;br /&gt;
Because serial datasets routinely contain tens of thousands to millions of still shots,&lt;br /&gt;
&amp;lt;code&amp;gt;cctbx.xfel.merge&amp;lt;/code&amp;gt; is built from the ground up to run under MPI across many nodes. It is&lt;br /&gt;
almost always launched with &amp;lt;code&amp;gt;mpirun&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;srun&amp;lt;/code&amp;gt;.  Note that MPI uses the term &#039;ranks&#039;&lt;br /&gt;
to distinguish independent processes that are running across more than one node.&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;cctbx.xfel.merge&amp;lt;/code&amp;gt; is organized as a sequence of &#039;&#039;&#039;workers&#039;&#039;&#039;. Each worker performs one&lt;br /&gt;
task — reading data, applying a correction, filtering, scaling, post-refining, computing a statistic,&lt;br /&gt;
or merging — and passes its (possibly modified) experiments and reflections on to the next worker.&lt;br /&gt;
The list of workers to run is the &amp;quot;step list&amp;quot;, and it is fully configurable: you can add, remove or&lt;br /&gt;
reorder steps with &amp;lt;code&amp;gt;dispatch.step_list&amp;lt;/code&amp;gt;. This is what makes the program flexible enough to&lt;br /&gt;
scale-and-merge in one pass, to scale subsets separately and merge later, or to run a reference-free&lt;br /&gt;
bootstrap.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;default&#039;&#039;&#039; step list is:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! # !! Worker !! Purpose&lt;br /&gt;
|-&lt;br /&gt;
| 1 || &amp;lt;code&amp;gt;input&amp;lt;/code&amp;gt; || Read integrated experiments (&amp;lt;code&amp;gt;.expt&amp;lt;/code&amp;gt;) and reflections (&amp;lt;code&amp;gt;.refl&amp;lt;/code&amp;gt;) from disk in DIALS format.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || &amp;lt;code&amp;gt;balance&amp;lt;/code&amp;gt; || Redistribute the input load evenly across MPI ranks (needed when there are fewer or more input files than ranks).&lt;br /&gt;
|-&lt;br /&gt;
| 3 || &amp;lt;code&amp;gt;model_scaling&amp;lt;/code&amp;gt; || Build the full Miller list, model intensities from the reference, and the resolution binner used for scaling and post-refinement.&lt;br /&gt;
|-&lt;br /&gt;
| 4 || &amp;lt;code&amp;gt;modify&amp;lt;/code&amp;gt; || Apply per-reflection modifications, e.g. polarization correction (and optionally re-indexing to resolve indexing ambiguity — see &amp;lt;code&amp;gt;modify.cosym&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;reindex_to_reference&amp;lt;/code&amp;gt;).&lt;br /&gt;
|-&lt;br /&gt;
| 5 || &amp;lt;code&amp;gt;filter&amp;lt;/code&amp;gt; || Reject whole experiments (or reflections) by resolution, unit cell, correlation to the reference, energy, etc.&lt;br /&gt;
|-&lt;br /&gt;
| 6 || &amp;lt;code&amp;gt;scale&amp;lt;/code&amp;gt; || Scale each lattice to the reference dataset (&amp;lt;code&amp;gt;mark0&amp;lt;/code&amp;gt;) or simply average (&amp;lt;code&amp;gt;mark1&amp;lt;/code&amp;gt;).&lt;br /&gt;
|-&lt;br /&gt;
| 7 || &amp;lt;code&amp;gt;postrefine&amp;lt;/code&amp;gt; || Post-refine per-image crystal parameters and partialities (Sauter 2015).&lt;br /&gt;
|-&lt;br /&gt;
| 8 || &amp;lt;code&amp;gt;statistics_unitcell&amp;lt;/code&amp;gt; || Determine and store the average unit cell.&lt;br /&gt;
|-&lt;br /&gt;
| 9 || &amp;lt;code&amp;gt;statistics_beam&amp;lt;/code&amp;gt; || Determine and store the average wavelength.&lt;br /&gt;
|-&lt;br /&gt;
| 10 || &amp;lt;code&amp;gt;model_statistics&amp;lt;/code&amp;gt; || Rebuild the Miller list / binner for statistics (may use the average unit cell).&lt;br /&gt;
|-&lt;br /&gt;
| 11 || &amp;lt;code&amp;gt;statistics_resolution&amp;lt;/code&amp;gt; || Per-crystal resolution statistics.&lt;br /&gt;
|-&lt;br /&gt;
| 12 || &amp;lt;code&amp;gt;group&amp;lt;/code&amp;gt; || Redistribute reflections across ranks so that every observation of a given HKL is gathered on the same rank prior to merging.&lt;br /&gt;
|-&lt;br /&gt;
| 13 || &amp;lt;code&amp;gt;errors_merge&amp;lt;/code&amp;gt; || Correct the merged error estimates with a per-HKL error model (e.g. Ev11, Brewster 2019b).&lt;br /&gt;
|-&lt;br /&gt;
| 14 || &amp;lt;code&amp;gt;statistics_intensity&amp;lt;/code&amp;gt; || Intensity statistics by resolution.&lt;br /&gt;
|-&lt;br /&gt;
| 15 || &amp;lt;code&amp;gt;merge&amp;lt;/code&amp;gt; || Merge symmetry-equivalent intensities, gather all HKLs at rank 0, and write &amp;quot;odd&amp;quot;, &amp;quot;even&amp;quot; and &amp;quot;all&amp;quot; MTZ files.&lt;br /&gt;
|-&lt;br /&gt;
| 16 || &amp;lt;code&amp;gt;statistics_intensity_cxi&amp;lt;/code&amp;gt; || CC½ / CC* and related statistics (ported from cxi.merge).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Additional, non-default workers are available in &amp;lt;code&amp;gt;xfel/merging/application/&amp;lt;/code&amp;gt; and can be&lt;br /&gt;
inserted into the step list, including &amp;lt;code&amp;gt;tdata&amp;lt;/code&amp;gt; (write out unit cells for clustering),&lt;br /&gt;
&amp;lt;code&amp;gt;export&amp;lt;/code&amp;gt; (batch MTZ for &#039;&#039;Careless&#039;&#039;), &amp;lt;code&amp;gt;publish&amp;lt;/code&amp;gt; (upload merged files to a&lt;br /&gt;
Google Drive folder), &amp;lt;code&amp;gt;monitor&amp;lt;/code&amp;gt; (resource-usage logging), &amp;lt;code&amp;gt;integrate&amp;lt;/code&amp;gt;&lt;br /&gt;
(on-the-fly integration from psana2/XTC2), &amp;lt;code&amp;gt;prepare&amp;lt;/code&amp;gt; (SpReAD energy binning), and&lt;br /&gt;
&amp;lt;code&amp;gt;lunus&amp;lt;/code&amp;gt; (diffuse-scattering deck). A &amp;lt;code&amp;gt;deltaccint&amp;lt;/code&amp;gt; worker (ΔCC½ lattice&lt;br /&gt;
filtering) can be added after &amp;lt;code&amp;gt;group&amp;lt;/code&amp;gt;. Custom workers can be supplied through the&lt;br /&gt;
&amp;lt;code&amp;gt;XFEL_CUSTOM_WORKER_PATH&amp;lt;/code&amp;gt; environment variable.&lt;br /&gt;
&lt;br /&gt;
== Basic usage ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;cctbx.xfel.merge&amp;lt;/code&amp;gt; is run under MPI:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mpirun cctbx.xfel.merge merge.phil&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A typical &amp;lt;code&amp;gt;merge.phil&amp;lt;/code&amp;gt; (from the program README):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
input.path=&amp;lt;path to data&amp;gt;&lt;br /&gt;
input.experiments_suffix=.expt&lt;br /&gt;
input.reflections_suffix=.refl&lt;br /&gt;
&lt;br /&gt;
filter.algorithm=unit_cell&lt;br /&gt;
filter.unit_cell.value.relative_length_tolerance=0.03&lt;br /&gt;
filter.outlier.min_corr=0.1&lt;br /&gt;
&lt;br /&gt;
select.algorithm=significance_filter&lt;br /&gt;
select.significance_filter.sigma=0.1&lt;br /&gt;
select.significance_filter.min_ct=200&lt;br /&gt;
select.significance_filter.max_ct=300&lt;br /&gt;
&lt;br /&gt;
scaling.model=&amp;lt;model.pdb or model.mtz&amp;gt;&lt;br /&gt;
scaling.resolution_scalar=0.96&lt;br /&gt;
&lt;br /&gt;
merging.d_min=1.8&lt;br /&gt;
merging.error.model=ev11&lt;br /&gt;
merging.merge_anomalous=True&lt;br /&gt;
&lt;br /&gt;
postrefinement.enable=True&lt;br /&gt;
statistics.n_bins=20&lt;br /&gt;
&lt;br /&gt;
output.do_timing=True&lt;br /&gt;
output.output_dir=&amp;lt;output folder&amp;gt;&lt;br /&gt;
output.prefix=&amp;lt;prefix for output files&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Explore the parameters with:&lt;br /&gt;
* &amp;lt;code&amp;gt;cctbx.xfel.merge -c&amp;lt;/code&amp;gt; — show configurable parameters&lt;br /&gt;
* &amp;lt;code&amp;gt;cctbx.xfel.merge -c -e 10 -a 2&amp;lt;/code&amp;gt; — show all parameters (expert level 10) with full help text&lt;br /&gt;
&lt;br /&gt;
== Two-stage scaling and merging ==&lt;br /&gt;
&lt;br /&gt;
For large, growing datasets (the mode used by the [[cctbx.xfel GUI]]), it is more efficient to scale&lt;br /&gt;
and post-refine each subset of data &#039;&#039;&#039;once&#039;&#039;&#039;, then merge repeatedly as more data arrive. This is&lt;br /&gt;
done by running the program twice with different step lists.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Stage 1 — scale each subset&#039;&#039;&#039; (stops after per-image work and writes intermediate DIALS files):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dispatch.step_list=input balance model_scaling modify filter scale postrefine \&lt;br /&gt;
    statistics_unitcell statistics_beam model_statistics statistics_resolution&lt;br /&gt;
input.parallel_file_load.method=uniform&lt;br /&gt;
output.save_experiments_and_reflections=True&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;output.save_experiments_and_reflections=True&amp;lt;/code&amp;gt; dumps the scaled/post-refined data as&lt;br /&gt;
experiment lists and reflection tables that the merge stage can read back in.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Stage 2 — merge the scaled subsets&#039;&#039;&#039; (add an &amp;lt;code&amp;gt;input.path&amp;lt;/code&amp;gt; for each finished subset):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dispatch.step_list=input model_scaling statistics_unitcell statistics_beam \&lt;br /&gt;
    model_statistics statistics_resolution group errors_merge statistics_intensity \&lt;br /&gt;
    merge statistics_intensity_cxi&lt;br /&gt;
input.parallel_file_load.method=uniform&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Merging without a reference (bootstrap / mark1) ==&lt;br /&gt;
&lt;br /&gt;
If no scaling/merging reference is available, use a bootstrap procedure. First run the&lt;br /&gt;
&amp;lt;code&amp;gt;mark1&amp;lt;/code&amp;gt; algorithm, which simply averages the data (all per-image scale factors = 1, no&lt;br /&gt;
post-refinement), specifying the target cell and symmetry explicitly:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
scaling.algorithm=mark1&lt;br /&gt;
scaling.unit_cell=&amp;lt;unit cell&amp;gt;&lt;br /&gt;
scaling.space_group=&amp;lt;space group&amp;gt;&lt;br /&gt;
merging.error.model=errors_from_sample_residuals&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The resulting MTZ is then used as the reference (&amp;lt;code&amp;gt;scaling.model=&amp;lt;/code&amp;gt;) for subsequent regular&lt;br /&gt;
merges. Iterate a few cycles; CC½ typically improves and converges over the first few rounds.&lt;br /&gt;
&lt;br /&gt;
== Important parameters ==&lt;br /&gt;
&lt;br /&gt;
Parameters are given by their full PHIL path with defaults in parentheses. The program exposes many&lt;br /&gt;
more parameters (see &amp;lt;code&amp;gt;-c -e 10 -a 2&amp;lt;/code&amp;gt;); those below are the ones most commonly set.&lt;br /&gt;
&lt;br /&gt;
=== Input ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.path&amp;lt;/code&amp;gt; || None || Path(s) to the integrated data — a folder, several folders, or individual files; wildcards allowed; may be repeated. Matching &amp;lt;code&amp;gt;.expt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;.refl&amp;lt;/code&amp;gt; files must both be present.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.experiments_suffix&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;_integrated.expt&amp;lt;/code&amp;gt; || Only load experiment files ending with this suffix.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.reflections_suffix&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;_integrated.refl&amp;lt;/code&amp;gt; || Only load reflection files ending with this suffix.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.parallel_file_load.method&amp;lt;/code&amp;gt; || uniform || &amp;lt;code&amp;gt;uniform&amp;lt;/code&amp;gt; spreads input files evenly over all ranks; &amp;lt;code&amp;gt;node_memory&amp;lt;/code&amp;gt; distributes so per-node memory limits are respected.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.alist.file&amp;lt;/code&amp;gt; || None || Path to a text file of experiment tags or filenames; combined with &amp;lt;code&amp;gt;input.alist.op=keep|reject&amp;lt;/code&amp;gt; to merge only (or exclude) a specified subset.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.persistent_refl_cols&amp;lt;/code&amp;gt; || None || Reflection-table columns to preserve through the pruning steps (and into saved tables).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Filtering whole experiments (&amp;lt;code&amp;gt;filter&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;filter&amp;lt;/code&amp;gt; section accepts or rejects &#039;&#039;&#039;entire experiments&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.algorithm&amp;lt;/code&amp;gt; || (none) || One or more of &amp;lt;code&amp;gt;n_obs&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;resolution&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;unit_cell&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;energy&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bootstrap&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;experiment_prefix&amp;lt;/code&amp;gt;. Nothing is filtered unless listed.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.unit_cell.algorithm&amp;lt;/code&amp;gt; || value || How to restrict unit cells: &amp;lt;code&amp;gt;value&amp;lt;/code&amp;gt; (compare to a target), &amp;lt;code&amp;gt;range&amp;lt;/code&amp;gt;, or &amp;lt;code&amp;gt;cluster&amp;lt;/code&amp;gt; (use a precomputed covariance clustering).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.unit_cell.value.relative_length_tolerance&amp;lt;/code&amp;gt; || 0.1 || Fractional deviation of cell edge lengths allowed vs. the target cell. Often tightened (e.g. 0.03).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.unit_cell.value.absolute_angle_tolerance&amp;lt;/code&amp;gt; || 2.0 || Allowed cell-angle deviation (degrees) vs. the target.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.unit_cell.value.target_unit_cell&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;target_space_group&amp;lt;/code&amp;gt; || Auto || Target cell/symmetry; &amp;lt;code&amp;gt;Auto&amp;lt;/code&amp;gt; uses the scaling model.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.outlier.min_corr&amp;lt;/code&amp;gt; || 0.1 || Minimum correlation of an image&#039;s intensities to the reference model; images below this are rejected. Only applied when a scaling model is present. Use &amp;lt;code&amp;gt;-1&amp;lt;/code&amp;gt; to accept all images regardless of correlation.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.resolution.d_min&amp;lt;/code&amp;gt; || None || Reject an experiment unless some of its reflections extend beyond this resolution.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Selecting individual reflections (&amp;lt;code&amp;gt;select&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;select&amp;lt;/code&amp;gt; section accepts or rejects &#039;&#039;&#039;individual reflections&#039;&#039;&#039; (contrast with&lt;br /&gt;
&amp;lt;code&amp;gt;filter&amp;lt;/code&amp;gt;, which acts on whole experiments).&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;select.algorithm&amp;lt;/code&amp;gt; || (none) || One or more of &amp;lt;code&amp;gt;significance_filter&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;panel&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cspad_sensor&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;isolation_forest&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;target_energy&amp;lt;/code&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;select.significance_filter.sigma&amp;lt;/code&amp;gt; || 0.5 || Trim each lattice at the resolution where the binned ⟨I/σ⟩ drops below this value.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;select.significance_filter.min_ct&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;max_ct&amp;lt;/code&amp;gt; || 10 / 50 || Target minimum/maximum mean reflections per resolution bin when choosing the number of bins. For large unit cells these are often raised (e.g. 200/300); for small cells, use the defaults.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Modifying intensities (&amp;lt;code&amp;gt;modify&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;modify.algorithm&amp;lt;/code&amp;gt; || polarization || Per-reflection corrections to apply (default applies the polarization correction).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;modify.cosym&amp;lt;/code&amp;gt; || — || Resolve an indexing ambiguity across the ensemble using the Gildea/Winter (Brehm/Diederichs) cosym method, optionally anchored to &amp;lt;code&amp;gt;scaling.model&amp;lt;/code&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;modify.reindex_to_reference&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;reindex_to_abc&amp;lt;/code&amp;gt; || — || Alternative re-indexing operators (to a reference model, or an explicit operator).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Scaling (&amp;lt;code&amp;gt;scaling&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;scaling.model&amp;lt;/code&amp;gt; || None || Reference dataset: a PDB file (uses the CRYST1 cell and computes model intensities, including bulk solvent) or an MTZ from a previous cycle. Required for &amp;lt;code&amp;gt;mark0&amp;lt;/code&amp;gt; scaling.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;scaling.algorithm&amp;lt;/code&amp;gt; || mark0 || &amp;lt;code&amp;gt;mark0&amp;lt;/code&amp;gt;: per-image scaling against the reference. &amp;lt;code&amp;gt;mark1&amp;lt;/code&amp;gt;: no scaling, just Monte-Carlo averaging (all scale factors = 1) — used for reference-free bootstrap.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;scaling.unit_cell&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;scaling.space_group&amp;lt;/code&amp;gt; || None || Cell/symmetry to use when no model is provided (i.e. &amp;lt;code&amp;gt;mark1&amp;lt;/code&amp;gt;).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;scaling.resolution_scalar&amp;lt;/code&amp;gt; || 0.969 || &amp;lt;code&amp;gt;merging.d_min&amp;lt;/code&amp;gt; is multiplied by this when deciding which reflections fall within the resolution limit, generating a few extra reference reflections to account for per-shot cell variation (e.g. set 0.96 for a few more).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;scaling.mtz.mtz_column_F&amp;lt;/code&amp;gt; || fobs || Column name in the reference MTZ containing the reference structure factors (intensities or amplitudes).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Post-refinement (&amp;lt;code&amp;gt;postrefinement&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;postrefinement.enable&amp;lt;/code&amp;gt; || True || Enable post-refinement of per-image parameters/partialities (Sauter 2015).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;postrefinement.algorithm&amp;lt;/code&amp;gt; || rs || Post-refinement protocol: &amp;lt;code&amp;gt;rs&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;rs2&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;rs_hybrid&amp;lt;/code&amp;gt;, or &amp;lt;code&amp;gt;eta_deff&amp;lt;/code&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Merging and error model (&amp;lt;code&amp;gt;merging&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;merging.d_min&amp;lt;/code&amp;gt; || None || High-resolution limit for scaling and merging.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;merging.d_max&amp;lt;/code&amp;gt; || None || Low-resolution limit (currently affects only CCiso).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;merging.merge_anomalous&amp;lt;/code&amp;gt; || False || &amp;lt;code&amp;gt;True&amp;lt;/code&amp;gt; merges Bijvoet mates together (higher multiplicity); &amp;lt;code&amp;gt;False&amp;lt;/code&amp;gt; keeps them separate to preserve the anomalous signal.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;merging.minimum_multiplicity&amp;lt;/code&amp;gt; || 2 || Do not produce a merged structure factor for HKLs measured fewer than this many times.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;merging.error.model&amp;lt;/code&amp;gt; || mm24 || Merged-sigma error model: &amp;lt;code&amp;gt;mm24&amp;lt;/code&amp;gt; (Mittan-Moreau 2024, current default), &amp;lt;code&amp;gt;ev11&amp;lt;/code&amp;gt; (Evans 2011 / sdfac-refine, recommended in the README), &amp;lt;code&amp;gt;ha14&amp;lt;/code&amp;gt;, or &amp;lt;code&amp;gt;errors_from_sample_residuals&amp;lt;/code&amp;gt; (no refined error terms — used with &amp;lt;code&amp;gt;mark1&amp;lt;/code&amp;gt; bootstrap).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;merging.set_average_unit_cell&amp;lt;/code&amp;gt; || True || Output MTZ adopts the (cluster-derived) average unit cell of the data rather than the reference model&#039;s cell.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Statistics (&amp;lt;code&amp;gt;statistics&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;statistics.n_bins&amp;lt;/code&amp;gt; || 10 || Number of resolution bins in the statistics tables.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;statistics.cciso.mtz_file&amp;lt;/code&amp;gt; || None || Isomorphous reference structure factors for R&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt; / CC&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;statistics.report_ML&amp;lt;/code&amp;gt; || True || Report per-frame max-likelihood attributes (domain size, mosaicity).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Output (&amp;lt;code&amp;gt;output&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.output_dir&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;.&amp;lt;/code&amp;gt; || Directory for output files (created if it does not exist).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.prefix&amp;lt;/code&amp;gt; || iobs || Prefix prepended to all output file names.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.save_experiments_and_reflections&amp;lt;/code&amp;gt; || False || Dump the final experiments/reflections from the last worker as DIALS files — used for the two-stage scale-then-merge workflow.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.do_timing&amp;lt;/code&amp;gt; || False || Log elapsed time per execution step.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.expanded_bookkeeping&amp;lt;/code&amp;gt; || False || Store extra provenance columns (input file/reflection indices, odd/even flag, original id) in the saved reflection tables.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Multiprocessing (&amp;lt;code&amp;gt;mp&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mp.method&amp;lt;/code&amp;gt; || mpi || Multiprocessing method (only &amp;lt;code&amp;gt;mpi&amp;lt;/code&amp;gt; is currently supported).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mp.debug.cProfile&amp;lt;/code&amp;gt; || False || Enable code profiling; a &amp;lt;code&amp;gt;.prof&amp;lt;/code&amp;gt; file is written per rank.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Output files ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;merge&amp;lt;/code&amp;gt; worker gathers all HKLs at rank 0 and writes three MTZ files, prefixed with&lt;br /&gt;
&amp;lt;code&amp;gt;output.prefix&amp;lt;/code&amp;gt; (default &amp;lt;code&amp;gt;iobs&amp;lt;/code&amp;gt;):&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;amp;lt;prefix&amp;amp;gt;_all.mtz&amp;lt;/code&amp;gt; — the merged dataset using all observations (the main result for structure solution)&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;amp;lt;prefix&amp;amp;gt;_odd.mtz&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;&amp;amp;lt;prefix&amp;amp;gt;_even.mtz&amp;lt;/code&amp;gt; — the two half-datasets used for CC½ and related half-dataset statistics&lt;br /&gt;
&lt;br /&gt;
A main log records the per-step progress and the merging statistics tables (completeness,&lt;br /&gt;
multiplicity, ⟨I/σ⟩, CC½, CC*, R-factors) by resolution bin. The merged MTZ can optionally be&lt;br /&gt;
uploaded to a shared [https://github.com/cctbx/cctbx_project/tree/master/xfel/merging/application/publish Google Drive folder] by adding the &amp;lt;code&amp;gt;publish&amp;lt;/code&amp;gt; worker.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
* Sauter NK (2015). &#039;&#039;J Synchrotron Radiat&#039;&#039; &#039;&#039;&#039;22&#039;&#039;&#039;, 239–48. (post-refinement)&lt;br /&gt;
* Uervirojnangkoorn M, &#039;&#039;et al.&#039;&#039; (2015). &#039;&#039;eLife&#039;&#039; 10.7554/eLife.05421. (PRIME / bootstrap)&lt;br /&gt;
* Brewster AS, &#039;&#039;et al.&#039;&#039; (2018). &#039;&#039;Acta Cryst.&#039;&#039; D &#039;&#039;&#039;74&#039;&#039;&#039;, 877–894.&lt;br /&gt;
* Brewster AS, &#039;&#039;et al.&#039;&#039; (2019a). &#039;&#039;Computational Crystallography Newsletter&#039;&#039; &#039;&#039;&#039;10&#039;&#039;&#039;, 22–39. (XFEL GUI)&lt;br /&gt;
* Brewster AS, &#039;&#039;et al.&#039;&#039; (2019b). &#039;&#039;Acta Cryst.&#039;&#039; D &#039;&#039;&#039;75&#039;&#039;&#039;, 959–968. (error models)&lt;br /&gt;
* Mittan-Moreau (2024). (mm24 error model)&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
* [[dials.stills_process]] — produces the integrated data that &amp;lt;code&amp;gt;cctbx.xfel.merge&amp;lt;/code&amp;gt; consumes&lt;br /&gt;
* [[cctbx.xfel GUI]] — orchestrates separate scaling and repeated merging as data are collected&lt;br /&gt;
* The program README at &amp;lt;code&amp;gt;xfel/merging/README.md&amp;lt;/code&amp;gt; in cctbx_project&lt;/div&gt;</summary>
		<author><name>Aaron</name></author>
	</entry>
	<entry>
		<id>http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Cctbx.xfel.merge&amp;diff=1771</id>
		<title>Cctbx.xfel.merge</title>
		<link rel="alternate" type="text/html" href="http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Cctbx.xfel.merge&amp;diff=1771"/>
		<updated>2026-08-21T23:00:04Z</updated>

		<summary type="html">&lt;p&gt;Aaron: /* Overview */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= &#039;&#039;cctbx.xfel.merge&#039;&#039; =&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;cctbx.xfel.merge&#039;&#039;&#039;&#039;&#039; is the scaling, post-refinement and merging program of cctbx.xfel. It takes&lt;br /&gt;
the per-image integrated results produced by &#039;&#039;[[dials.stills_process]]&#039;&#039; — one crystal per still shot —&lt;br /&gt;
and reduces the whole ensemble to a single set of merged structure-factor intensities (an MTZ file)&lt;br /&gt;
suitable for structure solution and refinement, together with the crystallographic quality&lt;br /&gt;
statistics (completeness, multiplicity, CC½, R-factors, etc.).&lt;br /&gt;
&lt;br /&gt;
Because serial datasets routinely contain tens of thousands to millions of still shots,&lt;br /&gt;
&amp;lt;code&amp;gt;cctbx.xfel.merge&amp;lt;/code&amp;gt; is built from the ground up to run under MPI across many nodes. It is&lt;br /&gt;
almost always launched with &amp;lt;code&amp;gt;mpirun&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;srun&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;cctbx.xfel.merge&amp;lt;/code&amp;gt; is organized as a sequence of &#039;&#039;&#039;workers&#039;&#039;&#039;. Each worker performs one&lt;br /&gt;
task — reading data, applying a correction, filtering, scaling, post-refining, computing a statistic,&lt;br /&gt;
or merging — and passes its (possibly modified) experiments and reflections on to the next worker.&lt;br /&gt;
The list of workers to run is the &amp;quot;step list&amp;quot;, and it is fully configurable: you can add, remove or&lt;br /&gt;
reorder steps with &amp;lt;code&amp;gt;dispatch.step_list&amp;lt;/code&amp;gt;. This is what makes the program flexible enough to&lt;br /&gt;
scale-and-merge in one pass, to scale subsets separately and merge later, or to run a reference-free&lt;br /&gt;
bootstrap.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;default&#039;&#039;&#039; step list is:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! # !! Worker !! Purpose&lt;br /&gt;
|-&lt;br /&gt;
| 1 || &amp;lt;code&amp;gt;input&amp;lt;/code&amp;gt; || Read integrated experiments (&amp;lt;code&amp;gt;.expt&amp;lt;/code&amp;gt;) and reflections (&amp;lt;code&amp;gt;.refl&amp;lt;/code&amp;gt;) from disk in DIALS format.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || &amp;lt;code&amp;gt;balance&amp;lt;/code&amp;gt; || Redistribute the input load evenly across MPI ranks (needed when there are fewer or more input files than ranks).&lt;br /&gt;
|-&lt;br /&gt;
| 3 || &amp;lt;code&amp;gt;model_scaling&amp;lt;/code&amp;gt; || Build the full Miller list, model intensities from the reference, and the resolution binner used for scaling and post-refinement.&lt;br /&gt;
|-&lt;br /&gt;
| 4 || &amp;lt;code&amp;gt;modify&amp;lt;/code&amp;gt; || Apply per-reflection modifications, e.g. polarization correction (and optionally re-indexing to resolve indexing ambiguity — see &amp;lt;code&amp;gt;modify.cosym&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;reindex_to_reference&amp;lt;/code&amp;gt;).&lt;br /&gt;
|-&lt;br /&gt;
| 5 || &amp;lt;code&amp;gt;filter&amp;lt;/code&amp;gt; || Reject whole experiments (or reflections) by resolution, unit cell, correlation to the reference, energy, etc.&lt;br /&gt;
|-&lt;br /&gt;
| 6 || &amp;lt;code&amp;gt;scale&amp;lt;/code&amp;gt; || Scale each lattice to the reference dataset (&amp;lt;code&amp;gt;mark0&amp;lt;/code&amp;gt;) or simply average (&amp;lt;code&amp;gt;mark1&amp;lt;/code&amp;gt;).&lt;br /&gt;
|-&lt;br /&gt;
| 7 || &amp;lt;code&amp;gt;postrefine&amp;lt;/code&amp;gt; || Post-refine per-image crystal parameters and partialities (Sauter 2015).&lt;br /&gt;
|-&lt;br /&gt;
| 8 || &amp;lt;code&amp;gt;statistics_unitcell&amp;lt;/code&amp;gt; || Determine and store the average unit cell.&lt;br /&gt;
|-&lt;br /&gt;
| 9 || &amp;lt;code&amp;gt;statistics_beam&amp;lt;/code&amp;gt; || Determine and store the average wavelength.&lt;br /&gt;
|-&lt;br /&gt;
| 10 || &amp;lt;code&amp;gt;model_statistics&amp;lt;/code&amp;gt; || Rebuild the Miller list / binner for statistics (may use the average unit cell).&lt;br /&gt;
|-&lt;br /&gt;
| 11 || &amp;lt;code&amp;gt;statistics_resolution&amp;lt;/code&amp;gt; || Per-crystal resolution statistics.&lt;br /&gt;
|-&lt;br /&gt;
| 12 || &amp;lt;code&amp;gt;group&amp;lt;/code&amp;gt; || Redistribute reflections across ranks so that every observation of a given HKL is gathered on the same rank prior to merging.&lt;br /&gt;
|-&lt;br /&gt;
| 13 || &amp;lt;code&amp;gt;errors_merge&amp;lt;/code&amp;gt; || Correct the merged error estimates with a per-HKL error model (e.g. Ev11, Brewster 2019b).&lt;br /&gt;
|-&lt;br /&gt;
| 14 || &amp;lt;code&amp;gt;statistics_intensity&amp;lt;/code&amp;gt; || Intensity statistics by resolution.&lt;br /&gt;
|-&lt;br /&gt;
| 15 || &amp;lt;code&amp;gt;merge&amp;lt;/code&amp;gt; || Merge symmetry-equivalent intensities, gather all HKLs at rank 0, and write &amp;quot;odd&amp;quot;, &amp;quot;even&amp;quot; and &amp;quot;all&amp;quot; MTZ files.&lt;br /&gt;
|-&lt;br /&gt;
| 16 || &amp;lt;code&amp;gt;statistics_intensity_cxi&amp;lt;/code&amp;gt; || CC½ / CC* and related statistics (ported from cxi.merge).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Additional, non-default workers are available in &amp;lt;code&amp;gt;xfel/merging/application/&amp;lt;/code&amp;gt; and can be&lt;br /&gt;
inserted into the step list, including &amp;lt;code&amp;gt;tdata&amp;lt;/code&amp;gt; (write out unit cells for clustering),&lt;br /&gt;
&amp;lt;code&amp;gt;export&amp;lt;/code&amp;gt; (batch MTZ for &#039;&#039;Careless&#039;&#039;), &amp;lt;code&amp;gt;publish&amp;lt;/code&amp;gt; (upload merged files to a&lt;br /&gt;
Google Drive folder), &amp;lt;code&amp;gt;monitor&amp;lt;/code&amp;gt; (resource-usage logging), &amp;lt;code&amp;gt;integrate&amp;lt;/code&amp;gt;&lt;br /&gt;
(on-the-fly integration from psana2/XTC2), &amp;lt;code&amp;gt;prepare&amp;lt;/code&amp;gt; (SpReAD energy binning), and&lt;br /&gt;
&amp;lt;code&amp;gt;lunus&amp;lt;/code&amp;gt; (diffuse-scattering deck). A &amp;lt;code&amp;gt;deltaccint&amp;lt;/code&amp;gt; worker (ΔCC½ lattice&lt;br /&gt;
filtering) can be added after &amp;lt;code&amp;gt;group&amp;lt;/code&amp;gt;. Custom workers can be supplied through the&lt;br /&gt;
&amp;lt;code&amp;gt;XFEL_CUSTOM_WORKER_PATH&amp;lt;/code&amp;gt; environment variable.&lt;br /&gt;
&lt;br /&gt;
== Basic usage ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;cctbx.xfel.merge&amp;lt;/code&amp;gt; is run under MPI:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mpirun cctbx.xfel.merge merge.phil&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A typical &amp;lt;code&amp;gt;merge.phil&amp;lt;/code&amp;gt; (from the program README):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
input.path=&amp;lt;path to data&amp;gt;&lt;br /&gt;
input.experiments_suffix=.expt&lt;br /&gt;
input.reflections_suffix=.refl&lt;br /&gt;
&lt;br /&gt;
filter.algorithm=unit_cell&lt;br /&gt;
filter.unit_cell.value.relative_length_tolerance=0.03&lt;br /&gt;
filter.outlier.min_corr=0.1&lt;br /&gt;
&lt;br /&gt;
select.algorithm=significance_filter&lt;br /&gt;
select.significance_filter.sigma=0.1&lt;br /&gt;
select.significance_filter.min_ct=200&lt;br /&gt;
select.significance_filter.max_ct=300&lt;br /&gt;
&lt;br /&gt;
scaling.model=&amp;lt;model.pdb or model.mtz&amp;gt;&lt;br /&gt;
scaling.resolution_scalar=0.96&lt;br /&gt;
&lt;br /&gt;
merging.d_min=1.8&lt;br /&gt;
merging.error.model=ev11&lt;br /&gt;
merging.merge_anomalous=True&lt;br /&gt;
&lt;br /&gt;
postrefinement.enable=True&lt;br /&gt;
statistics.n_bins=20&lt;br /&gt;
&lt;br /&gt;
output.do_timing=True&lt;br /&gt;
output.output_dir=&amp;lt;output folder&amp;gt;&lt;br /&gt;
output.prefix=&amp;lt;prefix for output files&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Explore the parameters with:&lt;br /&gt;
* &amp;lt;code&amp;gt;cctbx.xfel.merge -c&amp;lt;/code&amp;gt; — show configurable parameters&lt;br /&gt;
* &amp;lt;code&amp;gt;cctbx.xfel.merge -c -e 10 -a 2&amp;lt;/code&amp;gt; — show all parameters (expert level 10) with full help text&lt;br /&gt;
&lt;br /&gt;
== Two-stage scaling and merging ==&lt;br /&gt;
&lt;br /&gt;
For large, growing datasets (the mode used by the [[cctbx.xfel GUI]]), it is more efficient to scale&lt;br /&gt;
and post-refine each subset of data &#039;&#039;&#039;once&#039;&#039;&#039;, then merge repeatedly as more data arrive. This is&lt;br /&gt;
done by running the program twice with different step lists.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Stage 1 — scale each subset&#039;&#039;&#039; (stops after per-image work and writes intermediate DIALS files):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dispatch.step_list=input balance model_scaling modify filter scale postrefine \&lt;br /&gt;
    statistics_unitcell statistics_beam model_statistics statistics_resolution&lt;br /&gt;
input.parallel_file_load.method=uniform&lt;br /&gt;
output.save_experiments_and_reflections=True&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;output.save_experiments_and_reflections=True&amp;lt;/code&amp;gt; dumps the scaled/post-refined data as&lt;br /&gt;
experiment lists and reflection tables that the merge stage can read back in.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Stage 2 — merge the scaled subsets&#039;&#039;&#039; (add an &amp;lt;code&amp;gt;input.path&amp;lt;/code&amp;gt; for each finished subset):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dispatch.step_list=input model_scaling statistics_unitcell statistics_beam \&lt;br /&gt;
    model_statistics statistics_resolution group errors_merge statistics_intensity \&lt;br /&gt;
    merge statistics_intensity_cxi&lt;br /&gt;
input.parallel_file_load.method=uniform&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Merging without a reference (bootstrap / mark1) ==&lt;br /&gt;
&lt;br /&gt;
If no scaling/merging reference is available, use a bootstrap procedure. First run the&lt;br /&gt;
&amp;lt;code&amp;gt;mark1&amp;lt;/code&amp;gt; algorithm, which simply averages the data (all per-image scale factors = 1, no&lt;br /&gt;
post-refinement), specifying the target cell and symmetry explicitly:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
scaling.algorithm=mark1&lt;br /&gt;
scaling.unit_cell=&amp;lt;unit cell&amp;gt;&lt;br /&gt;
scaling.space_group=&amp;lt;space group&amp;gt;&lt;br /&gt;
merging.error.model=errors_from_sample_residuals&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The resulting MTZ is then used as the reference (&amp;lt;code&amp;gt;scaling.model=&amp;lt;/code&amp;gt;) for subsequent regular&lt;br /&gt;
merges. Iterate a few cycles; CC½ typically improves and converges over the first few rounds.&lt;br /&gt;
&lt;br /&gt;
== Important parameters ==&lt;br /&gt;
&lt;br /&gt;
Parameters are given by their full PHIL path with defaults in parentheses. The program exposes many&lt;br /&gt;
more parameters (see &amp;lt;code&amp;gt;-c -e 10 -a 2&amp;lt;/code&amp;gt;); those below are the ones most commonly set.&lt;br /&gt;
&lt;br /&gt;
=== Input ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.path&amp;lt;/code&amp;gt; || None || Path(s) to the integrated data — a folder, several folders, or individual files; wildcards allowed; may be repeated. Matching &amp;lt;code&amp;gt;.expt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;.refl&amp;lt;/code&amp;gt; files must both be present.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.experiments_suffix&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;_integrated.expt&amp;lt;/code&amp;gt; || Only load experiment files ending with this suffix.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.reflections_suffix&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;_integrated.refl&amp;lt;/code&amp;gt; || Only load reflection files ending with this suffix.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.parallel_file_load.method&amp;lt;/code&amp;gt; || uniform || &amp;lt;code&amp;gt;uniform&amp;lt;/code&amp;gt; spreads input files evenly over all ranks; &amp;lt;code&amp;gt;node_memory&amp;lt;/code&amp;gt; distributes so per-node memory limits are respected.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.alist.file&amp;lt;/code&amp;gt; || None || Path to a text file of experiment tags or filenames; combined with &amp;lt;code&amp;gt;input.alist.op=keep|reject&amp;lt;/code&amp;gt; to merge only (or exclude) a specified subset.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.persistent_refl_cols&amp;lt;/code&amp;gt; || None || Reflection-table columns to preserve through the pruning steps (and into saved tables).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Filtering whole experiments (&amp;lt;code&amp;gt;filter&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;filter&amp;lt;/code&amp;gt; section accepts or rejects &#039;&#039;&#039;entire experiments&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.algorithm&amp;lt;/code&amp;gt; || (none) || One or more of &amp;lt;code&amp;gt;n_obs&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;resolution&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;unit_cell&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;energy&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bootstrap&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;experiment_prefix&amp;lt;/code&amp;gt;. Nothing is filtered unless listed.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.unit_cell.algorithm&amp;lt;/code&amp;gt; || value || How to restrict unit cells: &amp;lt;code&amp;gt;value&amp;lt;/code&amp;gt; (compare to a target), &amp;lt;code&amp;gt;range&amp;lt;/code&amp;gt;, or &amp;lt;code&amp;gt;cluster&amp;lt;/code&amp;gt; (use a precomputed covariance clustering).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.unit_cell.value.relative_length_tolerance&amp;lt;/code&amp;gt; || 0.1 || Fractional deviation of cell edge lengths allowed vs. the target cell. Often tightened (e.g. 0.03).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.unit_cell.value.absolute_angle_tolerance&amp;lt;/code&amp;gt; || 2.0 || Allowed cell-angle deviation (degrees) vs. the target.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.unit_cell.value.target_unit_cell&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;target_space_group&amp;lt;/code&amp;gt; || Auto || Target cell/symmetry; &amp;lt;code&amp;gt;Auto&amp;lt;/code&amp;gt; uses the scaling model.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.outlier.min_corr&amp;lt;/code&amp;gt; || 0.1 || Minimum correlation of an image&#039;s intensities to the reference model; images below this are rejected. Only applied when a scaling model is present. Use &amp;lt;code&amp;gt;-1&amp;lt;/code&amp;gt; to accept all images regardless of correlation.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.resolution.d_min&amp;lt;/code&amp;gt; || None || Reject an experiment unless some of its reflections extend beyond this resolution.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Selecting individual reflections (&amp;lt;code&amp;gt;select&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;select&amp;lt;/code&amp;gt; section accepts or rejects &#039;&#039;&#039;individual reflections&#039;&#039;&#039; (contrast with&lt;br /&gt;
&amp;lt;code&amp;gt;filter&amp;lt;/code&amp;gt;, which acts on whole experiments).&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;select.algorithm&amp;lt;/code&amp;gt; || (none) || One or more of &amp;lt;code&amp;gt;significance_filter&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;panel&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cspad_sensor&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;isolation_forest&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;target_energy&amp;lt;/code&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;select.significance_filter.sigma&amp;lt;/code&amp;gt; || 0.5 || Trim each lattice at the resolution where the binned ⟨I/σ⟩ drops below this value.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;select.significance_filter.min_ct&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;max_ct&amp;lt;/code&amp;gt; || 10 / 50 || Target minimum/maximum mean reflections per resolution bin when choosing the number of bins. For large unit cells these are often raised (e.g. 200/300); for small cells, use the defaults.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Modifying intensities (&amp;lt;code&amp;gt;modify&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;modify.algorithm&amp;lt;/code&amp;gt; || polarization || Per-reflection corrections to apply (default applies the polarization correction).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;modify.cosym&amp;lt;/code&amp;gt; || — || Resolve an indexing ambiguity across the ensemble using the Gildea/Winter (Brehm/Diederichs) cosym method, optionally anchored to &amp;lt;code&amp;gt;scaling.model&amp;lt;/code&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;modify.reindex_to_reference&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;reindex_to_abc&amp;lt;/code&amp;gt; || — || Alternative re-indexing operators (to a reference model, or an explicit operator).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Scaling (&amp;lt;code&amp;gt;scaling&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;scaling.model&amp;lt;/code&amp;gt; || None || Reference dataset: a PDB file (uses the CRYST1 cell and computes model intensities, including bulk solvent) or an MTZ from a previous cycle. Required for &amp;lt;code&amp;gt;mark0&amp;lt;/code&amp;gt; scaling.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;scaling.algorithm&amp;lt;/code&amp;gt; || mark0 || &amp;lt;code&amp;gt;mark0&amp;lt;/code&amp;gt;: per-image scaling against the reference. &amp;lt;code&amp;gt;mark1&amp;lt;/code&amp;gt;: no scaling, just Monte-Carlo averaging (all scale factors = 1) — used for reference-free bootstrap.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;scaling.unit_cell&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;scaling.space_group&amp;lt;/code&amp;gt; || None || Cell/symmetry to use when no model is provided (i.e. &amp;lt;code&amp;gt;mark1&amp;lt;/code&amp;gt;).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;scaling.resolution_scalar&amp;lt;/code&amp;gt; || 0.969 || &amp;lt;code&amp;gt;merging.d_min&amp;lt;/code&amp;gt; is multiplied by this when deciding which reflections fall within the resolution limit, generating a few extra reference reflections to account for per-shot cell variation (e.g. set 0.96 for a few more).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;scaling.mtz.mtz_column_F&amp;lt;/code&amp;gt; || fobs || Column name in the reference MTZ containing the reference structure factors (intensities or amplitudes).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Post-refinement (&amp;lt;code&amp;gt;postrefinement&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;postrefinement.enable&amp;lt;/code&amp;gt; || True || Enable post-refinement of per-image parameters/partialities (Sauter 2015).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;postrefinement.algorithm&amp;lt;/code&amp;gt; || rs || Post-refinement protocol: &amp;lt;code&amp;gt;rs&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;rs2&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;rs_hybrid&amp;lt;/code&amp;gt;, or &amp;lt;code&amp;gt;eta_deff&amp;lt;/code&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Merging and error model (&amp;lt;code&amp;gt;merging&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;merging.d_min&amp;lt;/code&amp;gt; || None || High-resolution limit for scaling and merging.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;merging.d_max&amp;lt;/code&amp;gt; || None || Low-resolution limit (currently affects only CCiso).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;merging.merge_anomalous&amp;lt;/code&amp;gt; || False || &amp;lt;code&amp;gt;True&amp;lt;/code&amp;gt; merges Bijvoet mates together (higher multiplicity); &amp;lt;code&amp;gt;False&amp;lt;/code&amp;gt; keeps them separate to preserve the anomalous signal.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;merging.minimum_multiplicity&amp;lt;/code&amp;gt; || 2 || Do not produce a merged structure factor for HKLs measured fewer than this many times.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;merging.error.model&amp;lt;/code&amp;gt; || mm24 || Merged-sigma error model: &amp;lt;code&amp;gt;mm24&amp;lt;/code&amp;gt; (Mittan-Moreau 2024, current default), &amp;lt;code&amp;gt;ev11&amp;lt;/code&amp;gt; (Evans 2011 / sdfac-refine, recommended in the README), &amp;lt;code&amp;gt;ha14&amp;lt;/code&amp;gt;, or &amp;lt;code&amp;gt;errors_from_sample_residuals&amp;lt;/code&amp;gt; (no refined error terms — used with &amp;lt;code&amp;gt;mark1&amp;lt;/code&amp;gt; bootstrap).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;merging.set_average_unit_cell&amp;lt;/code&amp;gt; || True || Output MTZ adopts the (cluster-derived) average unit cell of the data rather than the reference model&#039;s cell.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Statistics (&amp;lt;code&amp;gt;statistics&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;statistics.n_bins&amp;lt;/code&amp;gt; || 10 || Number of resolution bins in the statistics tables.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;statistics.cciso.mtz_file&amp;lt;/code&amp;gt; || None || Isomorphous reference structure factors for R&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt; / CC&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;statistics.report_ML&amp;lt;/code&amp;gt; || True || Report per-frame max-likelihood attributes (domain size, mosaicity).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Output (&amp;lt;code&amp;gt;output&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.output_dir&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;.&amp;lt;/code&amp;gt; || Directory for output files (created if it does not exist).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.prefix&amp;lt;/code&amp;gt; || iobs || Prefix prepended to all output file names.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.save_experiments_and_reflections&amp;lt;/code&amp;gt; || False || Dump the final experiments/reflections from the last worker as DIALS files — used for the two-stage scale-then-merge workflow.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.do_timing&amp;lt;/code&amp;gt; || False || Log elapsed time per execution step.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.expanded_bookkeeping&amp;lt;/code&amp;gt; || False || Store extra provenance columns (input file/reflection indices, odd/even flag, original id) in the saved reflection tables.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Multiprocessing (&amp;lt;code&amp;gt;mp&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mp.method&amp;lt;/code&amp;gt; || mpi || Multiprocessing method (only &amp;lt;code&amp;gt;mpi&amp;lt;/code&amp;gt; is currently supported).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mp.debug.cProfile&amp;lt;/code&amp;gt; || False || Enable code profiling; a &amp;lt;code&amp;gt;.prof&amp;lt;/code&amp;gt; file is written per rank.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Output files ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;merge&amp;lt;/code&amp;gt; worker gathers all HKLs at rank 0 and writes three MTZ files, prefixed with&lt;br /&gt;
&amp;lt;code&amp;gt;output.prefix&amp;lt;/code&amp;gt; (default &amp;lt;code&amp;gt;iobs&amp;lt;/code&amp;gt;):&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;amp;lt;prefix&amp;amp;gt;_all.mtz&amp;lt;/code&amp;gt; — the merged dataset using all observations (the main result for structure solution)&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;amp;lt;prefix&amp;amp;gt;_odd.mtz&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;&amp;amp;lt;prefix&amp;amp;gt;_even.mtz&amp;lt;/code&amp;gt; — the two half-datasets used for CC½ and related half-dataset statistics&lt;br /&gt;
&lt;br /&gt;
A main log records the per-step progress and the merging statistics tables (completeness,&lt;br /&gt;
multiplicity, ⟨I/σ⟩, CC½, CC*, R-factors) by resolution bin. The merged MTZ can optionally be&lt;br /&gt;
uploaded to a shared [https://github.com/cctbx/cctbx_project/tree/master/xfel/merging/application/publish Google Drive folder] by adding the &amp;lt;code&amp;gt;publish&amp;lt;/code&amp;gt; worker.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
* Sauter NK (2015). &#039;&#039;J Synchrotron Radiat&#039;&#039; &#039;&#039;&#039;22&#039;&#039;&#039;, 239–48. (post-refinement)&lt;br /&gt;
* Uervirojnangkoorn M, &#039;&#039;et al.&#039;&#039; (2015). &#039;&#039;eLife&#039;&#039; 10.7554/eLife.05421. (PRIME / bootstrap)&lt;br /&gt;
* Brewster AS, &#039;&#039;et al.&#039;&#039; (2018). &#039;&#039;Acta Cryst.&#039;&#039; D &#039;&#039;&#039;74&#039;&#039;&#039;, 877–894.&lt;br /&gt;
* Brewster AS, &#039;&#039;et al.&#039;&#039; (2019a). &#039;&#039;Computational Crystallography Newsletter&#039;&#039; &#039;&#039;&#039;10&#039;&#039;&#039;, 22–39. (XFEL GUI)&lt;br /&gt;
* Brewster AS, &#039;&#039;et al.&#039;&#039; (2019b). &#039;&#039;Acta Cryst.&#039;&#039; D &#039;&#039;&#039;75&#039;&#039;&#039;, 959–968. (error models)&lt;br /&gt;
* Mittan-Moreau (2024). (mm24 error model)&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
* [[dials.stills_process]] — produces the integrated data that &amp;lt;code&amp;gt;cctbx.xfel.merge&amp;lt;/code&amp;gt; consumes&lt;br /&gt;
* [[cctbx.xfel GUI]] — orchestrates separate scaling and repeated merging as data are collected&lt;br /&gt;
* The program README at &amp;lt;code&amp;gt;xfel/merging/README.md&amp;lt;/code&amp;gt; in cctbx_project&lt;/div&gt;</summary>
		<author><name>Aaron</name></author>
	</entry>
	<entry>
		<id>http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Cctbx.xfel.merge&amp;diff=1770</id>
		<title>Cctbx.xfel.merge</title>
		<link rel="alternate" type="text/html" href="http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Cctbx.xfel.merge&amp;diff=1770"/>
		<updated>2026-08-21T22:58:36Z</updated>

		<summary type="html">&lt;p&gt;Aaron: /* cctbx.xfel.merge */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= &#039;&#039;cctbx.xfel.merge&#039;&#039; =&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;cctbx.xfel.merge&#039;&#039;&#039;&#039;&#039; is the scaling, post-refinement and merging program of cctbx.xfel. It takes&lt;br /&gt;
the per-image integrated results produced by &#039;&#039;[[dials.stills_process]]&#039;&#039; — one crystal per still shot —&lt;br /&gt;
and reduces the whole ensemble to a single set of merged structure-factor intensities (an MTZ file)&lt;br /&gt;
suitable for structure solution and refinement, together with the crystallographic quality&lt;br /&gt;
statistics (completeness, multiplicity, CC½, R-factors, etc.).&lt;br /&gt;
&lt;br /&gt;
Because serial datasets routinely contain tens of thousands to millions of still shots,&lt;br /&gt;
&amp;lt;code&amp;gt;cctbx.xfel.merge&amp;lt;/code&amp;gt; is built from the ground up to run under MPI across many nodes. It is&lt;br /&gt;
almost always launched with &amp;lt;code&amp;gt;mpirun&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;srun&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;cctbx.xfel.merge&amp;lt;/code&amp;gt; is organized as a sequence of &#039;&#039;&#039;workers&#039;&#039;&#039;. Each worker performs one&lt;br /&gt;
task — reading data, applying a correction, filtering, scaling, post-refining, computing a statistic,&lt;br /&gt;
or merging — and passes its (possibly modified) experiments and reflections on to the next worker.&lt;br /&gt;
The list of workers to run is the &amp;quot;step list&amp;quot;, and it is fully configurable: you can add, remove or&lt;br /&gt;
reorder steps with &amp;lt;code&amp;gt;dispatch.step_list&amp;lt;/code&amp;gt;. This is what makes the program flexible enough to&lt;br /&gt;
scale-and-merge in one pass, to scale subsets separately and merge later, or to run a reference-free&lt;br /&gt;
bootstrap.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;default&#039;&#039;&#039; step list is:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! # !! Worker !! Purpose&lt;br /&gt;
|-&lt;br /&gt;
| 1 || &amp;lt;code&amp;gt;input&amp;lt;/code&amp;gt; || Read integrated experiments (&amp;lt;code&amp;gt;.expt&amp;lt;/code&amp;gt;) and reflections (&amp;lt;code&amp;gt;.refl&amp;lt;/code&amp;gt;) from disk in DIALS format.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || &amp;lt;code&amp;gt;balance&amp;lt;/code&amp;gt; || Redistribute the input load evenly across MPI ranks (needed when there are fewer input files than ranks).&lt;br /&gt;
|-&lt;br /&gt;
| 3 || &amp;lt;code&amp;gt;model_scaling&amp;lt;/code&amp;gt; || Build the full Miller list, model intensities from the reference, and the resolution binner used for scaling and post-refinement.&lt;br /&gt;
|-&lt;br /&gt;
| 4 || &amp;lt;code&amp;gt;modify&amp;lt;/code&amp;gt; || Apply per-reflection modifications, e.g. polarization correction (and optionally re-indexing to resolve indexing ambiguity — see &amp;lt;code&amp;gt;modify.cosym&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;reindex_to_reference&amp;lt;/code&amp;gt;).&lt;br /&gt;
|-&lt;br /&gt;
| 5 || &amp;lt;code&amp;gt;filter&amp;lt;/code&amp;gt; || Reject whole experiments (or reflections) by resolution, unit cell, correlation to the reference, energy, etc.&lt;br /&gt;
|-&lt;br /&gt;
| 6 || &amp;lt;code&amp;gt;scale&amp;lt;/code&amp;gt; || Scale each lattice to the reference dataset (&amp;lt;code&amp;gt;mark0&amp;lt;/code&amp;gt;) or simply average (&amp;lt;code&amp;gt;mark1&amp;lt;/code&amp;gt;).&lt;br /&gt;
|-&lt;br /&gt;
| 7 || &amp;lt;code&amp;gt;postrefine&amp;lt;/code&amp;gt; || Post-refine per-image crystal parameters and partialities (Sauter 2015).&lt;br /&gt;
|-&lt;br /&gt;
| 8 || &amp;lt;code&amp;gt;statistics_unitcell&amp;lt;/code&amp;gt; || Determine and store the average unit cell.&lt;br /&gt;
|-&lt;br /&gt;
| 9 || &amp;lt;code&amp;gt;statistics_beam&amp;lt;/code&amp;gt; || Determine and store the average wavelength.&lt;br /&gt;
|-&lt;br /&gt;
| 10 || &amp;lt;code&amp;gt;model_statistics&amp;lt;/code&amp;gt; || Rebuild the Miller list / binner for statistics (may use the average unit cell).&lt;br /&gt;
|-&lt;br /&gt;
| 11 || &amp;lt;code&amp;gt;statistics_resolution&amp;lt;/code&amp;gt; || Per-crystal resolution statistics.&lt;br /&gt;
|-&lt;br /&gt;
| 12 || &amp;lt;code&amp;gt;group&amp;lt;/code&amp;gt; || Redistribute reflections across ranks so that every observation of a given HKL is gathered on the same rank prior to merging.&lt;br /&gt;
|-&lt;br /&gt;
| 13 || &amp;lt;code&amp;gt;errors_merge&amp;lt;/code&amp;gt; || Correct the merged error estimates with a per-HKL error model (e.g. Ev11, Brewster 2019b).&lt;br /&gt;
|-&lt;br /&gt;
| 14 || &amp;lt;code&amp;gt;statistics_intensity&amp;lt;/code&amp;gt; || Intensity statistics by resolution.&lt;br /&gt;
|-&lt;br /&gt;
| 15 || &amp;lt;code&amp;gt;merge&amp;lt;/code&amp;gt; || Merge symmetry-equivalent intensities, gather all HKLs at rank 0, and write &amp;quot;odd&amp;quot;, &amp;quot;even&amp;quot; and &amp;quot;all&amp;quot; MTZ files.&lt;br /&gt;
|-&lt;br /&gt;
| 16 || &amp;lt;code&amp;gt;statistics_intensity_cxi&amp;lt;/code&amp;gt; || CC½ / CC* and related statistics (ported from cxi.merge).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Additional, non-default workers are available in &amp;lt;code&amp;gt;xfel/merging/application/&amp;lt;/code&amp;gt; and can be&lt;br /&gt;
inserted into the step list, including &amp;lt;code&amp;gt;tdata&amp;lt;/code&amp;gt; (write out unit cells for clustering),&lt;br /&gt;
&amp;lt;code&amp;gt;export&amp;lt;/code&amp;gt; (batch MTZ for &#039;&#039;Careless&#039;&#039;), &amp;lt;code&amp;gt;publish&amp;lt;/code&amp;gt; (upload merged files to a&lt;br /&gt;
Google Drive folder), &amp;lt;code&amp;gt;monitor&amp;lt;/code&amp;gt; (resource-usage logging), &amp;lt;code&amp;gt;integrate&amp;lt;/code&amp;gt;&lt;br /&gt;
(on-the-fly integration from psana2/XTC2), &amp;lt;code&amp;gt;prepare&amp;lt;/code&amp;gt; (SpReAD energy binning), and&lt;br /&gt;
&amp;lt;code&amp;gt;lunus&amp;lt;/code&amp;gt; (diffuse-scattering deck). A &amp;lt;code&amp;gt;deltaccint&amp;lt;/code&amp;gt; worker (ΔCC½ lattice&lt;br /&gt;
filtering) can be added after &amp;lt;code&amp;gt;group&amp;lt;/code&amp;gt;. Custom workers can be supplied through the&lt;br /&gt;
&amp;lt;code&amp;gt;XFEL_CUSTOM_WORKER_PATH&amp;lt;/code&amp;gt; environment variable.&lt;br /&gt;
&lt;br /&gt;
== Basic usage ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;cctbx.xfel.merge&amp;lt;/code&amp;gt; is run under MPI:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mpirun cctbx.xfel.merge merge.phil&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A typical &amp;lt;code&amp;gt;merge.phil&amp;lt;/code&amp;gt; (from the program README):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
input.path=&amp;lt;path to data&amp;gt;&lt;br /&gt;
input.experiments_suffix=.expt&lt;br /&gt;
input.reflections_suffix=.refl&lt;br /&gt;
&lt;br /&gt;
filter.algorithm=unit_cell&lt;br /&gt;
filter.unit_cell.value.relative_length_tolerance=0.03&lt;br /&gt;
filter.outlier.min_corr=0.1&lt;br /&gt;
&lt;br /&gt;
select.algorithm=significance_filter&lt;br /&gt;
select.significance_filter.sigma=0.1&lt;br /&gt;
select.significance_filter.min_ct=200&lt;br /&gt;
select.significance_filter.max_ct=300&lt;br /&gt;
&lt;br /&gt;
scaling.model=&amp;lt;model.pdb or model.mtz&amp;gt;&lt;br /&gt;
scaling.resolution_scalar=0.96&lt;br /&gt;
&lt;br /&gt;
merging.d_min=1.8&lt;br /&gt;
merging.error.model=ev11&lt;br /&gt;
merging.merge_anomalous=True&lt;br /&gt;
&lt;br /&gt;
postrefinement.enable=True&lt;br /&gt;
statistics.n_bins=20&lt;br /&gt;
&lt;br /&gt;
output.do_timing=True&lt;br /&gt;
output.output_dir=&amp;lt;output folder&amp;gt;&lt;br /&gt;
output.prefix=&amp;lt;prefix for output files&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Explore the parameters with:&lt;br /&gt;
* &amp;lt;code&amp;gt;cctbx.xfel.merge -c&amp;lt;/code&amp;gt; — show configurable parameters&lt;br /&gt;
* &amp;lt;code&amp;gt;cctbx.xfel.merge -c -e 10 -a 2&amp;lt;/code&amp;gt; — show all parameters (expert level 10) with full help text&lt;br /&gt;
&lt;br /&gt;
== Two-stage scaling and merging ==&lt;br /&gt;
&lt;br /&gt;
For large, growing datasets (the mode used by the [[cctbx.xfel GUI]]), it is more efficient to scale&lt;br /&gt;
and post-refine each subset of data &#039;&#039;&#039;once&#039;&#039;&#039;, then merge repeatedly as more data arrive. This is&lt;br /&gt;
done by running the program twice with different step lists.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Stage 1 — scale each subset&#039;&#039;&#039; (stops after per-image work and writes intermediate DIALS files):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dispatch.step_list=input balance model_scaling modify filter scale postrefine \&lt;br /&gt;
    statistics_unitcell statistics_beam model_statistics statistics_resolution&lt;br /&gt;
input.parallel_file_load.method=uniform&lt;br /&gt;
output.save_experiments_and_reflections=True&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;output.save_experiments_and_reflections=True&amp;lt;/code&amp;gt; dumps the scaled/post-refined data as&lt;br /&gt;
experiment lists and reflection tables that the merge stage can read back in.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Stage 2 — merge the scaled subsets&#039;&#039;&#039; (add an &amp;lt;code&amp;gt;input.path&amp;lt;/code&amp;gt; for each finished subset):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dispatch.step_list=input model_scaling statistics_unitcell statistics_beam \&lt;br /&gt;
    model_statistics statistics_resolution group errors_merge statistics_intensity \&lt;br /&gt;
    merge statistics_intensity_cxi&lt;br /&gt;
input.parallel_file_load.method=uniform&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Merging without a reference (bootstrap / mark1) ==&lt;br /&gt;
&lt;br /&gt;
If no scaling/merging reference is available, use a bootstrap procedure. First run the&lt;br /&gt;
&amp;lt;code&amp;gt;mark1&amp;lt;/code&amp;gt; algorithm, which simply averages the data (all per-image scale factors = 1, no&lt;br /&gt;
post-refinement), specifying the target cell and symmetry explicitly:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
scaling.algorithm=mark1&lt;br /&gt;
scaling.unit_cell=&amp;lt;unit cell&amp;gt;&lt;br /&gt;
scaling.space_group=&amp;lt;space group&amp;gt;&lt;br /&gt;
merging.error.model=errors_from_sample_residuals&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The resulting MTZ is then used as the reference (&amp;lt;code&amp;gt;scaling.model=&amp;lt;/code&amp;gt;) for subsequent regular&lt;br /&gt;
merges. Iterate a few cycles; CC½ typically improves and converges over the first few rounds.&lt;br /&gt;
&lt;br /&gt;
== Important parameters ==&lt;br /&gt;
&lt;br /&gt;
Parameters are given by their full PHIL path with defaults in parentheses. The program exposes many&lt;br /&gt;
more parameters (see &amp;lt;code&amp;gt;-c -e 10 -a 2&amp;lt;/code&amp;gt;); those below are the ones most commonly set.&lt;br /&gt;
&lt;br /&gt;
=== Input ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.path&amp;lt;/code&amp;gt; || None || Path(s) to the integrated data — a folder, several folders, or individual files; wildcards allowed; may be repeated. Matching &amp;lt;code&amp;gt;.expt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;.refl&amp;lt;/code&amp;gt; files must both be present.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.experiments_suffix&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;_integrated.expt&amp;lt;/code&amp;gt; || Only load experiment files ending with this suffix.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.reflections_suffix&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;_integrated.refl&amp;lt;/code&amp;gt; || Only load reflection files ending with this suffix.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.parallel_file_load.method&amp;lt;/code&amp;gt; || uniform || &amp;lt;code&amp;gt;uniform&amp;lt;/code&amp;gt; spreads input files evenly over all ranks; &amp;lt;code&amp;gt;node_memory&amp;lt;/code&amp;gt; distributes so per-node memory limits are respected.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.alist.file&amp;lt;/code&amp;gt; || None || Path to a text file of experiment tags or filenames; combined with &amp;lt;code&amp;gt;input.alist.op=keep|reject&amp;lt;/code&amp;gt; to merge only (or exclude) a specified subset.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.persistent_refl_cols&amp;lt;/code&amp;gt; || None || Reflection-table columns to preserve through the pruning steps (and into saved tables).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Filtering whole experiments (&amp;lt;code&amp;gt;filter&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;filter&amp;lt;/code&amp;gt; section accepts or rejects &#039;&#039;&#039;entire experiments&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.algorithm&amp;lt;/code&amp;gt; || (none) || One or more of &amp;lt;code&amp;gt;n_obs&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;resolution&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;unit_cell&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;energy&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bootstrap&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;experiment_prefix&amp;lt;/code&amp;gt;. Nothing is filtered unless listed.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.unit_cell.algorithm&amp;lt;/code&amp;gt; || value || How to restrict unit cells: &amp;lt;code&amp;gt;value&amp;lt;/code&amp;gt; (compare to a target), &amp;lt;code&amp;gt;range&amp;lt;/code&amp;gt;, or &amp;lt;code&amp;gt;cluster&amp;lt;/code&amp;gt; (use a precomputed covariance clustering).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.unit_cell.value.relative_length_tolerance&amp;lt;/code&amp;gt; || 0.1 || Fractional deviation of cell edge lengths allowed vs. the target cell. Often tightened (e.g. 0.03).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.unit_cell.value.absolute_angle_tolerance&amp;lt;/code&amp;gt; || 2.0 || Allowed cell-angle deviation (degrees) vs. the target.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.unit_cell.value.target_unit_cell&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;target_space_group&amp;lt;/code&amp;gt; || Auto || Target cell/symmetry; &amp;lt;code&amp;gt;Auto&amp;lt;/code&amp;gt; uses the scaling model.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.outlier.min_corr&amp;lt;/code&amp;gt; || 0.1 || Minimum correlation of an image&#039;s intensities to the reference model; images below this are rejected. Only applied when a scaling model is present. Use &amp;lt;code&amp;gt;-1&amp;lt;/code&amp;gt; to accept all images regardless of correlation.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.resolution.d_min&amp;lt;/code&amp;gt; || None || Reject an experiment unless some of its reflections extend beyond this resolution.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Selecting individual reflections (&amp;lt;code&amp;gt;select&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;select&amp;lt;/code&amp;gt; section accepts or rejects &#039;&#039;&#039;individual reflections&#039;&#039;&#039; (contrast with&lt;br /&gt;
&amp;lt;code&amp;gt;filter&amp;lt;/code&amp;gt;, which acts on whole experiments).&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;select.algorithm&amp;lt;/code&amp;gt; || (none) || One or more of &amp;lt;code&amp;gt;significance_filter&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;panel&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cspad_sensor&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;isolation_forest&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;target_energy&amp;lt;/code&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;select.significance_filter.sigma&amp;lt;/code&amp;gt; || 0.5 || Trim each lattice at the resolution where the binned ⟨I/σ⟩ drops below this value.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;select.significance_filter.min_ct&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;max_ct&amp;lt;/code&amp;gt; || 10 / 50 || Target minimum/maximum mean reflections per resolution bin when choosing the number of bins. For large unit cells these are often raised (e.g. 200/300); for small cells, use the defaults.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Modifying intensities (&amp;lt;code&amp;gt;modify&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;modify.algorithm&amp;lt;/code&amp;gt; || polarization || Per-reflection corrections to apply (default applies the polarization correction).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;modify.cosym&amp;lt;/code&amp;gt; || — || Resolve an indexing ambiguity across the ensemble using the Gildea/Winter (Brehm/Diederichs) cosym method, optionally anchored to &amp;lt;code&amp;gt;scaling.model&amp;lt;/code&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;modify.reindex_to_reference&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;reindex_to_abc&amp;lt;/code&amp;gt; || — || Alternative re-indexing operators (to a reference model, or an explicit operator).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Scaling (&amp;lt;code&amp;gt;scaling&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;scaling.model&amp;lt;/code&amp;gt; || None || Reference dataset: a PDB file (uses the CRYST1 cell and computes model intensities, including bulk solvent) or an MTZ from a previous cycle. Required for &amp;lt;code&amp;gt;mark0&amp;lt;/code&amp;gt; scaling.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;scaling.algorithm&amp;lt;/code&amp;gt; || mark0 || &amp;lt;code&amp;gt;mark0&amp;lt;/code&amp;gt;: per-image scaling against the reference. &amp;lt;code&amp;gt;mark1&amp;lt;/code&amp;gt;: no scaling, just Monte-Carlo averaging (all scale factors = 1) — used for reference-free bootstrap.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;scaling.unit_cell&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;scaling.space_group&amp;lt;/code&amp;gt; || None || Cell/symmetry to use when no model is provided (i.e. &amp;lt;code&amp;gt;mark1&amp;lt;/code&amp;gt;).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;scaling.resolution_scalar&amp;lt;/code&amp;gt; || 0.969 || &amp;lt;code&amp;gt;merging.d_min&amp;lt;/code&amp;gt; is multiplied by this when deciding which reflections fall within the resolution limit, generating a few extra reference reflections to account for per-shot cell variation (e.g. set 0.96 for a few more).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;scaling.mtz.mtz_column_F&amp;lt;/code&amp;gt; || fobs || Column name in the reference MTZ containing the reference structure factors (intensities or amplitudes).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Post-refinement (&amp;lt;code&amp;gt;postrefinement&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;postrefinement.enable&amp;lt;/code&amp;gt; || True || Enable post-refinement of per-image parameters/partialities (Sauter 2015).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;postrefinement.algorithm&amp;lt;/code&amp;gt; || rs || Post-refinement protocol: &amp;lt;code&amp;gt;rs&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;rs2&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;rs_hybrid&amp;lt;/code&amp;gt;, or &amp;lt;code&amp;gt;eta_deff&amp;lt;/code&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Merging and error model (&amp;lt;code&amp;gt;merging&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;merging.d_min&amp;lt;/code&amp;gt; || None || High-resolution limit for scaling and merging.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;merging.d_max&amp;lt;/code&amp;gt; || None || Low-resolution limit (currently affects only CCiso).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;merging.merge_anomalous&amp;lt;/code&amp;gt; || False || &amp;lt;code&amp;gt;True&amp;lt;/code&amp;gt; merges Bijvoet mates together (higher multiplicity); &amp;lt;code&amp;gt;False&amp;lt;/code&amp;gt; keeps them separate to preserve the anomalous signal.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;merging.minimum_multiplicity&amp;lt;/code&amp;gt; || 2 || Do not produce a merged structure factor for HKLs measured fewer than this many times.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;merging.error.model&amp;lt;/code&amp;gt; || mm24 || Merged-sigma error model: &amp;lt;code&amp;gt;mm24&amp;lt;/code&amp;gt; (Mittan-Moreau 2024, current default), &amp;lt;code&amp;gt;ev11&amp;lt;/code&amp;gt; (Evans 2011 / sdfac-refine, recommended in the README), &amp;lt;code&amp;gt;ha14&amp;lt;/code&amp;gt;, or &amp;lt;code&amp;gt;errors_from_sample_residuals&amp;lt;/code&amp;gt; (no refined error terms — used with &amp;lt;code&amp;gt;mark1&amp;lt;/code&amp;gt; bootstrap).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;merging.set_average_unit_cell&amp;lt;/code&amp;gt; || True || Output MTZ adopts the (cluster-derived) average unit cell of the data rather than the reference model&#039;s cell.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Statistics (&amp;lt;code&amp;gt;statistics&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;statistics.n_bins&amp;lt;/code&amp;gt; || 10 || Number of resolution bins in the statistics tables.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;statistics.cciso.mtz_file&amp;lt;/code&amp;gt; || None || Isomorphous reference structure factors for R&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt; / CC&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;statistics.report_ML&amp;lt;/code&amp;gt; || True || Report per-frame max-likelihood attributes (domain size, mosaicity).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Output (&amp;lt;code&amp;gt;output&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.output_dir&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;.&amp;lt;/code&amp;gt; || Directory for output files (created if it does not exist).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.prefix&amp;lt;/code&amp;gt; || iobs || Prefix prepended to all output file names.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.save_experiments_and_reflections&amp;lt;/code&amp;gt; || False || Dump the final experiments/reflections from the last worker as DIALS files — used for the two-stage scale-then-merge workflow.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.do_timing&amp;lt;/code&amp;gt; || False || Log elapsed time per execution step.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.expanded_bookkeeping&amp;lt;/code&amp;gt; || False || Store extra provenance columns (input file/reflection indices, odd/even flag, original id) in the saved reflection tables.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Multiprocessing (&amp;lt;code&amp;gt;mp&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mp.method&amp;lt;/code&amp;gt; || mpi || Multiprocessing method (only &amp;lt;code&amp;gt;mpi&amp;lt;/code&amp;gt; is currently supported).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mp.debug.cProfile&amp;lt;/code&amp;gt; || False || Enable code profiling; a &amp;lt;code&amp;gt;.prof&amp;lt;/code&amp;gt; file is written per rank.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Output files ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;merge&amp;lt;/code&amp;gt; worker gathers all HKLs at rank 0 and writes three MTZ files, prefixed with&lt;br /&gt;
&amp;lt;code&amp;gt;output.prefix&amp;lt;/code&amp;gt; (default &amp;lt;code&amp;gt;iobs&amp;lt;/code&amp;gt;):&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;amp;lt;prefix&amp;amp;gt;_all.mtz&amp;lt;/code&amp;gt; — the merged dataset using all observations (the main result for structure solution)&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;amp;lt;prefix&amp;amp;gt;_odd.mtz&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;&amp;amp;lt;prefix&amp;amp;gt;_even.mtz&amp;lt;/code&amp;gt; — the two half-datasets used for CC½ and related half-dataset statistics&lt;br /&gt;
&lt;br /&gt;
A main log records the per-step progress and the merging statistics tables (completeness,&lt;br /&gt;
multiplicity, ⟨I/σ⟩, CC½, CC*, R-factors) by resolution bin. The merged MTZ can optionally be&lt;br /&gt;
uploaded to a shared [https://github.com/cctbx/cctbx_project/tree/master/xfel/merging/application/publish Google Drive folder] by adding the &amp;lt;code&amp;gt;publish&amp;lt;/code&amp;gt; worker.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
* Sauter NK (2015). &#039;&#039;J Synchrotron Radiat&#039;&#039; &#039;&#039;&#039;22&#039;&#039;&#039;, 239–48. (post-refinement)&lt;br /&gt;
* Uervirojnangkoorn M, &#039;&#039;et al.&#039;&#039; (2015). &#039;&#039;eLife&#039;&#039; 10.7554/eLife.05421. (PRIME / bootstrap)&lt;br /&gt;
* Brewster AS, &#039;&#039;et al.&#039;&#039; (2018). &#039;&#039;Acta Cryst.&#039;&#039; D &#039;&#039;&#039;74&#039;&#039;&#039;, 877–894.&lt;br /&gt;
* Brewster AS, &#039;&#039;et al.&#039;&#039; (2019a). &#039;&#039;Computational Crystallography Newsletter&#039;&#039; &#039;&#039;&#039;10&#039;&#039;&#039;, 22–39. (XFEL GUI)&lt;br /&gt;
* Brewster AS, &#039;&#039;et al.&#039;&#039; (2019b). &#039;&#039;Acta Cryst.&#039;&#039; D &#039;&#039;&#039;75&#039;&#039;&#039;, 959–968. (error models)&lt;br /&gt;
* Mittan-Moreau (2024). (mm24 error model)&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
* [[dials.stills_process]] — produces the integrated data that &amp;lt;code&amp;gt;cctbx.xfel.merge&amp;lt;/code&amp;gt; consumes&lt;br /&gt;
* [[cctbx.xfel GUI]] — orchestrates separate scaling and repeated merging as data are collected&lt;br /&gt;
* The program README at &amp;lt;code&amp;gt;xfel/merging/README.md&amp;lt;/code&amp;gt; in cctbx_project&lt;/div&gt;</summary>
		<author><name>Aaron</name></author>
	</entry>
	<entry>
		<id>http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Cctbx.xfel.merge&amp;diff=1769</id>
		<title>Cctbx.xfel.merge</title>
		<link rel="alternate" type="text/html" href="http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Cctbx.xfel.merge&amp;diff=1769"/>
		<updated>2026-08-21T22:57:30Z</updated>

		<summary type="html">&lt;p&gt;Aaron: Created page with &amp;quot;= &amp;#039;&amp;#039;cctbx.xfel.merge&amp;#039;&amp;#039; =  &amp;#039;&amp;#039;&amp;#039;&amp;#039;&amp;#039;cctbx.xfel.merge&amp;#039;&amp;#039;&amp;#039;&amp;#039;&amp;#039; is the scaling, post-refinement and merging program of cctbx.xfel. It takes the per-image integrated results produced by dials.stills_process — one crystal per still shot — and reduces the whole ensemble to a single set of merged structure-factor intensities (an MTZ file) suitable for structure solution and refinement, together with the crystallographic quality statistics (completeness, multiplicity, CC½, CC*,...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= &#039;&#039;cctbx.xfel.merge&#039;&#039; =&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;cctbx.xfel.merge&#039;&#039;&#039;&#039;&#039; is the scaling, post-refinement and merging program of cctbx.xfel. It takes&lt;br /&gt;
the per-image integrated results produced by [[dials.stills_process]] — one crystal per still shot —&lt;br /&gt;
and reduces the whole ensemble to a single set of merged structure-factor intensities (an MTZ file)&lt;br /&gt;
suitable for structure solution and refinement, together with the crystallographic quality&lt;br /&gt;
statistics (completeness, multiplicity, CC½, CC*, R-factors, etc.).&lt;br /&gt;
&lt;br /&gt;
Because serial datasets routinely contain tens of thousands to millions of still shots,&lt;br /&gt;
&amp;lt;code&amp;gt;cctbx.xfel.merge&amp;lt;/code&amp;gt; is built from the ground up to run under MPI across many nodes. It is&lt;br /&gt;
almost always launched with &amp;lt;code&amp;gt;mpirun&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;srun&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;cctbx.xfel.merge&amp;lt;/code&amp;gt; is organized as a sequence of &#039;&#039;&#039;workers&#039;&#039;&#039;. Each worker performs one&lt;br /&gt;
task — reading data, applying a correction, filtering, scaling, post-refining, computing a statistic,&lt;br /&gt;
or merging — and passes its (possibly modified) experiments and reflections on to the next worker.&lt;br /&gt;
The list of workers to run is the &amp;quot;step list&amp;quot;, and it is fully configurable: you can add, remove or&lt;br /&gt;
reorder steps with &amp;lt;code&amp;gt;dispatch.step_list&amp;lt;/code&amp;gt;. This is what makes the program flexible enough to&lt;br /&gt;
scale-and-merge in one pass, to scale subsets separately and merge later, or to run a reference-free&lt;br /&gt;
bootstrap.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;default&#039;&#039;&#039; step list is:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! # !! Worker !! Purpose&lt;br /&gt;
|-&lt;br /&gt;
| 1 || &amp;lt;code&amp;gt;input&amp;lt;/code&amp;gt; || Read integrated experiments (&amp;lt;code&amp;gt;.expt&amp;lt;/code&amp;gt;) and reflections (&amp;lt;code&amp;gt;.refl&amp;lt;/code&amp;gt;) from disk in DIALS format.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || &amp;lt;code&amp;gt;balance&amp;lt;/code&amp;gt; || Redistribute the input load evenly across MPI ranks (needed when there are fewer input files than ranks).&lt;br /&gt;
|-&lt;br /&gt;
| 3 || &amp;lt;code&amp;gt;model_scaling&amp;lt;/code&amp;gt; || Build the full Miller list, model intensities from the reference, and the resolution binner used for scaling and post-refinement.&lt;br /&gt;
|-&lt;br /&gt;
| 4 || &amp;lt;code&amp;gt;modify&amp;lt;/code&amp;gt; || Apply per-reflection modifications, e.g. polarization correction (and optionally re-indexing to resolve indexing ambiguity — see &amp;lt;code&amp;gt;modify.cosym&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;reindex_to_reference&amp;lt;/code&amp;gt;).&lt;br /&gt;
|-&lt;br /&gt;
| 5 || &amp;lt;code&amp;gt;filter&amp;lt;/code&amp;gt; || Reject whole experiments (or reflections) by resolution, unit cell, correlation to the reference, energy, etc.&lt;br /&gt;
|-&lt;br /&gt;
| 6 || &amp;lt;code&amp;gt;scale&amp;lt;/code&amp;gt; || Scale each lattice to the reference dataset (&amp;lt;code&amp;gt;mark0&amp;lt;/code&amp;gt;) or simply average (&amp;lt;code&amp;gt;mark1&amp;lt;/code&amp;gt;).&lt;br /&gt;
|-&lt;br /&gt;
| 7 || &amp;lt;code&amp;gt;postrefine&amp;lt;/code&amp;gt; || Post-refine per-image crystal parameters and partialities (Sauter 2015).&lt;br /&gt;
|-&lt;br /&gt;
| 8 || &amp;lt;code&amp;gt;statistics_unitcell&amp;lt;/code&amp;gt; || Determine and store the average unit cell.&lt;br /&gt;
|-&lt;br /&gt;
| 9 || &amp;lt;code&amp;gt;statistics_beam&amp;lt;/code&amp;gt; || Determine and store the average wavelength.&lt;br /&gt;
|-&lt;br /&gt;
| 10 || &amp;lt;code&amp;gt;model_statistics&amp;lt;/code&amp;gt; || Rebuild the Miller list / binner for statistics (may use the average unit cell).&lt;br /&gt;
|-&lt;br /&gt;
| 11 || &amp;lt;code&amp;gt;statistics_resolution&amp;lt;/code&amp;gt; || Per-crystal resolution statistics.&lt;br /&gt;
|-&lt;br /&gt;
| 12 || &amp;lt;code&amp;gt;group&amp;lt;/code&amp;gt; || Redistribute reflections across ranks so that every observation of a given HKL is gathered on the same rank prior to merging.&lt;br /&gt;
|-&lt;br /&gt;
| 13 || &amp;lt;code&amp;gt;errors_merge&amp;lt;/code&amp;gt; || Correct the merged error estimates with a per-HKL error model (e.g. Ev11, Brewster 2019b).&lt;br /&gt;
|-&lt;br /&gt;
| 14 || &amp;lt;code&amp;gt;statistics_intensity&amp;lt;/code&amp;gt; || Intensity statistics by resolution.&lt;br /&gt;
|-&lt;br /&gt;
| 15 || &amp;lt;code&amp;gt;merge&amp;lt;/code&amp;gt; || Merge symmetry-equivalent intensities, gather all HKLs at rank 0, and write &amp;quot;odd&amp;quot;, &amp;quot;even&amp;quot; and &amp;quot;all&amp;quot; MTZ files.&lt;br /&gt;
|-&lt;br /&gt;
| 16 || &amp;lt;code&amp;gt;statistics_intensity_cxi&amp;lt;/code&amp;gt; || CC½ / CC* and related statistics (ported from cxi.merge).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Additional, non-default workers are available in &amp;lt;code&amp;gt;xfel/merging/application/&amp;lt;/code&amp;gt; and can be&lt;br /&gt;
inserted into the step list, including &amp;lt;code&amp;gt;tdata&amp;lt;/code&amp;gt; (write out unit cells for clustering),&lt;br /&gt;
&amp;lt;code&amp;gt;export&amp;lt;/code&amp;gt; (batch MTZ for &#039;&#039;Careless&#039;&#039;), &amp;lt;code&amp;gt;publish&amp;lt;/code&amp;gt; (upload merged files to a&lt;br /&gt;
Google Drive folder), &amp;lt;code&amp;gt;monitor&amp;lt;/code&amp;gt; (resource-usage logging), &amp;lt;code&amp;gt;integrate&amp;lt;/code&amp;gt;&lt;br /&gt;
(on-the-fly integration from psana2/XTC2), &amp;lt;code&amp;gt;prepare&amp;lt;/code&amp;gt; (SpReAD energy binning), and&lt;br /&gt;
&amp;lt;code&amp;gt;lunus&amp;lt;/code&amp;gt; (diffuse-scattering deck). A &amp;lt;code&amp;gt;deltaccint&amp;lt;/code&amp;gt; worker (ΔCC½ lattice&lt;br /&gt;
filtering) can be added after &amp;lt;code&amp;gt;group&amp;lt;/code&amp;gt;. Custom workers can be supplied through the&lt;br /&gt;
&amp;lt;code&amp;gt;XFEL_CUSTOM_WORKER_PATH&amp;lt;/code&amp;gt; environment variable.&lt;br /&gt;
&lt;br /&gt;
== Basic usage ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;cctbx.xfel.merge&amp;lt;/code&amp;gt; is run under MPI:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mpirun cctbx.xfel.merge merge.phil&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A typical &amp;lt;code&amp;gt;merge.phil&amp;lt;/code&amp;gt; (from the program README):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
input.path=&amp;lt;path to data&amp;gt;&lt;br /&gt;
input.experiments_suffix=.expt&lt;br /&gt;
input.reflections_suffix=.refl&lt;br /&gt;
&lt;br /&gt;
filter.algorithm=unit_cell&lt;br /&gt;
filter.unit_cell.value.relative_length_tolerance=0.03&lt;br /&gt;
filter.outlier.min_corr=0.1&lt;br /&gt;
&lt;br /&gt;
select.algorithm=significance_filter&lt;br /&gt;
select.significance_filter.sigma=0.1&lt;br /&gt;
select.significance_filter.min_ct=200&lt;br /&gt;
select.significance_filter.max_ct=300&lt;br /&gt;
&lt;br /&gt;
scaling.model=&amp;lt;model.pdb or model.mtz&amp;gt;&lt;br /&gt;
scaling.resolution_scalar=0.96&lt;br /&gt;
&lt;br /&gt;
merging.d_min=1.8&lt;br /&gt;
merging.error.model=ev11&lt;br /&gt;
merging.merge_anomalous=True&lt;br /&gt;
&lt;br /&gt;
postrefinement.enable=True&lt;br /&gt;
statistics.n_bins=20&lt;br /&gt;
&lt;br /&gt;
output.do_timing=True&lt;br /&gt;
output.output_dir=&amp;lt;output folder&amp;gt;&lt;br /&gt;
output.prefix=&amp;lt;prefix for output files&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Explore the parameters with:&lt;br /&gt;
* &amp;lt;code&amp;gt;cctbx.xfel.merge -c&amp;lt;/code&amp;gt; — show configurable parameters&lt;br /&gt;
* &amp;lt;code&amp;gt;cctbx.xfel.merge -c -e 10 -a 2&amp;lt;/code&amp;gt; — show all parameters (expert level 10) with full help text&lt;br /&gt;
&lt;br /&gt;
== Two-stage scaling and merging ==&lt;br /&gt;
&lt;br /&gt;
For large, growing datasets (the mode used by the [[cctbx.xfel GUI]]), it is more efficient to scale&lt;br /&gt;
and post-refine each subset of data &#039;&#039;&#039;once&#039;&#039;&#039;, then merge repeatedly as more data arrive. This is&lt;br /&gt;
done by running the program twice with different step lists.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Stage 1 — scale each subset&#039;&#039;&#039; (stops after per-image work and writes intermediate DIALS files):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dispatch.step_list=input balance model_scaling modify filter scale postrefine \&lt;br /&gt;
    statistics_unitcell statistics_beam model_statistics statistics_resolution&lt;br /&gt;
input.parallel_file_load.method=uniform&lt;br /&gt;
output.save_experiments_and_reflections=True&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;output.save_experiments_and_reflections=True&amp;lt;/code&amp;gt; dumps the scaled/post-refined data as&lt;br /&gt;
experiment lists and reflection tables that the merge stage can read back in.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Stage 2 — merge the scaled subsets&#039;&#039;&#039; (add an &amp;lt;code&amp;gt;input.path&amp;lt;/code&amp;gt; for each finished subset):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dispatch.step_list=input model_scaling statistics_unitcell statistics_beam \&lt;br /&gt;
    model_statistics statistics_resolution group errors_merge statistics_intensity \&lt;br /&gt;
    merge statistics_intensity_cxi&lt;br /&gt;
input.parallel_file_load.method=uniform&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Merging without a reference (bootstrap / mark1) ==&lt;br /&gt;
&lt;br /&gt;
If no scaling/merging reference is available, use a bootstrap procedure. First run the&lt;br /&gt;
&amp;lt;code&amp;gt;mark1&amp;lt;/code&amp;gt; algorithm, which simply averages the data (all per-image scale factors = 1, no&lt;br /&gt;
post-refinement), specifying the target cell and symmetry explicitly:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
scaling.algorithm=mark1&lt;br /&gt;
scaling.unit_cell=&amp;lt;unit cell&amp;gt;&lt;br /&gt;
scaling.space_group=&amp;lt;space group&amp;gt;&lt;br /&gt;
merging.error.model=errors_from_sample_residuals&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The resulting MTZ is then used as the reference (&amp;lt;code&amp;gt;scaling.model=&amp;lt;/code&amp;gt;) for subsequent regular&lt;br /&gt;
merges. Iterate a few cycles; CC½ typically improves and converges over the first few rounds.&lt;br /&gt;
&lt;br /&gt;
== Important parameters ==&lt;br /&gt;
&lt;br /&gt;
Parameters are given by their full PHIL path with defaults in parentheses. The program exposes many&lt;br /&gt;
more parameters (see &amp;lt;code&amp;gt;-c -e 10 -a 2&amp;lt;/code&amp;gt;); those below are the ones most commonly set.&lt;br /&gt;
&lt;br /&gt;
=== Input ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.path&amp;lt;/code&amp;gt; || None || Path(s) to the integrated data — a folder, several folders, or individual files; wildcards allowed; may be repeated. Matching &amp;lt;code&amp;gt;.expt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;.refl&amp;lt;/code&amp;gt; files must both be present.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.experiments_suffix&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;_integrated.expt&amp;lt;/code&amp;gt; || Only load experiment files ending with this suffix.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.reflections_suffix&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;_integrated.refl&amp;lt;/code&amp;gt; || Only load reflection files ending with this suffix.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.parallel_file_load.method&amp;lt;/code&amp;gt; || uniform || &amp;lt;code&amp;gt;uniform&amp;lt;/code&amp;gt; spreads input files evenly over all ranks; &amp;lt;code&amp;gt;node_memory&amp;lt;/code&amp;gt; distributes so per-node memory limits are respected.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.alist.file&amp;lt;/code&amp;gt; || None || Path to a text file of experiment tags or filenames; combined with &amp;lt;code&amp;gt;input.alist.op=keep|reject&amp;lt;/code&amp;gt; to merge only (or exclude) a specified subset.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.persistent_refl_cols&amp;lt;/code&amp;gt; || None || Reflection-table columns to preserve through the pruning steps (and into saved tables).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Filtering whole experiments (&amp;lt;code&amp;gt;filter&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;filter&amp;lt;/code&amp;gt; section accepts or rejects &#039;&#039;&#039;entire experiments&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.algorithm&amp;lt;/code&amp;gt; || (none) || One or more of &amp;lt;code&amp;gt;n_obs&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;resolution&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;unit_cell&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;energy&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bootstrap&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;experiment_prefix&amp;lt;/code&amp;gt;. Nothing is filtered unless listed.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.unit_cell.algorithm&amp;lt;/code&amp;gt; || value || How to restrict unit cells: &amp;lt;code&amp;gt;value&amp;lt;/code&amp;gt; (compare to a target), &amp;lt;code&amp;gt;range&amp;lt;/code&amp;gt;, or &amp;lt;code&amp;gt;cluster&amp;lt;/code&amp;gt; (use a precomputed covariance clustering).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.unit_cell.value.relative_length_tolerance&amp;lt;/code&amp;gt; || 0.1 || Fractional deviation of cell edge lengths allowed vs. the target cell. Often tightened (e.g. 0.03).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.unit_cell.value.absolute_angle_tolerance&amp;lt;/code&amp;gt; || 2.0 || Allowed cell-angle deviation (degrees) vs. the target.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.unit_cell.value.target_unit_cell&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;target_space_group&amp;lt;/code&amp;gt; || Auto || Target cell/symmetry; &amp;lt;code&amp;gt;Auto&amp;lt;/code&amp;gt; uses the scaling model.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.outlier.min_corr&amp;lt;/code&amp;gt; || 0.1 || Minimum correlation of an image&#039;s intensities to the reference model; images below this are rejected. Only applied when a scaling model is present. Use &amp;lt;code&amp;gt;-1&amp;lt;/code&amp;gt; to accept all images regardless of correlation.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;filter.resolution.d_min&amp;lt;/code&amp;gt; || None || Reject an experiment unless some of its reflections extend beyond this resolution.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Selecting individual reflections (&amp;lt;code&amp;gt;select&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;select&amp;lt;/code&amp;gt; section accepts or rejects &#039;&#039;&#039;individual reflections&#039;&#039;&#039; (contrast with&lt;br /&gt;
&amp;lt;code&amp;gt;filter&amp;lt;/code&amp;gt;, which acts on whole experiments).&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;select.algorithm&amp;lt;/code&amp;gt; || (none) || One or more of &amp;lt;code&amp;gt;significance_filter&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;panel&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cspad_sensor&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;isolation_forest&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;target_energy&amp;lt;/code&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;select.significance_filter.sigma&amp;lt;/code&amp;gt; || 0.5 || Trim each lattice at the resolution where the binned ⟨I/σ⟩ drops below this value.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;select.significance_filter.min_ct&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;max_ct&amp;lt;/code&amp;gt; || 10 / 50 || Target minimum/maximum mean reflections per resolution bin when choosing the number of bins. For large unit cells these are often raised (e.g. 200/300); for small cells, use the defaults.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Modifying intensities (&amp;lt;code&amp;gt;modify&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;modify.algorithm&amp;lt;/code&amp;gt; || polarization || Per-reflection corrections to apply (default applies the polarization correction).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;modify.cosym&amp;lt;/code&amp;gt; || — || Resolve an indexing ambiguity across the ensemble using the Gildea/Winter (Brehm/Diederichs) cosym method, optionally anchored to &amp;lt;code&amp;gt;scaling.model&amp;lt;/code&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;modify.reindex_to_reference&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;reindex_to_abc&amp;lt;/code&amp;gt; || — || Alternative re-indexing operators (to a reference model, or an explicit operator).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Scaling (&amp;lt;code&amp;gt;scaling&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;scaling.model&amp;lt;/code&amp;gt; || None || Reference dataset: a PDB file (uses the CRYST1 cell and computes model intensities, including bulk solvent) or an MTZ from a previous cycle. Required for &amp;lt;code&amp;gt;mark0&amp;lt;/code&amp;gt; scaling.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;scaling.algorithm&amp;lt;/code&amp;gt; || mark0 || &amp;lt;code&amp;gt;mark0&amp;lt;/code&amp;gt;: per-image scaling against the reference. &amp;lt;code&amp;gt;mark1&amp;lt;/code&amp;gt;: no scaling, just Monte-Carlo averaging (all scale factors = 1) — used for reference-free bootstrap.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;scaling.unit_cell&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;scaling.space_group&amp;lt;/code&amp;gt; || None || Cell/symmetry to use when no model is provided (i.e. &amp;lt;code&amp;gt;mark1&amp;lt;/code&amp;gt;).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;scaling.resolution_scalar&amp;lt;/code&amp;gt; || 0.969 || &amp;lt;code&amp;gt;merging.d_min&amp;lt;/code&amp;gt; is multiplied by this when deciding which reflections fall within the resolution limit, generating a few extra reference reflections to account for per-shot cell variation (e.g. set 0.96 for a few more).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;scaling.mtz.mtz_column_F&amp;lt;/code&amp;gt; || fobs || Column name in the reference MTZ containing the reference structure factors (intensities or amplitudes).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Post-refinement (&amp;lt;code&amp;gt;postrefinement&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;postrefinement.enable&amp;lt;/code&amp;gt; || True || Enable post-refinement of per-image parameters/partialities (Sauter 2015).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;postrefinement.algorithm&amp;lt;/code&amp;gt; || rs || Post-refinement protocol: &amp;lt;code&amp;gt;rs&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;rs2&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;rs_hybrid&amp;lt;/code&amp;gt;, or &amp;lt;code&amp;gt;eta_deff&amp;lt;/code&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Merging and error model (&amp;lt;code&amp;gt;merging&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;merging.d_min&amp;lt;/code&amp;gt; || None || High-resolution limit for scaling and merging.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;merging.d_max&amp;lt;/code&amp;gt; || None || Low-resolution limit (currently affects only CCiso).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;merging.merge_anomalous&amp;lt;/code&amp;gt; || False || &amp;lt;code&amp;gt;True&amp;lt;/code&amp;gt; merges Bijvoet mates together (higher multiplicity); &amp;lt;code&amp;gt;False&amp;lt;/code&amp;gt; keeps them separate to preserve the anomalous signal.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;merging.minimum_multiplicity&amp;lt;/code&amp;gt; || 2 || Do not produce a merged structure factor for HKLs measured fewer than this many times.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;merging.error.model&amp;lt;/code&amp;gt; || mm24 || Merged-sigma error model: &amp;lt;code&amp;gt;mm24&amp;lt;/code&amp;gt; (Mittan-Moreau 2024, current default), &amp;lt;code&amp;gt;ev11&amp;lt;/code&amp;gt; (Evans 2011 / sdfac-refine, recommended in the README), &amp;lt;code&amp;gt;ha14&amp;lt;/code&amp;gt;, or &amp;lt;code&amp;gt;errors_from_sample_residuals&amp;lt;/code&amp;gt; (no refined error terms — used with &amp;lt;code&amp;gt;mark1&amp;lt;/code&amp;gt; bootstrap).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;merging.set_average_unit_cell&amp;lt;/code&amp;gt; || True || Output MTZ adopts the (cluster-derived) average unit cell of the data rather than the reference model&#039;s cell.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Statistics (&amp;lt;code&amp;gt;statistics&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;statistics.n_bins&amp;lt;/code&amp;gt; || 10 || Number of resolution bins in the statistics tables.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;statistics.cciso.mtz_file&amp;lt;/code&amp;gt; || None || Isomorphous reference structure factors for R&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt; / CC&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;statistics.report_ML&amp;lt;/code&amp;gt; || True || Report per-frame max-likelihood attributes (domain size, mosaicity).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Output (&amp;lt;code&amp;gt;output&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.output_dir&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;.&amp;lt;/code&amp;gt; || Directory for output files (created if it does not exist).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.prefix&amp;lt;/code&amp;gt; || iobs || Prefix prepended to all output file names.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.save_experiments_and_reflections&amp;lt;/code&amp;gt; || False || Dump the final experiments/reflections from the last worker as DIALS files — used for the two-stage scale-then-merge workflow.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.do_timing&amp;lt;/code&amp;gt; || False || Log elapsed time per execution step.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.expanded_bookkeeping&amp;lt;/code&amp;gt; || False || Store extra provenance columns (input file/reflection indices, odd/even flag, original id) in the saved reflection tables.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Multiprocessing (&amp;lt;code&amp;gt;mp&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mp.method&amp;lt;/code&amp;gt; || mpi || Multiprocessing method (only &amp;lt;code&amp;gt;mpi&amp;lt;/code&amp;gt; is currently supported).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mp.debug.cProfile&amp;lt;/code&amp;gt; || False || Enable code profiling; a &amp;lt;code&amp;gt;.prof&amp;lt;/code&amp;gt; file is written per rank.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Output files ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;merge&amp;lt;/code&amp;gt; worker gathers all HKLs at rank 0 and writes three MTZ files, prefixed with&lt;br /&gt;
&amp;lt;code&amp;gt;output.prefix&amp;lt;/code&amp;gt; (default &amp;lt;code&amp;gt;iobs&amp;lt;/code&amp;gt;):&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;amp;lt;prefix&amp;amp;gt;_all.mtz&amp;lt;/code&amp;gt; — the merged dataset using all observations (the main result for structure solution)&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;amp;lt;prefix&amp;amp;gt;_odd.mtz&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;&amp;amp;lt;prefix&amp;amp;gt;_even.mtz&amp;lt;/code&amp;gt; — the two half-datasets used for CC½ and related half-dataset statistics&lt;br /&gt;
&lt;br /&gt;
A main log records the per-step progress and the merging statistics tables (completeness,&lt;br /&gt;
multiplicity, ⟨I/σ⟩, CC½, CC*, R-factors) by resolution bin. The merged MTZ can optionally be&lt;br /&gt;
uploaded to a shared [https://github.com/cctbx/cctbx_project/tree/master/xfel/merging/application/publish Google Drive folder] by adding the &amp;lt;code&amp;gt;publish&amp;lt;/code&amp;gt; worker.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
* Sauter NK (2015). &#039;&#039;J Synchrotron Radiat&#039;&#039; &#039;&#039;&#039;22&#039;&#039;&#039;, 239–48. (post-refinement)&lt;br /&gt;
* Uervirojnangkoorn M, &#039;&#039;et al.&#039;&#039; (2015). &#039;&#039;eLife&#039;&#039; 10.7554/eLife.05421. (PRIME / bootstrap)&lt;br /&gt;
* Brewster AS, &#039;&#039;et al.&#039;&#039; (2018). &#039;&#039;Acta Cryst.&#039;&#039; D &#039;&#039;&#039;74&#039;&#039;&#039;, 877–894.&lt;br /&gt;
* Brewster AS, &#039;&#039;et al.&#039;&#039; (2019a). &#039;&#039;Computational Crystallography Newsletter&#039;&#039; &#039;&#039;&#039;10&#039;&#039;&#039;, 22–39. (XFEL GUI)&lt;br /&gt;
* Brewster AS, &#039;&#039;et al.&#039;&#039; (2019b). &#039;&#039;Acta Cryst.&#039;&#039; D &#039;&#039;&#039;75&#039;&#039;&#039;, 959–968. (error models)&lt;br /&gt;
* Mittan-Moreau (2024). (mm24 error model)&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
* [[dials.stills_process]] — produces the integrated data that &amp;lt;code&amp;gt;cctbx.xfel.merge&amp;lt;/code&amp;gt; consumes&lt;br /&gt;
* [[cctbx.xfel GUI]] — orchestrates separate scaling and repeated merging as data are collected&lt;br /&gt;
* The program README at &amp;lt;code&amp;gt;xfel/merging/README.md&amp;lt;/code&amp;gt; in cctbx_project&lt;/div&gt;</summary>
		<author><name>Aaron</name></author>
	</entry>
	<entry>
		<id>http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Dials.stills_process&amp;diff=1768</id>
		<title>Dials.stills process</title>
		<link rel="alternate" type="text/html" href="http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Dials.stills_process&amp;diff=1768"/>
		<updated>2026-08-21T22:55:23Z</updated>

		<summary type="html">&lt;p&gt;Aaron: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= dials.stills_process =&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;dials.stills_process&#039;&#039;&#039;&#039;&#039; is a stand-alone program for processing still diffraction images and is&lt;br /&gt;
the core data-reduction program of &#039;&#039;cctbx.xfel&#039;&#039;. It takes a set of&lt;br /&gt;
still diffraction images — typically serial femtosecond crystallography (SFX) snapshots from an&lt;br /&gt;
XFEL (LCLS, SACLA, EuXFEL) or still shots from a synchrotron — and analyzes each one, independently,&lt;br /&gt;
through the full DIALS pipeline: &#039;&#039;&#039;import → spot-finding → indexing → refinement → integration&#039;&#039;&#039;.&lt;br /&gt;
Its output (integrated intensities together with the per-image experimental models) is the input to&lt;br /&gt;
the merging program &#039;&#039;[[cctbx.xfel.merge]]&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Because every image is a separate still exposure of a different crystal (rather than a wedge of&lt;br /&gt;
a rotation series), each image is treated as its own experiment with its own crystal model. This&lt;br /&gt;
&amp;quot;one crystal per shot&amp;quot; model is what distinguishes stills processing from conventional rotation data&lt;br /&gt;
processing (e.g. &amp;lt;code&amp;gt;dials.import&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;dials.find_spots&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;dials.index&amp;lt;/code&amp;gt;, etc.), &lt;br /&gt;
and it drives most of the stills-specific defaults described below.&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
For each image, &amp;lt;code&amp;gt;dials.stills_process&amp;lt;/code&amp;gt; runs the following stages in order. Any stage can&lt;br /&gt;
be turned off with the &amp;lt;code&amp;gt;dispatch&amp;lt;/code&amp;gt; parameters; if a stage is disabled, processing stops&lt;br /&gt;
after the last enabled stage.&lt;br /&gt;
&lt;br /&gt;
# &#039;&#039;&#039;Import&#039;&#039;&#039; — read the image, apply reference geometry / gain / mask overrides, and build an experiment.&lt;br /&gt;
# &#039;&#039;&#039;Spot-finding&#039;&#039;&#039; — locate strong pixels and build strong reflections (&amp;lt;code&amp;gt;dispatch.find_spots&amp;lt;/code&amp;gt;).&lt;br /&gt;
# &#039;&#039;&#039;Hit finding&#039;&#039;&#039; — reject images with too few (or optionally too many) strong spots, so that only &amp;quot;hits&amp;quot; are indexed (&amp;lt;code&amp;gt;dispatch.hit_finder&amp;lt;/code&amp;gt;).&lt;br /&gt;
# &#039;&#039;&#039;Indexing&#039;&#039;&#039; — determine the crystal orientation and (optionally constrained) unit cell (&amp;lt;code&amp;gt;dispatch.index&amp;lt;/code&amp;gt;).&lt;br /&gt;
# &#039;&#039;&#039;Refinement&#039;&#039;&#039; — refine the crystal model and re-estimate the mosaic/domain-size parameters. Detector and beam are held fixed by default (&amp;lt;code&amp;gt;dispatch.refine&amp;lt;/code&amp;gt;).&lt;br /&gt;
# &#039;&#039;&#039;Integration&#039;&#039;&#039; — predict reflections and measure their intensities using the stills integrator (&amp;lt;code&amp;gt;dispatch.integrate&amp;lt;/code&amp;gt;), with an optional significance filter.&lt;br /&gt;
&lt;br /&gt;
The program applies a set of stills-specific defaults on top of the standard DIALS parameters,&lt;br /&gt;
including: indexing method &amp;lt;code&amp;gt;fft1d&amp;lt;/code&amp;gt;; the stills integrator with profile fitting turned off&lt;br /&gt;
(summation integration with a 2-D plane background); the stills refinement weighting strategy with&lt;br /&gt;
the detector and beam models fixed; and a re-estimation of per-crystal mosaic parameters&lt;br /&gt;
(domain size and mosaic angle) after refinement. These are sensible starting points for serial data&lt;br /&gt;
and normally do not need to be changed.&lt;br /&gt;
&lt;br /&gt;
Failures on individual images are, by default, caught and logged so that processing continues to the&lt;br /&gt;
next image (&amp;lt;code&amp;gt;dispatch.squash_errors=True&amp;lt;/code&amp;gt;) — essential when reducing tens of thousands of&lt;br /&gt;
shots of which only a fraction are hits.&lt;br /&gt;
&lt;br /&gt;
== Basic usage ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Process a directory of CBF stills, constraining the target cell/symmetry,&lt;br /&gt;
# using 32 parallel processes on one node&lt;br /&gt;
dials.stills_process /path/to/images/*.cbf process.phil mp.nproc=32&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A typical &amp;lt;code&amp;gt;process.phil&amp;lt;/code&amp;gt; for XFEL data looks like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
spotfinder.filter.min_spot_size=2&lt;br /&gt;
spotfinder.threshold.dispersion.gain=1.0&lt;br /&gt;
spotfinder.threshold.dispersion.global_threshold=100&lt;br /&gt;
&lt;br /&gt;
indexing.known_symmetry.space_group=P43212&lt;br /&gt;
indexing.known_symmetry.unit_cell=78.9,78.9,38.1,90,90,90&lt;br /&gt;
indexing.method=fft1d&lt;br /&gt;
&lt;br /&gt;
input.reference_geometry=refined.expt   # from a previous metrology refinement&lt;br /&gt;
&lt;br /&gt;
output.output_dir=out&lt;br /&gt;
mp.nproc=32&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Useful command-line helpers:&lt;br /&gt;
* &amp;lt;code&amp;gt;dials.stills_process -h&amp;lt;/code&amp;gt; — help and usage&lt;br /&gt;
* &amp;lt;code&amp;gt;dials.stills_process -c -e 2&amp;lt;/code&amp;gt; — show the configurable parameters (expert level 2)&lt;br /&gt;
* &amp;lt;code&amp;gt;dials.stills_process -c -a2&amp;lt;/code&amp;gt; — include attributes (help text) for each parameter&lt;br /&gt;
* &amp;lt;code&amp;gt;dials.stills_process ... input.show_image_tags=True&amp;lt;/code&amp;gt; — list the image tags in a dataset without processing (useful for selecting subsets with &amp;lt;code&amp;gt;input.image_tag&amp;lt;/code&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
== Important parameters ==&lt;br /&gt;
&lt;br /&gt;
The program exposes the entire DIALS parameter set (spot-finding, indexing, refinement, integration,&lt;br /&gt;
profile modelling, prediction). The parameters below are the ones most commonly adjusted for serial&lt;br /&gt;
still data. Parameters are given by their full PHIL path with their default value.&lt;br /&gt;
&lt;br /&gt;
=== Input ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.reference_geometry&amp;lt;/code&amp;gt; || None || Path to an &amp;lt;code&amp;gt;.expt&amp;lt;/code&amp;gt; file (or image) with a single detector model. Data are processed using &#039;&#039;this&#039;&#039; geometry instead of the geometry in the image headers. This is how a refined detector metrology from &amp;lt;code&amp;gt;cctbx.xfel&amp;lt;/code&amp;gt; ensemble refinement is applied — almost always set for XFEL data.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.sync_reference_geom&amp;lt;/code&amp;gt; || True || When a reference geometry is supplied, copy its refined local frames onto the image&#039;s detector hierarchy node-by-node (the hierarchies must match in shape). If False, the reference detector replaces the image detector wholesale.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.file_list&amp;lt;/code&amp;gt; || None || Path to a text file listing image paths, one per line (alternative to listing files on the command line).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.glob&amp;lt;/code&amp;gt; || None || Wildcard path(s) for large multi-file datasets (e.g. &amp;lt;code&amp;gt;*.cbf&amp;lt;/code&amp;gt;). May be given multiple times.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.image_tag&amp;lt;/code&amp;gt; || None || Process only images with the given tag(s). For single-image files the tag is the filename; for multi-image files (HDF5) it is &amp;lt;code&amp;gt;filename_imagenumber&amp;lt;/code&amp;gt; (image number is 5 digits with leading zeroes). Use &amp;lt;code&amp;gt;input.show_image_tags=True&amp;lt;/code&amp;gt; to list them.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.max_images&amp;lt;/code&amp;gt; || None || Limit the total number of images processed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Dispatch — controlling the pipeline ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dispatch.find_spots&amp;lt;/code&amp;gt; || True || Do spot-finding. Required for indexing/integration.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dispatch.index&amp;lt;/code&amp;gt; || True || Attempt to index. Requires &amp;lt;code&amp;gt;find_spots=True&amp;lt;/code&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dispatch.integrate&amp;lt;/code&amp;gt; || True || Integrate indexed images. Ignored if indexing/spot-finding is off.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dispatch.refine&amp;lt;/code&amp;gt; || False || Run an explicit model-refinement step after indexing (the stills indexer already refines; this is an additional pass, rarely needed).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dispatch.squash_errors&amp;lt;/code&amp;gt; || True || If an image fails, log it and continue to the next image. Set False to halt and show the full error when debugging.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dispatch.hit_finder.enable&amp;lt;/code&amp;gt; || True || Enable hit-finding. If disabled, every image is passed to indexing.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dispatch.hit_finder.minimum_number_of_reflections&amp;lt;/code&amp;gt; || 16 || Images with fewer strong spots than this are discarded as non-hits before indexing.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dispatch.hit_finder.maximum_number_of_reflections&amp;lt;/code&amp;gt; || None || If set, images with more strong spots than this are discarded (e.g. ice/junk).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dispatch.process_percent&amp;lt;/code&amp;gt; || None || Process only this percentage of events (evenly sampled). Useful for a quick look at a large dataset.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dispatch.coset&amp;lt;/code&amp;gt; || False || During integration, also integrate a sublattice coset as a negative control for regions with no Bragg diffraction (see &amp;lt;code&amp;gt;integration.coset.transformation&amp;lt;/code&amp;gt;).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dispatch.pre_import&amp;lt;/code&amp;gt; || False || Import all data before processing. Only needed when processing multiple &#039;&#039;multi-image&#039;&#039; files at once (not a recommended workflow). Single-file datasets (e.g. HDF5) are always pre-imported automatically.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Spot-finding ===&lt;br /&gt;
&lt;br /&gt;
Spot-finding uses the standard DIALS dispersion thresholding. The most impactful parameters for&lt;br /&gt;
serial data:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spotfinder.filter.min_spot_size&amp;lt;/code&amp;gt; || Auto || Minimum connected pixels for a spot. Auto = 3 for pixel-array detectors (SENSOR_PAD), 6 otherwise. Often lowered to 2 for sparse serial patterns.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spotfinder.threshold.dispersion.gain&amp;lt;/code&amp;gt; || None || Detector gain used in thresholding. Set this &#039;&#039;or&#039;&#039; the detector-model gain, not both (see gain note below).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spotfinder.threshold.dispersion.sigma_strong&amp;lt;/code&amp;gt; || 3 || Number of sigma above background for a pixel to be &amp;quot;strong&amp;quot;.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spotfinder.threshold.dispersion.sigma_background&amp;lt;/code&amp;gt; || 6 || Number of sigma for the background/dispersion test.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spotfinder.threshold.dispersion.global_threshold&amp;lt;/code&amp;gt; || 0 || Absolute pixel intensity floor; pixels below this are never considered strong. Raising it (e.g. 100) suppresses noise on many detectors.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spotfinder.threshold.dispersion.kernel_size&amp;lt;/code&amp;gt; || 3 3 || Local-area kernel (pixels) for the dispersion calculation.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Gain note:&#039;&#039;&#039; the detector gain should be set on the detector model &#039;&#039;or&#039;&#039; in the processing&lt;br /&gt;
parameters, never both. If a supplied gain (&amp;lt;code&amp;gt;spotfinder.threshold.dispersion.gain&amp;lt;/code&amp;gt; or&lt;br /&gt;
&amp;lt;code&amp;gt;integration.summation.detector_gain&amp;lt;/code&amp;gt;) conflicts with a non-unity gain already on the&lt;br /&gt;
detector model, the program raises an error. Override with&lt;br /&gt;
&amp;lt;code&amp;gt;input.ignore_gain_mismatch=True&amp;lt;/code&amp;gt; only if you understand the consequences.&lt;br /&gt;
&lt;br /&gt;
=== Indexing ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;indexing.known_symmetry.space_group&amp;lt;/code&amp;gt; || None || Target space group. Strongly recommended for serial data — constrains indexing and improves the hit/index rate.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;indexing.known_symmetry.unit_cell&amp;lt;/code&amp;gt; || None || Target unit cell (a,b,c,α,β,γ). Used together with the space group as the indexing target.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;indexing.method&amp;lt;/code&amp;gt; || fft1d || Basis-vector search method (&amp;lt;code&amp;gt;dials.stills_process&amp;lt;/code&amp;gt; defaults to &amp;lt;code&amp;gt;fft1d&amp;lt;/code&amp;gt;; &amp;lt;code&amp;gt;fft3d&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;real_space_grid_search&amp;lt;/code&amp;gt; are also available).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;indexing.stills.method_list&amp;lt;/code&amp;gt; || None || Ordered list of indexing methods to try in turn; if one fails, the next is attempted (e.g. &amp;lt;code&amp;gt;fft1d real_space_grid_search&amp;lt;/code&amp;gt;).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;indexing.stills.known_orientations&amp;lt;/code&amp;gt; || None || Paths to previously-processed experiment lists. If given, images are &#039;&#039;not&#039;&#039; re-indexed; the stored crystal orientations are reused (e.g. to re-integrate with new parameters). Supports wildcards; may be repeated.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;indexing.stills.require_known_orientation&amp;lt;/code&amp;gt; || False || When known orientations are supplied but an image is not found among them, controls whether to skip it (True) or fall back to indexing from scratch (False).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;indexing.stills.reflection_subsampling.enable&amp;lt;/code&amp;gt; || False || Retry indexing on random subsets of the strong spots (from &amp;lt;code&amp;gt;step_start&amp;lt;/code&amp;gt;% down to &amp;lt;code&amp;gt;step_stop&amp;lt;/code&amp;gt;% in &amp;lt;code&amp;gt;step_size&amp;lt;/code&amp;gt;% steps). Can rescue images that fail to index on the full spot list.  Especially valuble for multi-lattice images (multiple crystals in the beam) but does increase execution time!&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Integration ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;profile.gaussian_rs.parameters.sigma_b_cutoff&amp;lt;/code&amp;gt; || 0.1 || Maximum beam divergence (sigma_b, degrees) before an indexed crystal is rejected prior to integration. Guards against over-broad, poorly-modelled lattices.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;significance_filter.enable&amp;lt;/code&amp;gt; || False || Apply the stills significance filter, which trims each crystal to the resolution at which reflections remain statistically significant (see &amp;lt;code&amp;gt;significance_filter.isigi_cutoff&amp;lt;/code&amp;gt;, default 1.0).  Defaults to false here because it is typically applied in &#039;&#039;[[cctbx.xfel.merge]]&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;integration.integration_only_overrides.trusted_range&amp;lt;/code&amp;gt; || None || Override the panel trusted range [min, max] during integration only (e.g. to include pixels the header marks as untrusted).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;integration.coset.transformation&amp;lt;/code&amp;gt; || 6 || Which modulus-2 sublattice transformation defines the coset negative control when &amp;lt;code&amp;gt;dispatch.coset=True&amp;lt;/code&amp;gt; (0–6; 6 = body centering). See Sauter &amp;amp; Zwart, &#039;&#039;Acta Cryst.&#039;&#039; D (2009) &#039;&#039;&#039;65&#039;&#039;&#039;:553.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Output ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.output_dir&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;.&amp;lt;/code&amp;gt; || Directory for output files.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.composite_output&amp;lt;/code&amp;gt; || True || If True, each process writes &#039;&#039;one&#039;&#039; concatenated set of &amp;lt;code&amp;gt;.expt&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;.refl&amp;lt;/code&amp;gt; files covering all its successful images. If False, a separate pair of files is written per image (generates a very large number of files). Composite output is strongly preferred for large serial datasets.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.logging_dir&amp;lt;/code&amp;gt; || None || Directory for log files. Under MPI, per-rank logs (&amp;lt;code&amp;gt;log_rankNNNN.out&amp;lt;/code&amp;gt;, etc.) are written here.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.logging_option&amp;lt;/code&amp;gt; || normal || &amp;lt;code&amp;gt;normal&amp;lt;/code&amp;gt; (all logging), &amp;lt;code&amp;gt;suppressed&amp;lt;/code&amp;gt; (silences verbose DIALS refine/index output), or &amp;lt;code&amp;gt;disabled&amp;lt;/code&amp;gt; (almost no logging).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.*_filename&amp;lt;/code&amp;gt; || (templates) || Output filename templates for each stage: &amp;lt;code&amp;gt;strong&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;indexed&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;refined_experiments&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;integrated&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;integrated_experiments&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;coset&amp;lt;/code&amp;gt;. A &amp;lt;code&amp;gt;%s&amp;lt;/code&amp;gt; in the template is replaced with the process number for composite mode or the per-image tag for non-composite mode.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.integration_pickle&amp;lt;/code&amp;gt; || None || Write legacy &amp;lt;code&amp;gt;cxi.merge&amp;lt;/code&amp;gt;/PRIME integration pickle files (e.g. &amp;lt;code&amp;gt;int-%d-%s.pickle&amp;lt;/code&amp;gt;). Only needed for legacy merging workflows.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Multiprocessing ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mp.method&amp;lt;/code&amp;gt; || multiprocessing || Parallelization backend: &amp;lt;code&amp;gt;multiprocessing&amp;lt;/code&amp;gt; (single node), or &amp;lt;code&amp;gt;mpi&amp;lt;/code&amp;gt; for multi-node jobs (also &amp;lt;code&amp;gt;sge&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;lsf&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;pbs&amp;lt;/code&amp;gt;).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mp.nproc&amp;lt;/code&amp;gt; || 1 || Number of processes (for the &amp;lt;code&amp;gt;multiprocessing&amp;lt;/code&amp;gt; method). Set to the number of cores per node.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mp.composite_stride&amp;lt;/code&amp;gt; || None || For MPI composite output, how many ranks aggregate their results into one set of output files. Ideally set to the number of processes per node so that one composite file set is written per node rather than per rank.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Under MPI with more than two ranks, the program runs a client/server model: rank 0 (or rank 2 for&lt;br /&gt;
psana2 &amp;lt;code&amp;gt;.loc&amp;lt;/code&amp;gt; inputs) hands out images to worker ranks on demand, giving good load&lt;br /&gt;
balancing across the many fast-failing non-hits typical of serial data.&lt;br /&gt;
&lt;br /&gt;
== Output files ==&lt;br /&gt;
&lt;br /&gt;
With the default composite output, each process (or each aggregating rank under MPI) writes&lt;br /&gt;
concatenated files such as:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;amp;lt;tag&amp;amp;gt;_strong.refl&amp;lt;/code&amp;gt; — strong spots from spot-finding&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;amp;lt;tag&amp;amp;gt;_indexed.refl&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;&amp;amp;lt;tag&amp;amp;gt;_refined.expt&amp;lt;/code&amp;gt; — indexed reflections and their crystal models&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;amp;lt;tag&amp;amp;gt;_integrated.refl&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;&amp;amp;lt;tag&amp;amp;gt;_integrated.expt&amp;lt;/code&amp;gt; — integrated intensities and final models (the input to &#039;&#039;[[cctbx.xfel.merge]]&#039;&#039;)&lt;br /&gt;
&lt;br /&gt;
Per-image progress and status codes are recorded in &amp;lt;code&amp;gt;debug/debug_&amp;amp;lt;rank&amp;amp;gt;.txt&amp;lt;/code&amp;gt;, and&lt;br /&gt;
overall logging goes to &amp;lt;code&amp;gt;dials.process.log&amp;lt;/code&amp;gt; (or per-rank logs under MPI). These integrated&lt;br /&gt;
&amp;lt;code&amp;gt;.expt&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;.refl&amp;lt;/code&amp;gt; pairs are then scaled and merged with&lt;br /&gt;
&#039;&#039;[[cctbx.xfel.merge]]&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;[[cctbx.xfel.merge]]&#039;&#039; — scaling, post-refinement and merging of the integrated data&lt;br /&gt;
* The [http://dials.github.io DIALS documentation] for the underlying spot-finding, indexing, refinement and integration algorithms&lt;/div&gt;</summary>
		<author><name>Aaron</name></author>
	</entry>
	<entry>
		<id>http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Dials.stills_process&amp;diff=1767</id>
		<title>Dials.stills process</title>
		<link rel="alternate" type="text/html" href="http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Dials.stills_process&amp;diff=1767"/>
		<updated>2026-08-21T22:52:56Z</updated>

		<summary type="html">&lt;p&gt;Aaron: /* Output files */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= dials.stills_process =&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;dials.stills_process&#039;&#039;&#039;&#039;&#039; is a stand-alone program for processing still diffraction images and is&lt;br /&gt;
the core data-reduction program of &#039;&#039;cctbx.xfel&#039;&#039;. It takes a set of&lt;br /&gt;
still diffraction images — typically serial femtosecond crystallography (SFX) snapshots from an&lt;br /&gt;
XFEL (LCLS, SACLA, EuXFEL) or still shots from a synchrotron — and analyzes each one, independently,&lt;br /&gt;
through the full DIALS pipeline: &#039;&#039;&#039;import → spot-finding → indexing → refinement → integration&#039;&#039;&#039;.&lt;br /&gt;
Its output (integrated intensities together with the per-image experimental models) is the input to&lt;br /&gt;
the merging program [[cctbx.xfel.merge]].&lt;br /&gt;
&lt;br /&gt;
Because every image is a separate still exposure of a different crystal (rather than a wedge of&lt;br /&gt;
a rotation series), each image is treated as its own experiment with its own crystal model. This&lt;br /&gt;
&amp;quot;one crystal per shot&amp;quot; model is what distinguishes stills processing from conventional rotation data&lt;br /&gt;
processing (e.g. &amp;lt;code&amp;gt;dials.import&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;dials.find_spots&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;dials.index&amp;lt;/code&amp;gt;, etc.), &lt;br /&gt;
and it drives most of the stills-specific defaults described below.&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
For each image, &amp;lt;code&amp;gt;dials.stills_process&amp;lt;/code&amp;gt; runs the following stages in order. Any stage can&lt;br /&gt;
be turned off with the &amp;lt;code&amp;gt;dispatch&amp;lt;/code&amp;gt; parameters; if a stage is disabled, processing stops&lt;br /&gt;
after the last enabled stage.&lt;br /&gt;
&lt;br /&gt;
# &#039;&#039;&#039;Import&#039;&#039;&#039; — read the image, apply reference geometry / gain / mask overrides, and build an experiment.&lt;br /&gt;
# &#039;&#039;&#039;Spot-finding&#039;&#039;&#039; — locate strong pixels and build strong reflections (&amp;lt;code&amp;gt;dispatch.find_spots&amp;lt;/code&amp;gt;).&lt;br /&gt;
# &#039;&#039;&#039;Hit finding&#039;&#039;&#039; — reject images with too few (or optionally too many) strong spots, so that only &amp;quot;hits&amp;quot; are indexed (&amp;lt;code&amp;gt;dispatch.hit_finder&amp;lt;/code&amp;gt;).&lt;br /&gt;
# &#039;&#039;&#039;Indexing&#039;&#039;&#039; — determine the crystal orientation and (optionally constrained) unit cell (&amp;lt;code&amp;gt;dispatch.index&amp;lt;/code&amp;gt;).&lt;br /&gt;
# &#039;&#039;&#039;Refinement&#039;&#039;&#039; — refine the crystal model and re-estimate the mosaic/domain-size parameters. Detector and beam are held fixed by default (&amp;lt;code&amp;gt;dispatch.refine&amp;lt;/code&amp;gt;).&lt;br /&gt;
# &#039;&#039;&#039;Integration&#039;&#039;&#039; — predict reflections and measure their intensities using the stills integrator (&amp;lt;code&amp;gt;dispatch.integrate&amp;lt;/code&amp;gt;), with an optional significance filter.&lt;br /&gt;
&lt;br /&gt;
The program applies a set of stills-specific defaults on top of the standard DIALS parameters,&lt;br /&gt;
including: indexing method &amp;lt;code&amp;gt;fft1d&amp;lt;/code&amp;gt;; the stills integrator with profile fitting turned off&lt;br /&gt;
(summation integration with a 2-D plane background); the stills refinement weighting strategy with&lt;br /&gt;
the detector and beam models fixed; and a re-estimation of per-crystal mosaic parameters&lt;br /&gt;
(domain size and mosaic angle) after refinement. These are sensible starting points for serial data&lt;br /&gt;
and normally do not need to be changed.&lt;br /&gt;
&lt;br /&gt;
Failures on individual images are, by default, caught and logged so that processing continues to the&lt;br /&gt;
next image (&amp;lt;code&amp;gt;dispatch.squash_errors=True&amp;lt;/code&amp;gt;) — essential when reducing tens of thousands of&lt;br /&gt;
shots of which only a fraction are hits.&lt;br /&gt;
&lt;br /&gt;
== Basic usage ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Process a directory of CBF stills, constraining the target cell/symmetry,&lt;br /&gt;
# using 32 parallel processes on one node&lt;br /&gt;
dials.stills_process /path/to/images/*.cbf process.phil mp.nproc=32&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A typical &amp;lt;code&amp;gt;process.phil&amp;lt;/code&amp;gt; for XFEL data looks like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
spotfinder.filter.min_spot_size=2&lt;br /&gt;
spotfinder.threshold.dispersion.gain=1.0&lt;br /&gt;
spotfinder.threshold.dispersion.global_threshold=100&lt;br /&gt;
&lt;br /&gt;
indexing.known_symmetry.space_group=P43212&lt;br /&gt;
indexing.known_symmetry.unit_cell=78.9,78.9,38.1,90,90,90&lt;br /&gt;
indexing.method=fft1d&lt;br /&gt;
&lt;br /&gt;
input.reference_geometry=refined.expt   # from a previous metrology refinement&lt;br /&gt;
&lt;br /&gt;
output.output_dir=out&lt;br /&gt;
mp.nproc=32&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Useful command-line helpers:&lt;br /&gt;
* &amp;lt;code&amp;gt;dials.stills_process -h&amp;lt;/code&amp;gt; — help and usage&lt;br /&gt;
* &amp;lt;code&amp;gt;dials.stills_process -c -e 2&amp;lt;/code&amp;gt; — show the configurable parameters (expert level 2)&lt;br /&gt;
* &amp;lt;code&amp;gt;dials.stills_process -c -a2&amp;lt;/code&amp;gt; — include attributes (help text) for each parameter&lt;br /&gt;
* &amp;lt;code&amp;gt;dials.stills_process ... input.show_image_tags=True&amp;lt;/code&amp;gt; — list the image tags in a dataset without processing (useful for selecting subsets with &amp;lt;code&amp;gt;input.image_tag&amp;lt;/code&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
== Important parameters ==&lt;br /&gt;
&lt;br /&gt;
The program exposes the entire DIALS parameter set (spot-finding, indexing, refinement, integration,&lt;br /&gt;
profile modelling, prediction). The parameters below are the ones most commonly adjusted for serial&lt;br /&gt;
still data. Parameters are given by their full PHIL path with their default value.&lt;br /&gt;
&lt;br /&gt;
=== Input ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.reference_geometry&amp;lt;/code&amp;gt; || None || Path to an &amp;lt;code&amp;gt;.expt&amp;lt;/code&amp;gt; file (or image) with a single detector model. Data are processed using &#039;&#039;this&#039;&#039; geometry instead of the geometry in the image headers. This is how a refined detector metrology from &amp;lt;code&amp;gt;cctbx.xfel&amp;lt;/code&amp;gt; ensemble refinement is applied — almost always set for XFEL data.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.sync_reference_geom&amp;lt;/code&amp;gt; || True || When a reference geometry is supplied, copy its refined local frames onto the image&#039;s detector hierarchy node-by-node (the hierarchies must match in shape). If False, the reference detector replaces the image detector wholesale.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.file_list&amp;lt;/code&amp;gt; || None || Path to a text file listing image paths, one per line (alternative to listing files on the command line).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.glob&amp;lt;/code&amp;gt; || None || Wildcard path(s) for large multi-file datasets (e.g. &amp;lt;code&amp;gt;*.cbf&amp;lt;/code&amp;gt;). May be given multiple times.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.image_tag&amp;lt;/code&amp;gt; || None || Process only images with the given tag(s). For single-image files the tag is the filename; for multi-image files (HDF5) it is &amp;lt;code&amp;gt;filename_imagenumber&amp;lt;/code&amp;gt; (image number is 5 digits with leading zeroes). Use &amp;lt;code&amp;gt;input.show_image_tags=True&amp;lt;/code&amp;gt; to list them.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.max_images&amp;lt;/code&amp;gt; || None || Limit the total number of images processed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Dispatch — controlling the pipeline ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dispatch.find_spots&amp;lt;/code&amp;gt; || True || Do spot-finding. Required for indexing/integration.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dispatch.index&amp;lt;/code&amp;gt; || True || Attempt to index. Requires &amp;lt;code&amp;gt;find_spots=True&amp;lt;/code&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dispatch.integrate&amp;lt;/code&amp;gt; || True || Integrate indexed images. Ignored if indexing/spot-finding is off.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dispatch.refine&amp;lt;/code&amp;gt; || False || Run an explicit model-refinement step after indexing (the stills indexer already refines; this is an additional pass, rarely needed).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dispatch.squash_errors&amp;lt;/code&amp;gt; || True || If an image fails, log it and continue to the next image. Set False to halt and show the full error when debugging.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dispatch.hit_finder.enable&amp;lt;/code&amp;gt; || True || Enable hit-finding. If disabled, every image is passed to indexing.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dispatch.hit_finder.minimum_number_of_reflections&amp;lt;/code&amp;gt; || 16 || Images with fewer strong spots than this are discarded as non-hits before indexing.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dispatch.hit_finder.maximum_number_of_reflections&amp;lt;/code&amp;gt; || None || If set, images with more strong spots than this are discarded (e.g. ice/junk).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dispatch.process_percent&amp;lt;/code&amp;gt; || None || Process only this percentage of events (evenly sampled). Useful for a quick look at a large dataset.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dispatch.coset&amp;lt;/code&amp;gt; || False || During integration, also integrate a sublattice coset as a negative control for regions with no Bragg diffraction (see &amp;lt;code&amp;gt;integration.coset.transformation&amp;lt;/code&amp;gt;).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dispatch.pre_import&amp;lt;/code&amp;gt; || False || Import all data before processing. Only needed when processing multiple &#039;&#039;multi-image&#039;&#039; files at once (not a recommended workflow). Single-file datasets (e.g. HDF5) are always pre-imported automatically.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Spot-finding ===&lt;br /&gt;
&lt;br /&gt;
Spot-finding uses the standard DIALS dispersion thresholding. The most impactful parameters for&lt;br /&gt;
serial data:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spotfinder.filter.min_spot_size&amp;lt;/code&amp;gt; || Auto || Minimum connected pixels for a spot. Auto = 3 for pixel-array detectors (SENSOR_PAD), 6 otherwise. Often lowered to 2 for sparse serial patterns.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spotfinder.threshold.dispersion.gain&amp;lt;/code&amp;gt; || None || Detector gain used in thresholding. Set this &#039;&#039;or&#039;&#039; the detector-model gain, not both (see gain note below).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spotfinder.threshold.dispersion.sigma_strong&amp;lt;/code&amp;gt; || 3 || Number of sigma above background for a pixel to be &amp;quot;strong&amp;quot;.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spotfinder.threshold.dispersion.sigma_background&amp;lt;/code&amp;gt; || 6 || Number of sigma for the background/dispersion test.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spotfinder.threshold.dispersion.global_threshold&amp;lt;/code&amp;gt; || 0 || Absolute pixel intensity floor; pixels below this are never considered strong. Raising it (e.g. 100) suppresses noise on many detectors.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spotfinder.threshold.dispersion.kernel_size&amp;lt;/code&amp;gt; || 3 3 || Local-area kernel (pixels) for the dispersion calculation.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Gain note:&#039;&#039;&#039; the detector gain should be set on the detector model &#039;&#039;or&#039;&#039; in the processing&lt;br /&gt;
parameters, never both. If a supplied gain (&amp;lt;code&amp;gt;spotfinder.threshold.dispersion.gain&amp;lt;/code&amp;gt; or&lt;br /&gt;
&amp;lt;code&amp;gt;integration.summation.detector_gain&amp;lt;/code&amp;gt;) conflicts with a non-unity gain already on the&lt;br /&gt;
detector model, the program raises an error. Override with&lt;br /&gt;
&amp;lt;code&amp;gt;input.ignore_gain_mismatch=True&amp;lt;/code&amp;gt; only if you understand the consequences.&lt;br /&gt;
&lt;br /&gt;
=== Indexing ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;indexing.known_symmetry.space_group&amp;lt;/code&amp;gt; || None || Target space group. Strongly recommended for serial data — constrains indexing and improves the hit/index rate.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;indexing.known_symmetry.unit_cell&amp;lt;/code&amp;gt; || None || Target unit cell (a,b,c,α,β,γ). Used together with the space group as the indexing target.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;indexing.method&amp;lt;/code&amp;gt; || fft1d || Basis-vector search method (&amp;lt;code&amp;gt;dials.stills_process&amp;lt;/code&amp;gt; defaults to &amp;lt;code&amp;gt;fft1d&amp;lt;/code&amp;gt;; &amp;lt;code&amp;gt;fft3d&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;real_space_grid_search&amp;lt;/code&amp;gt; are also available).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;indexing.stills.method_list&amp;lt;/code&amp;gt; || None || Ordered list of indexing methods to try in turn; if one fails, the next is attempted (e.g. &amp;lt;code&amp;gt;fft1d real_space_grid_search&amp;lt;/code&amp;gt;).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;indexing.stills.known_orientations&amp;lt;/code&amp;gt; || None || Paths to previously-processed experiment lists. If given, images are &#039;&#039;not&#039;&#039; re-indexed; the stored crystal orientations are reused (e.g. to re-integrate with new parameters). Supports wildcards; may be repeated.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;indexing.stills.require_known_orientation&amp;lt;/code&amp;gt; || False || When known orientations are supplied but an image is not found among them, controls whether to skip it (True) or fall back to indexing from scratch (False).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;indexing.stills.reflection_subsampling.enable&amp;lt;/code&amp;gt; || False || Retry indexing on random subsets of the strong spots (from &amp;lt;code&amp;gt;step_start&amp;lt;/code&amp;gt;% down to &amp;lt;code&amp;gt;step_stop&amp;lt;/code&amp;gt;% in &amp;lt;code&amp;gt;step_size&amp;lt;/code&amp;gt;% steps). Can rescue images that fail to index on the full spot list.  Especially valuble for multi-lattice images (multiple crystals in the beam) but does increase execution time!&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Integration ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;profile.gaussian_rs.parameters.sigma_b_cutoff&amp;lt;/code&amp;gt; || 0.1 || Maximum beam divergence (sigma_b, degrees) before an indexed crystal is rejected prior to integration. Guards against over-broad, poorly-modelled lattices.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;significance_filter.enable&amp;lt;/code&amp;gt; || False || Apply the stills significance filter, which trims each crystal to the resolution at which reflections remain statistically significant (see &amp;lt;code&amp;gt;significance_filter.isigi_cutoff&amp;lt;/code&amp;gt;, default 1.0).  Defaults to false here because it is typically applied in &#039;&#039;[[cctbx.xfel.merge]]&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;integration.integration_only_overrides.trusted_range&amp;lt;/code&amp;gt; || None || Override the panel trusted range [min, max] during integration only (e.g. to include pixels the header marks as untrusted).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;integration.coset.transformation&amp;lt;/code&amp;gt; || 6 || Which modulus-2 sublattice transformation defines the coset negative control when &amp;lt;code&amp;gt;dispatch.coset=True&amp;lt;/code&amp;gt; (0–6; 6 = body centering). See Sauter &amp;amp; Zwart, &#039;&#039;Acta Cryst.&#039;&#039; D (2009) &#039;&#039;&#039;65&#039;&#039;&#039;:553.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Output ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.output_dir&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;.&amp;lt;/code&amp;gt; || Directory for output files.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.composite_output&amp;lt;/code&amp;gt; || True || If True, each process writes &#039;&#039;one&#039;&#039; concatenated set of &amp;lt;code&amp;gt;.expt&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;.refl&amp;lt;/code&amp;gt; files covering all its successful images. If False, a separate pair of files is written per image (generates a very large number of files). Composite output is strongly preferred for large serial datasets.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.logging_dir&amp;lt;/code&amp;gt; || None || Directory for log files. Under MPI, per-rank logs (&amp;lt;code&amp;gt;log_rankNNNN.out&amp;lt;/code&amp;gt;, etc.) are written here.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.logging_option&amp;lt;/code&amp;gt; || normal || &amp;lt;code&amp;gt;normal&amp;lt;/code&amp;gt; (all logging), &amp;lt;code&amp;gt;suppressed&amp;lt;/code&amp;gt; (silences verbose DIALS refine/index output), or &amp;lt;code&amp;gt;disabled&amp;lt;/code&amp;gt; (almost no logging).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.*_filename&amp;lt;/code&amp;gt; || (templates) || Output filename templates for each stage: &amp;lt;code&amp;gt;strong&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;indexed&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;refined_experiments&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;integrated&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;integrated_experiments&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;coset&amp;lt;/code&amp;gt;. A &amp;lt;code&amp;gt;%s&amp;lt;/code&amp;gt; in the template is replaced with the process number for composite mode or the per-image tag for non-composite mode.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.integration_pickle&amp;lt;/code&amp;gt; || None || Write legacy &amp;lt;code&amp;gt;cxi.merge&amp;lt;/code&amp;gt;/PRIME integration pickle files (e.g. &amp;lt;code&amp;gt;int-%d-%s.pickle&amp;lt;/code&amp;gt;). Only needed for legacy merging workflows.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Multiprocessing ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mp.method&amp;lt;/code&amp;gt; || multiprocessing || Parallelization backend: &amp;lt;code&amp;gt;multiprocessing&amp;lt;/code&amp;gt; (single node), or &amp;lt;code&amp;gt;mpi&amp;lt;/code&amp;gt; for multi-node jobs (also &amp;lt;code&amp;gt;sge&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;lsf&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;pbs&amp;lt;/code&amp;gt;).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mp.nproc&amp;lt;/code&amp;gt; || 1 || Number of processes (for the &amp;lt;code&amp;gt;multiprocessing&amp;lt;/code&amp;gt; method). Set to the number of cores per node.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mp.composite_stride&amp;lt;/code&amp;gt; || None || For MPI composite output, how many ranks aggregate their results into one set of output files. Ideally set to the number of processes per node so that one composite file set is written per node rather than per rank.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Under MPI with more than two ranks, the program runs a client/server model: rank 0 (or rank 2 for&lt;br /&gt;
psana2 &amp;lt;code&amp;gt;.loc&amp;lt;/code&amp;gt; inputs) hands out images to worker ranks on demand, giving good load&lt;br /&gt;
balancing across the many fast-failing non-hits typical of serial data.&lt;br /&gt;
&lt;br /&gt;
== Output files ==&lt;br /&gt;
&lt;br /&gt;
With the default composite output, each process (or each aggregating rank under MPI) writes&lt;br /&gt;
concatenated files such as:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;amp;lt;tag&amp;amp;gt;_strong.refl&amp;lt;/code&amp;gt; — strong spots from spot-finding&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;amp;lt;tag&amp;amp;gt;_indexed.refl&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;&amp;amp;lt;tag&amp;amp;gt;_refined.expt&amp;lt;/code&amp;gt; — indexed reflections and their crystal models&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;amp;lt;tag&amp;amp;gt;_integrated.refl&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;&amp;amp;lt;tag&amp;amp;gt;_integrated.expt&amp;lt;/code&amp;gt; — integrated intensities and final models (the input to &#039;&#039;[[cctbx.xfel.merge]]&#039;&#039;)&lt;br /&gt;
&lt;br /&gt;
Per-image progress and status codes are recorded in &amp;lt;code&amp;gt;debug/debug_&amp;amp;lt;rank&amp;amp;gt;.txt&amp;lt;/code&amp;gt;, and&lt;br /&gt;
overall logging goes to &amp;lt;code&amp;gt;dials.process.log&amp;lt;/code&amp;gt; (or per-rank logs under MPI). These integrated&lt;br /&gt;
&amp;lt;code&amp;gt;.expt&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;.refl&amp;lt;/code&amp;gt; pairs are then scaled and merged with&lt;br /&gt;
&#039;&#039;[[cctbx.xfel.merge]]&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
* [[cctbx.xfel.merge]] — scaling, post-refinement and merging of the integrated data&lt;br /&gt;
* [[IOTA]] — a front-end that supplies preset parameters for &amp;lt;code&amp;gt;dials.stills_process&amp;lt;/code&amp;gt;&lt;br /&gt;
* [[Data Processing at SACLA]] — SACLA-specific processing workflow&lt;br /&gt;
* The DIALS documentation for the underlying spot-finding, indexing, refinement and integration algorithms&lt;/div&gt;</summary>
		<author><name>Aaron</name></author>
	</entry>
	<entry>
		<id>http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Dials.stills_process&amp;diff=1766</id>
		<title>Dials.stills process</title>
		<link rel="alternate" type="text/html" href="http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Dials.stills_process&amp;diff=1766"/>
		<updated>2026-08-21T22:52:20Z</updated>

		<summary type="html">&lt;p&gt;Aaron: /* Overview */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= dials.stills_process =&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;dials.stills_process&#039;&#039;&#039;&#039;&#039; is a stand-alone program for processing still diffraction images and is&lt;br /&gt;
the core data-reduction program of &#039;&#039;cctbx.xfel&#039;&#039;. It takes a set of&lt;br /&gt;
still diffraction images — typically serial femtosecond crystallography (SFX) snapshots from an&lt;br /&gt;
XFEL (LCLS, SACLA, EuXFEL) or still shots from a synchrotron — and analyzes each one, independently,&lt;br /&gt;
through the full DIALS pipeline: &#039;&#039;&#039;import → spot-finding → indexing → refinement → integration&#039;&#039;&#039;.&lt;br /&gt;
Its output (integrated intensities together with the per-image experimental models) is the input to&lt;br /&gt;
the merging program [[cctbx.xfel.merge]].&lt;br /&gt;
&lt;br /&gt;
Because every image is a separate still exposure of a different crystal (rather than a wedge of&lt;br /&gt;
a rotation series), each image is treated as its own experiment with its own crystal model. This&lt;br /&gt;
&amp;quot;one crystal per shot&amp;quot; model is what distinguishes stills processing from conventional rotation data&lt;br /&gt;
processing (e.g. &amp;lt;code&amp;gt;dials.import&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;dials.find_spots&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;dials.index&amp;lt;/code&amp;gt;, etc.), &lt;br /&gt;
and it drives most of the stills-specific defaults described below.&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
For each image, &amp;lt;code&amp;gt;dials.stills_process&amp;lt;/code&amp;gt; runs the following stages in order. Any stage can&lt;br /&gt;
be turned off with the &amp;lt;code&amp;gt;dispatch&amp;lt;/code&amp;gt; parameters; if a stage is disabled, processing stops&lt;br /&gt;
after the last enabled stage.&lt;br /&gt;
&lt;br /&gt;
# &#039;&#039;&#039;Import&#039;&#039;&#039; — read the image, apply reference geometry / gain / mask overrides, and build an experiment.&lt;br /&gt;
# &#039;&#039;&#039;Spot-finding&#039;&#039;&#039; — locate strong pixels and build strong reflections (&amp;lt;code&amp;gt;dispatch.find_spots&amp;lt;/code&amp;gt;).&lt;br /&gt;
# &#039;&#039;&#039;Hit finding&#039;&#039;&#039; — reject images with too few (or optionally too many) strong spots, so that only &amp;quot;hits&amp;quot; are indexed (&amp;lt;code&amp;gt;dispatch.hit_finder&amp;lt;/code&amp;gt;).&lt;br /&gt;
# &#039;&#039;&#039;Indexing&#039;&#039;&#039; — determine the crystal orientation and (optionally constrained) unit cell (&amp;lt;code&amp;gt;dispatch.index&amp;lt;/code&amp;gt;).&lt;br /&gt;
# &#039;&#039;&#039;Refinement&#039;&#039;&#039; — refine the crystal model and re-estimate the mosaic/domain-size parameters. Detector and beam are held fixed by default (&amp;lt;code&amp;gt;dispatch.refine&amp;lt;/code&amp;gt;).&lt;br /&gt;
# &#039;&#039;&#039;Integration&#039;&#039;&#039; — predict reflections and measure their intensities using the stills integrator (&amp;lt;code&amp;gt;dispatch.integrate&amp;lt;/code&amp;gt;), with an optional significance filter.&lt;br /&gt;
&lt;br /&gt;
The program applies a set of stills-specific defaults on top of the standard DIALS parameters,&lt;br /&gt;
including: indexing method &amp;lt;code&amp;gt;fft1d&amp;lt;/code&amp;gt;; the stills integrator with profile fitting turned off&lt;br /&gt;
(summation integration with a 2-D plane background); the stills refinement weighting strategy with&lt;br /&gt;
the detector and beam models fixed; and a re-estimation of per-crystal mosaic parameters&lt;br /&gt;
(domain size and mosaic angle) after refinement. These are sensible starting points for serial data&lt;br /&gt;
and normally do not need to be changed.&lt;br /&gt;
&lt;br /&gt;
Failures on individual images are, by default, caught and logged so that processing continues to the&lt;br /&gt;
next image (&amp;lt;code&amp;gt;dispatch.squash_errors=True&amp;lt;/code&amp;gt;) — essential when reducing tens of thousands of&lt;br /&gt;
shots of which only a fraction are hits.&lt;br /&gt;
&lt;br /&gt;
== Basic usage ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Process a directory of CBF stills, constraining the target cell/symmetry,&lt;br /&gt;
# using 32 parallel processes on one node&lt;br /&gt;
dials.stills_process /path/to/images/*.cbf process.phil mp.nproc=32&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A typical &amp;lt;code&amp;gt;process.phil&amp;lt;/code&amp;gt; for XFEL data looks like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
spotfinder.filter.min_spot_size=2&lt;br /&gt;
spotfinder.threshold.dispersion.gain=1.0&lt;br /&gt;
spotfinder.threshold.dispersion.global_threshold=100&lt;br /&gt;
&lt;br /&gt;
indexing.known_symmetry.space_group=P43212&lt;br /&gt;
indexing.known_symmetry.unit_cell=78.9,78.9,38.1,90,90,90&lt;br /&gt;
indexing.method=fft1d&lt;br /&gt;
&lt;br /&gt;
input.reference_geometry=refined.expt   # from a previous metrology refinement&lt;br /&gt;
&lt;br /&gt;
output.output_dir=out&lt;br /&gt;
mp.nproc=32&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Useful command-line helpers:&lt;br /&gt;
* &amp;lt;code&amp;gt;dials.stills_process -h&amp;lt;/code&amp;gt; — help and usage&lt;br /&gt;
* &amp;lt;code&amp;gt;dials.stills_process -c -e 2&amp;lt;/code&amp;gt; — show the configurable parameters (expert level 2)&lt;br /&gt;
* &amp;lt;code&amp;gt;dials.stills_process -c -a2&amp;lt;/code&amp;gt; — include attributes (help text) for each parameter&lt;br /&gt;
* &amp;lt;code&amp;gt;dials.stills_process ... input.show_image_tags=True&amp;lt;/code&amp;gt; — list the image tags in a dataset without processing (useful for selecting subsets with &amp;lt;code&amp;gt;input.image_tag&amp;lt;/code&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
== Important parameters ==&lt;br /&gt;
&lt;br /&gt;
The program exposes the entire DIALS parameter set (spot-finding, indexing, refinement, integration,&lt;br /&gt;
profile modelling, prediction). The parameters below are the ones most commonly adjusted for serial&lt;br /&gt;
still data. Parameters are given by their full PHIL path with their default value.&lt;br /&gt;
&lt;br /&gt;
=== Input ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.reference_geometry&amp;lt;/code&amp;gt; || None || Path to an &amp;lt;code&amp;gt;.expt&amp;lt;/code&amp;gt; file (or image) with a single detector model. Data are processed using &#039;&#039;this&#039;&#039; geometry instead of the geometry in the image headers. This is how a refined detector metrology from &amp;lt;code&amp;gt;cctbx.xfel&amp;lt;/code&amp;gt; ensemble refinement is applied — almost always set for XFEL data.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.sync_reference_geom&amp;lt;/code&amp;gt; || True || When a reference geometry is supplied, copy its refined local frames onto the image&#039;s detector hierarchy node-by-node (the hierarchies must match in shape). If False, the reference detector replaces the image detector wholesale.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.file_list&amp;lt;/code&amp;gt; || None || Path to a text file listing image paths, one per line (alternative to listing files on the command line).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.glob&amp;lt;/code&amp;gt; || None || Wildcard path(s) for large multi-file datasets (e.g. &amp;lt;code&amp;gt;*.cbf&amp;lt;/code&amp;gt;). May be given multiple times.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.image_tag&amp;lt;/code&amp;gt; || None || Process only images with the given tag(s). For single-image files the tag is the filename; for multi-image files (HDF5) it is &amp;lt;code&amp;gt;filename_imagenumber&amp;lt;/code&amp;gt; (image number is 5 digits with leading zeroes). Use &amp;lt;code&amp;gt;input.show_image_tags=True&amp;lt;/code&amp;gt; to list them.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.max_images&amp;lt;/code&amp;gt; || None || Limit the total number of images processed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Dispatch — controlling the pipeline ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dispatch.find_spots&amp;lt;/code&amp;gt; || True || Do spot-finding. Required for indexing/integration.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dispatch.index&amp;lt;/code&amp;gt; || True || Attempt to index. Requires &amp;lt;code&amp;gt;find_spots=True&amp;lt;/code&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dispatch.integrate&amp;lt;/code&amp;gt; || True || Integrate indexed images. Ignored if indexing/spot-finding is off.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dispatch.refine&amp;lt;/code&amp;gt; || False || Run an explicit model-refinement step after indexing (the stills indexer already refines; this is an additional pass, rarely needed).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dispatch.squash_errors&amp;lt;/code&amp;gt; || True || If an image fails, log it and continue to the next image. Set False to halt and show the full error when debugging.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dispatch.hit_finder.enable&amp;lt;/code&amp;gt; || True || Enable hit-finding. If disabled, every image is passed to indexing.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dispatch.hit_finder.minimum_number_of_reflections&amp;lt;/code&amp;gt; || 16 || Images with fewer strong spots than this are discarded as non-hits before indexing.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dispatch.hit_finder.maximum_number_of_reflections&amp;lt;/code&amp;gt; || None || If set, images with more strong spots than this are discarded (e.g. ice/junk).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dispatch.process_percent&amp;lt;/code&amp;gt; || None || Process only this percentage of events (evenly sampled). Useful for a quick look at a large dataset.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dispatch.coset&amp;lt;/code&amp;gt; || False || During integration, also integrate a sublattice coset as a negative control for regions with no Bragg diffraction (see &amp;lt;code&amp;gt;integration.coset.transformation&amp;lt;/code&amp;gt;).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dispatch.pre_import&amp;lt;/code&amp;gt; || False || Import all data before processing. Only needed when processing multiple &#039;&#039;multi-image&#039;&#039; files at once (not a recommended workflow). Single-file datasets (e.g. HDF5) are always pre-imported automatically.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Spot-finding ===&lt;br /&gt;
&lt;br /&gt;
Spot-finding uses the standard DIALS dispersion thresholding. The most impactful parameters for&lt;br /&gt;
serial data:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spotfinder.filter.min_spot_size&amp;lt;/code&amp;gt; || Auto || Minimum connected pixels for a spot. Auto = 3 for pixel-array detectors (SENSOR_PAD), 6 otherwise. Often lowered to 2 for sparse serial patterns.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spotfinder.threshold.dispersion.gain&amp;lt;/code&amp;gt; || None || Detector gain used in thresholding. Set this &#039;&#039;or&#039;&#039; the detector-model gain, not both (see gain note below).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spotfinder.threshold.dispersion.sigma_strong&amp;lt;/code&amp;gt; || 3 || Number of sigma above background for a pixel to be &amp;quot;strong&amp;quot;.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spotfinder.threshold.dispersion.sigma_background&amp;lt;/code&amp;gt; || 6 || Number of sigma for the background/dispersion test.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spotfinder.threshold.dispersion.global_threshold&amp;lt;/code&amp;gt; || 0 || Absolute pixel intensity floor; pixels below this are never considered strong. Raising it (e.g. 100) suppresses noise on many detectors.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spotfinder.threshold.dispersion.kernel_size&amp;lt;/code&amp;gt; || 3 3 || Local-area kernel (pixels) for the dispersion calculation.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Gain note:&#039;&#039;&#039; the detector gain should be set on the detector model &#039;&#039;or&#039;&#039; in the processing&lt;br /&gt;
parameters, never both. If a supplied gain (&amp;lt;code&amp;gt;spotfinder.threshold.dispersion.gain&amp;lt;/code&amp;gt; or&lt;br /&gt;
&amp;lt;code&amp;gt;integration.summation.detector_gain&amp;lt;/code&amp;gt;) conflicts with a non-unity gain already on the&lt;br /&gt;
detector model, the program raises an error. Override with&lt;br /&gt;
&amp;lt;code&amp;gt;input.ignore_gain_mismatch=True&amp;lt;/code&amp;gt; only if you understand the consequences.&lt;br /&gt;
&lt;br /&gt;
=== Indexing ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;indexing.known_symmetry.space_group&amp;lt;/code&amp;gt; || None || Target space group. Strongly recommended for serial data — constrains indexing and improves the hit/index rate.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;indexing.known_symmetry.unit_cell&amp;lt;/code&amp;gt; || None || Target unit cell (a,b,c,α,β,γ). Used together with the space group as the indexing target.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;indexing.method&amp;lt;/code&amp;gt; || fft1d || Basis-vector search method (&amp;lt;code&amp;gt;dials.stills_process&amp;lt;/code&amp;gt; defaults to &amp;lt;code&amp;gt;fft1d&amp;lt;/code&amp;gt;; &amp;lt;code&amp;gt;fft3d&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;real_space_grid_search&amp;lt;/code&amp;gt; are also available).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;indexing.stills.method_list&amp;lt;/code&amp;gt; || None || Ordered list of indexing methods to try in turn; if one fails, the next is attempted (e.g. &amp;lt;code&amp;gt;fft1d real_space_grid_search&amp;lt;/code&amp;gt;).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;indexing.stills.known_orientations&amp;lt;/code&amp;gt; || None || Paths to previously-processed experiment lists. If given, images are &#039;&#039;not&#039;&#039; re-indexed; the stored crystal orientations are reused (e.g. to re-integrate with new parameters). Supports wildcards; may be repeated.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;indexing.stills.require_known_orientation&amp;lt;/code&amp;gt; || False || When known orientations are supplied but an image is not found among them, controls whether to skip it (True) or fall back to indexing from scratch (False).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;indexing.stills.reflection_subsampling.enable&amp;lt;/code&amp;gt; || False || Retry indexing on random subsets of the strong spots (from &amp;lt;code&amp;gt;step_start&amp;lt;/code&amp;gt;% down to &amp;lt;code&amp;gt;step_stop&amp;lt;/code&amp;gt;% in &amp;lt;code&amp;gt;step_size&amp;lt;/code&amp;gt;% steps). Can rescue images that fail to index on the full spot list.  Especially valuble for multi-lattice images (multiple crystals in the beam) but does increase execution time!&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Integration ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;profile.gaussian_rs.parameters.sigma_b_cutoff&amp;lt;/code&amp;gt; || 0.1 || Maximum beam divergence (sigma_b, degrees) before an indexed crystal is rejected prior to integration. Guards against over-broad, poorly-modelled lattices.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;significance_filter.enable&amp;lt;/code&amp;gt; || False || Apply the stills significance filter, which trims each crystal to the resolution at which reflections remain statistically significant (see &amp;lt;code&amp;gt;significance_filter.isigi_cutoff&amp;lt;/code&amp;gt;, default 1.0).  Defaults to false here because it is typically applied in &#039;&#039;[[cctbx.xfel.merge]]&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;integration.integration_only_overrides.trusted_range&amp;lt;/code&amp;gt; || None || Override the panel trusted range [min, max] during integration only (e.g. to include pixels the header marks as untrusted).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;integration.coset.transformation&amp;lt;/code&amp;gt; || 6 || Which modulus-2 sublattice transformation defines the coset negative control when &amp;lt;code&amp;gt;dispatch.coset=True&amp;lt;/code&amp;gt; (0–6; 6 = body centering). See Sauter &amp;amp; Zwart, &#039;&#039;Acta Cryst.&#039;&#039; D (2009) &#039;&#039;&#039;65&#039;&#039;&#039;:553.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Output ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.output_dir&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;.&amp;lt;/code&amp;gt; || Directory for output files.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.composite_output&amp;lt;/code&amp;gt; || True || If True, each process writes &#039;&#039;one&#039;&#039; concatenated set of &amp;lt;code&amp;gt;.expt&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;.refl&amp;lt;/code&amp;gt; files covering all its successful images. If False, a separate pair of files is written per image (generates a very large number of files). Composite output is strongly preferred for large serial datasets.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.logging_dir&amp;lt;/code&amp;gt; || None || Directory for log files. Under MPI, per-rank logs (&amp;lt;code&amp;gt;log_rankNNNN.out&amp;lt;/code&amp;gt;, etc.) are written here.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.logging_option&amp;lt;/code&amp;gt; || normal || &amp;lt;code&amp;gt;normal&amp;lt;/code&amp;gt; (all logging), &amp;lt;code&amp;gt;suppressed&amp;lt;/code&amp;gt; (silences verbose DIALS refine/index output), or &amp;lt;code&amp;gt;disabled&amp;lt;/code&amp;gt; (almost no logging).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.*_filename&amp;lt;/code&amp;gt; || (templates) || Output filename templates for each stage: &amp;lt;code&amp;gt;strong&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;indexed&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;refined_experiments&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;integrated&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;integrated_experiments&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;coset&amp;lt;/code&amp;gt;. A &amp;lt;code&amp;gt;%s&amp;lt;/code&amp;gt; in the template is replaced with the process number for composite mode or the per-image tag for non-composite mode.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.integration_pickle&amp;lt;/code&amp;gt; || None || Write legacy &amp;lt;code&amp;gt;cxi.merge&amp;lt;/code&amp;gt;/PRIME integration pickle files (e.g. &amp;lt;code&amp;gt;int-%d-%s.pickle&amp;lt;/code&amp;gt;). Only needed for legacy merging workflows.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Multiprocessing ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mp.method&amp;lt;/code&amp;gt; || multiprocessing || Parallelization backend: &amp;lt;code&amp;gt;multiprocessing&amp;lt;/code&amp;gt; (single node), or &amp;lt;code&amp;gt;mpi&amp;lt;/code&amp;gt; for multi-node jobs (also &amp;lt;code&amp;gt;sge&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;lsf&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;pbs&amp;lt;/code&amp;gt;).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mp.nproc&amp;lt;/code&amp;gt; || 1 || Number of processes (for the &amp;lt;code&amp;gt;multiprocessing&amp;lt;/code&amp;gt; method). Set to the number of cores per node.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mp.composite_stride&amp;lt;/code&amp;gt; || None || For MPI composite output, how many ranks aggregate their results into one set of output files. Ideally set to the number of processes per node so that one composite file set is written per node rather than per rank.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Under MPI with more than two ranks, the program runs a client/server model: rank 0 (or rank 2 for&lt;br /&gt;
psana2 &amp;lt;code&amp;gt;.loc&amp;lt;/code&amp;gt; inputs) hands out images to worker ranks on demand, giving good load&lt;br /&gt;
balancing across the many fast-failing non-hits typical of serial data.&lt;br /&gt;
&lt;br /&gt;
== Output files ==&lt;br /&gt;
&lt;br /&gt;
With the default composite output, each process (or each aggregating rank under MPI) writes&lt;br /&gt;
concatenated files such as:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;amp;lt;tag&amp;amp;gt;_strong.refl&amp;lt;/code&amp;gt; — strong spots from spot-finding&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;amp;lt;tag&amp;amp;gt;_indexed.refl&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;&amp;amp;lt;tag&amp;amp;gt;_refined.expt&amp;lt;/code&amp;gt; — indexed reflections and their crystal models&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;amp;lt;tag&amp;amp;gt;_integrated.refl&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;&amp;amp;lt;tag&amp;amp;gt;_integrated.expt&amp;lt;/code&amp;gt; — integrated intensities and final models (the input to [[cctbx.xfel.merge]])&lt;br /&gt;
&lt;br /&gt;
Per-image progress and status codes are recorded in &amp;lt;code&amp;gt;debug/debug_&amp;amp;lt;rank&amp;amp;gt;.txt&amp;lt;/code&amp;gt;, and&lt;br /&gt;
overall logging goes to &amp;lt;code&amp;gt;dials.process.log&amp;lt;/code&amp;gt; (or per-rank logs under MPI). These integrated&lt;br /&gt;
&amp;lt;code&amp;gt;.expt&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;.refl&amp;lt;/code&amp;gt; pairs are then scaled and merged with&lt;br /&gt;
[[cctbx.xfel.merge]].&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
* [[cctbx.xfel.merge]] — scaling, post-refinement and merging of the integrated data&lt;br /&gt;
* [[IOTA]] — a front-end that supplies preset parameters for &amp;lt;code&amp;gt;dials.stills_process&amp;lt;/code&amp;gt;&lt;br /&gt;
* [[Data Processing at SACLA]] — SACLA-specific processing workflow&lt;br /&gt;
* The DIALS documentation for the underlying spot-finding, indexing, refinement and integration algorithms&lt;/div&gt;</summary>
		<author><name>Aaron</name></author>
	</entry>
	<entry>
		<id>http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Dials.stills_process&amp;diff=1765</id>
		<title>Dials.stills process</title>
		<link rel="alternate" type="text/html" href="http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Dials.stills_process&amp;diff=1765"/>
		<updated>2026-08-21T22:51:29Z</updated>

		<summary type="html">&lt;p&gt;Aaron: /* Important parameters */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= dials.stills_process =&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;dials.stills_process&#039;&#039;&#039;&#039;&#039; is a stand-alone program for processing still diffraction images and is&lt;br /&gt;
the core data-reduction program of &#039;&#039;cctbx.xfel&#039;&#039;. It takes a set of&lt;br /&gt;
still diffraction images — typically serial femtosecond crystallography (SFX) snapshots from an&lt;br /&gt;
XFEL (LCLS, SACLA, EuXFEL) or still shots from a synchrotron — and analyzes each one, independently,&lt;br /&gt;
through the full DIALS pipeline: &#039;&#039;&#039;import → spot-finding → indexing → refinement → integration&#039;&#039;&#039;.&lt;br /&gt;
Its output (integrated intensities together with the per-image experimental models) is the input to&lt;br /&gt;
the merging program [[cctbx.xfel.merge]].&lt;br /&gt;
&lt;br /&gt;
Because every image is a separate still exposure of a different crystal (rather than a wedge of&lt;br /&gt;
a rotation series), each image is treated as its own experiment with its own crystal model. This&lt;br /&gt;
&amp;quot;one crystal per shot&amp;quot; model is what distinguishes stills processing from conventional rotation data&lt;br /&gt;
processing (e.g. &amp;lt;code&amp;gt;dials.import&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;dials.find_spots&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;dials.index&amp;lt;/code&amp;gt;, etc.), &lt;br /&gt;
and it drives most of the stills-specific defaults described below.&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
For each image, &amp;lt;code&amp;gt;dials.stills_process&amp;lt;/code&amp;gt; runs the following stages in order. Any stage can&lt;br /&gt;
be turned off with the &amp;lt;code&amp;gt;dispatch&amp;lt;/code&amp;gt; parameters; if a stage is disabled, processing stops&lt;br /&gt;
after the last enabled stage.&lt;br /&gt;
&lt;br /&gt;
# &#039;&#039;&#039;Import&#039;&#039;&#039; — read the image, apply reference geometry / gain / mask overrides, and build an experiment.&lt;br /&gt;
# &#039;&#039;&#039;Spot-finding&#039;&#039;&#039; — locate strong pixels and build strong reflections (&amp;lt;code&amp;gt;dispatch.find_spots&amp;lt;/code&amp;gt;).&lt;br /&gt;
# &#039;&#039;&#039;Hit finding&#039;&#039;&#039; — reject images with too few (or optionally too many) strong spots, so that only &amp;quot;hits&amp;quot; are indexed (&amp;lt;code&amp;gt;dispatch.hit_finder&amp;lt;/code&amp;gt;).&lt;br /&gt;
# &#039;&#039;&#039;Indexing&#039;&#039;&#039; — determine the crystal orientation and (optionally constrained) unit cell (&amp;lt;code&amp;gt;dispatch.index&amp;lt;/code&amp;gt;).&lt;br /&gt;
# &#039;&#039;&#039;Refinement&#039;&#039;&#039; — refine the crystal model and re-estimate the mosaic/domain-size parameters. Detector and beam are held fixed by default (&amp;lt;code&amp;gt;dispatch.refine&amp;lt;/code&amp;gt;).&lt;br /&gt;
# &#039;&#039;&#039;Integration&#039;&#039;&#039; — predict reflections and measure their intensities using the stills integrator (&amp;lt;code&amp;gt;dispatch.integrate&amp;lt;/code&amp;gt;), with optional Kapton absorption correction and a significance filter.&lt;br /&gt;
&lt;br /&gt;
The program applies a set of stills-specific defaults on top of the standard DIALS parameters,&lt;br /&gt;
including: indexing method &amp;lt;code&amp;gt;fft1d&amp;lt;/code&amp;gt;; the stills integrator with profile fitting turned off&lt;br /&gt;
(summation integration with a 2-D plane background); the stills refinement weighting strategy with&lt;br /&gt;
the detector and beam models fixed; and a re-estimation of per-crystal mosaic parameters&lt;br /&gt;
(domain size and mosaic angle) after refinement. These are sensible starting points for serial data&lt;br /&gt;
and normally do not need to be changed.&lt;br /&gt;
&lt;br /&gt;
Failures on individual images are, by default, caught and logged so that processing continues to the&lt;br /&gt;
next image (&amp;lt;code&amp;gt;dispatch.squash_errors=True&amp;lt;/code&amp;gt;) — essential when reducing tens of thousands of&lt;br /&gt;
shots of which only a fraction are hits.&lt;br /&gt;
&lt;br /&gt;
== Basic usage ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Process a directory of CBF stills, constraining the target cell/symmetry,&lt;br /&gt;
# using 32 parallel processes on one node&lt;br /&gt;
dials.stills_process /path/to/images/*.cbf process.phil mp.nproc=32&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A typical &amp;lt;code&amp;gt;process.phil&amp;lt;/code&amp;gt; for XFEL data looks like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
spotfinder.filter.min_spot_size=2&lt;br /&gt;
spotfinder.threshold.dispersion.gain=1.0&lt;br /&gt;
spotfinder.threshold.dispersion.global_threshold=100&lt;br /&gt;
&lt;br /&gt;
indexing.known_symmetry.space_group=P43212&lt;br /&gt;
indexing.known_symmetry.unit_cell=78.9,78.9,38.1,90,90,90&lt;br /&gt;
indexing.method=fft1d&lt;br /&gt;
&lt;br /&gt;
input.reference_geometry=refined.expt   # from a previous metrology refinement&lt;br /&gt;
&lt;br /&gt;
output.output_dir=out&lt;br /&gt;
mp.nproc=32&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Useful command-line helpers:&lt;br /&gt;
* &amp;lt;code&amp;gt;dials.stills_process -h&amp;lt;/code&amp;gt; — help and usage&lt;br /&gt;
* &amp;lt;code&amp;gt;dials.stills_process -c -e 2&amp;lt;/code&amp;gt; — show the configurable parameters (expert level 2)&lt;br /&gt;
* &amp;lt;code&amp;gt;dials.stills_process -c -a2&amp;lt;/code&amp;gt; — include attributes (help text) for each parameter&lt;br /&gt;
* &amp;lt;code&amp;gt;dials.stills_process ... input.show_image_tags=True&amp;lt;/code&amp;gt; — list the image tags in a dataset without processing (useful for selecting subsets with &amp;lt;code&amp;gt;input.image_tag&amp;lt;/code&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
== Important parameters ==&lt;br /&gt;
&lt;br /&gt;
The program exposes the entire DIALS parameter set (spot-finding, indexing, refinement, integration,&lt;br /&gt;
profile modelling, prediction). The parameters below are the ones most commonly adjusted for serial&lt;br /&gt;
still data. Parameters are given by their full PHIL path with their default value.&lt;br /&gt;
&lt;br /&gt;
=== Input ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.reference_geometry&amp;lt;/code&amp;gt; || None || Path to an &amp;lt;code&amp;gt;.expt&amp;lt;/code&amp;gt; file (or image) with a single detector model. Data are processed using &#039;&#039;this&#039;&#039; geometry instead of the geometry in the image headers. This is how a refined detector metrology from &amp;lt;code&amp;gt;cctbx.xfel&amp;lt;/code&amp;gt; ensemble refinement is applied — almost always set for XFEL data.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.sync_reference_geom&amp;lt;/code&amp;gt; || True || When a reference geometry is supplied, copy its refined local frames onto the image&#039;s detector hierarchy node-by-node (the hierarchies must match in shape). If False, the reference detector replaces the image detector wholesale.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.file_list&amp;lt;/code&amp;gt; || None || Path to a text file listing image paths, one per line (alternative to listing files on the command line).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.glob&amp;lt;/code&amp;gt; || None || Wildcard path(s) for large multi-file datasets (e.g. &amp;lt;code&amp;gt;*.cbf&amp;lt;/code&amp;gt;). May be given multiple times.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.image_tag&amp;lt;/code&amp;gt; || None || Process only images with the given tag(s). For single-image files the tag is the filename; for multi-image files (HDF5) it is &amp;lt;code&amp;gt;filename_imagenumber&amp;lt;/code&amp;gt; (image number is 5 digits with leading zeroes). Use &amp;lt;code&amp;gt;input.show_image_tags=True&amp;lt;/code&amp;gt; to list them.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.max_images&amp;lt;/code&amp;gt; || None || Limit the total number of images processed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Dispatch — controlling the pipeline ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dispatch.find_spots&amp;lt;/code&amp;gt; || True || Do spot-finding. Required for indexing/integration.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dispatch.index&amp;lt;/code&amp;gt; || True || Attempt to index. Requires &amp;lt;code&amp;gt;find_spots=True&amp;lt;/code&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dispatch.integrate&amp;lt;/code&amp;gt; || True || Integrate indexed images. Ignored if indexing/spot-finding is off.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dispatch.refine&amp;lt;/code&amp;gt; || False || Run an explicit model-refinement step after indexing (the stills indexer already refines; this is an additional pass, rarely needed).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dispatch.squash_errors&amp;lt;/code&amp;gt; || True || If an image fails, log it and continue to the next image. Set False to halt and show the full error when debugging.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dispatch.hit_finder.enable&amp;lt;/code&amp;gt; || True || Enable hit-finding. If disabled, every image is passed to indexing.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dispatch.hit_finder.minimum_number_of_reflections&amp;lt;/code&amp;gt; || 16 || Images with fewer strong spots than this are discarded as non-hits before indexing.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dispatch.hit_finder.maximum_number_of_reflections&amp;lt;/code&amp;gt; || None || If set, images with more strong spots than this are discarded (e.g. ice/junk).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dispatch.process_percent&amp;lt;/code&amp;gt; || None || Process only this percentage of events (evenly sampled). Useful for a quick look at a large dataset.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dispatch.coset&amp;lt;/code&amp;gt; || False || During integration, also integrate a sublattice coset as a negative control for regions with no Bragg diffraction (see &amp;lt;code&amp;gt;integration.coset.transformation&amp;lt;/code&amp;gt;).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dispatch.pre_import&amp;lt;/code&amp;gt; || False || Import all data before processing. Only needed when processing multiple &#039;&#039;multi-image&#039;&#039; files at once (not a recommended workflow). Single-file datasets (e.g. HDF5) are always pre-imported automatically.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Spot-finding ===&lt;br /&gt;
&lt;br /&gt;
Spot-finding uses the standard DIALS dispersion thresholding. The most impactful parameters for&lt;br /&gt;
serial data:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spotfinder.filter.min_spot_size&amp;lt;/code&amp;gt; || Auto || Minimum connected pixels for a spot. Auto = 3 for pixel-array detectors (SENSOR_PAD), 6 otherwise. Often lowered to 2 for sparse serial patterns.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spotfinder.threshold.dispersion.gain&amp;lt;/code&amp;gt; || None || Detector gain used in thresholding. Set this &#039;&#039;or&#039;&#039; the detector-model gain, not both (see gain note below).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spotfinder.threshold.dispersion.sigma_strong&amp;lt;/code&amp;gt; || 3 || Number of sigma above background for a pixel to be &amp;quot;strong&amp;quot;.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spotfinder.threshold.dispersion.sigma_background&amp;lt;/code&amp;gt; || 6 || Number of sigma for the background/dispersion test.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spotfinder.threshold.dispersion.global_threshold&amp;lt;/code&amp;gt; || 0 || Absolute pixel intensity floor; pixels below this are never considered strong. Raising it (e.g. 100) suppresses noise on many detectors.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spotfinder.threshold.dispersion.kernel_size&amp;lt;/code&amp;gt; || 3 3 || Local-area kernel (pixels) for the dispersion calculation.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Gain note:&#039;&#039;&#039; the detector gain should be set on the detector model &#039;&#039;or&#039;&#039; in the processing&lt;br /&gt;
parameters, never both. If a supplied gain (&amp;lt;code&amp;gt;spotfinder.threshold.dispersion.gain&amp;lt;/code&amp;gt; or&lt;br /&gt;
&amp;lt;code&amp;gt;integration.summation.detector_gain&amp;lt;/code&amp;gt;) conflicts with a non-unity gain already on the&lt;br /&gt;
detector model, the program raises an error. Override with&lt;br /&gt;
&amp;lt;code&amp;gt;input.ignore_gain_mismatch=True&amp;lt;/code&amp;gt; only if you understand the consequences.&lt;br /&gt;
&lt;br /&gt;
=== Indexing ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;indexing.known_symmetry.space_group&amp;lt;/code&amp;gt; || None || Target space group. Strongly recommended for serial data — constrains indexing and improves the hit/index rate.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;indexing.known_symmetry.unit_cell&amp;lt;/code&amp;gt; || None || Target unit cell (a,b,c,α,β,γ). Used together with the space group as the indexing target.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;indexing.method&amp;lt;/code&amp;gt; || fft1d || Basis-vector search method (&amp;lt;code&amp;gt;dials.stills_process&amp;lt;/code&amp;gt; defaults to &amp;lt;code&amp;gt;fft1d&amp;lt;/code&amp;gt;; &amp;lt;code&amp;gt;fft3d&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;real_space_grid_search&amp;lt;/code&amp;gt; are also available).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;indexing.stills.method_list&amp;lt;/code&amp;gt; || None || Ordered list of indexing methods to try in turn; if one fails, the next is attempted (e.g. &amp;lt;code&amp;gt;fft1d real_space_grid_search&amp;lt;/code&amp;gt;).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;indexing.stills.known_orientations&amp;lt;/code&amp;gt; || None || Paths to previously-processed experiment lists. If given, images are &#039;&#039;not&#039;&#039; re-indexed; the stored crystal orientations are reused (e.g. to re-integrate with new parameters). Supports wildcards; may be repeated.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;indexing.stills.require_known_orientation&amp;lt;/code&amp;gt; || False || When known orientations are supplied but an image is not found among them, controls whether to skip it (True) or fall back to indexing from scratch (False).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;indexing.stills.reflection_subsampling.enable&amp;lt;/code&amp;gt; || False || Retry indexing on random subsets of the strong spots (from &amp;lt;code&amp;gt;step_start&amp;lt;/code&amp;gt;% down to &amp;lt;code&amp;gt;step_stop&amp;lt;/code&amp;gt;% in &amp;lt;code&amp;gt;step_size&amp;lt;/code&amp;gt;% steps). Can rescue images that fail to index on the full spot list.  Especially valuble for multi-lattice images (multiple crystals in the beam) but does increase execution time!&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Integration ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;profile.gaussian_rs.parameters.sigma_b_cutoff&amp;lt;/code&amp;gt; || 0.1 || Maximum beam divergence (sigma_b, degrees) before an indexed crystal is rejected prior to integration. Guards against over-broad, poorly-modelled lattices.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;significance_filter.enable&amp;lt;/code&amp;gt; || False || Apply the stills significance filter, which trims each crystal to the resolution at which reflections remain statistically significant (see &amp;lt;code&amp;gt;significance_filter.isigi_cutoff&amp;lt;/code&amp;gt;, default 1.0).  Defaults to false here because it is typically applied in &#039;&#039;[[cctbx.xfel.merge]]&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;integration.integration_only_overrides.trusted_range&amp;lt;/code&amp;gt; || None || Override the panel trusted range [min, max] during integration only (e.g. to include pixels the header marks as untrusted).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;integration.coset.transformation&amp;lt;/code&amp;gt; || 6 || Which modulus-2 sublattice transformation defines the coset negative control when &amp;lt;code&amp;gt;dispatch.coset=True&amp;lt;/code&amp;gt; (0–6; 6 = body centering). See Sauter &amp;amp; Zwart, &#039;&#039;Acta Cryst.&#039;&#039; D (2009) &#039;&#039;&#039;65&#039;&#039;&#039;:553.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Output ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.output_dir&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;.&amp;lt;/code&amp;gt; || Directory for output files.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.composite_output&amp;lt;/code&amp;gt; || True || If True, each process writes &#039;&#039;one&#039;&#039; concatenated set of &amp;lt;code&amp;gt;.expt&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;.refl&amp;lt;/code&amp;gt; files covering all its successful images. If False, a separate pair of files is written per image (generates a very large number of files). Composite output is strongly preferred for large serial datasets.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.logging_dir&amp;lt;/code&amp;gt; || None || Directory for log files. Under MPI, per-rank logs (&amp;lt;code&amp;gt;log_rankNNNN.out&amp;lt;/code&amp;gt;, etc.) are written here.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.logging_option&amp;lt;/code&amp;gt; || normal || &amp;lt;code&amp;gt;normal&amp;lt;/code&amp;gt; (all logging), &amp;lt;code&amp;gt;suppressed&amp;lt;/code&amp;gt; (silences verbose DIALS refine/index output), or &amp;lt;code&amp;gt;disabled&amp;lt;/code&amp;gt; (almost no logging).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.*_filename&amp;lt;/code&amp;gt; || (templates) || Output filename templates for each stage: &amp;lt;code&amp;gt;strong&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;indexed&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;refined_experiments&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;integrated&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;integrated_experiments&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;coset&amp;lt;/code&amp;gt;. A &amp;lt;code&amp;gt;%s&amp;lt;/code&amp;gt; in the template is replaced with the process number for composite mode or the per-image tag for non-composite mode.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.integration_pickle&amp;lt;/code&amp;gt; || None || Write legacy &amp;lt;code&amp;gt;cxi.merge&amp;lt;/code&amp;gt;/PRIME integration pickle files (e.g. &amp;lt;code&amp;gt;int-%d-%s.pickle&amp;lt;/code&amp;gt;). Only needed for legacy merging workflows.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Multiprocessing ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mp.method&amp;lt;/code&amp;gt; || multiprocessing || Parallelization backend: &amp;lt;code&amp;gt;multiprocessing&amp;lt;/code&amp;gt; (single node), or &amp;lt;code&amp;gt;mpi&amp;lt;/code&amp;gt; for multi-node jobs (also &amp;lt;code&amp;gt;sge&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;lsf&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;pbs&amp;lt;/code&amp;gt;).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mp.nproc&amp;lt;/code&amp;gt; || 1 || Number of processes (for the &amp;lt;code&amp;gt;multiprocessing&amp;lt;/code&amp;gt; method). Set to the number of cores per node.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mp.composite_stride&amp;lt;/code&amp;gt; || None || For MPI composite output, how many ranks aggregate their results into one set of output files. Ideally set to the number of processes per node so that one composite file set is written per node rather than per rank.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Under MPI with more than two ranks, the program runs a client/server model: rank 0 (or rank 2 for&lt;br /&gt;
psana2 &amp;lt;code&amp;gt;.loc&amp;lt;/code&amp;gt; inputs) hands out images to worker ranks on demand, giving good load&lt;br /&gt;
balancing across the many fast-failing non-hits typical of serial data.&lt;br /&gt;
&lt;br /&gt;
== Output files ==&lt;br /&gt;
&lt;br /&gt;
With the default composite output, each process (or each aggregating rank under MPI) writes&lt;br /&gt;
concatenated files such as:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;amp;lt;tag&amp;amp;gt;_strong.refl&amp;lt;/code&amp;gt; — strong spots from spot-finding&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;amp;lt;tag&amp;amp;gt;_indexed.refl&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;&amp;amp;lt;tag&amp;amp;gt;_refined.expt&amp;lt;/code&amp;gt; — indexed reflections and their crystal models&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;amp;lt;tag&amp;amp;gt;_integrated.refl&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;&amp;amp;lt;tag&amp;amp;gt;_integrated.expt&amp;lt;/code&amp;gt; — integrated intensities and final models (the input to [[cctbx.xfel.merge]])&lt;br /&gt;
&lt;br /&gt;
Per-image progress and status codes are recorded in &amp;lt;code&amp;gt;debug/debug_&amp;amp;lt;rank&amp;amp;gt;.txt&amp;lt;/code&amp;gt;, and&lt;br /&gt;
overall logging goes to &amp;lt;code&amp;gt;dials.process.log&amp;lt;/code&amp;gt; (or per-rank logs under MPI). These integrated&lt;br /&gt;
&amp;lt;code&amp;gt;.expt&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;.refl&amp;lt;/code&amp;gt; pairs are then scaled and merged with&lt;br /&gt;
[[cctbx.xfel.merge]].&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
* [[cctbx.xfel.merge]] — scaling, post-refinement and merging of the integrated data&lt;br /&gt;
* [[IOTA]] — a front-end that supplies preset parameters for &amp;lt;code&amp;gt;dials.stills_process&amp;lt;/code&amp;gt;&lt;br /&gt;
* [[Data Processing at SACLA]] — SACLA-specific processing workflow&lt;br /&gt;
* The DIALS documentation for the underlying spot-finding, indexing, refinement and integration algorithms&lt;/div&gt;</summary>
		<author><name>Aaron</name></author>
	</entry>
	<entry>
		<id>http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Dials.stills_process&amp;diff=1764</id>
		<title>Dials.stills process</title>
		<link rel="alternate" type="text/html" href="http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Dials.stills_process&amp;diff=1764"/>
		<updated>2026-08-21T22:30:49Z</updated>

		<summary type="html">&lt;p&gt;Aaron: /* Basic usage */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= dials.stills_process =&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;dials.stills_process&#039;&#039;&#039;&#039;&#039; is a stand-alone program for processing still diffraction images and is&lt;br /&gt;
the core data-reduction program of &#039;&#039;cctbx.xfel&#039;&#039;. It takes a set of&lt;br /&gt;
still diffraction images — typically serial femtosecond crystallography (SFX) snapshots from an&lt;br /&gt;
XFEL (LCLS, SACLA, EuXFEL) or still shots from a synchrotron — and analyzes each one, independently,&lt;br /&gt;
through the full DIALS pipeline: &#039;&#039;&#039;import → spot-finding → indexing → refinement → integration&#039;&#039;&#039;.&lt;br /&gt;
Its output (integrated intensities together with the per-image experimental models) is the input to&lt;br /&gt;
the merging program [[cctbx.xfel.merge]].&lt;br /&gt;
&lt;br /&gt;
Because every image is a separate still exposure of a different crystal (rather than a wedge of&lt;br /&gt;
a rotation series), each image is treated as its own experiment with its own crystal model. This&lt;br /&gt;
&amp;quot;one crystal per shot&amp;quot; model is what distinguishes stills processing from conventional rotation data&lt;br /&gt;
processing (e.g. &amp;lt;code&amp;gt;dials.import&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;dials.find_spots&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;dials.index&amp;lt;/code&amp;gt;, etc.), &lt;br /&gt;
and it drives most of the stills-specific defaults described below.&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
For each image, &amp;lt;code&amp;gt;dials.stills_process&amp;lt;/code&amp;gt; runs the following stages in order. Any stage can&lt;br /&gt;
be turned off with the &amp;lt;code&amp;gt;dispatch&amp;lt;/code&amp;gt; parameters; if a stage is disabled, processing stops&lt;br /&gt;
after the last enabled stage.&lt;br /&gt;
&lt;br /&gt;
# &#039;&#039;&#039;Import&#039;&#039;&#039; — read the image, apply reference geometry / gain / mask overrides, and build an experiment.&lt;br /&gt;
# &#039;&#039;&#039;Spot-finding&#039;&#039;&#039; — locate strong pixels and build strong reflections (&amp;lt;code&amp;gt;dispatch.find_spots&amp;lt;/code&amp;gt;).&lt;br /&gt;
# &#039;&#039;&#039;Hit finding&#039;&#039;&#039; — reject images with too few (or optionally too many) strong spots, so that only &amp;quot;hits&amp;quot; are indexed (&amp;lt;code&amp;gt;dispatch.hit_finder&amp;lt;/code&amp;gt;).&lt;br /&gt;
# &#039;&#039;&#039;Indexing&#039;&#039;&#039; — determine the crystal orientation and (optionally constrained) unit cell (&amp;lt;code&amp;gt;dispatch.index&amp;lt;/code&amp;gt;).&lt;br /&gt;
# &#039;&#039;&#039;Refinement&#039;&#039;&#039; — refine the crystal model and re-estimate the mosaic/domain-size parameters. Detector and beam are held fixed by default (&amp;lt;code&amp;gt;dispatch.refine&amp;lt;/code&amp;gt;).&lt;br /&gt;
# &#039;&#039;&#039;Integration&#039;&#039;&#039; — predict reflections and measure their intensities using the stills integrator (&amp;lt;code&amp;gt;dispatch.integrate&amp;lt;/code&amp;gt;), with optional Kapton absorption correction and a significance filter.&lt;br /&gt;
&lt;br /&gt;
The program applies a set of stills-specific defaults on top of the standard DIALS parameters,&lt;br /&gt;
including: indexing method &amp;lt;code&amp;gt;fft1d&amp;lt;/code&amp;gt;; the stills integrator with profile fitting turned off&lt;br /&gt;
(summation integration with a 2-D plane background); the stills refinement weighting strategy with&lt;br /&gt;
the detector and beam models fixed; and a re-estimation of per-crystal mosaic parameters&lt;br /&gt;
(domain size and mosaic angle) after refinement. These are sensible starting points for serial data&lt;br /&gt;
and normally do not need to be changed.&lt;br /&gt;
&lt;br /&gt;
Failures on individual images are, by default, caught and logged so that processing continues to the&lt;br /&gt;
next image (&amp;lt;code&amp;gt;dispatch.squash_errors=True&amp;lt;/code&amp;gt;) — essential when reducing tens of thousands of&lt;br /&gt;
shots of which only a fraction are hits.&lt;br /&gt;
&lt;br /&gt;
== Basic usage ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Process a directory of CBF stills, constraining the target cell/symmetry,&lt;br /&gt;
# using 32 parallel processes on one node&lt;br /&gt;
dials.stills_process /path/to/images/*.cbf process.phil mp.nproc=32&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A typical &amp;lt;code&amp;gt;process.phil&amp;lt;/code&amp;gt; for XFEL data looks like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
spotfinder.filter.min_spot_size=2&lt;br /&gt;
spotfinder.threshold.dispersion.gain=1.0&lt;br /&gt;
spotfinder.threshold.dispersion.global_threshold=100&lt;br /&gt;
&lt;br /&gt;
indexing.known_symmetry.space_group=P43212&lt;br /&gt;
indexing.known_symmetry.unit_cell=78.9,78.9,38.1,90,90,90&lt;br /&gt;
indexing.method=fft1d&lt;br /&gt;
&lt;br /&gt;
input.reference_geometry=refined.expt   # from a previous metrology refinement&lt;br /&gt;
&lt;br /&gt;
output.output_dir=out&lt;br /&gt;
mp.nproc=32&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Useful command-line helpers:&lt;br /&gt;
* &amp;lt;code&amp;gt;dials.stills_process -h&amp;lt;/code&amp;gt; — help and usage&lt;br /&gt;
* &amp;lt;code&amp;gt;dials.stills_process -c -e 2&amp;lt;/code&amp;gt; — show the configurable parameters (expert level 2)&lt;br /&gt;
* &amp;lt;code&amp;gt;dials.stills_process -c -a2&amp;lt;/code&amp;gt; — include attributes (help text) for each parameter&lt;br /&gt;
* &amp;lt;code&amp;gt;dials.stills_process ... input.show_image_tags=True&amp;lt;/code&amp;gt; — list the image tags in a dataset without processing (useful for selecting subsets with &amp;lt;code&amp;gt;input.image_tag&amp;lt;/code&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
== Important parameters ==&lt;br /&gt;
&lt;br /&gt;
The program exposes the entire DIALS parameter set (spot-finding, indexing, refinement, integration,&lt;br /&gt;
profile modelling, prediction). The parameters below are the ones most commonly adjusted for serial&lt;br /&gt;
still data. Parameters are given by their full PHIL path with the default value in parentheses.&lt;br /&gt;
&lt;br /&gt;
=== Input ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.reference_geometry&amp;lt;/code&amp;gt; || None || Path to an &amp;lt;code&amp;gt;.expt&amp;lt;/code&amp;gt; file (or image) with a single detector model. Data are processed using &#039;&#039;this&#039;&#039; geometry instead of the geometry in the image headers. This is how a refined detector metrology from &amp;lt;code&amp;gt;cctbx.xfel&amp;lt;/code&amp;gt; ensemble refinement is applied — almost always set for XFEL data.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.sync_reference_geom&amp;lt;/code&amp;gt; || True || When a reference geometry is supplied, copy its refined local frames onto the image&#039;s detector hierarchy node-by-node (the hierarchies must match in shape). If False, the reference detector replaces the image detector wholesale.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.file_list&amp;lt;/code&amp;gt; || None || Path to a text file listing image paths, one per line (alternative to listing files on the command line).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.glob&amp;lt;/code&amp;gt; || None || Wildcard path(s) for large multi-file datasets (e.g. &amp;lt;code&amp;gt;*.cbf&amp;lt;/code&amp;gt;). May be given multiple times.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.image_tag&amp;lt;/code&amp;gt; || None || Process only images with the given tag(s). For single-image files the tag is the filename; for multi-image files (HDF5) it is &amp;lt;code&amp;gt;filename_imagenumber&amp;lt;/code&amp;gt;. Use &amp;lt;code&amp;gt;input.show_image_tags=True&amp;lt;/code&amp;gt; to list them.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.max_images&amp;lt;/code&amp;gt; || None || Limit the total number of images processed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Dispatch — controlling the pipeline ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dispatch.find_spots&amp;lt;/code&amp;gt; || True || Do spot-finding. Required for indexing/integration.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dispatch.index&amp;lt;/code&amp;gt; || True || Attempt to index. Requires &amp;lt;code&amp;gt;find_spots=True&amp;lt;/code&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dispatch.integrate&amp;lt;/code&amp;gt; || True || Integrate indexed images. Ignored if indexing/spot-finding is off.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dispatch.refine&amp;lt;/code&amp;gt; || False || Run an explicit model-refinement step after indexing (the stills indexer already refines; this is an additional pass, rarely needed).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dispatch.squash_errors&amp;lt;/code&amp;gt; || True || If an image fails, log it and continue to the next image. Set False to halt and show the full error when debugging.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dispatch.hit_finder.enable&amp;lt;/code&amp;gt; || True || Enable hit-finding. If disabled, every image is passed to indexing.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dispatch.hit_finder.minimum_number_of_reflections&amp;lt;/code&amp;gt; || 16 || Images with fewer strong spots than this are discarded as non-hits before indexing.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dispatch.hit_finder.maximum_number_of_reflections&amp;lt;/code&amp;gt; || None || If set, images with more strong spots than this are discarded (e.g. ice/junk).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dispatch.process_percent&amp;lt;/code&amp;gt; || None || Process only this percentage of events (evenly sampled). Useful for a quick look at a large dataset.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dispatch.coset&amp;lt;/code&amp;gt; || False || During integration, also integrate a sublattice coset as a negative control for regions with no Bragg diffraction (see &amp;lt;code&amp;gt;integration.coset.transformation&amp;lt;/code&amp;gt;).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dispatch.pre_import&amp;lt;/code&amp;gt; || False || Import all data before processing. Only needed when processing multiple &#039;&#039;multi-image&#039;&#039; files at once (not a recommended workflow). Single-file datasets are always pre-imported automatically.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Spot-finding ===&lt;br /&gt;
&lt;br /&gt;
Spot-finding uses the standard DIALS dispersion thresholding. The most impactful parameters for&lt;br /&gt;
serial data:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spotfinder.filter.min_spot_size&amp;lt;/code&amp;gt; || Auto || Minimum connected pixels for a spot. Auto = 3 for pixel-array detectors (SENSOR_PAD), 6 otherwise. Often lowered to 2 for sparse serial patterns.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spotfinder.threshold.dispersion.gain&amp;lt;/code&amp;gt; || None || Detector gain used in thresholding. Set this &#039;&#039;or&#039;&#039; the detector-model gain, not both (see gain note below).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spotfinder.threshold.dispersion.sigma_strong&amp;lt;/code&amp;gt; || 3 || Number of sigma above background for a pixel to be &amp;quot;strong&amp;quot;.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spotfinder.threshold.dispersion.sigma_background&amp;lt;/code&amp;gt; || 6 || Number of sigma for the background/dispersion test.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spotfinder.threshold.dispersion.global_threshold&amp;lt;/code&amp;gt; || 0 || Absolute pixel intensity floor; pixels below this are never considered strong. Raising it (e.g. 100) suppresses noise on many detectors.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spotfinder.threshold.dispersion.kernel_size&amp;lt;/code&amp;gt; || 3 3 || Local-area kernel (pixels) for the dispersion calculation.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Gain note:&#039;&#039;&#039; the detector gain should be set on the detector model &#039;&#039;or&#039;&#039; in the processing&lt;br /&gt;
parameters, never both. If a supplied gain (&amp;lt;code&amp;gt;spotfinder.threshold.dispersion.gain&amp;lt;/code&amp;gt; or&lt;br /&gt;
&amp;lt;code&amp;gt;integration.summation.detector_gain&amp;lt;/code&amp;gt;) conflicts with a non-unity gain already on the&lt;br /&gt;
detector model, the program raises an error. Override with&lt;br /&gt;
&amp;lt;code&amp;gt;input.ignore_gain_mismatch=True&amp;lt;/code&amp;gt; only if you understand the consequences.&lt;br /&gt;
&lt;br /&gt;
=== Indexing ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;indexing.known_symmetry.space_group&amp;lt;/code&amp;gt; || None || Target space group. Strongly recommended for serial data — constrains indexing and improves the hit/index rate.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;indexing.known_symmetry.unit_cell&amp;lt;/code&amp;gt; || None || Target unit cell (a,b,c,α,β,γ). Used together with the space group as the indexing target.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;indexing.method&amp;lt;/code&amp;gt; || fft1d || Basis-vector search method (&amp;lt;code&amp;gt;dials.stills_process&amp;lt;/code&amp;gt; defaults to &amp;lt;code&amp;gt;fft1d&amp;lt;/code&amp;gt;; &amp;lt;code&amp;gt;fft3d&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;real_space_grid_search&amp;lt;/code&amp;gt; are also available).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;indexing.stills.method_list&amp;lt;/code&amp;gt; || None || Ordered list of indexing methods to try in turn; if one fails, the next is attempted (e.g. &amp;lt;code&amp;gt;fft1d real_space_grid_search&amp;lt;/code&amp;gt;).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;indexing.stills.known_orientations&amp;lt;/code&amp;gt; || None || Paths to previously-processed experiment lists. If given, images are &#039;&#039;not&#039;&#039; re-indexed; the stored crystal orientations are reused (e.g. to re-integrate with new parameters). Supports wildcards; may be repeated.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;indexing.stills.require_known_orientation&amp;lt;/code&amp;gt; || False || When known orientations are supplied but an image is not found among them, controls whether to skip it (True) or fall back to indexing from scratch (False).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;indexing.stills.reflection_subsampling.enable&amp;lt;/code&amp;gt; || False || Retry indexing on random subsets of the strong spots (from &amp;lt;code&amp;gt;step_start&amp;lt;/code&amp;gt;% down to &amp;lt;code&amp;gt;step_stop&amp;lt;/code&amp;gt;% in &amp;lt;code&amp;gt;step_size&amp;lt;/code&amp;gt;% steps). Can rescue images that fail to index on the full spot list.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Integration ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;profile.gaussian_rs.parameters.sigma_b_cutoff&amp;lt;/code&amp;gt; || 0.1 || Maximum beam divergence (sigma_b, degrees) before an indexed crystal is rejected prior to integration. Guards against over-broad, poorly-modelled lattices.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;significance_filter.enable&amp;lt;/code&amp;gt; || False || Apply the stills significance filter, which trims each crystal to the resolution at which reflections remain statistically significant (see &amp;lt;code&amp;gt;significance_filter.isigi_cutoff&amp;lt;/code&amp;gt;, default 1.0).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;integration.integration_only_overrides.trusted_range&amp;lt;/code&amp;gt; || None || Override the panel trusted range [min, max] during integration only (e.g. to include pixels the header marks as untrusted).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;integration.absorption_correction&amp;lt;/code&amp;gt; || apply=False || Enable a Kapton absorption correction (&amp;lt;code&amp;gt;algorithm=fuller_kapton&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;kapton_2019&amp;lt;/code&amp;gt;). Requires shoeboxes to be retained via &amp;lt;code&amp;gt;integration.debug&amp;lt;/code&amp;gt; settings; the program checks this and errors otherwise.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;integration.coset.transformation&amp;lt;/code&amp;gt; || 6 || Which modulus-2 sublattice transformation defines the coset negative control when &amp;lt;code&amp;gt;dispatch.coset=True&amp;lt;/code&amp;gt; (0–6; 6 = body centering). See Sauter &amp;amp; Zwart, &#039;&#039;Acta Cryst.&#039;&#039; D (2009) &#039;&#039;&#039;65&#039;&#039;&#039;:553.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Output ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.output_dir&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;.&amp;lt;/code&amp;gt; || Directory for output files.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.composite_output&amp;lt;/code&amp;gt; || True || If True, each process writes &#039;&#039;one&#039;&#039; concatenated set of &amp;lt;code&amp;gt;.expt&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;.refl&amp;lt;/code&amp;gt; files covering all its successful images. If False, a separate pair of files is written per image (generates a very large number of files). Composite output is strongly preferred for large serial datasets.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.logging_dir&amp;lt;/code&amp;gt; || None || Directory for log files. Under MPI, per-rank logs (&amp;lt;code&amp;gt;log_rankNNNN.out&amp;lt;/code&amp;gt;, etc.) are written here.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.logging_option&amp;lt;/code&amp;gt; || normal || &amp;lt;code&amp;gt;normal&amp;lt;/code&amp;gt; (all logging), &amp;lt;code&amp;gt;suppressed&amp;lt;/code&amp;gt; (silences verbose DIALS refine/index output), or &amp;lt;code&amp;gt;disabled&amp;lt;/code&amp;gt; (almost no logging).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.*_filename&amp;lt;/code&amp;gt; || (templates) || Output filename templates for each stage: &amp;lt;code&amp;gt;strong&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;indexed&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;refined_experiments&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;integrated&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;integrated_experiments&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;coset&amp;lt;/code&amp;gt;. A &amp;lt;code&amp;gt;%s&amp;lt;/code&amp;gt; in the template is replaced with the per-image tag.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.integration_pickle&amp;lt;/code&amp;gt; || None || Write legacy &amp;lt;code&amp;gt;cxi.merge&amp;lt;/code&amp;gt;/PRIME integration pickle files (e.g. &amp;lt;code&amp;gt;int-%d-%s.pickle&amp;lt;/code&amp;gt;). Only needed for legacy merging workflows.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Multiprocessing ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mp.method&amp;lt;/code&amp;gt; || multiprocessing || Parallelization backend: &amp;lt;code&amp;gt;multiprocessing&amp;lt;/code&amp;gt; (single node), or &amp;lt;code&amp;gt;mpi&amp;lt;/code&amp;gt; for multi-node jobs (also &amp;lt;code&amp;gt;sge&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;lsf&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;pbs&amp;lt;/code&amp;gt;).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mp.nproc&amp;lt;/code&amp;gt; || 1 || Number of processes (for the &amp;lt;code&amp;gt;multiprocessing&amp;lt;/code&amp;gt; method). Set to the number of cores per node.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mp.composite_stride&amp;lt;/code&amp;gt; || None || For MPI composite output, how many ranks aggregate their results into one set of output files. Ideally set to the number of processes per node so that one composite file set is written per node rather than per rank.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Under MPI with more than two ranks, the program runs a client/server model: rank 0 (or rank 2 for&lt;br /&gt;
psana2 &amp;lt;code&amp;gt;.loc&amp;lt;/code&amp;gt; inputs) hands out images to worker ranks on demand, giving good load&lt;br /&gt;
balancing across the many fast-failing non-hits typical of serial data.&lt;br /&gt;
&lt;br /&gt;
== Output files ==&lt;br /&gt;
&lt;br /&gt;
With the default composite output, each process (or each aggregating rank under MPI) writes&lt;br /&gt;
concatenated files such as:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;amp;lt;tag&amp;amp;gt;_strong.refl&amp;lt;/code&amp;gt; — strong spots from spot-finding&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;amp;lt;tag&amp;amp;gt;_indexed.refl&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;&amp;amp;lt;tag&amp;amp;gt;_refined.expt&amp;lt;/code&amp;gt; — indexed reflections and their crystal models&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;amp;lt;tag&amp;amp;gt;_integrated.refl&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;&amp;amp;lt;tag&amp;amp;gt;_integrated.expt&amp;lt;/code&amp;gt; — integrated intensities and final models (the input to [[cctbx.xfel.merge]])&lt;br /&gt;
&lt;br /&gt;
Per-image progress and status codes are recorded in &amp;lt;code&amp;gt;debug/debug_&amp;amp;lt;rank&amp;amp;gt;.txt&amp;lt;/code&amp;gt;, and&lt;br /&gt;
overall logging goes to &amp;lt;code&amp;gt;dials.process.log&amp;lt;/code&amp;gt; (or per-rank logs under MPI). These integrated&lt;br /&gt;
&amp;lt;code&amp;gt;.expt&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;.refl&amp;lt;/code&amp;gt; pairs are then scaled and merged with&lt;br /&gt;
[[cctbx.xfel.merge]].&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
* [[cctbx.xfel.merge]] — scaling, post-refinement and merging of the integrated data&lt;br /&gt;
* [[IOTA]] — a front-end that supplies preset parameters for &amp;lt;code&amp;gt;dials.stills_process&amp;lt;/code&amp;gt;&lt;br /&gt;
* [[Data Processing at SACLA]] — SACLA-specific processing workflow&lt;br /&gt;
* The DIALS documentation for the underlying spot-finding, indexing, refinement and integration algorithms&lt;/div&gt;</summary>
		<author><name>Aaron</name></author>
	</entry>
	<entry>
		<id>http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Dials.stills_process&amp;diff=1763</id>
		<title>Dials.stills process</title>
		<link rel="alternate" type="text/html" href="http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Dials.stills_process&amp;diff=1763"/>
		<updated>2026-08-21T22:26:16Z</updated>

		<summary type="html">&lt;p&gt;Aaron: /* dials.stills_process */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= dials.stills_process =&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;dials.stills_process&#039;&#039;&#039;&#039;&#039; is a stand-alone program for processing still diffraction images and is&lt;br /&gt;
the core data-reduction program of &#039;&#039;cctbx.xfel&#039;&#039;. It takes a set of&lt;br /&gt;
still diffraction images — typically serial femtosecond crystallography (SFX) snapshots from an&lt;br /&gt;
XFEL (LCLS, SACLA, EuXFEL) or still shots from a synchrotron — and analyzes each one, independently,&lt;br /&gt;
through the full DIALS pipeline: &#039;&#039;&#039;import → spot-finding → indexing → refinement → integration&#039;&#039;&#039;.&lt;br /&gt;
Its output (integrated intensities together with the per-image experimental models) is the input to&lt;br /&gt;
the merging program [[cctbx.xfel.merge]].&lt;br /&gt;
&lt;br /&gt;
Because every image is a separate still exposure of a different crystal (rather than a wedge of&lt;br /&gt;
a rotation series), each image is treated as its own experiment with its own crystal model. This&lt;br /&gt;
&amp;quot;one crystal per shot&amp;quot; model is what distinguishes stills processing from conventional rotation data&lt;br /&gt;
processing (e.g. &amp;lt;code&amp;gt;dials.import&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;dials.find_spots&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;dials.index&amp;lt;/code&amp;gt;, etc.), &lt;br /&gt;
and it drives most of the stills-specific defaults described below.&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
For each image, &amp;lt;code&amp;gt;dials.stills_process&amp;lt;/code&amp;gt; runs the following stages in order. Any stage can&lt;br /&gt;
be turned off with the &amp;lt;code&amp;gt;dispatch&amp;lt;/code&amp;gt; parameters; if a stage is disabled, processing stops&lt;br /&gt;
after the last enabled stage.&lt;br /&gt;
&lt;br /&gt;
# &#039;&#039;&#039;Import&#039;&#039;&#039; — read the image, apply reference geometry / gain / mask overrides, and build an experiment.&lt;br /&gt;
# &#039;&#039;&#039;Spot-finding&#039;&#039;&#039; — locate strong pixels and build strong reflections (&amp;lt;code&amp;gt;dispatch.find_spots&amp;lt;/code&amp;gt;).&lt;br /&gt;
# &#039;&#039;&#039;Hit finding&#039;&#039;&#039; — reject images with too few (or optionally too many) strong spots, so that only &amp;quot;hits&amp;quot; are indexed (&amp;lt;code&amp;gt;dispatch.hit_finder&amp;lt;/code&amp;gt;).&lt;br /&gt;
# &#039;&#039;&#039;Indexing&#039;&#039;&#039; — determine the crystal orientation and (optionally constrained) unit cell (&amp;lt;code&amp;gt;dispatch.index&amp;lt;/code&amp;gt;).&lt;br /&gt;
# &#039;&#039;&#039;Refinement&#039;&#039;&#039; — refine the crystal model and re-estimate the mosaic/domain-size parameters. Detector and beam are held fixed by default (&amp;lt;code&amp;gt;dispatch.refine&amp;lt;/code&amp;gt;).&lt;br /&gt;
# &#039;&#039;&#039;Integration&#039;&#039;&#039; — predict reflections and measure their intensities using the stills integrator (&amp;lt;code&amp;gt;dispatch.integrate&amp;lt;/code&amp;gt;), with optional Kapton absorption correction and a significance filter.&lt;br /&gt;
&lt;br /&gt;
The program applies a set of stills-specific defaults on top of the standard DIALS parameters,&lt;br /&gt;
including: indexing method &amp;lt;code&amp;gt;fft1d&amp;lt;/code&amp;gt;; the stills integrator with profile fitting turned off&lt;br /&gt;
(summation integration with a 2-D plane background); the stills refinement weighting strategy with&lt;br /&gt;
the detector and beam models fixed; and a re-estimation of per-crystal mosaic parameters&lt;br /&gt;
(domain size and mosaic angle) after refinement. These are sensible starting points for serial data&lt;br /&gt;
and normally do not need to be changed.&lt;br /&gt;
&lt;br /&gt;
Failures on individual images are, by default, caught and logged so that processing continues to the&lt;br /&gt;
next image (&amp;lt;code&amp;gt;dispatch.squash_errors=True&amp;lt;/code&amp;gt;) — essential when reducing tens of thousands of&lt;br /&gt;
shots of which only a fraction are hits.&lt;br /&gt;
&lt;br /&gt;
== Basic usage ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Process a directory of CBF stills, constraining the target cell/symmetry,&lt;br /&gt;
# using 32 parallel processes on one node&lt;br /&gt;
dials.stills_process /path/to/images/*.cbf process.phil mp.nproc=32&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A typical &amp;lt;code&amp;gt;process.phil&amp;lt;/code&amp;gt; for XFEL data looks like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
spotfinder.filter.min_spot_size=2&lt;br /&gt;
spotfinder.threshold.dispersion.gain=1.0&lt;br /&gt;
spotfinder.threshold.dispersion.global_threshold=100&lt;br /&gt;
&lt;br /&gt;
indexing.known_symmetry.space_group=P43212&lt;br /&gt;
indexing.known_symmetry.unit_cell=78.9,78.9,38.1,90,90,90&lt;br /&gt;
indexing.method=fft1d&lt;br /&gt;
&lt;br /&gt;
integration.background.simple.outlier.algorithm=null&lt;br /&gt;
&lt;br /&gt;
input.reference_geometry=refined.expt   # from a previous metrology refinement&lt;br /&gt;
&lt;br /&gt;
output.composite_output=True&lt;br /&gt;
output.output_dir=out&lt;br /&gt;
mp.nproc=32&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Useful command-line helpers:&lt;br /&gt;
* &amp;lt;code&amp;gt;dials.stills_process -h&amp;lt;/code&amp;gt; — help and usage&lt;br /&gt;
* &amp;lt;code&amp;gt;dials.stills_process -c -e 2&amp;lt;/code&amp;gt; — show the configurable parameters (expert level 2)&lt;br /&gt;
* &amp;lt;code&amp;gt;dials.stills_process -c -a2&amp;lt;/code&amp;gt; — include attributes (help text) for each parameter&lt;br /&gt;
* &amp;lt;code&amp;gt;dials.stills_process ... input.show_image_tags=True&amp;lt;/code&amp;gt; — list the image tags in a dataset without processing (useful for selecting subsets with &amp;lt;code&amp;gt;input.image_tag&amp;lt;/code&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
== Important parameters ==&lt;br /&gt;
&lt;br /&gt;
The program exposes the entire DIALS parameter set (spot-finding, indexing, refinement, integration,&lt;br /&gt;
profile modelling, prediction). The parameters below are the ones most commonly adjusted for serial&lt;br /&gt;
still data. Parameters are given by their full PHIL path with the default value in parentheses.&lt;br /&gt;
&lt;br /&gt;
=== Input ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.reference_geometry&amp;lt;/code&amp;gt; || None || Path to an &amp;lt;code&amp;gt;.expt&amp;lt;/code&amp;gt; file (or image) with a single detector model. Data are processed using &#039;&#039;this&#039;&#039; geometry instead of the geometry in the image headers. This is how a refined detector metrology from &amp;lt;code&amp;gt;cctbx.xfel&amp;lt;/code&amp;gt; ensemble refinement is applied — almost always set for XFEL data.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.sync_reference_geom&amp;lt;/code&amp;gt; || True || When a reference geometry is supplied, copy its refined local frames onto the image&#039;s detector hierarchy node-by-node (the hierarchies must match in shape). If False, the reference detector replaces the image detector wholesale.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.file_list&amp;lt;/code&amp;gt; || None || Path to a text file listing image paths, one per line (alternative to listing files on the command line).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.glob&amp;lt;/code&amp;gt; || None || Wildcard path(s) for large multi-file datasets (e.g. &amp;lt;code&amp;gt;*.cbf&amp;lt;/code&amp;gt;). May be given multiple times.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.image_tag&amp;lt;/code&amp;gt; || None || Process only images with the given tag(s). For single-image files the tag is the filename; for multi-image files (HDF5) it is &amp;lt;code&amp;gt;filename_imagenumber&amp;lt;/code&amp;gt;. Use &amp;lt;code&amp;gt;input.show_image_tags=True&amp;lt;/code&amp;gt; to list them.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.max_images&amp;lt;/code&amp;gt; || None || Limit the total number of images processed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Dispatch — controlling the pipeline ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dispatch.find_spots&amp;lt;/code&amp;gt; || True || Do spot-finding. Required for indexing/integration.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dispatch.index&amp;lt;/code&amp;gt; || True || Attempt to index. Requires &amp;lt;code&amp;gt;find_spots=True&amp;lt;/code&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dispatch.integrate&amp;lt;/code&amp;gt; || True || Integrate indexed images. Ignored if indexing/spot-finding is off.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dispatch.refine&amp;lt;/code&amp;gt; || False || Run an explicit model-refinement step after indexing (the stills indexer already refines; this is an additional pass, rarely needed).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dispatch.squash_errors&amp;lt;/code&amp;gt; || True || If an image fails, log it and continue to the next image. Set False to halt and show the full error when debugging.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dispatch.hit_finder.enable&amp;lt;/code&amp;gt; || True || Enable hit-finding. If disabled, every image is passed to indexing.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dispatch.hit_finder.minimum_number_of_reflections&amp;lt;/code&amp;gt; || 16 || Images with fewer strong spots than this are discarded as non-hits before indexing.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dispatch.hit_finder.maximum_number_of_reflections&amp;lt;/code&amp;gt; || None || If set, images with more strong spots than this are discarded (e.g. ice/junk).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dispatch.process_percent&amp;lt;/code&amp;gt; || None || Process only this percentage of events (evenly sampled). Useful for a quick look at a large dataset.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dispatch.coset&amp;lt;/code&amp;gt; || False || During integration, also integrate a sublattice coset as a negative control for regions with no Bragg diffraction (see &amp;lt;code&amp;gt;integration.coset.transformation&amp;lt;/code&amp;gt;).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dispatch.pre_import&amp;lt;/code&amp;gt; || False || Import all data before processing. Only needed when processing multiple &#039;&#039;multi-image&#039;&#039; files at once (not a recommended workflow). Single-file datasets are always pre-imported automatically.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Spot-finding ===&lt;br /&gt;
&lt;br /&gt;
Spot-finding uses the standard DIALS dispersion thresholding. The most impactful parameters for&lt;br /&gt;
serial data:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spotfinder.filter.min_spot_size&amp;lt;/code&amp;gt; || Auto || Minimum connected pixels for a spot. Auto = 3 for pixel-array detectors (SENSOR_PAD), 6 otherwise. Often lowered to 2 for sparse serial patterns.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spotfinder.threshold.dispersion.gain&amp;lt;/code&amp;gt; || None || Detector gain used in thresholding. Set this &#039;&#039;or&#039;&#039; the detector-model gain, not both (see gain note below).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spotfinder.threshold.dispersion.sigma_strong&amp;lt;/code&amp;gt; || 3 || Number of sigma above background for a pixel to be &amp;quot;strong&amp;quot;.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spotfinder.threshold.dispersion.sigma_background&amp;lt;/code&amp;gt; || 6 || Number of sigma for the background/dispersion test.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spotfinder.threshold.dispersion.global_threshold&amp;lt;/code&amp;gt; || 0 || Absolute pixel intensity floor; pixels below this are never considered strong. Raising it (e.g. 100) suppresses noise on many detectors.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spotfinder.threshold.dispersion.kernel_size&amp;lt;/code&amp;gt; || 3 3 || Local-area kernel (pixels) for the dispersion calculation.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Gain note:&#039;&#039;&#039; the detector gain should be set on the detector model &#039;&#039;or&#039;&#039; in the processing&lt;br /&gt;
parameters, never both. If a supplied gain (&amp;lt;code&amp;gt;spotfinder.threshold.dispersion.gain&amp;lt;/code&amp;gt; or&lt;br /&gt;
&amp;lt;code&amp;gt;integration.summation.detector_gain&amp;lt;/code&amp;gt;) conflicts with a non-unity gain already on the&lt;br /&gt;
detector model, the program raises an error. Override with&lt;br /&gt;
&amp;lt;code&amp;gt;input.ignore_gain_mismatch=True&amp;lt;/code&amp;gt; only if you understand the consequences.&lt;br /&gt;
&lt;br /&gt;
=== Indexing ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;indexing.known_symmetry.space_group&amp;lt;/code&amp;gt; || None || Target space group. Strongly recommended for serial data — constrains indexing and improves the hit/index rate.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;indexing.known_symmetry.unit_cell&amp;lt;/code&amp;gt; || None || Target unit cell (a,b,c,α,β,γ). Used together with the space group as the indexing target.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;indexing.method&amp;lt;/code&amp;gt; || fft1d || Basis-vector search method (&amp;lt;code&amp;gt;dials.stills_process&amp;lt;/code&amp;gt; defaults to &amp;lt;code&amp;gt;fft1d&amp;lt;/code&amp;gt;; &amp;lt;code&amp;gt;fft3d&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;real_space_grid_search&amp;lt;/code&amp;gt; are also available).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;indexing.stills.method_list&amp;lt;/code&amp;gt; || None || Ordered list of indexing methods to try in turn; if one fails, the next is attempted (e.g. &amp;lt;code&amp;gt;fft1d real_space_grid_search&amp;lt;/code&amp;gt;).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;indexing.stills.known_orientations&amp;lt;/code&amp;gt; || None || Paths to previously-processed experiment lists. If given, images are &#039;&#039;not&#039;&#039; re-indexed; the stored crystal orientations are reused (e.g. to re-integrate with new parameters). Supports wildcards; may be repeated.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;indexing.stills.require_known_orientation&amp;lt;/code&amp;gt; || False || When known orientations are supplied but an image is not found among them, controls whether to skip it (True) or fall back to indexing from scratch (False).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;indexing.stills.reflection_subsampling.enable&amp;lt;/code&amp;gt; || False || Retry indexing on random subsets of the strong spots (from &amp;lt;code&amp;gt;step_start&amp;lt;/code&amp;gt;% down to &amp;lt;code&amp;gt;step_stop&amp;lt;/code&amp;gt;% in &amp;lt;code&amp;gt;step_size&amp;lt;/code&amp;gt;% steps). Can rescue images that fail to index on the full spot list.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Integration ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;profile.gaussian_rs.parameters.sigma_b_cutoff&amp;lt;/code&amp;gt; || 0.1 || Maximum beam divergence (sigma_b, degrees) before an indexed crystal is rejected prior to integration. Guards against over-broad, poorly-modelled lattices.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;significance_filter.enable&amp;lt;/code&amp;gt; || False || Apply the stills significance filter, which trims each crystal to the resolution at which reflections remain statistically significant (see &amp;lt;code&amp;gt;significance_filter.isigi_cutoff&amp;lt;/code&amp;gt;, default 1.0).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;integration.integration_only_overrides.trusted_range&amp;lt;/code&amp;gt; || None || Override the panel trusted range [min, max] during integration only (e.g. to include pixels the header marks as untrusted).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;integration.absorption_correction&amp;lt;/code&amp;gt; || apply=False || Enable a Kapton absorption correction (&amp;lt;code&amp;gt;algorithm=fuller_kapton&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;kapton_2019&amp;lt;/code&amp;gt;). Requires shoeboxes to be retained via &amp;lt;code&amp;gt;integration.debug&amp;lt;/code&amp;gt; settings; the program checks this and errors otherwise.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;integration.coset.transformation&amp;lt;/code&amp;gt; || 6 || Which modulus-2 sublattice transformation defines the coset negative control when &amp;lt;code&amp;gt;dispatch.coset=True&amp;lt;/code&amp;gt; (0–6; 6 = body centering). See Sauter &amp;amp; Zwart, &#039;&#039;Acta Cryst.&#039;&#039; D (2009) &#039;&#039;&#039;65&#039;&#039;&#039;:553.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Output ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.output_dir&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;.&amp;lt;/code&amp;gt; || Directory for output files.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.composite_output&amp;lt;/code&amp;gt; || True || If True, each process writes &#039;&#039;one&#039;&#039; concatenated set of &amp;lt;code&amp;gt;.expt&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;.refl&amp;lt;/code&amp;gt; files covering all its successful images. If False, a separate pair of files is written per image (generates a very large number of files). Composite output is strongly preferred for large serial datasets.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.logging_dir&amp;lt;/code&amp;gt; || None || Directory for log files. Under MPI, per-rank logs (&amp;lt;code&amp;gt;log_rankNNNN.out&amp;lt;/code&amp;gt;, etc.) are written here.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.logging_option&amp;lt;/code&amp;gt; || normal || &amp;lt;code&amp;gt;normal&amp;lt;/code&amp;gt; (all logging), &amp;lt;code&amp;gt;suppressed&amp;lt;/code&amp;gt; (silences verbose DIALS refine/index output), or &amp;lt;code&amp;gt;disabled&amp;lt;/code&amp;gt; (almost no logging).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.*_filename&amp;lt;/code&amp;gt; || (templates) || Output filename templates for each stage: &amp;lt;code&amp;gt;strong&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;indexed&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;refined_experiments&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;integrated&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;integrated_experiments&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;coset&amp;lt;/code&amp;gt;. A &amp;lt;code&amp;gt;%s&amp;lt;/code&amp;gt; in the template is replaced with the per-image tag.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.integration_pickle&amp;lt;/code&amp;gt; || None || Write legacy &amp;lt;code&amp;gt;cxi.merge&amp;lt;/code&amp;gt;/PRIME integration pickle files (e.g. &amp;lt;code&amp;gt;int-%d-%s.pickle&amp;lt;/code&amp;gt;). Only needed for legacy merging workflows.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Multiprocessing ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mp.method&amp;lt;/code&amp;gt; || multiprocessing || Parallelization backend: &amp;lt;code&amp;gt;multiprocessing&amp;lt;/code&amp;gt; (single node), or &amp;lt;code&amp;gt;mpi&amp;lt;/code&amp;gt; for multi-node jobs (also &amp;lt;code&amp;gt;sge&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;lsf&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;pbs&amp;lt;/code&amp;gt;).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mp.nproc&amp;lt;/code&amp;gt; || 1 || Number of processes (for the &amp;lt;code&amp;gt;multiprocessing&amp;lt;/code&amp;gt; method). Set to the number of cores per node.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mp.composite_stride&amp;lt;/code&amp;gt; || None || For MPI composite output, how many ranks aggregate their results into one set of output files. Ideally set to the number of processes per node so that one composite file set is written per node rather than per rank.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Under MPI with more than two ranks, the program runs a client/server model: rank 0 (or rank 2 for&lt;br /&gt;
psana2 &amp;lt;code&amp;gt;.loc&amp;lt;/code&amp;gt; inputs) hands out images to worker ranks on demand, giving good load&lt;br /&gt;
balancing across the many fast-failing non-hits typical of serial data.&lt;br /&gt;
&lt;br /&gt;
== Output files ==&lt;br /&gt;
&lt;br /&gt;
With the default composite output, each process (or each aggregating rank under MPI) writes&lt;br /&gt;
concatenated files such as:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;amp;lt;tag&amp;amp;gt;_strong.refl&amp;lt;/code&amp;gt; — strong spots from spot-finding&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;amp;lt;tag&amp;amp;gt;_indexed.refl&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;&amp;amp;lt;tag&amp;amp;gt;_refined.expt&amp;lt;/code&amp;gt; — indexed reflections and their crystal models&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;amp;lt;tag&amp;amp;gt;_integrated.refl&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;&amp;amp;lt;tag&amp;amp;gt;_integrated.expt&amp;lt;/code&amp;gt; — integrated intensities and final models (the input to [[cctbx.xfel.merge]])&lt;br /&gt;
&lt;br /&gt;
Per-image progress and status codes are recorded in &amp;lt;code&amp;gt;debug/debug_&amp;amp;lt;rank&amp;amp;gt;.txt&amp;lt;/code&amp;gt;, and&lt;br /&gt;
overall logging goes to &amp;lt;code&amp;gt;dials.process.log&amp;lt;/code&amp;gt; (or per-rank logs under MPI). These integrated&lt;br /&gt;
&amp;lt;code&amp;gt;.expt&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;.refl&amp;lt;/code&amp;gt; pairs are then scaled and merged with&lt;br /&gt;
[[cctbx.xfel.merge]].&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
* [[cctbx.xfel.merge]] — scaling, post-refinement and merging of the integrated data&lt;br /&gt;
* [[IOTA]] — a front-end that supplies preset parameters for &amp;lt;code&amp;gt;dials.stills_process&amp;lt;/code&amp;gt;&lt;br /&gt;
* [[Data Processing at SACLA]] — SACLA-specific processing workflow&lt;br /&gt;
* The DIALS documentation for the underlying spot-finding, indexing, refinement and integration algorithms&lt;/div&gt;</summary>
		<author><name>Aaron</name></author>
	</entry>
	<entry>
		<id>http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Dials.stills_process&amp;diff=1762</id>
		<title>Dials.stills process</title>
		<link rel="alternate" type="text/html" href="http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Dials.stills_process&amp;diff=1762"/>
		<updated>2026-08-21T22:25:47Z</updated>

		<summary type="html">&lt;p&gt;Aaron: /* dials.stills_process */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= dials.stills_process =&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;dials.stills_process&#039;&#039;&#039;&#039;&#039; is a stand-alone program for processing still diffraction images and is&lt;br /&gt;
 the core data-reduction program of &#039;&#039;cctbx.xfel&#039;&#039;. It takes a set of&lt;br /&gt;
still diffraction images — typically serial femtosecond crystallography (SFX) snapshots from an&lt;br /&gt;
XFEL (LCLS, SACLA, EuXFEL) or still shots from a synchrotron — and analyzes each one, independently,&lt;br /&gt;
through the full DIALS pipeline: &#039;&#039;&#039;import → spot-finding → indexing → refinement → integration&#039;&#039;&#039;.&lt;br /&gt;
Its output (integrated intensities together with the per-image experimental models) is the input to&lt;br /&gt;
the merging program [[cctbx.xfel.merge]].&lt;br /&gt;
&lt;br /&gt;
Because every image is a separate still exposure of a different crystal (rather than a wedge of&lt;br /&gt;
a rotation series), each image is treated as its own experiment with its own crystal model. This&lt;br /&gt;
&amp;quot;one crystal per shot&amp;quot; model is what distinguishes stills processing from conventional rotation data&lt;br /&gt;
processing (e.g. &amp;lt;code&amp;gt;dials.import&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;dials.find_spots&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;dials.index&amp;lt;/code&amp;gt;, etc.), &lt;br /&gt;
and it drives most of the stills-specific defaults described below.&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
For each image, &amp;lt;code&amp;gt;dials.stills_process&amp;lt;/code&amp;gt; runs the following stages in order. Any stage can&lt;br /&gt;
be turned off with the &amp;lt;code&amp;gt;dispatch&amp;lt;/code&amp;gt; parameters; if a stage is disabled, processing stops&lt;br /&gt;
after the last enabled stage.&lt;br /&gt;
&lt;br /&gt;
# &#039;&#039;&#039;Import&#039;&#039;&#039; — read the image, apply reference geometry / gain / mask overrides, and build an experiment.&lt;br /&gt;
# &#039;&#039;&#039;Spot-finding&#039;&#039;&#039; — locate strong pixels and build strong reflections (&amp;lt;code&amp;gt;dispatch.find_spots&amp;lt;/code&amp;gt;).&lt;br /&gt;
# &#039;&#039;&#039;Hit finding&#039;&#039;&#039; — reject images with too few (or optionally too many) strong spots, so that only &amp;quot;hits&amp;quot; are indexed (&amp;lt;code&amp;gt;dispatch.hit_finder&amp;lt;/code&amp;gt;).&lt;br /&gt;
# &#039;&#039;&#039;Indexing&#039;&#039;&#039; — determine the crystal orientation and (optionally constrained) unit cell (&amp;lt;code&amp;gt;dispatch.index&amp;lt;/code&amp;gt;).&lt;br /&gt;
# &#039;&#039;&#039;Refinement&#039;&#039;&#039; — refine the crystal model and re-estimate the mosaic/domain-size parameters. Detector and beam are held fixed by default (&amp;lt;code&amp;gt;dispatch.refine&amp;lt;/code&amp;gt;).&lt;br /&gt;
# &#039;&#039;&#039;Integration&#039;&#039;&#039; — predict reflections and measure their intensities using the stills integrator (&amp;lt;code&amp;gt;dispatch.integrate&amp;lt;/code&amp;gt;), with optional Kapton absorption correction and a significance filter.&lt;br /&gt;
&lt;br /&gt;
The program applies a set of stills-specific defaults on top of the standard DIALS parameters,&lt;br /&gt;
including: indexing method &amp;lt;code&amp;gt;fft1d&amp;lt;/code&amp;gt;; the stills integrator with profile fitting turned off&lt;br /&gt;
(summation integration with a 2-D plane background); the stills refinement weighting strategy with&lt;br /&gt;
the detector and beam models fixed; and a re-estimation of per-crystal mosaic parameters&lt;br /&gt;
(domain size and mosaic angle) after refinement. These are sensible starting points for serial data&lt;br /&gt;
and normally do not need to be changed.&lt;br /&gt;
&lt;br /&gt;
Failures on individual images are, by default, caught and logged so that processing continues to the&lt;br /&gt;
next image (&amp;lt;code&amp;gt;dispatch.squash_errors=True&amp;lt;/code&amp;gt;) — essential when reducing tens of thousands of&lt;br /&gt;
shots of which only a fraction are hits.&lt;br /&gt;
&lt;br /&gt;
== Basic usage ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Process a directory of CBF stills, constraining the target cell/symmetry,&lt;br /&gt;
# using 32 parallel processes on one node&lt;br /&gt;
dials.stills_process /path/to/images/*.cbf process.phil mp.nproc=32&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A typical &amp;lt;code&amp;gt;process.phil&amp;lt;/code&amp;gt; for XFEL data looks like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
spotfinder.filter.min_spot_size=2&lt;br /&gt;
spotfinder.threshold.dispersion.gain=1.0&lt;br /&gt;
spotfinder.threshold.dispersion.global_threshold=100&lt;br /&gt;
&lt;br /&gt;
indexing.known_symmetry.space_group=P43212&lt;br /&gt;
indexing.known_symmetry.unit_cell=78.9,78.9,38.1,90,90,90&lt;br /&gt;
indexing.method=fft1d&lt;br /&gt;
&lt;br /&gt;
integration.background.simple.outlier.algorithm=null&lt;br /&gt;
&lt;br /&gt;
input.reference_geometry=refined.expt   # from a previous metrology refinement&lt;br /&gt;
&lt;br /&gt;
output.composite_output=True&lt;br /&gt;
output.output_dir=out&lt;br /&gt;
mp.nproc=32&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Useful command-line helpers:&lt;br /&gt;
* &amp;lt;code&amp;gt;dials.stills_process -h&amp;lt;/code&amp;gt; — help and usage&lt;br /&gt;
* &amp;lt;code&amp;gt;dials.stills_process -c -e 2&amp;lt;/code&amp;gt; — show the configurable parameters (expert level 2)&lt;br /&gt;
* &amp;lt;code&amp;gt;dials.stills_process -c -a2&amp;lt;/code&amp;gt; — include attributes (help text) for each parameter&lt;br /&gt;
* &amp;lt;code&amp;gt;dials.stills_process ... input.show_image_tags=True&amp;lt;/code&amp;gt; — list the image tags in a dataset without processing (useful for selecting subsets with &amp;lt;code&amp;gt;input.image_tag&amp;lt;/code&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
== Important parameters ==&lt;br /&gt;
&lt;br /&gt;
The program exposes the entire DIALS parameter set (spot-finding, indexing, refinement, integration,&lt;br /&gt;
profile modelling, prediction). The parameters below are the ones most commonly adjusted for serial&lt;br /&gt;
still data. Parameters are given by their full PHIL path with the default value in parentheses.&lt;br /&gt;
&lt;br /&gt;
=== Input ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.reference_geometry&amp;lt;/code&amp;gt; || None || Path to an &amp;lt;code&amp;gt;.expt&amp;lt;/code&amp;gt; file (or image) with a single detector model. Data are processed using &#039;&#039;this&#039;&#039; geometry instead of the geometry in the image headers. This is how a refined detector metrology from &amp;lt;code&amp;gt;cctbx.xfel&amp;lt;/code&amp;gt; ensemble refinement is applied — almost always set for XFEL data.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.sync_reference_geom&amp;lt;/code&amp;gt; || True || When a reference geometry is supplied, copy its refined local frames onto the image&#039;s detector hierarchy node-by-node (the hierarchies must match in shape). If False, the reference detector replaces the image detector wholesale.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.file_list&amp;lt;/code&amp;gt; || None || Path to a text file listing image paths, one per line (alternative to listing files on the command line).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.glob&amp;lt;/code&amp;gt; || None || Wildcard path(s) for large multi-file datasets (e.g. &amp;lt;code&amp;gt;*.cbf&amp;lt;/code&amp;gt;). May be given multiple times.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.image_tag&amp;lt;/code&amp;gt; || None || Process only images with the given tag(s). For single-image files the tag is the filename; for multi-image files (HDF5) it is &amp;lt;code&amp;gt;filename_imagenumber&amp;lt;/code&amp;gt;. Use &amp;lt;code&amp;gt;input.show_image_tags=True&amp;lt;/code&amp;gt; to list them.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.max_images&amp;lt;/code&amp;gt; || None || Limit the total number of images processed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Dispatch — controlling the pipeline ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dispatch.find_spots&amp;lt;/code&amp;gt; || True || Do spot-finding. Required for indexing/integration.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dispatch.index&amp;lt;/code&amp;gt; || True || Attempt to index. Requires &amp;lt;code&amp;gt;find_spots=True&amp;lt;/code&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dispatch.integrate&amp;lt;/code&amp;gt; || True || Integrate indexed images. Ignored if indexing/spot-finding is off.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dispatch.refine&amp;lt;/code&amp;gt; || False || Run an explicit model-refinement step after indexing (the stills indexer already refines; this is an additional pass, rarely needed).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dispatch.squash_errors&amp;lt;/code&amp;gt; || True || If an image fails, log it and continue to the next image. Set False to halt and show the full error when debugging.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dispatch.hit_finder.enable&amp;lt;/code&amp;gt; || True || Enable hit-finding. If disabled, every image is passed to indexing.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dispatch.hit_finder.minimum_number_of_reflections&amp;lt;/code&amp;gt; || 16 || Images with fewer strong spots than this are discarded as non-hits before indexing.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dispatch.hit_finder.maximum_number_of_reflections&amp;lt;/code&amp;gt; || None || If set, images with more strong spots than this are discarded (e.g. ice/junk).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dispatch.process_percent&amp;lt;/code&amp;gt; || None || Process only this percentage of events (evenly sampled). Useful for a quick look at a large dataset.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dispatch.coset&amp;lt;/code&amp;gt; || False || During integration, also integrate a sublattice coset as a negative control for regions with no Bragg diffraction (see &amp;lt;code&amp;gt;integration.coset.transformation&amp;lt;/code&amp;gt;).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dispatch.pre_import&amp;lt;/code&amp;gt; || False || Import all data before processing. Only needed when processing multiple &#039;&#039;multi-image&#039;&#039; files at once (not a recommended workflow). Single-file datasets are always pre-imported automatically.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Spot-finding ===&lt;br /&gt;
&lt;br /&gt;
Spot-finding uses the standard DIALS dispersion thresholding. The most impactful parameters for&lt;br /&gt;
serial data:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spotfinder.filter.min_spot_size&amp;lt;/code&amp;gt; || Auto || Minimum connected pixels for a spot. Auto = 3 for pixel-array detectors (SENSOR_PAD), 6 otherwise. Often lowered to 2 for sparse serial patterns.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spotfinder.threshold.dispersion.gain&amp;lt;/code&amp;gt; || None || Detector gain used in thresholding. Set this &#039;&#039;or&#039;&#039; the detector-model gain, not both (see gain note below).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spotfinder.threshold.dispersion.sigma_strong&amp;lt;/code&amp;gt; || 3 || Number of sigma above background for a pixel to be &amp;quot;strong&amp;quot;.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spotfinder.threshold.dispersion.sigma_background&amp;lt;/code&amp;gt; || 6 || Number of sigma for the background/dispersion test.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spotfinder.threshold.dispersion.global_threshold&amp;lt;/code&amp;gt; || 0 || Absolute pixel intensity floor; pixels below this are never considered strong. Raising it (e.g. 100) suppresses noise on many detectors.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spotfinder.threshold.dispersion.kernel_size&amp;lt;/code&amp;gt; || 3 3 || Local-area kernel (pixels) for the dispersion calculation.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Gain note:&#039;&#039;&#039; the detector gain should be set on the detector model &#039;&#039;or&#039;&#039; in the processing&lt;br /&gt;
parameters, never both. If a supplied gain (&amp;lt;code&amp;gt;spotfinder.threshold.dispersion.gain&amp;lt;/code&amp;gt; or&lt;br /&gt;
&amp;lt;code&amp;gt;integration.summation.detector_gain&amp;lt;/code&amp;gt;) conflicts with a non-unity gain already on the&lt;br /&gt;
detector model, the program raises an error. Override with&lt;br /&gt;
&amp;lt;code&amp;gt;input.ignore_gain_mismatch=True&amp;lt;/code&amp;gt; only if you understand the consequences.&lt;br /&gt;
&lt;br /&gt;
=== Indexing ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;indexing.known_symmetry.space_group&amp;lt;/code&amp;gt; || None || Target space group. Strongly recommended for serial data — constrains indexing and improves the hit/index rate.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;indexing.known_symmetry.unit_cell&amp;lt;/code&amp;gt; || None || Target unit cell (a,b,c,α,β,γ). Used together with the space group as the indexing target.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;indexing.method&amp;lt;/code&amp;gt; || fft1d || Basis-vector search method (&amp;lt;code&amp;gt;dials.stills_process&amp;lt;/code&amp;gt; defaults to &amp;lt;code&amp;gt;fft1d&amp;lt;/code&amp;gt;; &amp;lt;code&amp;gt;fft3d&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;real_space_grid_search&amp;lt;/code&amp;gt; are also available).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;indexing.stills.method_list&amp;lt;/code&amp;gt; || None || Ordered list of indexing methods to try in turn; if one fails, the next is attempted (e.g. &amp;lt;code&amp;gt;fft1d real_space_grid_search&amp;lt;/code&amp;gt;).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;indexing.stills.known_orientations&amp;lt;/code&amp;gt; || None || Paths to previously-processed experiment lists. If given, images are &#039;&#039;not&#039;&#039; re-indexed; the stored crystal orientations are reused (e.g. to re-integrate with new parameters). Supports wildcards; may be repeated.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;indexing.stills.require_known_orientation&amp;lt;/code&amp;gt; || False || When known orientations are supplied but an image is not found among them, controls whether to skip it (True) or fall back to indexing from scratch (False).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;indexing.stills.reflection_subsampling.enable&amp;lt;/code&amp;gt; || False || Retry indexing on random subsets of the strong spots (from &amp;lt;code&amp;gt;step_start&amp;lt;/code&amp;gt;% down to &amp;lt;code&amp;gt;step_stop&amp;lt;/code&amp;gt;% in &amp;lt;code&amp;gt;step_size&amp;lt;/code&amp;gt;% steps). Can rescue images that fail to index on the full spot list.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Integration ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;profile.gaussian_rs.parameters.sigma_b_cutoff&amp;lt;/code&amp;gt; || 0.1 || Maximum beam divergence (sigma_b, degrees) before an indexed crystal is rejected prior to integration. Guards against over-broad, poorly-modelled lattices.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;significance_filter.enable&amp;lt;/code&amp;gt; || False || Apply the stills significance filter, which trims each crystal to the resolution at which reflections remain statistically significant (see &amp;lt;code&amp;gt;significance_filter.isigi_cutoff&amp;lt;/code&amp;gt;, default 1.0).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;integration.integration_only_overrides.trusted_range&amp;lt;/code&amp;gt; || None || Override the panel trusted range [min, max] during integration only (e.g. to include pixels the header marks as untrusted).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;integration.absorption_correction&amp;lt;/code&amp;gt; || apply=False || Enable a Kapton absorption correction (&amp;lt;code&amp;gt;algorithm=fuller_kapton&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;kapton_2019&amp;lt;/code&amp;gt;). Requires shoeboxes to be retained via &amp;lt;code&amp;gt;integration.debug&amp;lt;/code&amp;gt; settings; the program checks this and errors otherwise.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;integration.coset.transformation&amp;lt;/code&amp;gt; || 6 || Which modulus-2 sublattice transformation defines the coset negative control when &amp;lt;code&amp;gt;dispatch.coset=True&amp;lt;/code&amp;gt; (0–6; 6 = body centering). See Sauter &amp;amp; Zwart, &#039;&#039;Acta Cryst.&#039;&#039; D (2009) &#039;&#039;&#039;65&#039;&#039;&#039;:553.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Output ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.output_dir&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;.&amp;lt;/code&amp;gt; || Directory for output files.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.composite_output&amp;lt;/code&amp;gt; || True || If True, each process writes &#039;&#039;one&#039;&#039; concatenated set of &amp;lt;code&amp;gt;.expt&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;.refl&amp;lt;/code&amp;gt; files covering all its successful images. If False, a separate pair of files is written per image (generates a very large number of files). Composite output is strongly preferred for large serial datasets.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.logging_dir&amp;lt;/code&amp;gt; || None || Directory for log files. Under MPI, per-rank logs (&amp;lt;code&amp;gt;log_rankNNNN.out&amp;lt;/code&amp;gt;, etc.) are written here.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.logging_option&amp;lt;/code&amp;gt; || normal || &amp;lt;code&amp;gt;normal&amp;lt;/code&amp;gt; (all logging), &amp;lt;code&amp;gt;suppressed&amp;lt;/code&amp;gt; (silences verbose DIALS refine/index output), or &amp;lt;code&amp;gt;disabled&amp;lt;/code&amp;gt; (almost no logging).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.*_filename&amp;lt;/code&amp;gt; || (templates) || Output filename templates for each stage: &amp;lt;code&amp;gt;strong&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;indexed&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;refined_experiments&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;integrated&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;integrated_experiments&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;coset&amp;lt;/code&amp;gt;. A &amp;lt;code&amp;gt;%s&amp;lt;/code&amp;gt; in the template is replaced with the per-image tag.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.integration_pickle&amp;lt;/code&amp;gt; || None || Write legacy &amp;lt;code&amp;gt;cxi.merge&amp;lt;/code&amp;gt;/PRIME integration pickle files (e.g. &amp;lt;code&amp;gt;int-%d-%s.pickle&amp;lt;/code&amp;gt;). Only needed for legacy merging workflows.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Multiprocessing ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mp.method&amp;lt;/code&amp;gt; || multiprocessing || Parallelization backend: &amp;lt;code&amp;gt;multiprocessing&amp;lt;/code&amp;gt; (single node), or &amp;lt;code&amp;gt;mpi&amp;lt;/code&amp;gt; for multi-node jobs (also &amp;lt;code&amp;gt;sge&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;lsf&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;pbs&amp;lt;/code&amp;gt;).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mp.nproc&amp;lt;/code&amp;gt; || 1 || Number of processes (for the &amp;lt;code&amp;gt;multiprocessing&amp;lt;/code&amp;gt; method). Set to the number of cores per node.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mp.composite_stride&amp;lt;/code&amp;gt; || None || For MPI composite output, how many ranks aggregate their results into one set of output files. Ideally set to the number of processes per node so that one composite file set is written per node rather than per rank.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Under MPI with more than two ranks, the program runs a client/server model: rank 0 (or rank 2 for&lt;br /&gt;
psana2 &amp;lt;code&amp;gt;.loc&amp;lt;/code&amp;gt; inputs) hands out images to worker ranks on demand, giving good load&lt;br /&gt;
balancing across the many fast-failing non-hits typical of serial data.&lt;br /&gt;
&lt;br /&gt;
== Output files ==&lt;br /&gt;
&lt;br /&gt;
With the default composite output, each process (or each aggregating rank under MPI) writes&lt;br /&gt;
concatenated files such as:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;amp;lt;tag&amp;amp;gt;_strong.refl&amp;lt;/code&amp;gt; — strong spots from spot-finding&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;amp;lt;tag&amp;amp;gt;_indexed.refl&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;&amp;amp;lt;tag&amp;amp;gt;_refined.expt&amp;lt;/code&amp;gt; — indexed reflections and their crystal models&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;amp;lt;tag&amp;amp;gt;_integrated.refl&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;&amp;amp;lt;tag&amp;amp;gt;_integrated.expt&amp;lt;/code&amp;gt; — integrated intensities and final models (the input to [[cctbx.xfel.merge]])&lt;br /&gt;
&lt;br /&gt;
Per-image progress and status codes are recorded in &amp;lt;code&amp;gt;debug/debug_&amp;amp;lt;rank&amp;amp;gt;.txt&amp;lt;/code&amp;gt;, and&lt;br /&gt;
overall logging goes to &amp;lt;code&amp;gt;dials.process.log&amp;lt;/code&amp;gt; (or per-rank logs under MPI). These integrated&lt;br /&gt;
&amp;lt;code&amp;gt;.expt&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;.refl&amp;lt;/code&amp;gt; pairs are then scaled and merged with&lt;br /&gt;
[[cctbx.xfel.merge]].&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
* [[cctbx.xfel.merge]] — scaling, post-refinement and merging of the integrated data&lt;br /&gt;
* [[IOTA]] — a front-end that supplies preset parameters for &amp;lt;code&amp;gt;dials.stills_process&amp;lt;/code&amp;gt;&lt;br /&gt;
* [[Data Processing at SACLA]] — SACLA-specific processing workflow&lt;br /&gt;
* The DIALS documentation for the underlying spot-finding, indexing, refinement and integration algorithms&lt;/div&gt;</summary>
		<author><name>Aaron</name></author>
	</entry>
	<entry>
		<id>http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Dials.stills_process&amp;diff=1761</id>
		<title>Dials.stills process</title>
		<link rel="alternate" type="text/html" href="http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Dials.stills_process&amp;diff=1761"/>
		<updated>2026-08-21T22:22:06Z</updated>

		<summary type="html">&lt;p&gt;Aaron: Created page with &amp;quot;= dials.stills_process =  &amp;#039;&amp;#039;&amp;#039;dials.stills_process&amp;#039;&amp;#039;&amp;#039; is the core data-reduction program of cctbx.xfel. It takes a set of still diffraction images — typically serial femtosecond crystallography (SFX) snapshots from an XFEL (LCLS, SACLA, EuXFEL) or still shots from a synchrotron — and reduces each one, independently, through the full DIALS pipeline: &amp;#039;&amp;#039;&amp;#039;import → spot-finding → indexing → refinement → integration&amp;#039;&amp;#039;&amp;#039;. Its output (integrated intensities together wi...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= dials.stills_process =&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;dials.stills_process&#039;&#039;&#039; is the core data-reduction program of cctbx.xfel. It takes a set of&lt;br /&gt;
still diffraction images — typically serial femtosecond crystallography (SFX) snapshots from an&lt;br /&gt;
XFEL (LCLS, SACLA, EuXFEL) or still shots from a synchrotron — and reduces each one, independently,&lt;br /&gt;
through the full DIALS pipeline: &#039;&#039;&#039;import → spot-finding → indexing → refinement → integration&#039;&#039;&#039;.&lt;br /&gt;
Its output (integrated intensities together with the per-image experimental models) is the input to&lt;br /&gt;
the merging program [[cctbx.xfel.merge]].&lt;br /&gt;
&lt;br /&gt;
Because every image is a separate stationary exposure of a different crystal (rather than a wedge of&lt;br /&gt;
a rotation series), each image is treated as its own experiment with its own crystal model. This&lt;br /&gt;
&amp;quot;one crystal per shot&amp;quot; model is what distinguishes stills processing from conventional rotation data&lt;br /&gt;
processing (e.g. &amp;lt;code&amp;gt;dials.process&amp;lt;/code&amp;gt;), and it drives most of the stills-specific defaults&lt;br /&gt;
described below.&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
For each image, &amp;lt;code&amp;gt;dials.stills_process&amp;lt;/code&amp;gt; runs the following stages in order. Any stage can&lt;br /&gt;
be turned off with the &amp;lt;code&amp;gt;dispatch&amp;lt;/code&amp;gt; parameters; if a stage is disabled, processing stops&lt;br /&gt;
after the last enabled stage.&lt;br /&gt;
&lt;br /&gt;
# &#039;&#039;&#039;Import&#039;&#039;&#039; — read the image, apply reference geometry / gain / mask overrides, and build an experiment.&lt;br /&gt;
# &#039;&#039;&#039;Spot-finding&#039;&#039;&#039; — locate strong pixels and build strong reflections (&amp;lt;code&amp;gt;dispatch.find_spots&amp;lt;/code&amp;gt;).&lt;br /&gt;
# &#039;&#039;&#039;Hit finding&#039;&#039;&#039; — reject images with too few (or optionally too many) strong spots, so that only &amp;quot;hits&amp;quot; are indexed (&amp;lt;code&amp;gt;dispatch.hit_finder&amp;lt;/code&amp;gt;).&lt;br /&gt;
# &#039;&#039;&#039;Indexing&#039;&#039;&#039; — determine the crystal orientation and (optionally constrained) unit cell (&amp;lt;code&amp;gt;dispatch.index&amp;lt;/code&amp;gt;).&lt;br /&gt;
# &#039;&#039;&#039;Refinement&#039;&#039;&#039; — refine the crystal model and re-estimate the mosaic/domain-size parameters. Detector and beam are held fixed by default (&amp;lt;code&amp;gt;dispatch.refine&amp;lt;/code&amp;gt;).&lt;br /&gt;
# &#039;&#039;&#039;Integration&#039;&#039;&#039; — predict reflections and measure their intensities using the stills integrator (&amp;lt;code&amp;gt;dispatch.integrate&amp;lt;/code&amp;gt;), with optional Kapton absorption correction and a significance filter.&lt;br /&gt;
&lt;br /&gt;
The program applies a set of stills-specific defaults on top of the standard DIALS parameters,&lt;br /&gt;
including: indexing method &amp;lt;code&amp;gt;fft1d&amp;lt;/code&amp;gt;; the stills integrator with profile fitting turned off&lt;br /&gt;
(summation integration with a 2-D plane background); the stills refinement weighting strategy with&lt;br /&gt;
the detector and beam models fixed; and a re-estimation of per-crystal mosaic parameters&lt;br /&gt;
(domain size and mosaic angle) after refinement. These are sensible starting points for serial data&lt;br /&gt;
and normally do not need to be changed.&lt;br /&gt;
&lt;br /&gt;
Failures on individual images are, by default, caught and logged so that processing continues to the&lt;br /&gt;
next image (&amp;lt;code&amp;gt;dispatch.squash_errors=True&amp;lt;/code&amp;gt;) — essential when reducing tens of thousands of&lt;br /&gt;
shots of which only a fraction are hits.&lt;br /&gt;
&lt;br /&gt;
== Basic usage ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Process a directory of CBF stills, constraining the target cell/symmetry,&lt;br /&gt;
# using 32 parallel processes on one node&lt;br /&gt;
dials.stills_process /path/to/images/*.cbf process.phil mp.nproc=32&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A typical &amp;lt;code&amp;gt;process.phil&amp;lt;/code&amp;gt; for XFEL data looks like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
spotfinder.filter.min_spot_size=2&lt;br /&gt;
spotfinder.threshold.dispersion.gain=1.0&lt;br /&gt;
spotfinder.threshold.dispersion.global_threshold=100&lt;br /&gt;
&lt;br /&gt;
indexing.known_symmetry.space_group=P43212&lt;br /&gt;
indexing.known_symmetry.unit_cell=78.9,78.9,38.1,90,90,90&lt;br /&gt;
indexing.method=fft1d&lt;br /&gt;
&lt;br /&gt;
integration.background.simple.outlier.algorithm=null&lt;br /&gt;
&lt;br /&gt;
input.reference_geometry=refined.expt   # from a previous metrology refinement&lt;br /&gt;
&lt;br /&gt;
output.composite_output=True&lt;br /&gt;
output.output_dir=out&lt;br /&gt;
mp.nproc=32&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Useful command-line helpers:&lt;br /&gt;
* &amp;lt;code&amp;gt;dials.stills_process -h&amp;lt;/code&amp;gt; — help and usage&lt;br /&gt;
* &amp;lt;code&amp;gt;dials.stills_process -c -e 2&amp;lt;/code&amp;gt; — show the configurable parameters (expert level 2)&lt;br /&gt;
* &amp;lt;code&amp;gt;dials.stills_process -c -a2&amp;lt;/code&amp;gt; — include attributes (help text) for each parameter&lt;br /&gt;
* &amp;lt;code&amp;gt;dials.stills_process ... input.show_image_tags=True&amp;lt;/code&amp;gt; — list the image tags in a dataset without processing (useful for selecting subsets with &amp;lt;code&amp;gt;input.image_tag&amp;lt;/code&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
== Important parameters ==&lt;br /&gt;
&lt;br /&gt;
The program exposes the entire DIALS parameter set (spot-finding, indexing, refinement, integration,&lt;br /&gt;
profile modelling, prediction). The parameters below are the ones most commonly adjusted for serial&lt;br /&gt;
still data. Parameters are given by their full PHIL path with the default value in parentheses.&lt;br /&gt;
&lt;br /&gt;
=== Input ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.reference_geometry&amp;lt;/code&amp;gt; || None || Path to an &amp;lt;code&amp;gt;.expt&amp;lt;/code&amp;gt; file (or image) with a single detector model. Data are processed using &#039;&#039;this&#039;&#039; geometry instead of the geometry in the image headers. This is how a refined detector metrology from &amp;lt;code&amp;gt;cctbx.xfel&amp;lt;/code&amp;gt; ensemble refinement is applied — almost always set for XFEL data.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.sync_reference_geom&amp;lt;/code&amp;gt; || True || When a reference geometry is supplied, copy its refined local frames onto the image&#039;s detector hierarchy node-by-node (the hierarchies must match in shape). If False, the reference detector replaces the image detector wholesale.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.file_list&amp;lt;/code&amp;gt; || None || Path to a text file listing image paths, one per line (alternative to listing files on the command line).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.glob&amp;lt;/code&amp;gt; || None || Wildcard path(s) for large multi-file datasets (e.g. &amp;lt;code&amp;gt;*.cbf&amp;lt;/code&amp;gt;). May be given multiple times.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.image_tag&amp;lt;/code&amp;gt; || None || Process only images with the given tag(s). For single-image files the tag is the filename; for multi-image files (HDF5) it is &amp;lt;code&amp;gt;filename_imagenumber&amp;lt;/code&amp;gt;. Use &amp;lt;code&amp;gt;input.show_image_tags=True&amp;lt;/code&amp;gt; to list them.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;input.max_images&amp;lt;/code&amp;gt; || None || Limit the total number of images processed.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Dispatch — controlling the pipeline ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dispatch.find_spots&amp;lt;/code&amp;gt; || True || Do spot-finding. Required for indexing/integration.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dispatch.index&amp;lt;/code&amp;gt; || True || Attempt to index. Requires &amp;lt;code&amp;gt;find_spots=True&amp;lt;/code&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dispatch.integrate&amp;lt;/code&amp;gt; || True || Integrate indexed images. Ignored if indexing/spot-finding is off.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dispatch.refine&amp;lt;/code&amp;gt; || False || Run an explicit model-refinement step after indexing (the stills indexer already refines; this is an additional pass, rarely needed).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dispatch.squash_errors&amp;lt;/code&amp;gt; || True || If an image fails, log it and continue to the next image. Set False to halt and show the full error when debugging.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dispatch.hit_finder.enable&amp;lt;/code&amp;gt; || True || Enable hit-finding. If disabled, every image is passed to indexing.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dispatch.hit_finder.minimum_number_of_reflections&amp;lt;/code&amp;gt; || 16 || Images with fewer strong spots than this are discarded as non-hits before indexing.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dispatch.hit_finder.maximum_number_of_reflections&amp;lt;/code&amp;gt; || None || If set, images with more strong spots than this are discarded (e.g. ice/junk).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dispatch.process_percent&amp;lt;/code&amp;gt; || None || Process only this percentage of events (evenly sampled). Useful for a quick look at a large dataset.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dispatch.coset&amp;lt;/code&amp;gt; || False || During integration, also integrate a sublattice coset as a negative control for regions with no Bragg diffraction (see &amp;lt;code&amp;gt;integration.coset.transformation&amp;lt;/code&amp;gt;).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dispatch.pre_import&amp;lt;/code&amp;gt; || False || Import all data before processing. Only needed when processing multiple &#039;&#039;multi-image&#039;&#039; files at once (not a recommended workflow). Single-file datasets are always pre-imported automatically.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Spot-finding ===&lt;br /&gt;
&lt;br /&gt;
Spot-finding uses the standard DIALS dispersion thresholding. The most impactful parameters for&lt;br /&gt;
serial data:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spotfinder.filter.min_spot_size&amp;lt;/code&amp;gt; || Auto || Minimum connected pixels for a spot. Auto = 3 for pixel-array detectors (SENSOR_PAD), 6 otherwise. Often lowered to 2 for sparse serial patterns.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spotfinder.threshold.dispersion.gain&amp;lt;/code&amp;gt; || None || Detector gain used in thresholding. Set this &#039;&#039;or&#039;&#039; the detector-model gain, not both (see gain note below).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spotfinder.threshold.dispersion.sigma_strong&amp;lt;/code&amp;gt; || 3 || Number of sigma above background for a pixel to be &amp;quot;strong&amp;quot;.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spotfinder.threshold.dispersion.sigma_background&amp;lt;/code&amp;gt; || 6 || Number of sigma for the background/dispersion test.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spotfinder.threshold.dispersion.global_threshold&amp;lt;/code&amp;gt; || 0 || Absolute pixel intensity floor; pixels below this are never considered strong. Raising it (e.g. 100) suppresses noise on many detectors.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spotfinder.threshold.dispersion.kernel_size&amp;lt;/code&amp;gt; || 3 3 || Local-area kernel (pixels) for the dispersion calculation.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Gain note:&#039;&#039;&#039; the detector gain should be set on the detector model &#039;&#039;or&#039;&#039; in the processing&lt;br /&gt;
parameters, never both. If a supplied gain (&amp;lt;code&amp;gt;spotfinder.threshold.dispersion.gain&amp;lt;/code&amp;gt; or&lt;br /&gt;
&amp;lt;code&amp;gt;integration.summation.detector_gain&amp;lt;/code&amp;gt;) conflicts with a non-unity gain already on the&lt;br /&gt;
detector model, the program raises an error. Override with&lt;br /&gt;
&amp;lt;code&amp;gt;input.ignore_gain_mismatch=True&amp;lt;/code&amp;gt; only if you understand the consequences.&lt;br /&gt;
&lt;br /&gt;
=== Indexing ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;indexing.known_symmetry.space_group&amp;lt;/code&amp;gt; || None || Target space group. Strongly recommended for serial data — constrains indexing and improves the hit/index rate.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;indexing.known_symmetry.unit_cell&amp;lt;/code&amp;gt; || None || Target unit cell (a,b,c,α,β,γ). Used together with the space group as the indexing target.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;indexing.method&amp;lt;/code&amp;gt; || fft1d || Basis-vector search method (&amp;lt;code&amp;gt;dials.stills_process&amp;lt;/code&amp;gt; defaults to &amp;lt;code&amp;gt;fft1d&amp;lt;/code&amp;gt;; &amp;lt;code&amp;gt;fft3d&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;real_space_grid_search&amp;lt;/code&amp;gt; are also available).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;indexing.stills.method_list&amp;lt;/code&amp;gt; || None || Ordered list of indexing methods to try in turn; if one fails, the next is attempted (e.g. &amp;lt;code&amp;gt;fft1d real_space_grid_search&amp;lt;/code&amp;gt;).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;indexing.stills.known_orientations&amp;lt;/code&amp;gt; || None || Paths to previously-processed experiment lists. If given, images are &#039;&#039;not&#039;&#039; re-indexed; the stored crystal orientations are reused (e.g. to re-integrate with new parameters). Supports wildcards; may be repeated.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;indexing.stills.require_known_orientation&amp;lt;/code&amp;gt; || False || When known orientations are supplied but an image is not found among them, controls whether to skip it (True) or fall back to indexing from scratch (False).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;indexing.stills.reflection_subsampling.enable&amp;lt;/code&amp;gt; || False || Retry indexing on random subsets of the strong spots (from &amp;lt;code&amp;gt;step_start&amp;lt;/code&amp;gt;% down to &amp;lt;code&amp;gt;step_stop&amp;lt;/code&amp;gt;% in &amp;lt;code&amp;gt;step_size&amp;lt;/code&amp;gt;% steps). Can rescue images that fail to index on the full spot list.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Integration ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;profile.gaussian_rs.parameters.sigma_b_cutoff&amp;lt;/code&amp;gt; || 0.1 || Maximum beam divergence (sigma_b, degrees) before an indexed crystal is rejected prior to integration. Guards against over-broad, poorly-modelled lattices.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;significance_filter.enable&amp;lt;/code&amp;gt; || False || Apply the stills significance filter, which trims each crystal to the resolution at which reflections remain statistically significant (see &amp;lt;code&amp;gt;significance_filter.isigi_cutoff&amp;lt;/code&amp;gt;, default 1.0).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;integration.integration_only_overrides.trusted_range&amp;lt;/code&amp;gt; || None || Override the panel trusted range [min, max] during integration only (e.g. to include pixels the header marks as untrusted).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;integration.absorption_correction&amp;lt;/code&amp;gt; || apply=False || Enable a Kapton absorption correction (&amp;lt;code&amp;gt;algorithm=fuller_kapton&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;kapton_2019&amp;lt;/code&amp;gt;). Requires shoeboxes to be retained via &amp;lt;code&amp;gt;integration.debug&amp;lt;/code&amp;gt; settings; the program checks this and errors otherwise.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;integration.coset.transformation&amp;lt;/code&amp;gt; || 6 || Which modulus-2 sublattice transformation defines the coset negative control when &amp;lt;code&amp;gt;dispatch.coset=True&amp;lt;/code&amp;gt; (0–6; 6 = body centering). See Sauter &amp;amp; Zwart, &#039;&#039;Acta Cryst.&#039;&#039; D (2009) &#039;&#039;&#039;65&#039;&#039;&#039;:553.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Output ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.output_dir&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;.&amp;lt;/code&amp;gt; || Directory for output files.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.composite_output&amp;lt;/code&amp;gt; || True || If True, each process writes &#039;&#039;one&#039;&#039; concatenated set of &amp;lt;code&amp;gt;.expt&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;.refl&amp;lt;/code&amp;gt; files covering all its successful images. If False, a separate pair of files is written per image (generates a very large number of files). Composite output is strongly preferred for large serial datasets.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.logging_dir&amp;lt;/code&amp;gt; || None || Directory for log files. Under MPI, per-rank logs (&amp;lt;code&amp;gt;log_rankNNNN.out&amp;lt;/code&amp;gt;, etc.) are written here.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.logging_option&amp;lt;/code&amp;gt; || normal || &amp;lt;code&amp;gt;normal&amp;lt;/code&amp;gt; (all logging), &amp;lt;code&amp;gt;suppressed&amp;lt;/code&amp;gt; (silences verbose DIALS refine/index output), or &amp;lt;code&amp;gt;disabled&amp;lt;/code&amp;gt; (almost no logging).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.*_filename&amp;lt;/code&amp;gt; || (templates) || Output filename templates for each stage: &amp;lt;code&amp;gt;strong&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;indexed&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;refined_experiments&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;integrated&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;integrated_experiments&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;coset&amp;lt;/code&amp;gt;. A &amp;lt;code&amp;gt;%s&amp;lt;/code&amp;gt; in the template is replaced with the per-image tag.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;output.integration_pickle&amp;lt;/code&amp;gt; || None || Write legacy &amp;lt;code&amp;gt;cxi.merge&amp;lt;/code&amp;gt;/PRIME integration pickle files (e.g. &amp;lt;code&amp;gt;int-%d-%s.pickle&amp;lt;/code&amp;gt;). Only needed for legacy merging workflows.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Multiprocessing ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Default !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mp.method&amp;lt;/code&amp;gt; || multiprocessing || Parallelization backend: &amp;lt;code&amp;gt;multiprocessing&amp;lt;/code&amp;gt; (single node), or &amp;lt;code&amp;gt;mpi&amp;lt;/code&amp;gt; for multi-node jobs (also &amp;lt;code&amp;gt;sge&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;lsf&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;pbs&amp;lt;/code&amp;gt;).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mp.nproc&amp;lt;/code&amp;gt; || 1 || Number of processes (for the &amp;lt;code&amp;gt;multiprocessing&amp;lt;/code&amp;gt; method). Set to the number of cores per node.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;mp.composite_stride&amp;lt;/code&amp;gt; || None || For MPI composite output, how many ranks aggregate their results into one set of output files. Ideally set to the number of processes per node so that one composite file set is written per node rather than per rank.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Under MPI with more than two ranks, the program runs a client/server model: rank 0 (or rank 2 for&lt;br /&gt;
psana2 &amp;lt;code&amp;gt;.loc&amp;lt;/code&amp;gt; inputs) hands out images to worker ranks on demand, giving good load&lt;br /&gt;
balancing across the many fast-failing non-hits typical of serial data.&lt;br /&gt;
&lt;br /&gt;
== Output files ==&lt;br /&gt;
&lt;br /&gt;
With the default composite output, each process (or each aggregating rank under MPI) writes&lt;br /&gt;
concatenated files such as:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;amp;lt;tag&amp;amp;gt;_strong.refl&amp;lt;/code&amp;gt; — strong spots from spot-finding&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;amp;lt;tag&amp;amp;gt;_indexed.refl&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;&amp;amp;lt;tag&amp;amp;gt;_refined.expt&amp;lt;/code&amp;gt; — indexed reflections and their crystal models&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;amp;lt;tag&amp;amp;gt;_integrated.refl&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;&amp;amp;lt;tag&amp;amp;gt;_integrated.expt&amp;lt;/code&amp;gt; — integrated intensities and final models (the input to [[cctbx.xfel.merge]])&lt;br /&gt;
&lt;br /&gt;
Per-image progress and status codes are recorded in &amp;lt;code&amp;gt;debug/debug_&amp;amp;lt;rank&amp;amp;gt;.txt&amp;lt;/code&amp;gt;, and&lt;br /&gt;
overall logging goes to &amp;lt;code&amp;gt;dials.process.log&amp;lt;/code&amp;gt; (or per-rank logs under MPI). These integrated&lt;br /&gt;
&amp;lt;code&amp;gt;.expt&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;.refl&amp;lt;/code&amp;gt; pairs are then scaled and merged with&lt;br /&gt;
[[cctbx.xfel.merge]].&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
* [[cctbx.xfel.merge]] — scaling, post-refinement and merging of the integrated data&lt;br /&gt;
* [[IOTA]] — a front-end that supplies preset parameters for &amp;lt;code&amp;gt;dials.stills_process&amp;lt;/code&amp;gt;&lt;br /&gt;
* [[Data Processing at SACLA]] — SACLA-specific processing workflow&lt;br /&gt;
* The DIALS documentation for the underlying spot-finding, indexing, refinement and integration algorithms&lt;/div&gt;</summary>
		<author><name>Aaron</name></author>
	</entry>
	<entry>
		<id>http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Main_Page&amp;diff=1760</id>
		<title>Main Page</title>
		<link rel="alternate" type="text/html" href="http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Main_Page&amp;diff=1760"/>
		<updated>2026-08-21T22:15:20Z</updated>

		<summary type="html">&lt;p&gt;Aaron: /* cctbx.xfel resources */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;News! See our [[https://doi.org/10.1101/2025.05.04.652045 new preprint]]!  This paper shows current best practices using &#039;&#039;cctbx.xfel&#039;&#039; with &#039;&#039;DIALS&#039;&#039; for serial crystallographic data.&lt;br /&gt;
&lt;br /&gt;
= Open-source tools for serial crystallographic data processing =&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;cctbx.xfel&#039;&#039; is a suite of software tools designed to process diffraction data from serial femtosecond crystallography (SFX) measurements at an X-ray free-electron laser (XFEL) or a synchrotron.  Built on the Computational Crystallographic Toolbox ([https://cctbx.github.io/ &#039;&#039;cctbx&#039;&#039;]), the same toolbox on which [http://www.phenix-online.org &#039;&#039;PHENIX&#039;&#039;], and [http://dials.github.io DIALS] are built, it enables the user to solve difficult problems relating to processing serial crystallographic data.  The programs and modules provided by &#039;&#039;cctbx.xfel&#039;&#039; can reduce a large set of still diffraction images recorded at Stanford’s Linac Coherent Light Source ([http://lcls.slac.stanford.edu LCLS]), [http://sacla.xfel.jp SACLA], the [https://www.xfel.eu/ European XFEL], or a synchrotron, to a single MTZ file containing merged reflection intensities suitable for structure solution.&lt;br /&gt;
&lt;br /&gt;
== &#039;&#039;cctbx.xfel&#039;&#039; resources ==&lt;br /&gt;
&lt;br /&gt;
The current best resource is our pre-print, [https://doi.org/10.1101/2025.05.04.652045 &#039;&#039;cctbx.xfel: a suite for processing serial crystallographic data.&#039;&#039;].  This paper describes the algorithms and ideas behind the implementation and execution of the two main programs of &#039;&#039;cctbx.xfel&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;[[dials.stills_process]]&#039;&#039;: this program runs through all the first steps of processing data using dials: import (reading image headers), spot finding, indexing, geometry refinement, and integration.  Serial images are independent from each other, so this program is optimized for massively parallel systems, but can be adapted to a variety of single and multi-processing modes.&lt;br /&gt;
* &#039;&#039;cctbx.xfel.merge&#039;&#039;: this program runs through the remaining steps of processing: scaling and merging to produce a full dataset (.mtz file).  For documentation, see our [https://github.com/cctbx/cctbx_project/tree/master/xfel/merging Github project]&lt;br /&gt;
&lt;br /&gt;
Additional resources:&lt;br /&gt;
&lt;br /&gt;
* Our [http://cci.lbl.gov/publications/download/CCN_2019_p22_Brewster.pdf 2019 newsletter article] describes how to use the &#039;&#039;cctbx.xfel&#039;&#039; GUI, an interactive program for handling large XFEL datasets.&lt;br /&gt;
&lt;br /&gt;
* [[Overview]] to the system architecture at LCLS and real-time progress monitoring of data processing&lt;br /&gt;
* Installation: there are two ways to get &#039;&#039;cctbx.xfel&#039;&#039;:&lt;br /&gt;
** &#039;&#039;cctbx.xfel&#039;&#039; is installed for general use at SLAC.  To start using an existing installation, [[Using the pre-built cctbx at LCLS|simply source the current build]]. &lt;br /&gt;
** [https://dials.github.io/installation.html Download] a binary bundle of DIALS. Use this option if you will not be processing LCLS data because, for example, if you have serial crystallographic data from a synchrotron.&lt;br /&gt;
** Build a psana/cctbx.xfel build [https://github.com/cctbx/cctbx_project/tree/master/xfel/conda_envs from scratch]. Use this option if you want to process LCLS data outside of LCLS or want your own build.&lt;br /&gt;
* [[Tutorials]] on pre-processing, data reduction, and merging. &lt;br /&gt;
&lt;br /&gt;
Other related information:&lt;br /&gt;
&lt;br /&gt;
* [[Serial XFEL Crystallography References]]&lt;br /&gt;
&lt;br /&gt;
This project is under active development.  For any assistance, please contact the authors.&lt;/div&gt;</summary>
		<author><name>Aaron</name></author>
	</entry>
	<entry>
		<id>http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=2017_cxi_merge_tutorial&amp;diff=1759</id>
		<title>2017 cxi merge tutorial</title>
		<link rel="alternate" type="text/html" href="http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=2017_cxi_merge_tutorial&amp;diff=1759"/>
		<updated>2026-08-19T18:36:00Z</updated>

		<summary type="html">&lt;p&gt;Aaron: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Archived}}&lt;br /&gt;
&lt;br /&gt;
This is an updated, worked example of data merging using cxi.merge, for presentation at the Feb 17, 2017 Berkeley Lab Serial Crystallography Workshop.  Previous documentation sets are [[Merging | here]] and [[Advanced Merging | here]].  Literature description is in the [http://dx.doi.org/10.1038/nmeth.2887 Hattne (2014)], the [http://dx.doi.org/10.7554/eLife.05421 PRIME paper], the [http://dx.doi.org/10.1107/S1399004714024134 Sauter (2014)] and [http://dx.doi.org/10.1107/S1600577514028203 Sauter (2015)] papers.  Math derivations are further described in the source code release in file postrefinement_rs_model.pdf.&lt;br /&gt;
&lt;br /&gt;
== Initial characterization ==&lt;br /&gt;
In this example, we are given integrated still-shot data collected by Danny Axford at Diamond, for P6 myoglobin, PDB code [http://www.rcsb.org/pdb/explore/explore.do?structureId=5M3S 5M3S].&lt;br /&gt;
&lt;br /&gt;
* /net/dials/raid1/aaron/zurich0038/jr_006_batches/split_reintegrated/extracted # cctbx-style integration pickles &lt;br /&gt;
* /net/dials/raid1/aaron/zurich0038/jr_006_batches/sig_filter/split_reintegrated/extracted  # same data, with per-image resolution cutoff during integration&lt;br /&gt;
&lt;br /&gt;
Unix ls reveals 5031 *.pickle files in each directory. &lt;br /&gt;
&lt;br /&gt;
Immediately there is a problem:&lt;br /&gt;
&lt;br /&gt;
 $ cxi.print_pickle /net/dials/raid1/aaron/zurich0038/jr_006_batches/sig_filter/split_reintegrated/extracted/*.pickle&lt;br /&gt;
&lt;br /&gt;
...fails on image 0059 with a traceback; it looks like the file is corrupted.&lt;br /&gt;
&lt;br /&gt;
So focus on the data without integration resolution cutoff:&lt;br /&gt;
&lt;br /&gt;
 $ cxi.print_pickle /net/dials/raid1/aaron/zurich0038/jr_006_batches/split_reintegrated/extracted/*.pickle&lt;br /&gt;
&lt;br /&gt;
Some conclusions with the aid of grep:&lt;br /&gt;
* all integration pickles have space group P6 (good)&lt;br /&gt;
* distance and beam center is fixed throughout the integrated dataset&lt;br /&gt;
* Unit cells are variable but do seem to cluster around 91.4 91.4 45.9 90 90 120&lt;br /&gt;
&lt;br /&gt;
 phenix.fetch_pdb --mtz 5m3s&lt;br /&gt;
&lt;br /&gt;
Merge command file:&lt;br /&gt;
 #!/bin/csh -f&lt;br /&gt;
 &lt;br /&gt;
 set effective_params = &amp;quot;d_min=DMIN \&lt;br /&gt;
 data=/net/dials/raid1/aaron/zurich0038/jr_006_batches/split_reintegrated/extracted/*.pickle \&lt;br /&gt;
 output.n_bins=10 \&lt;br /&gt;
 pixel_size=0.172 \&lt;br /&gt;
 backend=FS \&lt;br /&gt;
 nproc=1 \&lt;br /&gt;
 model=5m3s.pdb \&lt;br /&gt;
 merge_anomalous=True \&lt;br /&gt;
 plot_single_index_histograms=False \&lt;br /&gt;
 scaling.algorithm=mark0 \&lt;br /&gt;
 raw_data.sdfac_auto=False \&lt;br /&gt;
 scaling.mtz_file=5m3s.mtz \&lt;br /&gt;
 scaling.show_plots=False \&lt;br /&gt;
 scaling.log_cutoff=None \&lt;br /&gt;
 scaling.mtz_column_F=i-obs \&lt;br /&gt;
 scaling.report_ML=True \&lt;br /&gt;
 set_average_unit_cell=True \&lt;br /&gt;
 rescale_with_average_cell=False \&lt;br /&gt;
 significance_filter.apply=True \&lt;br /&gt;
 significance_filter.min_ct=30 \&lt;br /&gt;
 significance_filter.sigma=0.2 \&lt;br /&gt;
 include_negatives=NEG \&lt;br /&gt;
 postrefinement.enable=True \&lt;br /&gt;
 postrefinement.algorithm=rs \&lt;br /&gt;
 output.prefix=TAG&amp;quot;&lt;br /&gt;
 set tag = p6m&lt;br /&gt;
 set dmin = 2.5&lt;br /&gt;
 set neg = True&lt;br /&gt;
 set eff = `echo $effective_params|sed -e &amp;quot;s,FS,Flex,g&amp;quot;|sed -e &amp;quot;s,DMIN,$dmin,g&amp;quot;|sed -e &amp;quot;s,NEG,$neg,g&amp;quot;|sed -e &amp;quot;s,TAG,$tag,g&amp;quot;`&lt;br /&gt;
 &lt;br /&gt;
 cxi.merge ${eff}&lt;br /&gt;
 exit&lt;br /&gt;
 cxi.xmerge ${eff}&lt;br /&gt;
 phenix.xtriage ${tag}_s0_mark0.mtz scaling.input.xray_data.obs_labels=imean&lt;br /&gt;
&lt;br /&gt;
Initial trial nproc=1 just to see if it runs.  Had to fix PDB reference. Can&#039;t use *.pickle on the data= line&lt;br /&gt;
&lt;br /&gt;
Scale-up trial nproc=60, no postrefinement.&lt;br /&gt;
set the MTZ flag = i_obs&lt;br /&gt;
  4493 of 5031 integration files were accepted&lt;br /&gt;
  0 rejected due to wrong Bravais group&lt;br /&gt;
  11 rejected for unit cell outliers&lt;br /&gt;
  22 rejected for low signal&lt;br /&gt;
  505 rejected due to up-front poor correlation under min_corr parameter&lt;br /&gt;
  0 rejected for file errors or no reindex matrix&lt;br /&gt;
Usage: 5m3s.mtz does not contain any observations labelled [fobs, imean, i-obs].  Please set scaling.mtz_column_F to one of [iobs].&lt;br /&gt;
  File &amp;quot;/net/viper/raid1/sauter/proj-e/modules/cctbx_project/xfel/cxi/util.py&amp;quot;, line 13, in is_odd_numbered&lt;br /&gt;
    return int(os.path.basename(file_name).split(allowable)[0][-1])%2==1&lt;br /&gt;
ValueError: invalid literal for int() with base 10: &#039;d&#039;&lt;br /&gt;
&lt;br /&gt;
Something is wrong in the ability to determine even/odd numbered-ness.  Added &amp;quot;_extracted.pickle&amp;quot; in the code; had to put it first.&lt;br /&gt;
&lt;br /&gt;
Table of Scaling Results:&lt;br /&gt;
&lt;br /&gt;
 ---------------------------------------------------------------------------------------------------------&lt;br /&gt;
                                       CC      N     CC     N     R     R     R   Scale  Scale    SpSig&lt;br /&gt;
 Bin  Resolution Range  Completeness  int    int    iso   iso    int  split  iso   int    iso      Test&lt;br /&gt;
 ---------------------------------------------------------------------------------------------------------&lt;br /&gt;
   1 -1.0000 -  5.3861     [809/809] 80.0%     809 75.2%    805 61.0% 40.1% 52.9% 0.551 214.059 12489.8850&lt;br /&gt;
   2  5.3861 -  4.2749     [791/791] 54.9%     791 74.5%    791 53.0% 38.8% 49.7% 0.693 270.307 1785.4625&lt;br /&gt;
   3  4.2749 -  3.7345     [781/781] 65.8%     781 81.6%    781 46.5% 33.6% 40.7% 0.762 337.287 1149.4218&lt;br /&gt;
   4  3.7345 -  3.3930     [776/776] 63.9%     776 74.5%    776 49.3% 36.4% 48.6% 0.764 283.109  758.0388&lt;br /&gt;
   5  3.3930 -  3.1498     [765/765] 67.1%     765 81.9%    765 48.4% 35.6% 43.4% 0.795 338.091  533.7650&lt;br /&gt;
   6  3.1498 -  2.9641     [771/771] 58.6%     771 72.4%    771 49.3% 36.6% 50.7% 0.759 286.707  222.4718&lt;br /&gt;
   7  2.9641 -  2.8156     [765/765] 56.0%     765 72.3%    765 48.5% 35.3% 46.7% 0.765 320.954  154.5299&lt;br /&gt;
   8  2.8156 -  2.6930     [746/746] 63.0%     746 76.1%    746 46.4% 34.3% 42.6% 0.867 357.183  99.4430&lt;br /&gt;
   9  2.6930 -  2.5894     [790/790] 52.1%     790 69.4%    790 50.4% 37.4% 47.5% 0.814 314.326  113.1264&lt;br /&gt;
  10  2.5894 -  2.5000     [757/757] 54.9%     757 78.6%    757 52.4% 38.9% 44.4% 0.794 306.403  109.0768&lt;br /&gt;
 &lt;br /&gt;
 All                     [7751/7751] 74.9%    7751 78.8%   7747 51.9% 36.9% 50.1% 0.680 266.538   1298.0&lt;br /&gt;
 ---------------------------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
Of course we know the data do not scale because this is a polar space group, and data must be sorted by Brehm/Diederichs method.&lt;br /&gt;
&lt;br /&gt;
== Breaking the indexing ambiguity ==&lt;br /&gt;
&lt;br /&gt;
Take note of our detail instructions on [[Resolving an Indexing Ambiguity]].  Do this in three steps:&lt;br /&gt;
&lt;br /&gt;
=== 1) Generate a database of observations ===&lt;br /&gt;
&lt;br /&gt;
step1.csh:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/csh -f&lt;br /&gt;
&lt;br /&gt;
set effective_params = &amp;quot;d_min=DMIN \&lt;br /&gt;
data=/net/dials/raid1/aaron/zurich0038/jr_006_batches/split_reintegrated/extracted \&lt;br /&gt;
output.n_bins=10 \&lt;br /&gt;
pixel_size=0.172 \&lt;br /&gt;
backend=FS \&lt;br /&gt;
nproc=60 \&lt;br /&gt;
merge_anomalous=True \&lt;br /&gt;
plot_single_index_histograms=False \&lt;br /&gt;
scaling.algorithm=mark1 \&lt;br /&gt;
target_unit_cell=91.4,91.4,45.9,90,90,120 \&lt;br /&gt;
target_space_group=P6 \&lt;br /&gt;
raw_data.sdfac_auto=False \&lt;br /&gt;
include_negatives=NEG \&lt;br /&gt;
postrefinement.enable=False \&lt;br /&gt;
output.prefix=TAG&amp;quot;&lt;br /&gt;
&lt;br /&gt;
set tag = p6m&lt;br /&gt;
set dmin = 2.5&lt;br /&gt;
set neg = False&lt;br /&gt;
set eff = `echo $effective_params|sed -e &amp;quot;s,FS,Flex,g&amp;quot;|sed -e &amp;quot;s,DMIN,$dmin,g&amp;quot;|sed -e &amp;quot;s,NEG,$neg,g&amp;quot;|sed -e &amp;quot;s,TAG,$tag,g&amp;quot;`&lt;br /&gt;
&lt;br /&gt;
cxi.merge ${eff}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This yields 4988 of 5031 integration files accepted.&lt;br /&gt;
&lt;br /&gt;
=== 2) Sort the lattices ===&lt;br /&gt;
&lt;br /&gt;
step2.csh:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/csh -f&lt;br /&gt;
&lt;br /&gt;
set effective_params = &amp;quot;d_min=DMIN \&lt;br /&gt;
pixel_size=0.172 \&lt;br /&gt;
target_unit_cell=91.4,91.4,45.9,90,90,120 \&lt;br /&gt;
target_space_group=P6 \&lt;br /&gt;
backend=FS \&lt;br /&gt;
nproc=60 \&lt;br /&gt;
merge_anomalous=True \&lt;br /&gt;
output.prefix=TAG&amp;quot;&lt;br /&gt;
&lt;br /&gt;
set tag = p6m&lt;br /&gt;
set dmin = 3.5&lt;br /&gt;
set neg = False&lt;br /&gt;
set eff = `echo $effective_params|sed -e &amp;quot;s,FS,Flex,g&amp;quot;|sed -e &amp;quot;s,DMIN,$dmin,g&amp;quot;|sed -e &amp;quot;s,NEG,$neg,g&amp;quot;|sed -e &amp;quot;s,TAG,$tag,g&amp;quot;`&lt;br /&gt;
&lt;br /&gt;
cxi.brehm_diederichs ${eff}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
14 plots total.  h,k,l=2503  h,-h-k,-1=2485  total 4988&lt;br /&gt;
&lt;br /&gt;
=== 3) Apply reindexing operators and merge ===&lt;br /&gt;
&lt;br /&gt;
== cxi.merge program output ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
----------------------------------------------------------------------------------------&lt;br /&gt;
                                            &amp;lt;asu   &amp;lt;obs&lt;br /&gt;
Bin  Resolution Range  Completeness   %    multi&amp;gt; multi&amp;gt; n_meas   &amp;lt;I&amp;gt;    &amp;lt;I/sig(I)&amp;gt;&lt;br /&gt;
----------------------------------------------------------------------------------------&lt;br /&gt;
  1   -1.000 - 5.386    [1490/1490] 100.00 102.21 102.21 152295   103994   103.244&lt;br /&gt;
  2    5.386 - 4.275    [1500/1500] 100.00  62.76  62.76  94141   128403    95.046&lt;br /&gt;
  3    4.275 - 3.735    [1499/1499] 100.00  53.90  53.90  80795   143552    92.607&lt;br /&gt;
  4    3.735 - 3.393    [1497/1497] 100.00  47.14  47.14  70571   112723    70.575&lt;br /&gt;
  5    3.393 - 3.150    [1477/1477] 100.00  43.96  43.96  64928    76925    51.011&lt;br /&gt;
  6    3.150 - 2.964    [1488/1488] 100.00  39.87  39.87  59330    57060    37.899&lt;br /&gt;
  7    2.964 - 2.816    [1483/1483] 100.00  38.17  38.17  56611    44079    32.085&lt;br /&gt;
  8    2.816 - 2.693    [1455/1455] 100.00  36.34  36.34  52874    37117    27.460&lt;br /&gt;
  9    2.693 - 2.589    [1530/1530] 100.00  34.49  34.49  52763    30496    24.443&lt;br /&gt;
 10    2.589 - 2.500    [1476/1476] 100.00  31.83  31.83  46974    27147    21.564&lt;br /&gt;
&lt;br /&gt;
All                   [14895/14895] 100.00  49.10  49.10 731282    76275    55.681&lt;br /&gt;
----------------------------------------------------------------------------------------&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== cxi.xmerge program output ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
--------------------------------------&lt;br /&gt;
Bin  Resolution Range # images %accept&lt;br /&gt;
--------------------------------------&lt;br /&gt;
  1 -1.0000 -  5.3861     4712  100.00&lt;br /&gt;
  2  5.3861 -  4.2749     4663  98.96&lt;br /&gt;
  3  4.2749 -  3.7345     4646  98.60&lt;br /&gt;
  4  3.7345 -  3.3930     4614  97.92&lt;br /&gt;
  5  3.3930 -  3.1498     4578  97.16&lt;br /&gt;
  6  3.1498 -  2.9641     4552  96.60&lt;br /&gt;
  7  2.9641 -  2.8156     4521  95.95&lt;br /&gt;
  8  2.8156 -  2.6930     4499  95.48&lt;br /&gt;
  9  2.6930 -  2.5894     4477  95.01&lt;br /&gt;
 10  2.5894 -  2.5000     4416  93.72&lt;br /&gt;
&lt;br /&gt;
All                       4721&lt;br /&gt;
--------------------------------------&lt;br /&gt;
--------------------------------------------------------------------------------------------------------&lt;br /&gt;
                                      CC      N     CC     N     R     R     R   Scale  Scale    SpSig&lt;br /&gt;
Bin  Resolution Range  Completeness  int    int    iso   iso    int  split  iso   int    iso      Test&lt;br /&gt;
--------------------------------------------------------------------------------------------------------&lt;br /&gt;
  1 -1.0000 -  5.3861   [1490/1490] 87.3%    1490 88.1%   1484 46.3% 32.9% 42.6% 0.772 300.328 8084.8580&lt;br /&gt;
  2  5.3861 -  4.2749   [1500/1500] 76.4%    1500 89.3%   1500 43.8% 30.6% 34.5% 0.761 425.498 1728.0907&lt;br /&gt;
  3  4.2749 -  3.7345   [1499/1499] 80.1%    1499 91.6%   1499 42.5% 26.7% 34.5% 0.684 430.028 1556.6316&lt;br /&gt;
  4  3.7345 -  3.3930   [1497/1497] 80.5%    1497 90.3%   1497 37.9% 27.2% 29.9% 0.846 481.795  600.5001&lt;br /&gt;
  5  3.3930 -  3.1498   [1477/1477] 84.2%    1477 90.0%   1477 37.2% 26.4% 31.4% 0.838 477.825  269.5784&lt;br /&gt;
  6  3.1498 -  2.9641   [1492/1492] 80.0%    1492 91.5%   1492 39.8% 28.6% 28.3% 0.866 511.386  165.9517&lt;br /&gt;
  7  2.9641 -  2.8156   [1483/1483] 76.7%    1483 90.0%   1483 39.3% 28.7% 30.1% 0.865 470.331  102.0659&lt;br /&gt;
  8  2.8156 -  2.6930   [1451/1451] 76.8%    1451 90.7%   1451 38.5% 28.2% 27.3% 0.883 492.758  88.6666&lt;br /&gt;
  9  2.6930 -  2.5894   [1532/1532] 76.6%    1532 89.4%   1532 40.1% 29.3% 30.5% 0.879 452.831  52.0092&lt;br /&gt;
 10  2.5894 -  2.5000   [1472/1472] 77.2%    1472 88.9%   1474 42.9% 31.4% 35.3% 0.801 393.866  52.6667&lt;br /&gt;
&lt;br /&gt;
All                   [14893/14893] 84.7%   14893 88.6%  14889 41.6% 29.0% 39.8% 0.771 378.964   804.8&lt;br /&gt;
--------------------------------------------------------------------------------------------------------&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Table of results ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
| style=&amp;quot;padding: 5px;&amp;quot;| Tag&lt;br /&gt;
| style=&amp;quot;padding: 5px;&amp;quot;| Method&lt;br /&gt;
| style=&amp;quot;padding: 5px;&amp;quot;| Details&lt;br /&gt;
| style=&amp;quot;padding: 5px;&amp;quot;| Resolution&amp;lt;br&amp;gt;(Angstrom)&lt;br /&gt;
| style=&amp;quot;padding: 5px;&amp;quot;| # files &amp;lt;br&amp;gt;accepted&lt;br /&gt;
| style=&amp;quot;padding: 5px;&amp;quot;| CC1/2 &amp;lt;br&amp;gt; (highest shell)&lt;br /&gt;
| style=&amp;quot;padding: 5px;&amp;quot;| CCiso &amp;lt;br&amp;gt; (highest shell)&lt;br /&gt;
| style=&amp;quot;padding: 5px;&amp;quot;| &amp;lt;|L|&amp;gt; test&amp;lt;br&amp;gt;(0.5 perfect)&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 10px;&amp;quot;| nopost&lt;br /&gt;
| style=&amp;quot;padding: 5px;&amp;quot;| no postrefinement&lt;br /&gt;
| style=&amp;quot;padding: 5px;&amp;quot;| scale only&lt;br /&gt;
| style=&amp;quot;padding: 5px;&amp;quot; | 2.5&lt;br /&gt;
| style=&amp;quot;padding: 5px;&amp;quot;| 4962 (4828)&lt;br /&gt;
| style=&amp;quot;padding: 5px;&amp;quot;| 77.5% (66.2%)&lt;br /&gt;
| style=&amp;quot;padding: 5px;&amp;quot;| 84.0% (85.8%)&lt;br /&gt;
| style=&amp;quot;padding: 5px;&amp;quot;| 0.475&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 10px;&amp;quot;| basic&lt;br /&gt;
| style=&amp;quot;padding: 5px;&amp;quot;| rs&lt;br /&gt;
| style=&amp;quot;padding: 5px;&amp;quot;| refine scale, B, rotx,roty&lt;br /&gt;
| style=&amp;quot;padding: 5px;&amp;quot; | 2.5&lt;br /&gt;
| style=&amp;quot;padding: 5px;&amp;quot;| 4942 (4650)&lt;br /&gt;
| style=&amp;quot;padding: 5px;&amp;quot;| 84.7% (77.2%)&lt;br /&gt;
| style=&amp;quot;padding: 5px;&amp;quot;| 88.6% (88.9%)&lt;br /&gt;
| style=&amp;quot;padding: 5px;&amp;quot;| 0.477&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 10px;&amp;quot;| trial1&lt;br /&gt;
| style=&amp;quot;padding: 5px;&amp;quot;| rs2&amp;lt;br&amp;gt;unit weighting&amp;lt;br&amp;gt;lorentzian lineshape&lt;br /&gt;
| style=&amp;quot;padding: 5px;&amp;quot;| analytical derivatives&amp;lt;br&amp;gt;better convergence test&amp;lt;br&amp;gt;Flex database&lt;br /&gt;
| style=&amp;quot;padding: 5px;&amp;quot; | 2.5&lt;br /&gt;
| style=&amp;quot;padding: 5px;&amp;quot;| 4719 (4458)&lt;br /&gt;
| style=&amp;quot;padding: 5px;&amp;quot;| 88.2% (74.8%)&lt;br /&gt;
| style=&amp;quot;padding: 5px;&amp;quot;| 89.5% (89.1%)&lt;br /&gt;
| style=&amp;quot;padding: 5px;&amp;quot;| 0.480&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 10px;&amp;quot;| trial2&lt;br /&gt;
| style=&amp;quot;padding: 5px;&amp;quot;| rs2&amp;lt;br&amp;gt;unit weighting&amp;lt;br&amp;gt;gaussian lineshape&lt;br /&gt;
| style=&amp;quot;padding: 5px;&amp;quot;| &lt;br /&gt;
| style=&amp;quot;padding: 5px;&amp;quot; | 2.5&lt;br /&gt;
| style=&amp;quot;padding: 5px;&amp;quot;| 4721 (4416)&lt;br /&gt;
| style=&amp;quot;padding: 5px;&amp;quot;| 90.9% (69.6%)&lt;br /&gt;
| style=&amp;quot;padding: 5px;&amp;quot;| 90.9% (89.1%)&lt;br /&gt;
| style=&amp;quot;padding: 5px;&amp;quot;| 0.508&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 10px;&amp;quot;| trial3&lt;br /&gt;
| style=&amp;quot;padding: 5px;&amp;quot;| rs_hybrid&amp;lt;br&amp;gt;gentle weighting (|I|/sigma**2)&amp;lt;br&amp;gt;gaussian lineshape&lt;br /&gt;
| style=&amp;quot;padding: 5px;&amp;quot;| rs2: LBFGS &amp;lt;br&amp;gt; LevMar to refine Rs&lt;br /&gt;
| style=&amp;quot;padding: 5px;&amp;quot; | 2.5&lt;br /&gt;
| style=&amp;quot;padding: 5px;&amp;quot;| 4059 (3783)&lt;br /&gt;
| style=&amp;quot;padding: 5px;&amp;quot;| 93.5% (37.3%)&lt;br /&gt;
| style=&amp;quot;padding: 5px;&amp;quot;| 95.4% (89.1%)&lt;br /&gt;
| style=&amp;quot;padding: 5px;&amp;quot;| 0.518&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 10px;&amp;quot;| trial3 / cycle2&lt;br /&gt;
| style=&amp;quot;padding: 5px;&amp;quot;| rs_hybrid&amp;lt;br&amp;gt;gentle weighting (|I|/sigma**2)&amp;lt;br&amp;gt;gaussian lineshape&amp;lt;br&amp;gt;recycle model&lt;br /&gt;
| style=&amp;quot;padding: 5px;&amp;quot;| Use mtz from trial 3&amp;lt;br&amp;gt; as a scaling reference&lt;br /&gt;
| style=&amp;quot;padding: 5px;&amp;quot; | 2.5&lt;br /&gt;
| style=&amp;quot;padding: 5px;&amp;quot;| 3716 (3432)&lt;br /&gt;
| style=&amp;quot;padding: 5px;&amp;quot;| 92.8% (48.1%)&lt;br /&gt;
| style=&amp;quot;padding: 5px;&amp;quot;| 93.3% (85.7%)&lt;br /&gt;
| style=&amp;quot;padding: 5px;&amp;quot;| 0.522&lt;br /&gt;
|- &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Useful:&lt;br /&gt;
 export BOOST_ADAPTBX_FPE_DEFAULT=1&lt;br /&gt;
 nproc=1&lt;br /&gt;
 postrefinement.show_trumpet_plot=True&lt;/div&gt;</summary>
		<author><name>Aaron</name></author>
	</entry>
	<entry>
		<id>http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Updating_cppxfel&amp;diff=1758</id>
		<title>Updating cppxfel</title>
		<link rel="alternate" type="text/html" href="http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Updating_cppxfel&amp;diff=1758"/>
		<updated>2026-08-19T18:35:25Z</updated>

		<summary type="html">&lt;p&gt;Aaron: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Archived}}&lt;br /&gt;
&lt;br /&gt;
In the case of updating the cppxfel installation, open a terminal and navigate to the &amp;lt;code&amp;gt;cppxfel&amp;lt;/code&amp;gt; directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;cd /absolute/path/to/dials/dials-dev-508/modules/cppxfel&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, pull the latest code from the repository.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;git pull&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If necessary, some command line tools may need to be configured. To do this, type&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;libtbx.configure cppxfel&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, the C++ code will need recompiling.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd ../../build&lt;br /&gt;
make&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The new distribution of cppxfel will be available to use.&lt;/div&gt;</summary>
		<author><name>Aaron</name></author>
	</entry>
	<entry>
		<id>http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Tutorials&amp;diff=1757</id>
		<title>Tutorials</title>
		<link rel="alternate" type="text/html" href="http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Tutorials&amp;diff=1757"/>
		<updated>2026-08-19T18:35:12Z</updated>

		<summary type="html">&lt;p&gt;Aaron: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Archived}}&lt;br /&gt;
&lt;br /&gt;
Available tutorials:&lt;br /&gt;
&lt;br /&gt;
* [https://github.com/phyy-nx/dials_refinement_brewster2018/wiki List of tutorials] as part of our recent paper, [https://doi.org/10.1107/S2059798318009191 Brewster 2018].&lt;br /&gt;
* [[2017_dials.stills_process | dials.stills_process]] for processing synchrotron data, including detector position refinement&lt;/div&gt;</summary>
		<author><name>Aaron</name></author>
	</entry>
	<entry>
		<id>http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Setup&amp;diff=1756</id>
		<title>Setup</title>
		<link rel="alternate" type="text/html" href="http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Setup&amp;diff=1756"/>
		<updated>2026-08-19T18:34:53Z</updated>

		<summary type="html">&lt;p&gt;Aaron: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Archived}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- XXX Should probably rename this page to &amp;quot;Set up &#039;&#039;cctbx.xfel&#039;&#039;&amp;quot; or some such --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Prerequisities ==&lt;br /&gt;
&lt;br /&gt;
The installation root directories of &#039;&#039;cctbx.xfel&#039;&#039; affect the absolute paths used in the following instructions and differ from site to site.  Some common installation root directories are listed below.&lt;br /&gt;
{| class=&amp;quot;wikitable sortable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Site&lt;br /&gt;
!class=&amp;quot;unsortable&amp;quot;| Installation build directory&lt;br /&gt;
!class=&amp;quot;unsortable&amp;quot;| Installation source directory&lt;br /&gt;
!class=&amp;quot;unsortable&amp;quot;| Notes&lt;br /&gt;
|-&lt;br /&gt;
| BNL&lt;br /&gt;
| &amp;lt;code&amp;gt;/usr/local/crys_test/cctbx/cctbx_build&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;/usr/local/crys_test/cctbx&amp;lt;/code&amp;gt;&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| CCI, LBNL&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| No central, shared installation available&lt;br /&gt;
|-&lt;br /&gt;
| NERSC&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| No central, shared installation available&lt;br /&gt;
|-&lt;br /&gt;
| SLAC&lt;br /&gt;
| &amp;lt;code&amp;gt;/reg/g/cctbx/build&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;/reg/g/cctbx/sources&amp;lt;/code&amp;gt;&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&#039;&#039;cctbx.xfel&#039;&#039; can be installed anywhere on the filesystem where write access is granted.  Developers will generally have &#039;&#039;cctbx.xfel&#039;&#039; installed in their home directory.  Even if &#039;&#039;cctbx.xfel&#039;&#039; is already installed, the environment must first be [[Set up PSDM software | prepared for the PSDM software distribution]].&lt;br /&gt;
&lt;br /&gt;
== &#039;&#039;cctbx.xfel&#039;&#039; setup ==&lt;br /&gt;
&lt;br /&gt;
To start using &#039;&#039;cctbx.xfel&#039;&#039;, the environment has to be configured.  The details depend on the &#039;&#039;cctbx.xfel&#039;&#039; installation root directories and the user&#039;s shell.&lt;br /&gt;
In what follows &amp;lt;code&amp;gt;&amp;lt;b&amp;gt;&amp;lt;i&amp;gt;/path/to/cctbx/build&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;&amp;lt;b&amp;gt;&amp;lt;i&amp;gt;/path/to/cctbx/sources&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;&amp;lt;/code&amp;gt; should be replaced with the actual build  and source directories of the &#039;&#039;cctbx.xfel&#039;&#039; installation.  bash-users can prepare the environment for &#039;&#039;cctbx.xfel&#039;&#039; using&lt;br /&gt;
 $ . &amp;lt;b&amp;gt;&amp;lt;i&amp;gt;/path/to/cctbx/build&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;/setpaths.sh&lt;br /&gt;
From a csh, the corresponding command is&lt;br /&gt;
 % source &amp;lt;b&amp;gt;&amp;lt;i&amp;gt;/path/to/cctbx/build&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;/setpaths.csh&lt;br /&gt;
Sourcing &amp;lt;code&amp;gt;setpaths&amp;lt;/code&amp;gt; only modifies the environment of the &amp;lt;em&amp;gt;current shell&amp;lt;/em&amp;gt;, and would have to be repeated every time a new shell is started.  To make the changes persistent, add&lt;br /&gt;
 test -r &amp;lt;b&amp;gt;&amp;lt;i&amp;gt;/reg/g/cctbx/build&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;/setpaths.sh &amp;amp;&amp;amp; \&lt;br /&gt;
   . &amp;lt;b&amp;gt;&amp;lt;i&amp;gt;/reg/g/cctbx/build&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;/setpaths.sh&lt;br /&gt;
to &amp;lt;code&amp;gt;~/.bashrc&amp;lt;/code&amp;gt;, or&lt;br /&gt;
 test -r &amp;lt;b&amp;gt;&amp;lt;i&amp;gt;/reg/g/cctbx/build&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;/setpaths.csh &amp;amp;&amp;amp; \&lt;br /&gt;
   source &amp;lt;b&amp;gt;&amp;lt;i&amp;gt;/reg/g/cctbx/build&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;/setpaths.csh&lt;br /&gt;
to &amp;lt;code&amp;gt;~/.cshrc&amp;lt;/code&amp;gt; as appropriate.&lt;br /&gt;
&lt;br /&gt;
To make the &#039;&#039;cctbx.xfel&#039;&#039; analysis modules available to PSDM&#039;s &#039;&#039;pyana&#039;&#039;,&lt;br /&gt;
 $ cd &amp;lt;b&amp;gt;&amp;lt;i&amp;gt;/path/to/test/release&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;&lt;br /&gt;
 $ sit_setup&lt;br /&gt;
 $ cd &amp;lt;b&amp;gt;&amp;lt;i&amp;gt;my_ana_pkg&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;&lt;br /&gt;
 $ ln -fns &amp;lt;b&amp;gt;&amp;lt;i&amp;gt;/path/to/cctbx/sources&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;/cctbx_project/xfel/cxi/cspad_ana src&lt;br /&gt;
 $ cd ..&lt;br /&gt;
 $ scons&lt;br /&gt;
where &amp;lt;code&amp;gt;&amp;lt;b&amp;gt;&amp;lt;i&amp;gt;/path/to/test/release&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;&amp;lt;b&amp;gt;&amp;lt;i&amp;gt;my_ana_pkg&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;&amp;lt;/code&amp;gt; are the path to the test release and the name of the analysis package chosen while [[Set up PSDM software | setting up the PSDM software distribution]].  The last step compiles the &#039;&#039;cctbx.xfel&#039;&#039; analysis modules.  These steps need only be performed once.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
At SLAC, test that it is working by &amp;lt;i&amp;gt;e.g.&amp;lt;/i&amp;gt;&lt;br /&gt;
 $ cxi.pyana -c /reg/g/cctbx/tutorials/setup/test.cfg /reg/d/ana11/cxi/data/Mar2013calib/xtc/e236-r0004-s00-c00.xtc&lt;br /&gt;
This should start a viewer, displaying dark-subtracted averages from an XTC stream.  Press the green run button to see the images.  This particular stream has a series of misses at its beginning; hits will appear presently.  More specifically, this command starts &#039;&#039;pyana&#039;&#039; with a configuration file (&amp;lt;code&amp;gt;-c&amp;lt;/code&amp;gt;) and an XTC file.  For more information, see the [[Overview]] and other tutorial pages.&lt;br /&gt;
--&amp;gt;&lt;/div&gt;</summary>
		<author><name>Aaron</name></author>
	</entry>
	<entry>
		<id>http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Set_up_PSDM_software&amp;diff=1755</id>
		<title>Set up PSDM software</title>
		<link rel="alternate" type="text/html" href="http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Set_up_PSDM_software&amp;diff=1755"/>
		<updated>2026-08-19T18:33:59Z</updated>

		<summary type="html">&lt;p&gt;Aaron: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Archived}}&lt;br /&gt;
&lt;br /&gt;
THIS IS DEPRECATED.  psana is now provided using conda.  [https://exafel.github.io/docs/psana-cctbx-instal Directions].&lt;br /&gt;
&lt;br /&gt;
Note that throughout the instructions &amp;lt;code&amp;gt;$&amp;lt;/code&amp;gt; denotes the prompt of any unprivileged user on the system.  Certain shells may be configured to use &amp;lt;code&amp;gt;%&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;&amp;amp;gt;&amp;lt;/code&amp;gt; for that purpose.  The prompt should &amp;lt;em&amp;gt;not&amp;lt;/em&amp;gt; be included in the commands typed to the shell.&lt;br /&gt;
&lt;br /&gt;
== Prerequisites ==&lt;br /&gt;
&lt;br /&gt;
The [https://confluence.slac.stanford.edu/display/PSDM/Software+Distribution Photon Science Data Management (PSDM)] software distribution must be installed.  The PSDM software distribution provides &#039;&#039;psana&#039;&#039;, which is a critical dependency of &#039;&#039;cctbx.xfel&#039;&#039;.  Its installation root directory affects the absolute paths used in the following instructions and differs from site to site.  Some common installation root directories are listed below.&lt;br /&gt;
{| class=&amp;quot;wikitable sortable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Site&lt;br /&gt;
! class=&amp;quot;unsortable&amp;quot;| Installation root directory&lt;br /&gt;
! class=&amp;quot;unsortable&amp;quot;| Notes&lt;br /&gt;
|-&lt;br /&gt;
| BNL&lt;br /&gt;
| &amp;lt;code&amp;gt;/usr/local/crys/psdm&amp;lt;/code&amp;gt;&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| CCI, LBNL&lt;br /&gt;
| &amp;lt;code&amp;gt;/net/viper/raid1/psdm&amp;lt;/code&amp;gt;&lt;br /&gt;
| Only available on viper.lbl.gov&lt;br /&gt;
|-&lt;br /&gt;
| NERSC&lt;br /&gt;
| &amp;lt;code&amp;gt;/global/project/projectdirs/lcls/psdm-carver&amp;lt;/code&amp;gt;&lt;br /&gt;
| Only to be used on the carver system&lt;br /&gt;
|-&lt;br /&gt;
| SLAC&lt;br /&gt;
| &amp;lt;code&amp;gt;/reg/g/psdm&amp;lt;/code&amp;gt;&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
The PSDM software distribution is supported on the most popular flavors of Linux and is installed at several sites worldwide.  Separate installation and maintenance instructions are provided by the PSDM project at [https://confluence.slac.stanford.edu/display/PSDM/Software+Distribution PSDM software distribution].  The package can be installed anywhere on the filesystem, and it is generally possible to install it without superuser privileges.&lt;br /&gt;
&lt;br /&gt;
== Create a test release and an analysis package ==&lt;br /&gt;
&lt;br /&gt;
A &amp;lt;i&amp;gt;test release&amp;lt;/i&amp;gt;, which refers to a particular release of the PSDM distribution, is represented by a directory in the file system, often called &amp;lt;code&amp;gt;analysis-rel&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;myrelease&amp;lt;/code&amp;gt;. An analysis package within the test release in turn refers to the files implementing the analysis modules of the package. Details about test releases and analysis packages are covered in [https://confluence.slac.stanford.edu/display/PCDS/Analysis+Workbook.+Quick+Tour Analysis Workbook.  Quick Tour].  To prepare the environment for using the PSDM software distribution, bash-users should source &amp;lt;code&amp;gt;ana_env.sh&amp;lt;/code&amp;gt;,&lt;br /&gt;
 $ . &amp;lt;b&amp;gt;&amp;lt;i&amp;gt;/path/to/psdm&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;/etc/ana_env.sh&lt;br /&gt;
where &amp;lt;code&amp;gt;&amp;lt;b&amp;gt;&amp;lt;i&amp;gt;/path/to/psdm&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;&amp;lt;/code&amp;gt; should be replaced with the path to the installation root directory.  csh-users should source &amp;lt;code&amp;gt;ana_env.csh&amp;lt;/code&amp;gt; instead,&lt;br /&gt;
 % source &amp;lt;b&amp;gt;&amp;lt;i&amp;gt;/path/to/psdm&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;/etc/ana_env.csh&lt;br /&gt;
Sourcing &amp;lt;code&amp;gt;ana_env.sh&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;ana_env.csh&amp;lt;/code&amp;gt; only modifies the environment of the &amp;lt;em&amp;gt;current shell&amp;lt;/em&amp;gt;, and would have to be repeated every time a new shell is started.  To make the changes persistent, add&lt;br /&gt;
 test -r &amp;lt;b&amp;gt;&amp;lt;i&amp;gt;/path/to/psdm&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;/etc/ana_env.sh &amp;amp;&amp;amp; . &amp;lt;b&amp;gt;&amp;lt;i&amp;gt;/path/to/psdm&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;/etc/ana_env.sh&lt;br /&gt;
to &amp;lt;code&amp;gt;~/.bashrc&amp;lt;/code&amp;gt;, or&lt;br /&gt;
 test -r &amp;lt;b&amp;gt;&amp;lt;i&amp;gt;/path/to/psdm&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;/etc/ana_env.csh &amp;amp;&amp;amp; source &amp;lt;b&amp;gt;&amp;lt;i&amp;gt;/path/to/psdm&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;/etc/ana_env.csh&lt;br /&gt;
to &amp;lt;code&amp;gt;~/.cshrc&amp;lt;/code&amp;gt; as appropriate.  This ensures the environment is properly prepared for non-interactive shells, &amp;lt;i&amp;gt;e.g.&amp;lt;/i&amp;gt; the shells that are used to run jobs submitted to the cluster.  To also be able to use the PSDM software from interactive shells, it is recommended that bash-users put&lt;br /&gt;
 test -r ~/.bashrc &amp;amp;&amp;amp; . ~/.bashrc&lt;br /&gt;
near the top of &amp;lt;code&amp;gt;~/.bash_profile&amp;lt;/code&amp;gt;.  There is no need to edit any additional files for csh-users, because csh always reads &amp;lt;code&amp;gt;~/.cshrc&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
A test released based on the most current PSDM distribution is then set up in the current working directory using&lt;br /&gt;
 $ newrel ana-current &amp;lt;i&amp;gt;myrelease&amp;lt;/i&amp;gt;&lt;br /&gt;
 $ cd &amp;lt;i&amp;gt;myrelease&amp;lt;/i&amp;gt;&lt;br /&gt;
 $ sit_setup&lt;br /&gt;
 $ newpkg &amp;lt;i&amp;gt;my_ana_pkg&amp;lt;/i&amp;gt;&lt;br /&gt;
Note that the names for the test release and the analysis package, &amp;lt;i&amp;gt;myrelease&amp;lt;/i&amp;gt; and &amp;lt;i&amp;gt;my_ana_pkg&amp;lt;/i&amp;gt; above, are common, but nevertheless arbitrary, choices.&lt;br /&gt;
&lt;br /&gt;
These steps only need to be performed once.&lt;br /&gt;
&lt;br /&gt;
== External links ==&lt;br /&gt;
&lt;br /&gt;
* [https://confluence.slac.stanford.edu/display/PSDM/psana+-+User+Manual Psana User Manual]&lt;br /&gt;
* [https://confluence.slac.stanford.edu/display/PSDM/Packages+and+Releases Packages and Releases]&lt;/div&gt;</summary>
		<author><name>Aaron</name></author>
	</entry>
	<entry>
		<id>http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Resolving_an_Indexing_Ambiguity&amp;diff=1754</id>
		<title>Resolving an Indexing Ambiguity</title>
		<link rel="alternate" type="text/html" href="http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Resolving_an_Indexing_Ambiguity&amp;diff=1754"/>
		<updated>2026-08-19T18:33:35Z</updated>

		<summary type="html">&lt;p&gt;Aaron: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Archived}}&lt;br /&gt;
&lt;br /&gt;
Here we describe the use of [http://dx.doi.org/10.1107/S1399004713025431 Brehm &amp;amp; Diederichs algorithm 2] to resolve the indexing ambiguity for XFEL data.  This is applicable for all polar space groups (where the Bravais symmetry is higher than the space group symmetry) and also for cases with pseudo symmetry (e.g., a monoclinic cell with a near 90-degree beta angle).&lt;br /&gt;
&lt;br /&gt;
== Brief Description of the Workflow ==&lt;br /&gt;
&lt;br /&gt;
It is assumed that the reader is familiar with the tutorial for [[Merging]].  The usual workflow of &amp;lt;code&amp;gt;cxi.merge&amp;lt;/code&amp;gt; followed by &amp;lt;code&amp;gt;cxi.xmerge&amp;lt;/code&amp;gt; will fail in the xmerge step if there are reindexing operators (not H,K,L) that relate the individual indexed lattices to one another.  We resolve this by (1) running the &amp;lt;code&amp;gt;cxi.merge&amp;lt;/code&amp;gt; step to generate a database with all the observations; (2) use Brehm-Diederichs algorithm 2 to identify the reindexing operators with &amp;lt;code&amp;gt;cxi.brehm_diederichs&amp;lt;/code&amp;gt;; (3) re-run the &amp;lt;code&amp;gt;cxi.merge + cxi.xmerge&amp;lt;/code&amp;gt; process with the additional list of reindexing operators as input.&lt;br /&gt;
&lt;br /&gt;
== Detailed Step-By-Step Instructions ==&lt;br /&gt;
&lt;br /&gt;
=== Create a Database of Observations ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ vi myoglobin_step1.csh&lt;br /&gt;
#!/bin/csh -f&lt;br /&gt;
set trial=${1}&lt;br /&gt;
&lt;br /&gt;
set runs = 127,130,132,134,135,140,141,142,144&lt;br /&gt;
set datastring = \&lt;br /&gt;
`python -c &amp;quot;print &#039; &#039;.join([&#039;data=/my_results/L785/r%04d/${trial}/integration&#039;%i for i in [${runs}]])&amp;quot;`&lt;br /&gt;
set tag = myoglobin_${trial}&lt;br /&gt;
&lt;br /&gt;
set effective_params = &amp;quot;d_min=2.0 \&lt;br /&gt;
output.n_bins=20 \&lt;br /&gt;
${datastring} \&lt;br /&gt;
scaling.algorithm=mark1 \&lt;br /&gt;
target_unit_cell=90.3,90.3,45.2,90,90,120 \&lt;br /&gt;
target_space_group=P6 \&lt;br /&gt;
nproc=16 \&lt;br /&gt;
merge_anomalous=True \&lt;br /&gt;
mysql.runtag=${tag} \&lt;br /&gt;
mysql.passwd=terp888 \&lt;br /&gt;
mysql.user=nick \&lt;br /&gt;
mysql.database=xfelnks \&lt;br /&gt;
scaling.mtz_file=fake_filename.mtz \&lt;br /&gt;
pixel_size = 0.079346 \&lt;br /&gt;
output.prefix=${tag}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
cxi.merge ${effective_params} # Note the xmerge script is NOT run here&lt;br /&gt;
&lt;br /&gt;
$./myoglobin_step1.csh 009 # create the database from trial 009&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Noteworthy parameters:&lt;br /&gt;
* &amp;lt;code&amp;gt;d_min&amp;lt;/code&amp;gt; is the high-resolution limit to be used for resolving the indexing ambiguity, not final merging.  There is a trade-off:  including too many data slows down the determination of lattice-lattice correlation coefficients, which scales as the number of common Miller indices.  Including too few data makes the determination of correlation coefficients unreliable or undefined.  Future:  the program will print out &amp;lt;L&amp;gt;, the average number of observation pairs per correlation coefficient so the resolution limit can be sensibly adjusted.  &lt;br /&gt;
* &amp;lt;code&amp;gt;scaling.algorithm&amp;lt;/code&amp;gt; is set to mark1 here (no scaling) to illustrate how data would be processed from an unknown structure.  As a consequence (see the [[Advanced Merging]] page) we set the &amp;lt;code&amp;gt;target_unit_cell&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;target_space_group&amp;lt;/code&amp;gt; but do not provide a PDB &amp;lt;code&amp;gt;model&amp;lt;/code&amp;gt;.  Also &amp;lt;code&amp;gt;scaling.mtz_file&amp;lt;/code&amp;gt; is set to a dummy value.&lt;br /&gt;
* &amp;lt;code&amp;gt;nproc&amp;lt;/code&amp;gt; is the number of processors to be used for writing the database.  Use as many single-host processors as are available up to a limit of about 16, beyond which there is no further benefit, at least on Linux.&lt;br /&gt;
* &amp;lt;code&amp;gt;merge_anomalous=True&amp;lt;/code&amp;gt;. Since we are trying to maximize the number of common Miller indices for each lattice pair we want to merge the Bijvoet pairs, even if we will look for dispersive differences in the final merging step.&lt;br /&gt;
* &amp;lt;code&amp;gt;backend&amp;lt;/code&amp;gt;. Use whatever backend is available on your system; choices are FS, MySQL (default), and SQLite.&lt;br /&gt;
&lt;br /&gt;
=== Sort the Lattices ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ vi myoglobin_step2.csh&lt;br /&gt;
#!/bin/csh -f&lt;br /&gt;
set trial=${1}&lt;br /&gt;
set tag = myoglobin_${trial}&lt;br /&gt;
&lt;br /&gt;
set effective_params = &amp;quot;d_min=2.0 \&lt;br /&gt;
target_unit_cell=90.3,90.3,45.2,90,90,120 \&lt;br /&gt;
target_space_group=P6 \&lt;br /&gt;
nproc=32 \&lt;br /&gt;
merge_anomalous=True \&lt;br /&gt;
mysql.runtag=${tag} \&lt;br /&gt;
mysql.passwd=terp888 \&lt;br /&gt;
mysql.user=nick \&lt;br /&gt;
mysql.database=xfelnks \&lt;br /&gt;
pixel_size = 0.079346 \&lt;br /&gt;
output.prefix=${tag}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
cxi.brehm_diederichs ${effective_params}&lt;br /&gt;
&lt;br /&gt;
$./myoglobin_step2.csh 009 # sort the lattices from trial 009&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Noteworthy parameters:&lt;br /&gt;
* &amp;lt;code&amp;gt;d_min&amp;lt;/code&amp;gt; is the high-resolution limit to be used for resolving the indexing ambiguity, not final merging.  There is a trade-off:  including too many data slows down the determination of lattice-lattice correlation coefficients, which scales as the number of common Miller indices.  Including too few data makes the determination of correlation coefficients unreliable or undefined.  Future:  the program will print out &amp;lt;L&amp;gt;, the average number of observation pairs per correlation coefficient so the resolution limit can be sensibly adjusted.  &lt;br /&gt;
* &amp;lt;code&amp;gt;nproc&amp;lt;/code&amp;gt; is the number of processors used on a single host.  Must either be set to 1 or &amp;gt;=5; there is no implementation for 2-4.  If there are a large number of images (&amp;gt;2000) it is advantageous to set this number as high as possible [we use 64 on our AMD Linux machine].  BUT IF THERE ARE FEWER THAN ~500 IMAGES, you must use nproc=1.&lt;br /&gt;
* &amp;lt;code&amp;gt;target_unit_cell&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;target_space_group&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;merge_anomalous&amp;lt;/code&amp;gt; are mandatory and should be set to the same values used in the myoglobin_step1.csh script above.  &lt;br /&gt;
* Likewise, &amp;lt;code&amp;gt;mysql.runtag&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;output.prefix&amp;lt;/code&amp;gt; should use the same values.&lt;br /&gt;
&lt;br /&gt;
Output files from this script:&lt;br /&gt;
* &amp;lt;b&amp;gt;${tag}_intensities_presort.pickle&amp;lt;/b&amp;gt; contains a Python tuple with two Miller arrays, the first giving all intensites input into the calculation, and the second assigning each intensity to a lattice [crystal] number.  For development, not actually used for anything.&lt;br /&gt;
* &amp;lt;b&amp;gt;${tag}_lookup.pickle&amp;lt;/b&amp;gt; is a Python dictionary whose keys are the reindexing operators, and values are lists of lattice [crystal] numbers to be reindexed accordingly.&lt;br /&gt;
* &amp;lt;b&amp;gt;${tag}_reverse_lookup.pickle&amp;lt;/b&amp;gt; is a Python dictionary whose keys are the original integrated data pickle file names, and values are the reindexing operator to be applied to each file.  This output is actually used in the next step.&lt;br /&gt;
&lt;br /&gt;
=== Apply Reindexing Operators and Merge ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ vi myoglobin_step3.csh&lt;br /&gt;
#!/bin/csh -f&lt;br /&gt;
set trial=${1}&lt;br /&gt;
&lt;br /&gt;
set runs = 127,130,132,134,135,140,141,142,144&lt;br /&gt;
set datastring = \&lt;br /&gt;
`python -c &amp;quot;print &#039; &#039;.join([&#039;data=/my_results/L785/r%04d/${trial}/integration&#039;%i for i in [${runs}]])&amp;quot;`&lt;br /&gt;
set tag = myoglobin_${trial}_step3&lt;br /&gt;
&lt;br /&gt;
set effective_params = &amp;quot;d_min=1.8 \&lt;br /&gt;
d_max=6.0 \&lt;br /&gt;
output.n_bins=20 \&lt;br /&gt;
${datastring} \&lt;br /&gt;
merging.reverse_lookup=myoglobin_${trial}_reverse_lookup.pickle&lt;br /&gt;
scaling.algorithm=mark0 \&lt;br /&gt;
model=3u3e.pdb \&lt;br /&gt;
model_reindex_op=h,-h-k,-l \&lt;br /&gt;
nproc=16 \&lt;br /&gt;
merge_anomalous=False \&lt;br /&gt;
mysql.runtag=${tag} \&lt;br /&gt;
mysql.passwd=terp888 \&lt;br /&gt;
mysql.user=nick \&lt;br /&gt;
mysql.database=xfelnks \&lt;br /&gt;
scaling.mtz_file=3u3e.data.mtz \&lt;br /&gt;
scaling.mtz_column_F=fmodel \&lt;br /&gt;
pixel_size = 0.079346 \&lt;br /&gt;
output.prefix=${tag}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
cxi.merge ${effective_params} &lt;br /&gt;
cxi.xmerge ${effective_params} &lt;br /&gt;
&lt;br /&gt;
$./myoglobin_step3.csh 009 # apply the reindexing operators and merge&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Noteworthy parameters:&lt;br /&gt;
* &amp;lt;code&amp;gt;d_min&amp;lt;/code&amp;gt; is now set to the highest-resolution desired for the merging step.&lt;br /&gt;
* &amp;lt;code&amp;gt;merge_anomalous=False&amp;lt;/code&amp;gt;. If looking for dispersive differences, set this to False.&lt;br /&gt;
* &amp;lt;code&amp;gt;scaling.algorithm&amp;lt;/code&amp;gt; is set to mark0 here to illustrate scaling of a P6 myoglobin XFEL data set against an isomorphous structure already in the PDB.&lt;br /&gt;
* &amp;lt;code&amp;gt;model&amp;lt;/code&amp;gt; The PDB file used for scaling individual crystals in the cxi.merge step. &lt;br /&gt;
* &amp;lt;code&amp;gt;model_reindex_op&amp;lt;/code&amp;gt; A total kludge.  Since there is an indexing ambiguity and we&#039;ve sorted it out for the XFEL data, there is still the possibility that the reference model is indexed the &amp;quot;wrong&amp;quot; way.   This parameter lets us reindex the reference to coincide with the XFEL data.  Default value is &amp;quot;h,k,l&amp;quot;, no reindexing.&lt;br /&gt;
* &amp;lt;code&amp;gt;scaling.mtz_file&amp;lt;/code&amp;gt;.  For the statistics in cxi.xmerge, this is set to an mtz file with Fcalc&#039;s from &amp;lt;em&amp;gt;phenix.fmodel 3u3e.pdb high_resolution=1.78 output.type=real&amp;lt;/em&amp;gt;.  &lt;br /&gt;
* &amp;lt;code&amp;gt;scaling.mtz_column_F&amp;lt;/code&amp;gt; is set to whatever column name contains the reference F&#039;s in this case &amp;quot;fmodel&amp;quot;.&lt;br /&gt;
* &amp;lt;code&amp;gt;d_max&amp;lt;/code&amp;gt; is set so that isomorphous correlation coefficients are not calculated on the very low resolution reflections, since the Fcalc&#039;s have no solvent contribution.  If an observed reference data set were used for the mtz_file this precaution would be unnecessary.&lt;br /&gt;
* &amp;lt;code&amp;gt;nproc&amp;lt;/code&amp;gt; is the number of processors to be used for merging.  Use as many single-host processors as are available up to a limit of about 16, beyond which there is no further benefit, at least on Linux.&lt;br /&gt;
* &amp;lt;code&amp;gt;merging.reverse_lookup&amp;lt;/code&amp;gt; Sets the cxi.merge script to reindex all the integrated data files according to the operators determined in step 2, and to ignore any integrated data for which no reindexing operator was determined.  In the cxi.xmerge script, each reindexing operator in turn is considered in order to report isomorphous CC and R statistics against the reference data set.  It is up to the user to look at the output to find the reindexing that gives the highest CCiso values.&lt;/div&gt;</summary>
		<author><name>Aaron</name></author>
	</entry>
	<entry>
		<id>http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Progress_monitoring&amp;diff=1753</id>
		<title>Progress monitoring</title>
		<link rel="alternate" type="text/html" href="http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Progress_monitoring&amp;diff=1753"/>
		<updated>2026-08-19T18:33:20Z</updated>

		<summary type="html">&lt;p&gt;Aaron: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Archived}}&lt;br /&gt;
&lt;br /&gt;
If configured to do so, &#039;&#039;cctbx.xfel&#039;&#039; can use a mysql database during hit finding to log the hit rate and other useful parameters, enabling real-time monitoring via a graphical display.  &lt;br /&gt;
&lt;br /&gt;
== Configuring trial monitoring ==&lt;br /&gt;
Add to the mod_hitfind section of your pyana config file these lines:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cxi.lsf will replace this with its deterimined id, otherwise&lt;br /&gt;
# set it to the ID you wish.  0 is the default.&lt;br /&gt;
trial_id        = 0&lt;br /&gt;
db_logging      = True&lt;br /&gt;
sql_buffer_size = 5&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These three parameters turn on and configure database-backed logging of hitfinding results:&lt;br /&gt;
* trial_id: we find it useful to organize processing in numbered trials.  Whenever we go back and change the parameters of our processing, adjusting the target cell or spotfinder parameters for example, we re-process under a different trial ID.  When you submit your processing job using cxi.lsf, you can specify the trial ID on the command line with –t.  What you specify will overwrite what is listed here in the cfg file.  If you use bsub, then what is in the cfg file is what’s used.  Note, it isn’t a good idea to re-use the trial_id when re-prossing the data if database logging is being used, simply because the hits will be logged twice which will clutter future analysis.  Finally, if you want to see which trials you have used for which runs, execute &#039;&#039;&#039;cxi.list_db_metadata&#039;&#039;&#039;&lt;br /&gt;
* db_logging: Switch for turning on and off logging&lt;br /&gt;
* sql_buffer_size: a queue size for regulating how often to add data to the database.  In our experience, 5 has been just fine.&lt;br /&gt;
&lt;br /&gt;
== Monitoring hit finding in real time ==&lt;br /&gt;
After submitting a job with db logging enabled, use cxi.monitor_trials &amp;lt;trial number&amp;gt; to display the hit rate during processing.  Other command line options and their defaults are listed below, including the ability to display multiple runs at once.  The default is to display the 5 latest runs by timestamp.&lt;br /&gt;
* t_wait = 8000: amount of time in ms between queries to the database&lt;br /&gt;
* hit_cutoff = 16: the number of bragg spots before a frame is considered a hit.  If this is different than what’s in your config file, then the monitor will be using a different cutoff to display which frames are hits.&lt;br /&gt;
* average_window = 1000: how many frames are in the sliding averaging window shown in the hit % graph&lt;br /&gt;
* n_points = 1000: how many total points to display on the graph.  Set it to 0 to display all the data points (can be computationally intensive).&lt;br /&gt;
* display_time = 1800: number of seconds of experiment time to display.  Displays this number of seconds unless that would add up to more than 5 runs.&lt;br /&gt;
* run_num = display only this run&lt;br /&gt;
* run_min = start at this run&lt;br /&gt;
* run_max = end with this run&lt;/div&gt;</summary>
		<author><name>Aaron</name></author>
	</entry>
	<entry>
		<id>http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Processing_L498_thermolysin&amp;diff=1752</id>
		<title>Processing L498 thermolysin</title>
		<link rel="alternate" type="text/html" href="http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Processing_L498_thermolysin&amp;diff=1752"/>
		<updated>2026-08-19T18:32:59Z</updated>

		<summary type="html">&lt;p&gt;Aaron: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Archived}}&lt;br /&gt;
&lt;br /&gt;
This page contains instructions for reproducing the results reported in the 2014 &#039;&#039;cctbx.xfel&#039;&#039; paper&amp;lt;ref name=&amp;quot;Hattne:2014&amp;quot;&amp;gt;[http://dx.doi.org/10.1038/nmeth.2887 Hattne, J &amp;lt;i&amp;gt;et al.&amp;lt;/i&amp;gt; Accurate macromolecular structures using minimal measurements from X-ray free-electron lasers. &amp;lt;i&amp;gt;Nat. Methods&amp;lt;/i&amp;gt; &amp;lt;b&amp;gt;In press&amp;lt;/b&amp;gt; (2014).]&amp;lt;/ref&amp;gt;.  The data are available from the [http://cxidb.org Coherent X-ray Imaging Data Bank] ([http://cxidb.org/id-23 CXIDB ID 23]; [http://cxidb.org/id-23-raw.html raw XTC files], 4.0 TiB), and must be downloaded to a local disk prior to starting the analysis.  Furthermore, the [https://confluence.slac.stanford.edu/display/PSDM/Software+Distribution PSDM Software Distribution] must be [[Set up PSDM software | set up]], along with a test release and an empty analysis package.  A [http://www.mysql.com MySQL] database is required to merge the integrated diffraction intensities.  In the interest of keeping this guide as general as possible, no particular queuing system is assumed to be available. Processing time depends strongly on the computational resources available; using 48 processors on a 64-core 1.4 GHz Opteron-based computer, the analysis takes around 24 hours.  The instructions assume some familiarity with &#039;&#039;cctbx.xfel&#039;&#039; and its installation and configuration procedure.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Installing a &#039;&#039;cctbx.xfel&#039;&#039; snapshot from March 28, 2013 ==&lt;br /&gt;
&lt;br /&gt;
The thermolysin data for the &#039;&#039;cctbx.xfel&#039;&#039; paper was processed around March 28, 2013.  Unfortunately,  regular nightly releases are not available for that time, but a custom source-code bundle has been prepared.  This bundle differs from the regular &#039;&#039;cctbx&#039;&#039; bundles in that [http://adder.lbl.gov/labelit &#039;&#039;LABELIT&#039;&#039;] is included, and that the directory layout is identical to that of a developer installation.  To download and unpack the bundle in the current directory:&lt;br /&gt;
 $ wget http://adder.lbl.gov/cctbx.xfel/downloads/cctbx.xfel-20130328.tar.gz&lt;br /&gt;
 $ tar -xpvzf cctbx.xfel-20130328.tar.gz&lt;br /&gt;
Next, create a build directory (called &amp;lt;code&amp;gt;&amp;lt;i&amp;gt;phenix-build-20130328&amp;lt;/i&amp;gt;&amp;lt;/code&amp;gt; below, but that is an arbitrary choice), in which the sources are configured and compiled.  The Python interpreter required to complete this step &amp;lt;em&amp;gt;must&amp;lt;/em&amp;gt; be the one supplied by the PSDM Software Distribution.  Once the PSDM software has been [[Set up PSDM software | set up]], this interpreter can be located using&lt;br /&gt;
 $ find $SIT_ROOT/sw/external/python -perm /0111 -type f -wholename &amp;quot;*/$SIT_ARCH/*/python&amp;quot;&lt;br /&gt;
To prepare the build directory using this interpreter&lt;br /&gt;
 $ mkdir &amp;lt;i&amp;gt;phenix-build-20130328&amp;lt;/i&amp;gt;&lt;br /&gt;
 $ cd &amp;lt;i&amp;gt;phenix-build-20130328&amp;lt;/i&amp;gt;&lt;br /&gt;
 $ &amp;lt;b&amp;gt;&amp;lt;i&amp;gt;python&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt; ../phenix-src-20130328/cctbx_project/libtbx/configure.py cxi_xdr_xes xfel&lt;br /&gt;
 $ . setpaths.sh&lt;br /&gt;
where &amp;lt;code&amp;gt;&amp;lt;b&amp;gt;&amp;lt;i&amp;gt;python&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;&amp;lt;/code&amp;gt; is the path to the Python interpreter located using the previous find-command.  Note that csh-users should run &amp;lt;code&amp;gt;source setpaths.csh&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;. setpaths.sh&amp;lt;/code&amp;gt;.  Then compile the sources:&lt;br /&gt;
 $ make&lt;br /&gt;
 $ make&lt;br /&gt;
Note that the &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; command may need to be run twice in order to complete the build.  Once &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; does not produce any output from the compiler, the build is complete.&lt;br /&gt;
&lt;br /&gt;
To make the &#039;&#039;cctbx.xfel&#039;&#039; analysis modules available to PSDM&#039;s &#039;&#039;pyana&#039;&#039;,&lt;br /&gt;
 $ cd &amp;lt;b&amp;gt;&amp;lt;i&amp;gt;/path/to/test/release&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;&lt;br /&gt;
 $ sit_setup&lt;br /&gt;
 $ cd &amp;lt;b&amp;gt;&amp;lt;i&amp;gt;my_ana_pkg&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;&lt;br /&gt;
 $ ln -fns &amp;lt;b&amp;gt;&amp;lt;i&amp;gt;/path/to&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;/phenix-src-20130328/cctbx_project/xfel/cxi/cspad_ana src&lt;br /&gt;
 $ cd ..&lt;br /&gt;
 $ scons&lt;br /&gt;
where &amp;lt;code&amp;gt;&amp;lt;b&amp;gt;&amp;lt;i&amp;gt;/path/to/test/release&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;&amp;lt;b&amp;gt;&amp;lt;i&amp;gt;my_ana_pkg&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;&amp;lt;/code&amp;gt; are the path to the test release and the name of the analysis package chosen while [[Set up PSDM software | setting up the PSDM software distribution]], respectively.  &amp;lt;code&amp;gt;&amp;lt;b&amp;gt;&amp;lt;i&amp;gt;/path/to&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;&amp;lt;/code&amp;gt; denotes the path to the directory containing the unpacked &#039;&#039;cctbx.xfel&#039;&#039; sources.  The last step compiles the &#039;&#039;cctbx.xfel&#039;&#039; analysis modules.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Creating a dark image ==&lt;br /&gt;
&lt;br /&gt;
To meaningfully process the thermolysin diffraction data, an average of all the images in a &amp;lt;i&amp;gt;dark run&amp;lt;/i&amp;gt;—a run without any X-rays impinging on the detector—must be subtracted from the individual diffraction images.  The configuration file below can be used to produce such an average, as well as an image of the standard deviation of all the pixels over the course of the run. &lt;br /&gt;
 [pyana]&lt;br /&gt;
 modules = my_ana_pkg.mod_average&lt;br /&gt;
 num-cpu = &amp;lt;i&amp;gt;4&amp;lt;/i&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 [my_ana_pkg.mod_average]&lt;br /&gt;
 address         = CxiDs1-0|Cspad-0&lt;br /&gt;
 calib_dir       = &amp;lt;b&amp;gt;&amp;lt;i&amp;gt;/path/to&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;/phenix-src-20130328/cctbx_project/xfel/metrology/CSPad/run4/CxiDs1.0_Cspad.0&lt;br /&gt;
 avg_basename    = &amp;lt;i&amp;gt;Ds1-avg&amp;lt;/i&amp;gt;&lt;br /&gt;
 avg_dirname     = &amp;lt;i&amp;gt;r0031&amp;lt;/i&amp;gt;&lt;br /&gt;
 stddev_basename = &amp;lt;i&amp;gt;Ds1-stddev&amp;lt;/i&amp;gt;&lt;br /&gt;
 stddev_dirname  = &amp;lt;i&amp;gt;r0031&amp;lt;/i&amp;gt;&lt;br /&gt;
&amp;lt;b&amp;gt;&amp;lt;i&amp;gt;/path/to&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt; refers to the directory containing the unpacked &#039;&#039;cctbx.xfel&#039;&#039; sources.  All other options with values set in italics can be modified without adversely affecting averaging.  The above file will use four simultaneous processes, and write the average and standard deviation images to files whose names start with &amp;lt;code&amp;gt;Ds1-avg&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;Ds1-stddev&amp;lt;/code&amp;gt;, respectively, both in a directory called  &amp;lt;code&amp;gt;&amp;lt;i&amp;gt;r0031&amp;lt;/i&amp;gt;&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
The data deposited at the [http://cxidb.org/id-23 CXIDB] contains a dark run, &amp;lt;code&amp;gt;r0031&amp;lt;/code&amp;gt;.  To average the images in that run, save the above configuration file to disk, &amp;lt;i&amp;gt;e.g.&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;&amp;lt;i&amp;gt;L498-dark.cfg&amp;lt;/i&amp;gt;&amp;lt;/code&amp;gt;, apply modifications as necessary, and execute&lt;br /&gt;
 $ cxi.pyana -c &amp;lt;i&amp;gt;L498-dark.cfg&amp;lt;/i&amp;gt; &amp;lt;b&amp;gt;&amp;lt;i&amp;gt;/path/to/xtc/files&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;/e157-r0031-*.xtc&lt;br /&gt;
where &amp;lt;b&amp;gt;&amp;lt;i&amp;gt;/path/to/xtc/files&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt; is the path to the directory containing the raw XTC files downloaded from [http://cxidb.org/id-23 CXIDB].  The files written to the &amp;lt;code&amp;gt;&amp;lt;i&amp;gt;r0031&amp;lt;/i&amp;gt;&amp;lt;/code&amp;gt; directory will have a current date stamp appended, which can safely be removed to simplify subsequent configuration files.&lt;br /&gt;
 $ cd &amp;lt;i&amp;gt;r0031&amp;lt;/i&amp;gt;&lt;br /&gt;
 $ mv &amp;lt;i&amp;gt;Ds1-avg20140308104336073.pickle&amp;lt;/i&amp;gt; Ds1-avg.pickle&lt;br /&gt;
 $ mv &amp;lt;i&amp;gt;Ds1-stddev20140308104336371.pickle&amp;lt;/i&amp;gt; Ds1-stddev.pickle&lt;br /&gt;
 $ cd ..&lt;br /&gt;
Note that the date stamp on the generated files above depends on the time of their creation.  Further details are available on the [[Preparatory steps#Create a dark average|Create a dark image]] page of the [[Tutorials|tutorials]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Indexing the thermolysin data ==&lt;br /&gt;
&lt;br /&gt;
A configuration file for processing the primary lattices in the thermolysin data is shown below.&lt;br /&gt;
 [pyana]&lt;br /&gt;
 modules = my_ana_pkg.mod_hitfind:threshold \&lt;br /&gt;
           my_ana_pkg.mod_hitfind:index&lt;br /&gt;
 num-cpu = &amp;lt;i&amp;gt;48&amp;lt;/i&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 [my_ana_pkg.mod_hitfind]&lt;br /&gt;
 address     = CxiDs1-0|Cspad-0&lt;br /&gt;
 calib_dir   = &amp;lt;b&amp;gt;&amp;lt;i&amp;gt;/path/to&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;/phenix-src-20130328/cxi_xdr_xes/cftbx/metrology/CSPad/run4/CxiDs1.0:Cspad.0&lt;br /&gt;
 dark_path   = &amp;lt;i&amp;gt;r0031/Ds1-avg.pickle&amp;lt;/i&amp;gt;&lt;br /&gt;
 dark_stddev = &amp;lt;i&amp;gt;r0031/Ds1-stddev.pickle&amp;lt;/i&amp;gt;&lt;br /&gt;
 db_logging  = False&lt;br /&gt;
 detz_offset = 575&lt;br /&gt;
 &lt;br /&gt;
 [my_ana_pkg.mod_hitfind:threshold]&lt;br /&gt;
 dispatch        = nop&lt;br /&gt;
 distl_flags     = permissive&lt;br /&gt;
 distl_min_peaks = 16&lt;br /&gt;
 threshold       = 450&lt;br /&gt;
 xtal_target     = hitfind&lt;br /&gt;
 &lt;br /&gt;
 [my_ana_pkg.mod_hitfind:index]&lt;br /&gt;
 dispatch             = index&lt;br /&gt;
 integration_dirname  = &amp;lt;i&amp;gt;integration-first-lattice&amp;lt;/i&amp;gt;&lt;br /&gt;
 integration_basename = int-&lt;br /&gt;
 xtal_target          = thermolysin27&lt;br /&gt;
The configuration file above instructs &amp;lt;code&amp;gt;mod_hitfind&amp;lt;/code&amp;gt; to use 48 processes.  It disables all image output, which reduces the amount of disk space required to perform the analysis to about 3.4 GiB.  &amp;lt;b&amp;gt;&amp;lt;i&amp;gt;/path/to&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt; again refers to the directory containing the unpacked &#039;&#039;cctbx.xfel&#039;&#039; sources, and &amp;lt;code&amp;gt;dark_path&amp;lt;/code&amp;gt; as well as &amp;lt;code&amp;gt;dark_stddev&amp;lt;/code&amp;gt; may have to be changed to reflect the location of the previously generated dark images.  Integration results will be written to the directory &amp;lt;i&amp;gt;integration-first-lattice&amp;lt;/i&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Due to particularities of the thermolysin measurement, processing needs to proceed in two batches.  To analyze the first batch, runs 16 through 27, save the above configuration file to disk, &amp;lt;i&amp;gt;e.g.&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;&amp;lt;i&amp;gt;L498-indexigrate.cfg&amp;lt;/i&amp;gt;&amp;lt;/code&amp;gt;, apply modifications as necessary, and execute&lt;br /&gt;
 $ cxi.pyana -c &amp;lt;i&amp;gt;L498-indexigrate.cfg&amp;lt;/i&amp;gt; &amp;lt;b&amp;gt;&amp;lt;i&amp;gt;/path/to/xtc/files&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;/e157-r0016-*.xtc&lt;br /&gt;
 $ cxi.pyana -c &amp;lt;i&amp;gt;L498-indexigrate.cfg&amp;lt;/i&amp;gt; &amp;lt;b&amp;gt;&amp;lt;i&amp;gt;/path/to/xtc/files&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;/e157-r0017-*.xtc&lt;br /&gt;
 $ …&lt;br /&gt;
 $ cxi.pyana -c &amp;lt;i&amp;gt;L498-indexigrate.cfg&amp;lt;/i&amp;gt; &amp;lt;b&amp;gt;&amp;lt;i&amp;gt;/path/to/xtc/files&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;/e157-r0027-*.xtc&lt;br /&gt;
where &amp;lt;b&amp;gt;&amp;lt;i&amp;gt;/path/to/xtc/files&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt; is the path to the directory containing the raw XTC files.  The second batch, runs 71 through 73, was recorded using a different distance between the interaction region and the detector.  Whilst the changes to the detector position are automatically handled by &#039;&#039;cctbx.xfel&#039;&#039;, the resulting difference in shadowing is not.  Different areas of the detector should be ignored at the different distances, and this is accounted for by the value of the &amp;lt;code&amp;gt;xtal_target&amp;lt;/code&amp;gt; option in the configuration file.  To analyze this set of runs, edit &amp;lt;code&amp;gt;&amp;lt;i&amp;gt;L498-indexigrate.cfg&amp;lt;/i&amp;gt;&amp;lt;/code&amp;gt;, change &amp;lt;code&amp;gt;thermolysin27&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;thermolysin73&amp;lt;/code&amp;gt;, and&lt;br /&gt;
 $ cxi.pyana -c &amp;lt;i&amp;gt;L498-indexigrate.cfg&amp;lt;/i&amp;gt; &amp;lt;b&amp;gt;&amp;lt;i&amp;gt;/path/to/xtc/files&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;/e157-r0071-*.xtc&lt;br /&gt;
 $ cxi.pyana -c &amp;lt;i&amp;gt;L498-indexigrate.cfg&amp;lt;/i&amp;gt; &amp;lt;b&amp;gt;&amp;lt;i&amp;gt;/path/to/xtc/files&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;/e157-r0072-*.xtc&lt;br /&gt;
 $ cxi.pyana -c &amp;lt;i&amp;gt;L498-indexigrate.cfg&amp;lt;/i&amp;gt; &amp;lt;b&amp;gt;&amp;lt;i&amp;gt;/path/to/xtc/files&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;/e157-r0073-*.xtc&lt;br /&gt;
On successful completion, the number of files in the &amp;lt;i&amp;gt;integration-first-lattice&amp;lt;/i&amp;gt; directory corresponds to the number of successfully integrated images.  Owing to variations in hardware and compiler internals, it may deviate slightly from 11,583, the number reported in the &#039;&#039;cctbx.xfel&#039;&#039; paper&amp;lt;ref name=&amp;quot;Hattne:2014&amp;quot;/&amp;gt;.  Further details are available on the [[Indexing and integration|indexing and integration]] page of the [[Tutorials|tutorials]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Indexing the secondary lattice ===&lt;br /&gt;
&lt;br /&gt;
Indexing the secondary lattice is very similar to indexing the primary lattice, but requires a change to the source code.  Edit &amp;lt;code&amp;gt;&amp;lt;b&amp;gt;&amp;lt;i&amp;gt;/path/to&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;/phenix-src-20130328/labelit_regression/xfel/xfel_targets.py&amp;lt;/code&amp;gt;, and uncomment (&amp;lt;i&amp;gt;i.e.&amp;lt;/i&amp;gt; remove the leading &amp;lt;code&amp;gt;#&amp;lt;/code&amp;gt; character) &amp;lt;code&amp;gt;&amp;quot;outlier_detection.switch=True&amp;quot;&amp;lt;/code&amp;gt; on line 25.  Then edit the configuration file, &amp;lt;code&amp;gt;&amp;lt;i&amp;gt;L498-indexigrate.cfg&amp;lt;/i&amp;gt;&amp;lt;/code&amp;gt; above, and change &amp;lt;i&amp;gt;integration-first-lattice&amp;lt;/i&amp;gt; to &amp;lt;i&amp;gt;integration-second-lattice&amp;lt;/i&amp;gt; in order not to overwrite the results of the previous analysis of the primary lattice.  Before reanalyzing the first batch, ensure that &amp;lt;code&amp;gt;xtal_target&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;thermolysin27&amp;lt;/code&amp;gt;.&lt;br /&gt;
 $ cxi.pyana -c &amp;lt;i&amp;gt;L498-indexigrate.cfg&amp;lt;/i&amp;gt; &amp;lt;b&amp;gt;&amp;lt;i&amp;gt;/path/to/xtc/files&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;/e157-r0016-*.xtc&lt;br /&gt;
 $ cxi.pyana -c &amp;lt;i&amp;gt;L498-indexigrate.cfg&amp;lt;/i&amp;gt; &amp;lt;b&amp;gt;&amp;lt;i&amp;gt;/path/to/xtc/files&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;/e157-r0017-*.xtc&lt;br /&gt;
 $ …&lt;br /&gt;
 $ cxi.pyana -c &amp;lt;i&amp;gt;L498-indexigrate.cfg&amp;lt;/i&amp;gt; &amp;lt;b&amp;gt;&amp;lt;i&amp;gt;/path/to/xtc/files&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;/e157-r0027-*.xtc&lt;br /&gt;
Then set &amp;lt;code&amp;gt;xtal_target&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;thermolysin73&amp;lt;/code&amp;gt; in the configuration file, and process the second batch.&lt;br /&gt;
 $ cxi.pyana -c &amp;lt;i&amp;gt;L498-indexigrate.cfg&amp;lt;/i&amp;gt; &amp;lt;b&amp;gt;&amp;lt;i&amp;gt;/path/to/xtc/files&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;/e157-r0071-*.xtc&lt;br /&gt;
 $ cxi.pyana -c &amp;lt;i&amp;gt;L498-indexigrate.cfg&amp;lt;/i&amp;gt; &amp;lt;b&amp;gt;&amp;lt;i&amp;gt;/path/to/xtc/files&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;/e157-r0072-*.xtc&lt;br /&gt;
 $ cxi.pyana -c &amp;lt;i&amp;gt;L498-indexigrate.cfg&amp;lt;/i&amp;gt; &amp;lt;b&amp;gt;&amp;lt;i&amp;gt;/path/to/xtc/files&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;/e157-r0073-*.xtc&lt;br /&gt;
The number of integrated secondary lattices should be close to 2,021, the number reported in the &#039;&#039;cctbx.xfel&#039;&#039; paper&amp;lt;ref name=&amp;quot;Hattne:2014&amp;quot;/&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Merging all integrated images ==&lt;br /&gt;
&lt;br /&gt;
The phil-file below defines values suitable for merging the primary and secondary lattices previously integrated.&lt;br /&gt;
 data                         = &amp;lt;i&amp;gt;integration-first-lattice&amp;lt;/i&amp;gt;&lt;br /&gt;
 data                         = &amp;lt;i&amp;gt;integration-second-lattice&amp;lt;/i&amp;gt;&lt;br /&gt;
 d_min                        = 2.10&lt;br /&gt;
 merge_anomalous              = True&lt;br /&gt;
 min_corr                     = -1&lt;br /&gt;
 model                        = &amp;lt;i&amp;gt;2tli.pdb&amp;lt;/i&amp;gt;&lt;br /&gt;
 nproc                        = &amp;lt;i&amp;gt;16&amp;lt;/i&amp;gt;&lt;br /&gt;
 plot_single_index_histograms = False&lt;br /&gt;
 raw_data.sdfac_auto          = True&lt;br /&gt;
 rescale_with_average_cell    = True&lt;br /&gt;
 significance_filter.apply    = True&lt;br /&gt;
 set_average_unit_cell        = True&lt;br /&gt;
 pixel_size                   = 0.11&lt;br /&gt;
 mysql {&lt;br /&gt;
     database = &amp;lt;i&amp;gt;db_name&amp;lt;/i&amp;gt;&lt;br /&gt;
     passwd   = &amp;lt;i&amp;gt;db_passwd&amp;lt;/i&amp;gt;&lt;br /&gt;
     runtag   = &amp;lt;i&amp;gt;L498_thermolysin&amp;lt;/i&amp;gt;&lt;br /&gt;
     user     = &amp;lt;i&amp;gt;db_user&amp;lt;/i&amp;gt;&lt;br /&gt;
 }&lt;br /&gt;
 output {&lt;br /&gt;
     n_bins = &amp;lt;i&amp;gt;10&amp;lt;/i&amp;gt;&lt;br /&gt;
     prefix = &amp;lt;i&amp;gt;L498_thermolysin&amp;lt;/i&amp;gt;&lt;br /&gt;
 }&lt;br /&gt;
 scaling {&lt;br /&gt;
     algorithm  = mark0&lt;br /&gt;
     mtz_file   = &amp;lt;i&amp;gt;2tli.mtz&amp;lt;/i&amp;gt;&lt;br /&gt;
     show_plots = False&lt;br /&gt;
     log_cutoff = 0.0&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;i&amp;gt;integration-first-lattice&amp;lt;/i&amp;gt;&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;&amp;lt;i&amp;gt;integration-second-lattice&amp;lt;/i&amp;gt;&amp;lt;/code&amp;gt; may need to be adjusted to point to the directories where the [[#Indexing and integration | indexing and integration step]] left its results.  &amp;lt;code&amp;gt;&amp;lt;i&amp;gt;db_name&amp;lt;/i&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;code&amp;gt;, &amp;lt;i&amp;gt;db_user&amp;lt;/i&amp;gt;&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;&amp;lt;i&amp;gt;db_passwd&amp;lt;/i&amp;gt;&amp;lt;/code&amp;gt; must be substituted with the database name and access credentials to a [http://www.mysql.com MySQL] database.  Databases on hosts other than the one used to merge the thermolysin data can be accessed by additionally specifying the &amp;lt;code&amp;gt;mysql.host&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;mysql.port&amp;lt;/code&amp;gt; options.  The model and structure factors for the scaling reference, &amp;lt;code&amp;gt;model&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;scaling.mtz_file&amp;lt;/code&amp;gt; above, are both available for download from the [http://www.rcsb.org RCSB Protein Data Bank] ([http://www.rcsb.org/pdb/explore/explore.do?structureId=2tli PDB ID 2tli]).  If the [http://www.phenix-online.org &#039;&#039;PHENIX&#039;&#039;] suite is installed, these are conveniently obtained at the command line using&lt;br /&gt;
 $ phenix.fetch_pdb --mtz 2tli&lt;br /&gt;
&lt;br /&gt;
To merge the thermolysin data, save the suitably modified configuration file to &amp;lt;i&amp;gt;e.g.&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;L498-merge.phil&amp;lt;/code&amp;gt;, and run&lt;br /&gt;
 $ cxi.merge L498-merge.phil&lt;br /&gt;
 $ cxi.xmerge L498-merge.phil&lt;br /&gt;
Merging statistics are printed on standard output.  The merged MTZ-file is written to a file whose name is determined by the value of &amp;lt;code&amp;gt;output.prefix&amp;lt;/code&amp;gt; in the configuration file (with the values shown above, the output file would be &amp;lt;code&amp;gt;L498_thermolysin.mtz&amp;lt;/code&amp;gt;).  Note that the version of merging programs from 28 March, 2013 do &amp;lt;em&amp;gt;not&amp;lt;/em&amp;gt; not report the &amp;lt;i&amp;gt;R&amp;lt;/i&amp;gt;&amp;lt;sub&amp;gt;split&amp;lt;/sub&amp;gt; statistic.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Aaron</name></author>
	</entry>
	<entry>
		<id>http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Processing_Blog&amp;diff=1751</id>
		<title>Processing Blog</title>
		<link rel="alternate" type="text/html" href="http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Processing_Blog&amp;diff=1751"/>
		<updated>2026-08-19T18:32:44Z</updated>

		<summary type="html">&lt;p&gt;Aaron: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Archived}}&lt;br /&gt;
&lt;br /&gt;
Data Processing Blog&lt;br /&gt;
&lt;br /&gt;
== Reindexing operator needed to identify C-axis in an orthorhombic setting (6 May 2014 NKS)==&lt;br /&gt;
The user brought us data from an orthorhombic space group.  The synchrotron structure had been solved and published with this unit cell:&lt;br /&gt;
&lt;br /&gt;
space group P 2&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt; 2&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt; 2&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;&lt;br /&gt;
unit cell 107.5 75.0 51.3 90 90 90&lt;br /&gt;
&lt;br /&gt;
However, the program &amp;lt;code&amp;gt;cxi.merge&amp;lt;/code&amp;gt; fails to merge any XFEL data when the synchrotron-solved PDB file is used as the &amp;quot;&amp;lt;code&amp;gt;model&amp;lt;/code&amp;gt;&amp;quot; for isomorphous scaling.  Knowing that the axes of an orthorhombic group can be permuted, we immediately suspected a mismatch between the XFEL unit cell and the PDB unit cell.  To inspect the XFEL integration results, we use the command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;cxi.print_pickle [integration_result_file.pickle]&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
All of the integration pickle files had this unit cell:&lt;br /&gt;
&lt;br /&gt;
Laue group P 2 2 2 unit cell 50.1 73.6 103.8 90 90 90&lt;br /&gt;
&lt;br /&gt;
Therefore we added the following item to the phil-parameters for &amp;lt;code&amp;gt;cxi.merge&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;data_reindex_op=l,k,h&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This reindexing had the desired effect of aligning the new data with the reference model.&lt;br /&gt;
&lt;br /&gt;
== A tricky case of merging resolution limits ==&lt;br /&gt;
Merging some data today where the default per-frame resolution filter settings were cutting things a little too harshly, and discarding a lot more data than expected (based on manual inspection of a maximum projection pattern). So, how to change this? CXTBX.XFEL performs a per-frame resolution test at two stages: during integration, and during merging. Here, we are going to discuss editing the during merging part of things. There are two phil parameters you can play with for this: significance_filter.sigma (default 0.5), and significance_filter.max_ct (default 50). The sigma option will remove resolution bins such that all accepted bins have Mean(I/sigma) &amp;gt;= sigma, and the max_ct option will set the bin sizes so that the number of bins is maximized, subject to mean bin population &amp;lt;= max_ct. &lt;br /&gt;
&lt;br /&gt;
A quick inspection of the terminal output from cxi.merge showed that in many cases, the Mean(I/sigma) was jumping up and down a lot, for example: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Step 4. Filter on global resolution and map to asu&lt;br /&gt;
&lt;br /&gt;
 Bin  Resolution Range  Compl.         &amp;lt;I&amp;gt;     &amp;lt;I/sig(I)&amp;gt;&lt;br /&gt;
   1 22.4216 -  8.1030 [127/5229]       646.3       3.8&lt;br /&gt;
   2  8.1030 -  6.4828 [ 45/5157]       428.9       1.7&lt;br /&gt;
   3  6.4828 -  5.6785 [103/5257]        89.3       0.7&lt;br /&gt;
   4  5.6785 -  5.1663 [107/5182]        62.2       0.4&lt;br /&gt;
   5  5.1663 -  4.7999 [101/5201]       121.2       0.5&lt;br /&gt;
   6  4.7999 -  4.5193 [ 78/5189]        93.9       0.3&lt;br /&gt;
   7  4.5193 -  4.2946 [ 83/5191]        36.2       0.2&lt;br /&gt;
   8  4.2946 -  4.1089 [ 71/5156]       197.4       0.7&lt;br /&gt;
   9  4.1089 -  3.9516 [ 67/5199]        43.5       0.3&lt;br /&gt;
  10  3.9516 -  3.8159 [ 74/5170]        83.3       0.4&lt;br /&gt;
  11  3.8159 -  3.6971 [110/5194]        12.7       0.2&lt;br /&gt;
  12  3.6971 -  3.5919 [ 76/5227]        16.9       0.2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Using the defaults, this file would cut off at 5.7 A, but I would like it to go to 4.8, since it looks like that is a legitimate 0.5 in the I/sigI column. Changing the bin size should average this out. I therefore re-ran the merging with the following in my phil file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
significance_filter{ &lt;br /&gt;
    sigma=0.5&lt;br /&gt;
    max_ct=100&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This helped a bit, and the per-image cuttoffs were looking more sensible. I then tweaked the sigma down to 0.4, since it decreased gradually to around this point before going mental, and got even better results. &lt;br /&gt;
&lt;br /&gt;
When doing this, how do you know when you are just adding junk to your file? If you observe lots of variation in your intensities per image per bin, then it&#039;s fairly safe to increase max_ct. This has the effect of smoothing things out, but may also underestimate your resolution if the bins become too large. Reducing sigma, on the other hand, can easily introduce junk data. The only real way to test for this is to see if your statistics from cxi.xmerge, in particular CC1/2, get better. &lt;br /&gt;
&lt;br /&gt;
--[[User:Zeldin|Zeldin]] ([[User talk:Zeldin|talk]]) 23:19, 17 April 2014 (UTC)&lt;br /&gt;
&lt;br /&gt;
== A Traceback error in April ==&lt;br /&gt;
&lt;br /&gt;
15 April 2014.  A user writes:&lt;br /&gt;
&lt;br /&gt;
I am seeing a Traceback error during integration with pyana:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/cctbx_project/myrelease/cxi_data/present_image_0000001&lt;br /&gt;
&lt;br /&gt;
Beam center is not immediately clear; rigorously retesting 9 solutions&lt;br /&gt;
Beam x 96.6 y 97.1, initial score 9; refined rmsd: None&lt;br /&gt;
Beam x 96.8 y 97.5, initial score 8; refined rmsd: None&lt;br /&gt;
Beam x 96.6 y 97.0, initial score 7; refined rmsd: None&lt;br /&gt;
Beam x 96.6 y 97.2, initial score 7; refined rmsd: None&lt;br /&gt;
Beam x 96.7 y 97.4, initial score 6; refined rmsd: None&lt;br /&gt;
Beam x 96.6 y 97.3, initial score 6; refined rmsd: None&lt;br /&gt;
Beam x 96.9 y 97.0, initial score 6; refined rmsd: None&lt;br /&gt;
Beam x 96.9 y 97.1, initial score 6; refined rmsd: None&lt;br /&gt;
Process Process-2:&lt;br /&gt;
&lt;br /&gt;
Traceback (most recent call last):&lt;br /&gt;
  File &amp;quot;/usr/local/crys_test/psdm/sw/external/python/2.7.2/x86_64-rhel6-gcc44-opt/lib/python2.7/multiprocessing/process.py&amp;quot;, line 258, in _bootstrap&lt;br /&gt;
    self.run()&lt;br /&gt;
  File &amp;quot;/usr/local/crys_test/psdm/sw/external/python/2.7.2/x86_64-rhel6-gcc44-opt/lib/python2.7/multiprocessing/process.py&amp;quot;, line 114, in run&lt;br /&gt;
    self._target(*self._args, **self._kwargs)&lt;br /&gt;
  File &amp;quot;/usr/local/crys/psdm/sw/releases/ana-current/arch/x86_64-rhel6-gcc44-opt/python/pyana/pyanamod.py&amp;quot;, line 126, in _proc&lt;br /&gt;
    for req in proto.getRequest():&lt;br /&gt;
  File &amp;quot;/usr/local/crys/psdm/sw/releases/ana-current/arch/x86_64-rhel6-gcc44-opt/python/pyana/mp_proto.py&amp;quot;, line 121, in getRequest&lt;br /&gt;
    opcode = self._conn.recv_bytes()&lt;br /&gt;
EOFError&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Reply:&lt;br /&gt;
&lt;br /&gt;
* It&#039;s not clear what&#039;s causing the EOFError.  However, we should at least check for memory leaks that would cause Pyana processing to draw to a standstill.  The diagnostic is to use the &amp;quot;top&amp;quot; command in the Unix shell.  Observe whether or not the subprocess memory use continually increases as more images are processed.  Correct behavior is for the memory use to reach a stationary plateau. We recently fixed a memory leak bug (March 2014), but it is worth checking this to make sure.&lt;br /&gt;
&lt;br /&gt;
* You should generally not get a &amp;quot;rigorously retesting 9 solutions&amp;quot; message for XFEL indexing.  Generally for XFELs we know the beam position accurately so there is no need to search for the direct beam. Your phil file should include beam_search_scope=0.5 to avoid a large search radius.  However, your log indicates a narrow search, likely indicating that spot finder sees numerous spots that are unphysically close.  Many things could be done to safeguard you from this:&lt;br /&gt;
** Careful use of detector masks, as described in [[Preparatory steps]] on the tutorial wiki .  This would avoid picking spots on compromised areas of the detector. Aaron is this correct?&lt;br /&gt;
** Use distl.minimum_spot_area=1 instead of =0.  This would avoid picking random local-maxima pixels as spots, but there is a tradeoff.&lt;br /&gt;
** Set the phil file resolution cutoff (3 different places) to a value close to where you actually intend to cut off the merging.  This avoids picking spots for indexing that aren&#039;t real spots.&lt;br /&gt;
&lt;br /&gt;
* I notice you are using integration.detector_gain=7.5.  However, we&#039;ve been having a lot of trouble with setting this to anything else but 1.0.  Until we can sort out the code, I recommend using gain=1.0 during processing, and then in the cxi.merge phil use significance_filter.sigma=0.5.  This combination should help retain as many reflections as possible.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Low resolution reflections missing ==&lt;br /&gt;
&lt;br /&gt;
A user was indexing using cxi.index and finding many low resolution spots not being predicted.  Here, cxi.index refuses to predict spots that are overlapped.  Setting integration.background_factor=1 and integration.guard_width_sq=3 can force a better outcome.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Indexing images with fewer spots ==&lt;br /&gt;
&lt;br /&gt;
A user was having a hard time with images that had clear diffraction patterns with between 20 to 40 spots but that didn&#039;t index with cxi.index.  Here&#039;s how we resolved the problem.&lt;br /&gt;
&lt;br /&gt;
Add the following to the indexing phil file:&lt;br /&gt;
&lt;br /&gt;
1) target cell and known setting.  These parameters provide constraints on the still-image indexing procedure algorithm that finds basis vectors without the benefit of additional images with rotational data.  See the [[phil]] section.  Example for lysozyme:&lt;br /&gt;
 target_cell = 38 74 74 90 90 90&lt;br /&gt;
 known_setting = 9&lt;br /&gt;
&lt;br /&gt;
2) Add distl_minimum_number_spots_for_indexing=20 and model_refinement_minimum_N=10 to the phil file.  These parameters set lower limits on the number of spots needed for indexing and crystal model refinement. For patterns with fewer spots, it disables two checks for enough spots to proceed.&lt;br /&gt;
&lt;br /&gt;
== Wrong Bravais lattice chosen during indexing ==&lt;br /&gt;
  &lt;br /&gt;
Some of the user&#039;s images produced integration results in the triclinic setting, but they had included a target cell in the hexagonal setting.  Here are the lines at the end of the log file that show the symptom:&lt;br /&gt;
&lt;br /&gt;
  $ cxi.index -d -n 16 target=&amp;lt;parameters.phil&amp;gt; &amp;lt;image.pickle&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  New Horizons Integration results:&lt;br /&gt;
  Solution  SpaceGroup Beam x   y  distance  Resolution Mosaicity RMS&lt;br /&gt;
      12           P3 156.63 156.52  374.79       4.00    0.5    0.246&lt;br /&gt;
  :)   1           P1 156.63 156.52  374.79      11.63    0.5    0.041&lt;br /&gt;
&lt;br /&gt;
The :) shows that the software chose the triclinic setting for its final solution.  The explanation is that LABELIT compares the ratio of RMS values from the highest to the lowest symmetry settings (RMS is the root mean squared difference between observed and predicted spot positions, in mm).  The default is to allow a factor 3.5 ratio, no more.  This parameter can be altered in the *.phil file or on the command line:&lt;br /&gt;
&lt;br /&gt;
 $ cxi.index -d -n 16 target=&amp;lt;parameters.phil&amp;gt; &amp;lt;image.pickle&amp;gt; mosflm_rmsd_tolerance=10&lt;br /&gt;
&lt;br /&gt;
The parameter is called &amp;quot;mosflm&amp;quot; rmsd tolerance for legacy reasons:  LABELIT uses MOSFLM as the integration engine; however cctbx.xfel has its own integration engine.&lt;br /&gt;
Result:&lt;br /&gt;
&lt;br /&gt;
  New Horizons Integration results:&lt;br /&gt;
  Solution  SpaceGroup Beam x   y  distance  Resolution Mosaicity RMS&lt;br /&gt;
  :)  12           P3 156.63 156.52  374.79       4.00    0.5    0.246&lt;br /&gt;
       1           P1 156.63 156.52  374.79      11.63    0.5    0.041&lt;br /&gt;
&lt;br /&gt;
Now the higher symmetry setting is chosen as the final solution.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Processing stills ==&lt;br /&gt;
&lt;br /&gt;
Here&#039;s a recent example of processing still from the MAR detector at XPP&lt;br /&gt;
&lt;br /&gt;
General reference:&lt;br /&gt;
[[Indexing individual stills]]&lt;br /&gt;
&lt;br /&gt;
All the commands listed here have some help with the --help option.&lt;br /&gt;
&lt;br /&gt;
 cd &amp;lt;path to directory with .mccd files from xpp&amp;gt;&lt;br /&gt;
 cxi.image2pickle -v -c *.mccd&lt;br /&gt;
 mkdir pickles&lt;br /&gt;
 mv -v *.pickle pickles&lt;br /&gt;
&lt;br /&gt;
Converting the images to pickle format, using the -c (crop) option, sets them up a bit nicer for the indexer  Next, I picked one of the high res images and looked at the spotfinding parameters for the program:&lt;br /&gt;
&lt;br /&gt;
 distl.image_viewer distl.minimum_signal_height=5 distl.minimum_spot_area=2 distl.minimum_spot_height=5 pickles/&amp;lt;one of the image files&amp;gt;.pickle&lt;br /&gt;
&lt;br /&gt;
My initial guess (based on my experience with the MAR detector) showed a reasonable diffraction pattern picked out in red by the spotfinder.&lt;br /&gt;
&lt;br /&gt;
I then took a phil file that had been working well for us from another experiment, and edited it using these spotfinding parameters.  Seeing as I didn&#039;t know the unit cell, I removed the target cell.  I created a results directory and called this first test trial 000, and indexed all the images.&lt;br /&gt;
&lt;br /&gt;
 mkdir -p results/000&lt;br /&gt;
 cxi.index -d -s -n 12 -o results/000 target=[[stills_target.phil]] pickles | tee results/trial_000.out&lt;br /&gt;
&lt;br /&gt;
This indexed around 202 images.  To get an idea of the unit cell, I entered the trial 000 directory and ran&lt;br /&gt;
cluster.unit_cell --log .  Most of the images were in the following cluster:&lt;br /&gt;
&lt;br /&gt;
 cluster_26      166       192.5(1.3 ) 192.5(1.5 ) 291.1(2.9 ) 90.00 (0.00) 90.00 (0.00) 90.00 (0.00)&lt;br /&gt;
 163 in P4, 3 in P222.&lt;br /&gt;
&lt;br /&gt;
The numbers in parentheses are standard deviations for those cell dimensions.  Now, indexing stills is greatly helped when the symmetry is known upfront, so I added a target_cell to the phil file, like so:&lt;br /&gt;
&lt;br /&gt;
 # Derived from average cell after scaling and merging.&lt;br /&gt;
 target_cell = 192.5 192.5 291.1 90.00 90.00 90.00&lt;br /&gt;
 known_setting = 9&lt;br /&gt;
&lt;br /&gt;
For the space group, cxi.index uses a known_setting parameter.  P4 is in the tetragonal setting.  From this webpage:&lt;br /&gt;
&lt;br /&gt;
[[Phil]]&lt;br /&gt;
&lt;br /&gt;
that means I need to use a known setting value of 9.&lt;br /&gt;
&lt;br /&gt;
I decided to use the LCLS computing cluster for the next indexing trial.  I was logged into psana on an interactive node provided to me by the cluster, and others were logged in to the same node concurrently.  The queuing system would ensure I got my own node for the job:&lt;br /&gt;
&lt;br /&gt;
 mkdir results/001&lt;br /&gt;
 bsub -n 12 -q psanaq -o results/trial_001.out cxi.index -s -n 12 -d -o results/001 target=[[stills_target.phil]] pickles&lt;br /&gt;
&lt;br /&gt;
This yielded 218 indexed images.&lt;br /&gt;
&lt;br /&gt;
I did two rounds of merging/postrefinement with prime.postrefine.  Post refinement trial 000, using indexing trial 001, in directory 001_000, I used the wrong number of amino acids per asymmetric unit, but it got me a sense of the completeness limits.  Using that I remerged to an ambitious 3.3 angstroms, in directory 001_001.  The files of interest are:&lt;br /&gt;
&lt;br /&gt;
prime/001_001/log.txt&lt;br /&gt;
prime/001_001/postref_cycle_2_merge.mtz&lt;br /&gt;
&lt;br /&gt;
Command for merging:&lt;br /&gt;
 bsub -n 12 -q psanaq -o results/trial_001.out cxi.index -s -n 12 -d -o results/001 target=[[prime.phil]] pickles&lt;br /&gt;
&lt;br /&gt;
Documentation for prime is on the wiki.&lt;br /&gt;
&lt;br /&gt;
Where to go from here?  I would look at which files indexed and which didn’t.  See if there are some that didn’t index that should have.  Maybe that could improve the completeness.  One could look into prime.iota, which does a grid search for spotfinder parameters.  Also, cxi.index, if you don’t supply the -d flag, will pop up a few images showing the indexing results overlaid on the image (first in the triclinic setting and then in the best symmetry setting).  Red pixels are spotfinder spots, blue are integrated and yellow are background.   One could run cxi.index with a single file to see how it&#039;s doing (don’t forget to supply a target, like the command above).&lt;/div&gt;</summary>
		<author><name>Aaron</name></author>
	</entry>
	<entry>
		<id>http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Preparatory_steps_pyana_version&amp;diff=1750</id>
		<title>Preparatory steps pyana version</title>
		<link rel="alternate" type="text/html" href="http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Preparatory_steps_pyana_version&amp;diff=1750"/>
		<updated>2026-08-19T18:32:29Z</updated>

		<summary type="html">&lt;p&gt;Aaron: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Archived}}&lt;br /&gt;
&lt;br /&gt;
This tutorial covers averaging dark and light runs, and creating mask images.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Setup your scratch area ==&lt;br /&gt;
&lt;br /&gt;
Create a scratch folder and populate it with some directories that will be used during this tutorial, changing &amp;lt;code&amp;gt;&amp;lt;b&amp;gt;&amp;lt;i&amp;gt;&amp;lt;username&amp;gt;&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;&amp;lt;/code&amp;gt; to your SLAC account name:&lt;br /&gt;
&lt;br /&gt;
 $ cd /reg/g/cctbx/tutorials/scratch/&lt;br /&gt;
 $ mkdir &amp;lt;b&amp;gt;&amp;lt;i&amp;gt;&amp;lt;username&amp;gt;&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;&lt;br /&gt;
 $ cd &amp;lt;b&amp;gt;&amp;lt;i&amp;gt;&amp;lt;username&amp;gt;&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;&lt;br /&gt;
 $ mkdir darks&lt;br /&gt;
 $ mkdir averages&lt;br /&gt;
 $ mkdir results&lt;br /&gt;
&lt;br /&gt;
Or you may use a directory in your home folder.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Create a dark average ==&lt;br /&gt;
&lt;br /&gt;
The CSPAD detector at LCLS is sensitive to temperature distortions and, unlike images collected at a synchrotron source, its output is not automatically dark-subtracted.  Because of this it is necessary to periodically record a dark run with the shutters closed during an LCLS experiment.  The dark run should contain on the order of at least 1000 images.  Before an experimental run can be processed, this dark run must be averaged so that subsequent experimental data can have the dark subtracted from each image.  Furthermore, events during collection can necessitate a new dark, such as ice in the beam over-saturating creating dead pixels or a change in temperature.&lt;br /&gt;
&lt;br /&gt;
To create the average, start by copying the &amp;lt;code&amp;gt;dark.cfg&amp;lt;/code&amp;gt; file to your pyana directory:&lt;br /&gt;
 $ cd ~/myrelease&lt;br /&gt;
 $ sit_setup&lt;br /&gt;
 $ cp /reg/g/cctbx/tutorials/preprocessing/dark.cfg .&lt;br /&gt;
&lt;br /&gt;
Open &amp;lt;code&amp;gt;dark.cfg&amp;lt;/code&amp;gt;.  It will look something like this:&lt;br /&gt;
 [pyana]&lt;br /&gt;
 modules = my_ana_pkg.mod_average&lt;br /&gt;
 num-cpu = 8&lt;br /&gt;
 &lt;br /&gt;
 [my_ana_pkg.mod_average]&lt;br /&gt;
 calib_dir       = /reg/g/cctbx/sources/cctbx_project/xfel/metrology/CSPad/run4/CxiDs1.0_Cspad.0&lt;br /&gt;
 avg_dirname     = /reg/g/cctbx/tutorials/scratch/&amp;lt;b&amp;gt;&amp;lt;i&amp;gt;&amp;lt;username&amp;gt;&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;/darks&lt;br /&gt;
 stddev_dirname  = /reg/g/cctbx/tutorials/scratch/&amp;lt;b&amp;gt;&amp;lt;i&amp;gt;&amp;lt;username&amp;gt;&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;/darks&lt;br /&gt;
 max_dirname     = /reg/g/cctbx/tutorials/scratch/&amp;lt;b&amp;gt;&amp;lt;i&amp;gt;&amp;lt;username&amp;gt;&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;/darks&lt;br /&gt;
 detz_offset     = 581&lt;br /&gt;
 address         = CxiDs1-0|Cspad-0&lt;br /&gt;
 avg_basename    = Ds1-r0002-avg&lt;br /&gt;
 stddev_basename = Ds1-r0002-stddev&lt;br /&gt;
 max_basename    = Ds1-r0002-max&lt;br /&gt;
&lt;br /&gt;
The configuration file is broken into two sections, the [[#&#039;&#039;pyana&#039;&#039; section | &#039;&#039;pyana&#039;&#039; section]] and the [[#Modules section | modules section]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;pyana&#039;&#039; section ===&lt;br /&gt;
The &#039;&#039;pyana&#039;&#039; section specifies which modules to run.  In this case we are running &#039;&#039;cctbx.xfel&#039;&#039;&#039;s &amp;lt;code&amp;gt;mod_average&amp;lt;/code&amp;gt; module.  If we were running multiple modules, we could chain them together here, and each module would be executed in sequence using the parameters specified in the corresponding module section.  We also request a number of processes to parallelize the job with.  Even though averaging must be done on a single host, on that host the processing can be split up among multiple cores.  Note, other aspects of &#039;&#039;cctbx.xfel&#039;&#039;, such as indexing and integration, do not have this restriction.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Module section ===&lt;br /&gt;
The module section specifies parameters specific to averaging:&lt;br /&gt;
;calib_dir&lt;br /&gt;
: this directory is provided by LCLS and includes the layout information of the 64 tiles of the CSPAD detector&lt;br /&gt;
;avg_dirname&lt;br /&gt;
: directory to place the average image&lt;br /&gt;
;stddev_dirname&lt;br /&gt;
: directory to place the standard deviation image&lt;br /&gt;
;max_dirname&lt;br /&gt;
: directory to place the maximum projection image&lt;br /&gt;
;detz_offset&lt;br /&gt;
: experiment-specific number used to calculate the detector distance.  This is the distance in millimeters between the sample interaction region and the far end of the detector stage.  The XTC stream contains the distance from the detector stage to the detector.  These two numbers are subtracted to calculate the distance between sample interaction region and the detector.  We determine this number experimentally using a grid search, testing a range of potential detz_offsets and choosing the one that shows the greatest success at indexing images&lt;br /&gt;
;address&lt;br /&gt;
: the name of the detector in the XTC stream&lt;br /&gt;
;avg_basename&lt;br /&gt;
: this name is prepended to a date stamp to name the average image&lt;br /&gt;
;stddev_basename&lt;br /&gt;
: this name is prepended to a date stamp to name the standard deviation image&lt;br /&gt;
;max_basename&lt;br /&gt;
: this name is prepended to a date stamp to name the maximum projection image image&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Running and testing the command ===&lt;br /&gt;
&lt;br /&gt;
Before starting the averaging job the command, replace &amp;lt;code&amp;gt;&amp;lt;b&amp;gt;&amp;lt;i&amp;gt;&amp;lt;username&amp;gt;&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;&amp;lt;/code&amp;gt; in the configuration file with your user name.  To average run 2 using the modified configuration file, execute&lt;br /&gt;
 $ cxi.lsf -c ~/myrelease/dark.cfg -i /reg/d/ana11/cxi/data/Mar2013calib/xtc \&lt;br /&gt;
     -o /reg/g/cctbx/tutorials/scratch/&amp;lt;b&amp;gt;&amp;lt;i&amp;gt;&amp;lt;username&amp;gt;&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt; -p 6 -q psanaq -r 2 -s&lt;br /&gt;
This will request 6 processors, overriding the &amp;lt;code&amp;gt;num-cpu&amp;lt;/code&amp;gt; parameter set in the configuration file.  The directory specified in the &amp;lt;code&amp;gt;-i&amp;lt;/code&amp;gt; option will be searched for XTC streams, and output will be arranged in the directory defined by the value of the &amp;lt;code&amp;gt;-o&amp;lt;/code&amp;gt; option.  The &amp;lt;code&amp;gt;-s&amp;lt;/code&amp;gt; option tells &#039;&#039;cxi.lsf&#039;&#039; to process all the streams on the same host—this is a requirement for averaging.  The job will be scheduled in the queue called &amp;lt;code&amp;gt;psanaq&amp;lt;/code&amp;gt;, which is one of several available queues.  Note that the job must be submitted from the &amp;lt;code&amp;gt;~/myrelease&amp;lt;/code&amp;gt; directory.&lt;br /&gt;
&lt;br /&gt;
Type &amp;lt;code&amp;gt;bjobs&amp;lt;/code&amp;gt; to see if the job is running.  When it is, follow the output thusly:&lt;br /&gt;
 $ tail -f /reg/g/cctbx/tutorials/scratch/&amp;lt;b&amp;gt;&amp;lt;i&amp;gt;&amp;lt;username&amp;gt;&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;/r0002/000/stdout/sNN.out&lt;br /&gt;
Note the presence of the &amp;lt;code&amp;gt;000&amp;lt;/code&amp;gt; directory.  &#039;&#039;cxi.lsf&#039;&#039; places the output of each job in a separate &amp;lt;i&amp;gt;trial&amp;lt;/i&amp;gt; directory, and prints this directory just before exiting.  By default, trial numbers start at zero and increase by one with each subsequent analysis of the same run.  To use any other, previously unused, trial number,  use &#039;&#039;cxi.lsf&#039;&#039;&#039;s &amp;lt;code&amp;gt;-t&amp;lt;/code&amp;gt; option.&lt;br /&gt;
&lt;br /&gt;
When the average has been completed, the output can be inspected using the &#039;&#039;cctbx&#039;&#039; image viewer:&lt;br /&gt;
 $ cctbx.image_viewer /reg/g/cctbx/tutorials/scratch/&amp;lt;b&amp;gt;&amp;lt;i&amp;gt;&amp;lt;username&amp;gt;&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;/r0002/000/out/Ds1-r0002-*.pickle&lt;br /&gt;
&lt;br /&gt;
== Averaging an experimental light run ==&lt;br /&gt;
&lt;br /&gt;
Once the dark average is completed, experimental, lighted, runs can be averaged to see the extent of diffraction and potential pathologies in the run.  Copy the &amp;lt;code&amp;gt;average.cfg&amp;lt;/code&amp;gt; file from the tutorials directory to your pyana directory:&lt;br /&gt;
 $ cd ~/myrelease&lt;br /&gt;
 $ cp /reg/g/cctbx/tutorials/preprocessing/average.cfg .&lt;br /&gt;
&lt;br /&gt;
The configuration file will look like this:&lt;br /&gt;
 [pyana]&lt;br /&gt;
 modules = my_ana_pkg.mod_average&lt;br /&gt;
 num-cpu = 8&lt;br /&gt;
 &lt;br /&gt;
 [my_ana_pkg.mod_average]&lt;br /&gt;
 calib_dir      = /reg/g/cctbx/sources/cctbx_project/xfel/metrology/CSPad/run4/CxiDs1.0_Cspad.0&lt;br /&gt;
 dark_path      = /reg/g/cctbx/tutorials/scratch/&amp;lt;b&amp;gt;&amp;lt;i&amp;gt;&amp;lt;username&amp;gt;&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;/r0002/000/out/&amp;lt;b&amp;gt;&amp;lt;i&amp;gt;&amp;lt;name of dark average&amp;gt;&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;.pickle&lt;br /&gt;
 dark_stddev    = /reg/g/cctbx/tutorials/scratch/&amp;lt;b&amp;gt;&amp;lt;i&amp;gt;&amp;lt;username&amp;gt;&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;/r0002/000/out/&amp;lt;b&amp;gt;&amp;lt;i&amp;gt;&amp;lt;name of dark stddev&amp;gt;&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;.pickle&lt;br /&gt;
 avg_dirname    = /reg/g/cctbx/tutorials/scratch/&amp;lt;b&amp;gt;&amp;lt;i&amp;gt;&amp;lt;username&amp;gt;&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;/averages&lt;br /&gt;
 stddev_dirname = /reg/g/cctbx/tutorials/scratch/&amp;lt;b&amp;gt;&amp;lt;i&amp;gt;&amp;lt;username&amp;gt;&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;/averages&lt;br /&gt;
 max_dirname    = /reg/g/cctbx/tutorials/scratch/&amp;lt;b&amp;gt;&amp;lt;i&amp;gt;&amp;lt;username&amp;gt;&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;/averages&lt;br /&gt;
 detz_offset    = 581&lt;br /&gt;
 address         = CxiDs1-0|Cspad-0&lt;br /&gt;
 avg_basename    = Ds1-r0003-avg&lt;br /&gt;
 stddev_basename = Ds1-r0003-stddev&lt;br /&gt;
 max_basename    = Ds1-r0003-max&lt;br /&gt;
The only difference is the addition of two parameters:&lt;br /&gt;
;dark_path&lt;br /&gt;
: path to the average dark image created before&lt;br /&gt;
;dark_stddev&lt;br /&gt;
: path to the standard deviation dark image created before&lt;br /&gt;
&lt;br /&gt;
The job is ran as before using &#039;&#039;cxi.lsf&#039;&#039;, again remembering to change all instances of &amp;lt;code&amp;gt;&amp;lt;b&amp;gt;&amp;lt;i&amp;gt;&amp;lt;username&amp;gt;&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;&amp;lt;/code&amp;gt; to your own SLAC user name.  Here you must also change &amp;lt;code&amp;gt;&amp;lt;b&amp;gt;&amp;lt;i&amp;gt;&amp;lt;name of dark average&amp;gt;&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;&amp;lt;b&amp;gt;&amp;lt;i&amp;gt;&amp;lt;name of dark stddev&amp;gt;&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;&amp;lt;/code&amp;gt; to the names of the average and standard deviation images created in the previous step.  The result of the run will be three new images that can be viewed with &#039;&#039;cctbx.image_viewer&#039;&#039; in the same manner as the darks were.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Information contained in the light average ==&lt;br /&gt;
&lt;br /&gt;
Firstly, the light and dark images can be used to mask of any bad pixels.  Inactive and non-bonded pixels, as well as hypersensitive pixels and any beam stop (if used) should be masked out.  The light images (maximum in particular) also serve as a virtual, dark-subtracted, powder pattern that can used to inspect the data for diffraction.  The light maximum should also flag up obvious errors in metrology, because rings will be non-continuous if the quadrants are misaligned. Intensity values from the corners of the light average or maximum are also useful to estimate background when taking first guesses at thresholds for hit-finding and integration.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Creating a mask image ==&lt;br /&gt;
&#039;&#039;cctbx.xfel&#039;&#039; uses three images to create a mask.  Those images, and the purposes of them are listed below:&lt;br /&gt;
* Average image from a dark run: pixels ≤ 0 are considered dead, pixels &amp;gt; 2000 are too sensitive&lt;br /&gt;
* Standard deviation from a dark run: pixels ≤ 0 are considered dead, pixels ≥ 10 are too uncertain&lt;br /&gt;
* Maximum projection from a lighted run (&#039;&#039;i.e.&#039;&#039; an experimental run): pixels &amp;lt; 300 are considered non-bonded or in a shadow.  [N.B.–this assumes a lot–300 may be appropriate for XPP data collected at atmosphere; not CXI data &amp;lt;i&amp;gt;in vacuo&amp;lt;/i&amp;gt;–NKS.] The presence of diffracting data is not needed, but also will not interfere.&lt;br /&gt;
&lt;br /&gt;
To create the mask, execute these commands:&lt;br /&gt;
 $ cd /reg/g/cctbx/tutorials/scratch/&amp;lt;b&amp;gt;&amp;lt;i&amp;gt;&amp;lt;username&amp;gt;&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;/&lt;br /&gt;
 $ mkdir masks&lt;br /&gt;
 $ cd masks&lt;br /&gt;
 $ cxi.make_mask -m 10 &amp;lt;b&amp;gt;&amp;lt;i&amp;gt;&amp;lt;name of dark average&amp;gt;&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;.pickle &amp;lt;b&amp;gt;&amp;lt;i&amp;gt;&amp;lt;name of dark standard deviation&amp;gt;&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;.pickle \&lt;br /&gt;
     &amp;lt;b&amp;gt;&amp;lt;i&amp;gt;&amp;lt;name of light maximum projection&amp;gt;&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;.pickle&lt;br /&gt;
&lt;br /&gt;
A new image is created where each pixel has one of two values: -2 (masked out pixels), and 0 (good pixels).  Note, the maximum projection minimum pixel value is overridden here to a value that is more sensible for the tutorial&#039;s lysozyme data.  You will likely need to adjust this parameter based on your data (see below for details and for further overrides).  &lt;br /&gt;
&lt;br /&gt;
Use the resultant mask image during processing with &#039;&#039;cctbx.xfel&#039;&#039; by adding this flag to your pyana config file:&lt;br /&gt;
 mask_path = &amp;lt;b&amp;gt;&amp;lt;i&amp;gt;&amp;lt;path to mask file&amp;gt;&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;&lt;br /&gt;
In addition, a polygon and a circle can be specified using the &amp;lt;code&amp;gt;--poly_mask&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;--circle_mask&amp;lt;/code&amp;gt; parameters:&lt;br /&gt;
 $ cxi.make_mask --poly_mask=17,854,76,967,760,982,762,879 --circle_mask=855,939,103 Cspad-avg.pickle Cspad-stddev.pickle Cspad-max.pickle&lt;br /&gt;
This example creates a mask image with a polygon [with vertices (17,854), (76,967), (760,982), and (762,879)] masked out, and a circle with center (855,939) and radius 103 masked out. Only one polygon and circle can be specified at the moment.&lt;br /&gt;
&lt;br /&gt;
The mask can be examined with &#039;&#039;cctbx.image_viewer&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
==== Applying the mask ====&lt;br /&gt;
&lt;br /&gt;
Once the mask is created, it needs to be referenced by your configuration file:&lt;br /&gt;
&lt;br /&gt;
 mask_path = &amp;lt;absolute path to mask file&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Further, the indexing software needs to know what value to use as the masked-out value.  Add the following to your phil files for indexing:&lt;br /&gt;
&lt;br /&gt;
 integration.mask_pixel_value=-2&lt;br /&gt;
&lt;br /&gt;
Where -2 is the default mask value, but it can be whatever you specify using the -x option cxi.make_mask (see below).&lt;br /&gt;
&lt;br /&gt;
=== Options ===&lt;br /&gt;
&lt;br /&gt;
Some additional options are available for specifying the details of the masking operation:&lt;br /&gt;
;-a,  --avg_max (default 2000)&lt;br /&gt;
: specifies the maximum value in ADU a pixel in the average image can have before it&#039;s masked out.  The minimum is always zero.&lt;br /&gt;
;-s, --stddev_max (default 10)&lt;br /&gt;
: specifies the maximum value in ADU a pixel in the standard deviation image can have before it&#039;s masked out.  The minimum is always zero.&lt;br /&gt;
;-m, --maxproj_min (default 300)&lt;br /&gt;
: specifies the minimum value in ADU a pixel in the maximum projection image can have before it&#039;s masked out.  Of the three parameters for controlling cutoffs in &#039;&#039;cxi.make_mask&#039;&#039;, the -m option is unique from the -a and -s options in that it will likely vary the according to your sample&#039;s background.  Carefully examine the corners of your lighted maximum projection and choose a value lower than the ADU values displayed.  Also note that there is no cutoff on the high end of the maximum projection image specified in the mask, as that is defined as the saturation value for the detector.&lt;br /&gt;
;-x, --mask_pix_val (default -2)&lt;br /&gt;
: specifies the value to use when masking out a pixel. In other words, bad pixels in images in the XTC stream will be replaced with this value.&lt;br /&gt;
;-o, --output (default mask_.pickle)&lt;br /&gt;
: specifies the output file path, should be *.pickle, can include directory.&lt;/div&gt;</summary>
		<author><name>Aaron</name></author>
	</entry>
	<entry>
		<id>http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Preparatory_steps&amp;diff=1749</id>
		<title>Preparatory steps</title>
		<link rel="alternate" type="text/html" href="http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Preparatory_steps&amp;diff=1749"/>
		<updated>2026-08-19T18:32:08Z</updated>

		<summary type="html">&lt;p&gt;Aaron: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Archived}}&lt;br /&gt;
&lt;br /&gt;
This tutorial covers averaging dark and light runs, and creating mask images.&lt;br /&gt;
&lt;br /&gt;
== Setup your scratch area ==&lt;br /&gt;
&lt;br /&gt;
Create a scratch folder and populate it with some directories that will be used during this tutorial.  Usually you will work within the ftc directory of your experiment, for example:&lt;br /&gt;
&lt;br /&gt;
/reg/d/psdm/cxi/cxi49812/ftc&lt;br /&gt;
&lt;br /&gt;
In that directory, add a directory for your username, changing &amp;lt;code&amp;gt;&amp;lt;b&amp;gt;&amp;lt;I&amp;gt;expname&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;&amp;lt;/code&amp;gt; to your experiment name and &amp;lt;code&amp;gt;&amp;lt;b&amp;gt;&amp;lt;i&amp;gt;&amp;lt;username&amp;gt;&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;&amp;lt;/code&amp;gt; to your SLAC account name:&lt;br /&gt;
&lt;br /&gt;
 $ cd /reg/d/psdm/cxi/&amp;lt;b&amp;gt;&amp;lt;i&amp;gt;&amp;lt;expname&amp;gt;&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;/ftc&lt;br /&gt;
 $ mkdir &amp;lt;b&amp;gt;&amp;lt;i&amp;gt;&amp;lt;username&amp;gt;&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;&lt;br /&gt;
 $ cd &amp;lt;b&amp;gt;&amp;lt;i&amp;gt;&amp;lt;username&amp;gt;&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;&lt;br /&gt;
 $ mkdir darks&lt;br /&gt;
 $ mkdir averages&lt;br /&gt;
 $ mkdir results&lt;br /&gt;
&lt;br /&gt;
You may use a directory in your home folder for saving results but this is not advised as it will fill quickly.&lt;br /&gt;
&lt;br /&gt;
Finally, create a directory in your myrelease folder to hold config files and phil files needed during processing:&lt;br /&gt;
 $ cd ~/myrelease&lt;br /&gt;
 $ mkdir &amp;lt;b&amp;gt;&amp;lt;i&amp;gt;&amp;lt;expname&amp;gt;&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Create a dark average ==&lt;br /&gt;
&lt;br /&gt;
The CSPAD detector at LCLS is sensitive to temperature distortions and, unlike images collected at a synchrotron source, its output is not automatically dark-subtracted.  Because of this it is necessary to periodically record a dark run with the shutters closed during an LCLS experiment.  The dark run should contain on the order of at least 1000 images.  Before an experimental run can be processed, this dark run must be averaged so that subsequent experimental data can have the dark subtracted from each image.  Furthermore, events during collection can necessitate a new dark, such as ice in the beam over-saturating creating dead pixels or a change in temperature.&lt;br /&gt;
&lt;br /&gt;
To create the average, you will need this config file: [[dark.cfg]].  Save it to your myrelease/&amp;lt;b&amp;gt;&amp;lt;i&amp;gt;&amp;lt;expname&amp;gt;&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt; folder.&lt;br /&gt;
&lt;br /&gt;
The configuration file is broken into two sections, the [[#psana section | &#039;&#039;psana&#039;&#039; section]] and the [[#Modules section | modules section]].&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;psana&#039;&#039; section ===&lt;br /&gt;
The &#039;&#039;psana&#039;&#039; section specifies which modules to run.  In this case we are running the built in module &amp;lt;code&amp;gt;CSPadPixCoords.CSPadNDArrProducer&amp;lt;/code&amp;gt;.  This module is fully documented in [https://confluence.slac.stanford.edu/display/PSDM/psana+-+Module+Catalog#psana-ModuleCatalog-ModuleCSPadPixCoords::CSPadNDArrProducer SLAC&#039;s module catalog].  If we were running multiple modules, we could chain them together here, and each module would be executed in sequence using the parameters specified in the corresponding module section.   &lt;br /&gt;
&lt;br /&gt;
=== Module section ===&lt;br /&gt;
The module section specifies parameters specific to the CSPadPixCoords.CSPadNDArrProducer.  The user should only ever need to change the source, which dictates which detector is going to be averaged.  This string can be obtained from the beamline operator.&lt;br /&gt;
&lt;br /&gt;
=== Running and testing the command ===&lt;br /&gt;
&lt;br /&gt;
To average a dark run, the user can use cxi.mpi_average.  Run it with no parameters to get a full help listing with examples.  To test it on 10 events before using the queuing system, run it as follows:&lt;br /&gt;
&lt;br /&gt;
 $ cxi.mpi_average -c &#039;&#039;&#039;&#039;&#039;expname&#039;&#039;&#039;&#039;&#039;/dark.cfg -x &#039;&#039;&#039;&#039;&#039;expname&#039;&#039;&#039;&#039;&#039; -r &#039;&#039;&#039;&#039;&#039;runnumber&#039;&#039;&#039;&#039;&#039; -a &#039;&#039;&#039;&#039;&#039;address&#039;&#039;&#039;&#039;&#039; -d &#039;&#039;&#039;&#039;&#039;detzoffset&#039;&#039;&#039;&#039;&#039; -n 10 -p&lt;br /&gt;
&lt;br /&gt;
The options are described as follows:&lt;br /&gt;
&lt;br /&gt;
* -c: path to the dark config file&lt;br /&gt;
* -x: your experiment name&lt;br /&gt;
* -r: the dark run number&lt;br /&gt;
* -a: the address string for the detector. Will be something like CxiDs1.0:Cspad.0&lt;br /&gt;
* -d: The detz offset.  This is the offset (in mm) from the sample interaction region to the back the CSPAD detector rail at CXI.  Typically it&#039;s on the order of between 560 and 580 mm.  The beamline operator will provide you with a value.  At XPP you must specify the detector distance directly as their CSPAD is on a robot arm.&lt;br /&gt;
* -p: write the output as image pickle files.  Currently the standard file format for &#039;&#039;cctbx.xfel&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
When complete, three new .pickle files will be present in your directory.  The dark average will be named &#039;&#039;&#039;&#039;&#039;expname&#039;&#039;&#039;&#039;&#039;_avg-r&#039;&#039;&#039;&#039;&#039;runnum&#039;&#039;&#039;&#039;&#039;.pickle.  A similar stddev and max file will be found as well.  Use the -o option to put these averages somewhere else, such as a location available for all users to access for your experiment, e.g. /reg/d/psdm/&#039;&#039;&#039;&#039;&#039;instrumentname&#039;&#039;&#039;&#039;&#039;/&#039;&#039;&#039;&#039;&#039;expname&#039;&#039;&#039;&#039;&#039;/res/darks&lt;br /&gt;
&lt;br /&gt;
Now, to submit the averaging job to the processing queue using many processor and all the events, use bsub:&lt;br /&gt;
&lt;br /&gt;
 $ bsub -a mympi -n 100 -q psanacsq -o dark_average.log cxi.mpi_average -c &#039;&#039;&#039;&#039;&#039;expname&#039;&#039;&#039;&#039;&#039;/dark.cfg -x &#039;&#039;&#039;&#039;&#039;expname&#039;&#039;&#039;&#039;&#039; -r &#039;&#039;&#039;&#039;&#039;runnumber&#039;&#039;&#039;&#039;&#039; -a &#039;&#039;&#039;&#039;&#039;address&#039;&#039;&#039;&#039;&#039; -d &#039;&#039;&#039;&#039;&#039;detzoffset&#039;&#039;&#039;&#039;&#039; -p&lt;br /&gt;
&lt;br /&gt;
The job will be scheduled in the queue called &amp;lt;code&amp;gt;psanacsq&amp;lt;/code&amp;gt;, which is one of several available queues, using 100 cores.  Note that the job must be submitted from the &amp;lt;code&amp;gt;~/myrelease&amp;lt;/code&amp;gt; directory.&lt;br /&gt;
&lt;br /&gt;
Type &amp;lt;code&amp;gt;bjobs&amp;lt;/code&amp;gt; to see if the job is running.  When it is, follow the output thusly:&lt;br /&gt;
 $ tail -f dark_average.log&lt;br /&gt;
&lt;br /&gt;
When the average has been completed, the output can be inspected using the &#039;&#039;cctbx&#039;&#039; image viewer:&lt;br /&gt;
 $ cctbx.image_viewer &amp;lt;path to pickle files&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Averaging an experimental light run ==&lt;br /&gt;
&lt;br /&gt;
Experimental, lighted, runs can be averaged to see the extent of diffraction and potential pathologies in the run.  Here, you will need this config file [[average.cfg]].  Copy the file from to your myrelease/&#039;&#039;&#039;&#039;&#039;expname&#039;&#039;&#039;&#039;&#039; directory.&lt;br /&gt;
&lt;br /&gt;
The configuration file uses two new modules, [https://confluence.slac.stanford.edu/display/PSDM/psana+-+Module+Catalog#psana-ModuleCatalog-Modulecspad_mod.CsPadCalib cspad_mod.CsPadCalib] and pyimgalgos.cspad_gainmap (currently undocumented).  The former uses darks prepared by [[calibman]] for dark subtraction and performs common mode correction.  The latter applies any high/low gain pixel mask applied during data collection.  Note how the data from one module is passed to the next module using inkey and outkey.  cxi.mpi_average looks for the final data using the outkey &#039;&#039;image0&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Submit the job and view the results exactly as before, with the exception of using this average.cfg file instead.&lt;br /&gt;
&lt;br /&gt;
== Information contained in the light average ==&lt;br /&gt;
&lt;br /&gt;
Firstly, the light and dark images can be used to mask of any bad pixels.  Inactive and non-bonded pixels, as well as hypersensitive pixels and any beam stop (if used) should be masked out.  The light images (maximum in particular) also serve as a virtual, dark-subtracted, powder pattern that can used to inspect the data for diffraction.  The light maximum should also flag up obvious errors in metrology, because rings will be non-continuous if the quadrants are misaligned. Intensity values from the corners of the light average or maximum are also useful to estimate background when taking first guesses at thresholds for hit-finding and integration.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Creating a mask image ==&lt;br /&gt;
&#039;&#039;cctbx.xfel&#039;&#039; uses three images to create a mask.  Those images, and the purposes of them are listed below:&lt;br /&gt;
* Average image from a dark run: pixels ≤ 0 are considered dead, pixels &amp;gt; 2000 are too sensitive&lt;br /&gt;
* Standard deviation from a dark run: pixels ≤ 0 are considered dead, pixels ≥ 10 are too uncertain&lt;br /&gt;
* Maximum projection from a lighted run (&#039;&#039;i.e.&#039;&#039; an experimental run): pixels &amp;lt; 300 are considered non-bonded or in a shadow.  [N.B.–this assumes a lot–300 may be appropriate for XPP data collected at atmosphere; not CXI data &amp;lt;i&amp;gt;in vacuo&amp;lt;/i&amp;gt;–NKS.] The presence of diffracting data is not needed, but also will not interfere.&lt;br /&gt;
&lt;br /&gt;
To create the mask, execute this command:&lt;br /&gt;
 $ cxi.make_mask -m 10 &amp;lt;b&amp;gt;&amp;lt;i&amp;gt;&amp;lt;name of dark average&amp;gt;&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;.pickle &amp;lt;b&amp;gt;&amp;lt;i&amp;gt;&amp;lt;name of dark standard deviation&amp;gt;&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;.pickle \&lt;br /&gt;
     &amp;lt;b&amp;gt;&amp;lt;i&amp;gt;&amp;lt;name of light maximum projection&amp;gt;&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;.pickle&lt;br /&gt;
&lt;br /&gt;
A new image is created where each pixel has one of two values: -2 (masked out pixels), and 0 (good pixels).  Note, the maximum projection minimum pixel value is overridden here to a value that is more sensible for the tutorial&#039;s lysozyme data.  You will likely need to adjust this parameter based on your data (see below for details and for further overrides).  &lt;br /&gt;
&lt;br /&gt;
Use the resultant mask image during processing with &#039;&#039;cctbx.xfel&#039;&#039; by adding this flag to your pyana config file:&lt;br /&gt;
 mask_path = &amp;lt;b&amp;gt;&amp;lt;i&amp;gt;&amp;lt;path to mask file&amp;gt;&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;&lt;br /&gt;
In addition, a polygon and a circle can be specified using the &amp;lt;code&amp;gt;--poly_mask&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;--circle_mask&amp;lt;/code&amp;gt; parameters:&lt;br /&gt;
 $ cxi.make_mask --poly_mask=17,854,76,967,760,982,762,879 --circle_mask=855,939,103 Cspad-avg.pickle Cspad-stddev.pickle Cspad-max.pickle&lt;br /&gt;
This example creates a mask image with a polygon [with vertices (17,854), (76,967), (760,982), and (762,879)] masked out, and a circle with center (855,939) and radius 103 masked out. Only one polygon and circle can be specified at the moment.&lt;br /&gt;
&lt;br /&gt;
The mask can be examined with &#039;&#039;cctbx.image_viewer&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
==== Applying the mask ====&lt;br /&gt;
&lt;br /&gt;
Once the mask is created, it needs to be referenced by your configuration file:&lt;br /&gt;
&lt;br /&gt;
 mask_path = &amp;lt;absolute path to mask file&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Further, the indexing software needs to know what value to use as the masked-out value.  Add the following to your phil files for indexing:&lt;br /&gt;
&lt;br /&gt;
 integration.mask_pixel_value=-2&lt;br /&gt;
&lt;br /&gt;
Where -2 is the default mask value, but it can be whatever you specify using the -x option cxi.make_mask (see below).&lt;br /&gt;
&lt;br /&gt;
=== Options ===&lt;br /&gt;
&lt;br /&gt;
Some additional options are available for specifying the details of the masking operation:&lt;br /&gt;
;-a,  --avg_max (default 2000)&lt;br /&gt;
: specifies the maximum value in ADU a pixel in the average image can have before it&#039;s masked out.  The minimum is always zero.&lt;br /&gt;
;-s, --stddev_max (default 10)&lt;br /&gt;
: specifies the maximum value in ADU a pixel in the standard deviation image can have before it&#039;s masked out.  The minimum is always zero.&lt;br /&gt;
;-m, --maxproj_min (default 300)&lt;br /&gt;
: specifies the minimum value in ADU a pixel in the maximum projection image can have before it&#039;s masked out.  Of the three parameters for controlling cutoffs in &#039;&#039;cxi.make_mask&#039;&#039;, the -m option is unique from the -a and -s options in that it will likely vary the according to your sample&#039;s background.  Carefully examine the corners of your lighted maximum projection and choose a value lower than the ADU values displayed.  Also note that there is no cutoff on the high end of the maximum projection image specified in the mask, as that is defined as the saturation value for the detector.&lt;br /&gt;
;-x, --mask_pix_val (default -2)&lt;br /&gt;
: specifies the value to use when masking out a pixel. In other words, bad pixels in images in the XTC stream will be replaced with this value.&lt;br /&gt;
;-o, --output (default mask_.pickle)&lt;br /&gt;
: specifies the output file path, should be *.pickle, can include directory.&lt;/div&gt;</summary>
		<author><name>Aaron</name></author>
	</entry>
	<entry>
		<id>http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Phil&amp;diff=1748</id>
		<title>Phil</title>
		<link rel="alternate" type="text/html" href="http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Phil&amp;diff=1748"/>
		<updated>2026-08-19T18:31:39Z</updated>

		<summary type="html">&lt;p&gt;Aaron: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Archived}}&lt;br /&gt;
&lt;br /&gt;
As described in the [[overview]], &#039;&#039;phil&#039;&#039; files contain parameters used during hitfinding, indexing and integration.  This tutorial uses two &#039;&#039;phil&#039;&#039; files during the indexing and integration step: Ls04-lysozyme.phil and metrology-7.1.phil.  The former specifies parameters specific to the processing run, while the latter specifies whole-pixel and sub-pixel metrology corrections applied to the 64 CSPAD sensor tiles.&lt;br /&gt;
&lt;br /&gt;
== Hitfinding/indexing/integration &#039;&#039;phil&#039;&#039; file ==&lt;br /&gt;
&lt;br /&gt;
For the tutorial, Ls04-lysozyme.phil, stored in the /reg/d/ffb/cxi/temp/cctbx/tutorials/indexing directory but copied to your ~/myrelease directory during use, contains configuration settings we worked out that best process this data.  The file will look like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# -*- mode: Conf -*-&lt;br /&gt;
&lt;br /&gt;
include file metrology-7.1.phil&lt;br /&gt;
&lt;br /&gt;
# From looking at 35 images integrated with detz_offset = 581 and&lt;br /&gt;
# without target_cell set.&lt;br /&gt;
target_cell = 38 79 79 90 90 90&lt;br /&gt;
target_cell_centring_type = P&lt;br /&gt;
known_setting = 9&lt;br /&gt;
&lt;br /&gt;
distl_highres_limit = 2.0&lt;br /&gt;
force_method2_resolution_limit = 2.0&lt;br /&gt;
&lt;br /&gt;
mosaicity_limit = 1&lt;br /&gt;
&lt;br /&gt;
# Set to True to pick up second lattice, if present.&lt;br /&gt;
#outlier_detection_switch = True&lt;br /&gt;
&lt;br /&gt;
# TEST&lt;br /&gt;
distl_minimum_number_spots_for_indexing = 20&lt;br /&gt;
&lt;br /&gt;
distl {&lt;br /&gt;
  res.outer = 2.0&lt;br /&gt;
  minimum_signal_height = 5&lt;br /&gt;
  #minimum_spot_height = 10&lt;br /&gt;
  minimum_spot_height = 5&lt;br /&gt;
  minimum_spot_area = 1&lt;br /&gt;
  spot_area_maximum_factor = 20&lt;br /&gt;
  compactness_filter = False&lt;br /&gt;
  #method2_cutoff_percentage = 5&lt;br /&gt;
  method2_cutoff_percentage = 2.5&lt;br /&gt;
&lt;br /&gt;
  # Avoids intensity filter.&lt;br /&gt;
  #peak_intensity_maximum_factor = 10000&lt;br /&gt;
  peak_intensity_maximum_factor = 100&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
indexing {&lt;br /&gt;
  # Set to True to generate correction vectors.&lt;br /&gt;
  verbose_cv = True&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
integration {&lt;br /&gt;
  background_factor = 2&lt;br /&gt;
&lt;br /&gt;
  #detector_gain = 7.5&lt;br /&gt;
  detector_gain = 1.0&lt;br /&gt;
&lt;br /&gt;
  #model = use_case_3_simulated_annealing_7&lt;br /&gt;
  model = user_supplied&lt;br /&gt;
&lt;br /&gt;
  signal_penetration = 0.5&lt;br /&gt;
  #spot_shape_verbose = False [This time consuming option prints out a detailed shape analysis of every spot]&lt;br /&gt;
  spotfinder_subset = spots_non-ice&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Several lines of parameters are given, then a few parameter blocks are specified, enclosed in {} brackets.  The parameters in detail:&lt;br /&gt;
* include file metrology-7.1.phil: this line specifies another &#039;&#039;phil&#039;&#039; file to include.  In this case, the included file specifies metrology corrections (see below).&lt;br /&gt;
* target_cell: the known unit cell for this sample.  In the form a, b, c, alpha, beta, gamma.  Must be in the primitive setting, or specify a target_cell_centring_type.  Or, convert the dimensions first to the primitive setting with &#039;&#039;iotbx.lattice_symmetry&#039;&#039;.&lt;br /&gt;
* target_cell_centring_type: the centering type of the Bravais lattice: P (default), C, I, R, or F.&lt;br /&gt;
* known_setting: this is the setting number of the true Bravais symmetry as output by the autoindexing procedure in &#039;&#039;LABELIT&#039;&#039;.  The indexing process fundamentally determines the triclinic cell, but also a list of possible Bravais lattices.  Normally we associate the following setting numbers with the crystal systems:&lt;br /&gt;
**Triclinic=1&lt;br /&gt;
**Monoclinic=2&lt;br /&gt;
**Orthorhombic=5&lt;br /&gt;
**Rhombohedral=5&lt;br /&gt;
**Tetragonal=9&lt;br /&gt;
**Hexagonal=12&lt;br /&gt;
**Cubic=22&lt;br /&gt;
**However, the assumptions break down if there is pseudosymmetry, i.e., if a higher-symmetry Bravais lattice is close to the true Bravais symmetry.  In these cases, a careful inspection of the &#039;&#039;LABELIT&#039;&#039; output is necessary to choose the setting, and it may be necessary to implement new code in &#039;&#039;cctbx.xfel&#039;&#039; for this (contact the authors).&lt;br /&gt;
* distl_highres_limit and force_method2_resolution_limit: only process to this resolution limit.  [Note these are #1 and #2 of 3 resolution flags that all must be set together]&lt;br /&gt;
* mosaicity_limit: maximum moisicity before a frame is rejected&lt;br /&gt;
* distl_minimum_number_spots_for_indexing: indexing will not proceed unless there are at least this many good spots found on the image&lt;br /&gt;
* Subcategory &amp;lt;code&amp;gt;distl&amp;lt;/code&amp;gt;: parameters specific to spot finding.  &#039;&#039;&#039;NOTE:  More extensive documentation on spotfinder and other parameters is at the [http://cci.lbl.gov/labelit/html/spotfinder.html spot finder web site]&#039;&#039;&#039;&lt;br /&gt;
** res.outer: resolution limit for &#039;&#039;spotfinder&#039;&#039; [Note this is #3 of 3 resolution flags that all must be set together]&lt;br /&gt;
** minimum_signal_height: in units of background noise sigma, how much signal is needed for a spot&lt;br /&gt;
** minimum_spot_height: minimum height for a pixel to be considered a maximum (after it&#039;s determined to be signal)&lt;br /&gt;
** minimum_spot_area: minimum area in pixels for each spot.  NOTE: there is a longstanding bug in Spotfinder; increment this number by +1 to get the actually-used minimum area.&lt;br /&gt;
** spot_area_maximum_factor: in multiples of minimum spot area, how large spots are allowed to be&lt;br /&gt;
** compactness_filter: (Use False).  This is an experimental algorithm that insists that spots need to be compact; e.g., a line 4 pixels long is not an acceptable spot.  However, it turns out that many XFEL spots are not compact, so this algorithm degrades XFEL performance. &lt;br /&gt;
** method2_cutoff_percentage: Controls how method2 (see the Spotfinder paper) chooses the resolution cutoff.  Synchrotron data: 25 is OK.  XFEL stills: requires low values, try 5.  Lower numbers result in  the determination of more expansive values for the resolution cutoff. &lt;br /&gt;
** peak_intensity_maximum_factor: a peak intensity filter&lt;br /&gt;
* Subcategory &amp;lt;code&amp;gt;indexing&amp;lt;/code&amp;gt;:&lt;br /&gt;
** verbose_cv: if true, correction vectors are generated.  This is verbose output required for the metrology cutoff.  Not for routine users.&lt;br /&gt;
* Subcategory &amp;lt;code&amp;gt;integration&amp;lt;/code&amp;gt;:&lt;br /&gt;
** background_factor: ratio of # pixels used for background subtraction : # pixels in spot&lt;br /&gt;
** detector_gain: ADU units per photon&lt;br /&gt;
** model: &#039;&#039;labelit&#039;&#039; has several integration models, and allows users to provide their own.  The model listed here is custom for these xfel applications&lt;br /&gt;
** signal_penetration: thickness of the CSPAD sensors.&lt;br /&gt;
** spotfinder_subset: which spots found by &#039;&#039;spotfinder&#039;&#039; to use.  Choose from: &amp;lt; add &amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Metrology phil ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Update 12/11/13: quad translations and tile translations should no longer be specified in the phil file.  These live in the code for now.  We are re-working the file storage type and in the future we won&#039;t need these at all.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;cctbx.xfel&#039;&#039; applies 4 levels of metrology:&lt;br /&gt;
* Optical metrology: this is supplied by LCLS.  The pyana config file specifies a path to a directory where initial tile placements are specified.&lt;br /&gt;
* Quadrant translations: adjustments to each of the 4 quadrants as a whole. &#039;&#039;(12/11/13: specified in the codebase)&#039;&#039;&lt;br /&gt;
* Unit-pixel or whole-pixel metrology: a series of whole-pixel translations applied to each tile. &#039;&#039;(12/11/13: specified in the codebase)&#039;&#039;&lt;br /&gt;
* Sub-pixel metrology: fractional corrections including translations and rotations of each tile.  Used during integration.&lt;br /&gt;
&lt;br /&gt;
Sub-pixel metrology corrections are contained in the metrology &#039;&#039;phil&#039;&#039; file.  For this tutorial that is metrology-7.1.phil:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
distl {&lt;br /&gt;
  detector_tiling = None&lt;br /&gt;
  peripheral_margin = 1&lt;br /&gt;
)&lt;br /&gt;
integration {&lt;br /&gt;
  # This is L785_119.&lt;br /&gt;
  subpixel_joint_model {&lt;br /&gt;
    rotations = \&lt;br /&gt;
       0.1056719175    0.1080664532  -0.2151669703  -0.2099097279   \&lt;br /&gt;
       ...&lt;br /&gt;
    translations = \&lt;br /&gt;
       0.2700895641   -0.6117579705  -0.5111648376  -0.8676594815   \&lt;br /&gt;
       ...&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These parameters are in detail:&lt;br /&gt;
* distl subsection: quadrant translations and single-pixel tile translations&lt;br /&gt;
** detector_tiling: &amp;lt; add &amp;gt;&lt;br /&gt;
** peripheral_margin: how many pixels to leave as a border around the final image&lt;br /&gt;
* integration subsection: sub-pixel adjustments applied during reflection integration:&lt;br /&gt;
** subpixel_joint_model: root tag for the sub-pixel corrections&lt;br /&gt;
*** rotations: angles in degrees for each tile (64)&lt;br /&gt;
*** translation: x/y translations for each tile (128)&lt;br /&gt;
&lt;br /&gt;
== Comparing two phil files ==&lt;br /&gt;
&lt;br /&gt;
Often phil files are edited repeatedly by users.  cxi.mpi_submit saves copies of phil files as they are used as a record of which trials were processed using which parameters.  Now, say you have two different phil files that you want to see the differences between them.  Due to comments or rearrangements, diffing the two files isn&#039;t making your life easier.  Do this:&lt;br /&gt;
&lt;br /&gt;
 $ cxi.parameters &amp;gt; default.phil&lt;br /&gt;
 $ libtbx.phil --diff default.phil file1.phil &amp;gt; a.txt&lt;br /&gt;
 $ libtbx.phil --diff default.phil file2.phil &amp;gt; b.txt&lt;br /&gt;
 $ diff a.txt b.txt&lt;br /&gt;
&lt;br /&gt;
This will show the true differences between the phil files.  Note also that cxi.parameters is a useful tool for seeing all the default parameters available in &#039;&#039;cctbx.xfel&#039;&#039;.&lt;/div&gt;</summary>
		<author><name>Aaron</name></author>
	</entry>
	<entry>
		<id>http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Mod_image_dict&amp;diff=1747</id>
		<title>Mod image dict</title>
		<link rel="alternate" type="text/html" href="http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Mod_image_dict&amp;diff=1747"/>
		<updated>2026-08-19T18:31:05Z</updated>

		<summary type="html">&lt;p&gt;Aaron: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Archived}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[psana]&lt;br /&gt;
modules = my_ana_pkg.mod_image_dict&lt;br /&gt;
[my_ana_pkg.mod_image_dict]&lt;br /&gt;
address         = MfxEndstation-0|Rayonix-0&lt;br /&gt;
dark_path       = None&lt;br /&gt;
dark_stddev     = None&lt;br /&gt;
mask_path       = None&lt;br /&gt;
detz_offset     = 89.0&lt;br /&gt;
gain_map_path   = None&lt;br /&gt;
gain_map_level  = None&lt;br /&gt;
override_beam_x = 962.0&lt;br /&gt;
override_beam_y = 963.0&lt;br /&gt;
override_energy = None&lt;br /&gt;
bin_size        = 2&lt;br /&gt;
crop_rayonix    = False&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These parameters are for a Rayonix image. Use crop_rayonix to trim the image such that it is square and centered on the beam center.  Useful for the LABELIT backend of &#039;&#039;cctbx.xfel&#039;&#039; but not needed for DIALS.&lt;/div&gt;</summary>
		<author><name>Aaron</name></author>
	</entry>
	<entry>
		<id>http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Metrology_refinement&amp;diff=1746</id>
		<title>Metrology refinement</title>
		<link rel="alternate" type="text/html" href="http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Metrology_refinement&amp;diff=1746"/>
		<updated>2026-08-19T18:30:47Z</updated>

		<summary type="html">&lt;p&gt;Aaron: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Archived}}&lt;br /&gt;
&lt;br /&gt;
Accurate data integration requires highly precise knowledge of pixel positions in laboratory space (metrology).  Gaining this knowledge is especially difficult due to the [[CSPAD Pattern | segmented nature of the CSPAD detector]], which is tiled into 64 application-specific integrated circuits (ASICs).  The 64 ASICs are arranged in quadrants that are approximately 4-fold rotationally symmetric, with 8 sensors per quadrant and 2 ASICs per sensor.   The sensors are field-serviceable, and may therefore change from Run to Run.     &lt;br /&gt;
&lt;br /&gt;
We thus need to determine positions and rotations for all 64 tiles, ideally down to an accuracy on order of 10 microns. As a general overview, cctbx takes the following steps:&lt;br /&gt;
&lt;br /&gt;
* Tile placement in physical space is measured by the beamline operators optically using electron microscopy.  This is done at the per-sensor level (2 ASICs per sensor).  &lt;br /&gt;
&lt;br /&gt;
* Relative positions of the quadrants are determined coarsely by considering powder rings.&lt;br /&gt;
&lt;br /&gt;
* Sensor positions are refined based on Bragg spot diffraction, allowing for whole-pixel translations in x and y.&lt;br /&gt;
&lt;br /&gt;
* ASIC positions are refined to subpixel accuracy based on Bragg diffraction, allow for sub-pixel translations and rotations.&lt;br /&gt;
&lt;br /&gt;
Most of these steps may be performed by general users, but some require editing the source code.  Therefore, it may be suitable to consult the software authors.  Please don&#039;t hesitate to ask for assistance regarding any aspect of this procedure.&lt;br /&gt;
&lt;br /&gt;
This page is superseded by the Aug. 2014 tutorial documented here: [[L498_Thermolysin]]&lt;br /&gt;
&lt;br /&gt;
== Optical Metrology ==&lt;br /&gt;
&lt;br /&gt;
LCLS provides initial tile placements.  Periodically the detector is disassembled and re-built, necessitating new calibration information.  The optical measurements are included in the &#039;&#039;cctbx.xfel&#039;&#039; in the source code and are reference by your &#039;&#039;pyana&#039;&#039; config file.  See [[Preparatory_steps]] for more information.&lt;br /&gt;
&lt;br /&gt;
== Quadrant positioning ==&lt;br /&gt;
&lt;br /&gt;
===Problem statement===&lt;br /&gt;
&lt;br /&gt;
The optical metrology step above determines only the sensor positions relative to the frames of reference of each quadrant; but not the absolute position of each quadrant in space.  At the XPP instrument, the LCLS-provided initial tile placements may additionally place the quadrants, but this should be confirmed.  At the CXI instrument, the forward detector DS1 has rail-mounted quadrants to allow re-sizing of the central hole.  At CXI, quadrant placement should be assessed for both the forward and back (DS2) detectors.   &lt;br /&gt;
&lt;br /&gt;
===Method===&lt;br /&gt;
cctbx includes a special GUI to adjust quadrant positions visually, based on connectivity of concentric rings on a powder pattern.  True powders can be used (silver behenate), or a powder pattern can be synthesized by averaging protein crystal Bragg patterns from an entire run (see [[Preparatory_steps]]).  If protein patterns are averaged, it is most useful to view powder rings on a standard deviation or composite maximum image; rings on the average image itself tend to be faint.&lt;br /&gt;
&lt;br /&gt;
Once a suitable image is obtained, start the calibration tool with this command:&lt;br /&gt;
&lt;br /&gt;
 # For silver behenate:&lt;br /&gt;
 cxi.view &amp;lt;powder pattern image path&amp;gt; viewer.calibrate_silver=true distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Note, the flag distl.detector_format_version is a legacy requirement that will be phased out.&lt;br /&gt;
&lt;br /&gt;
Usually the standard deviation or maximum projection will show virtual powder ring.  An image with strong rings to moderate resolution is desired. &lt;br /&gt;
&lt;br /&gt;
Once loaded, you will see your image and many red rings, incidentally corresponding to the diffraction pattern of silver behenate.  Additionally, a separate settings panel will be present with 8 input boxes corresponding to the x and y offsets of each of the four quadrants, UL, UR, LL, and LR (upper and lower, left and right).  Manually adjust the offsets until the powder rings are circular through the whole image, using the red rings as guides.  These corrections will but put into your phil parameters file in the distl quad_translations entry in this form:&lt;br /&gt;
&lt;br /&gt;
 distl {&lt;br /&gt;
   quad_translations =  2 -6  3 -6 -7  0 -1 -4&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Where the numbers are listed in this order: ULX ULY, URX URY, LLX LLY, LRX, LRY&lt;br /&gt;
&lt;br /&gt;
== Unit pixel metrology corrections ==&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;cctbx.xfel&#039;&#039; then refines tile positions to whole pixel, and then sub-pixel precision by calculating spot positions on a highly diffracting dataset and refining tile locations versus actual spot positions for each tile. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Sub-pixel metrology corrections ==&lt;br /&gt;
&lt;br /&gt;
distl.tile_flags&lt;/div&gt;</summary>
		<author><name>Aaron</name></author>
	</entry>
	<entry>
		<id>http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Merging&amp;diff=1745</id>
		<title>Merging</title>
		<link rel="alternate" type="text/html" href="http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Merging&amp;diff=1745"/>
		<updated>2026-08-19T18:30:24Z</updated>

		<summary type="html">&lt;p&gt;Aaron: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Archived}}&lt;br /&gt;
&lt;br /&gt;
The result of [[Indexing and integration]] is a set of Python pickle files, each of which essentially contains a table of Miller indices of the observed reflections, their integrated intensities, and estimated errors.  In the general case, these files reflect the measurements from single shots, each exposing different crystals with a unique pulse of X-rays.  &#039;&#039;Merging&#039;&#039; refers to the procedure applied to unite all these observations into a single data set.  During merging, a distinct multiplicative factor, which accounts for the variance in pulse intensity and crystal size, is applied to the observations from a single shot to bring all the observations onto a common scale.  After rejecting possible outliers, the intensities for individual reflections are summed, and their errors are propagated in quadrature.  The result of merging is an mtz file suited for further processing, &#039;&#039;e.g.&#039;&#039; molecular replacement.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Merging a set of integration files ==&lt;br /&gt;
In &#039;&#039;cctbx.xfel&#039;&#039; the per-image scale factors are determined using a &#039;&#039;scaling reference&#039;&#039;.  This scaling reference is expected to be a previously solved, isomorphous data set.  The scale factor is determined by a least-squares fit of the observations to the reference intensities, after applying corrections for polarization&amp;lt;ref&amp;gt;[http://dx.doi.org/10.1107/S0021889882012060 Kahn, R, &amp;lt;i&amp;gt;et al.&amp;lt;/i&amp;gt; Macromolecular Crystallography with Synchrotron Radiation: Photographic Data Collection and Polarization Correction. &amp;lt;i&amp;gt;J Appl Cryst&amp;lt;/i&amp;gt; &amp;lt;b&amp;gt;15&amp;lt;/b&amp;gt;, 330–337 (1982).]&amp;lt;/ref&amp;gt;, and a significance filter, which limits the resolution of each diffraction pattern based on the signal-to-noise ratio.  Lattices not conforming to the Bravais symmetry of the scaling reference are rejected.  By default non-isomorphous lattices with cell lengths differing by more than 10% in length from the mean, or 2° in the angles are also rejected, as are lattices that correlate poorly with the scaling reference.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;cxi.merge&#039;&#039; may take several passes over the integrated images.  In order to speed up processing, &#039;&#039;cxi.merge&#039;&#039; will write the scaled data to a back  end database during each pass.  Currently three database back ends are implemented.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;FS&amp;lt;/code&amp;gt; is the simplest back end.  It stores the scaled intensities, their Miller indices, and information about the shots they were observed during in three flat files on the file system.&lt;br /&gt;
&lt;br /&gt;
* The &amp;lt;code&amp;gt;MySQL&amp;lt;/code&amp;gt; back end stores data in a MySQL database.  The database must be set up beforehand, and credentials to access it must be supplied in the parameters passed to &#039;&#039;cxi.merge&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
* The &amp;lt;code&amp;gt;SQLite&amp;lt;/code&amp;gt; back end uses a simple SQLite database, which is written to a single file on the file system.  It is easier to use than the &amp;lt;code&amp;gt;MySQL&amp;lt;/code&amp;gt; back end and more efficient than the &amp;lt;code&amp;gt;FS&amp;lt;/code&amp;gt; backend.  Regrettably, the &amp;lt;code&amp;gt;SQLite&amp;lt;/code&amp;gt; back end does not appear to work on the Lustre file system.&lt;br /&gt;
&lt;br /&gt;
In &#039;&#039;cctbx.xfel&#039;&#039; images are merged using the &amp;lt;code&amp;gt;cxi.merge&amp;lt;/code&amp;gt; command.  &amp;lt;code&amp;gt;cxi.merge&amp;lt;/code&amp;gt; accepts several options which can conveniently be assembled in a &#039;&#039;phil&#039;&#039; file.  In this tutorial only a subset of the available options are defined.&lt;br /&gt;
&lt;br /&gt;
; backend&lt;br /&gt;
: Back end database; &amp;lt;code&amp;gt;FS&amp;lt;/code&amp;gt; for flat-file ASCII data storage, &amp;lt;code&amp;gt;MySQL&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;SQLite&amp;lt;/code&amp;gt; for the respective proper database back ends.  &lt;br /&gt;
; d_min&lt;br /&gt;
: Limiting resolution for scaling and merging&lt;br /&gt;
; pixel_size&lt;br /&gt;
: set the pixel size for the detector used, this is a single value (0.11 for CSPad)&lt;br /&gt;
; data&lt;br /&gt;
: Directory containing integrated data in pickle format.  Repeat to specify additional directories.&lt;br /&gt;
; merge_anomalous&lt;br /&gt;
: &amp;lt;code&amp;gt;True&amp;lt;/code&amp;gt; to merge anomalous contributors (&#039;&#039;i.e.&#039;&#039; Bijvoet mates), &amp;lt;code&amp;gt;False&amp;lt;/code&amp;gt; to preserve them&lt;br /&gt;
; min_corr&lt;br /&gt;
: Correlation cutoff for rejecting individual frames&lt;br /&gt;
; model&lt;br /&gt;
: The scaling reference, PDB filename containing atomic coordinates and isomorphous &amp;lt;code&amp;gt;CRYST1&amp;lt;/code&amp;gt; record.  Note:  quick command to download a pdb file from the Internet is: &amp;lt;code&amp;gt; phenix.fetch_pdb [pdb_code]&amp;lt;/code&amp;gt;&lt;br /&gt;
; nproc&lt;br /&gt;
: Specifies the number of scaling processes &#039;&#039;cxi.merge&#039;&#039; may have running at any one time&lt;br /&gt;
; output.prefix&lt;br /&gt;
: Prefix for all output file names&lt;br /&gt;
; rawdata.sdfac_auto&lt;br /&gt;
: &amp;lt;code&amp;gt;True&amp;lt;/code&amp;gt; to apply &amp;lt;code&amp;gt;SDFAC&amp;lt;/code&amp;gt; correction to each image, assuming negative intensities are normally distributed noise&lt;br /&gt;
; rescale_with_average_cell&lt;br /&gt;
: Rescale the images a second time, requiring images to conform to the average unit cell.  If set to &amp;lt;code&amp;gt;True&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;set_average_unit_cell&amp;lt;/code&amp;gt; must also be set to &amp;lt;code&amp;gt;True&amp;lt;/code&amp;gt;.&lt;br /&gt;
; set_average_unit_cell&lt;br /&gt;
: If &amp;lt;code&amp;gt;True&amp;lt;/code&amp;gt; set the unit cell of the merged data to the average of the merged images, otherwise use the unit cell of the scaling reference&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The merged data is written to an mtz-file named &amp;lt;code&amp;gt;&amp;lt;i&amp;gt;output.prefix&amp;lt;/i&amp;gt;.mtz&amp;lt;/code&amp;gt;.  Standard output, redirected to &amp;lt;code&amp;gt;merge.out&amp;lt;/code&amp;gt; above, mainly consists of statistics for each individual image as it is scaled.  The output concludes with a section labelled &amp;lt;code&amp;gt;FINISHED MERGING&amp;lt;/code&amp;gt;, which first lists the number of accepted and rejected images,&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 962 of 1185 integration files were accepted&lt;br /&gt;
 127 rejected due to wrong Bravais group&lt;br /&gt;
 1 rejected for unit cell outliers&lt;br /&gt;
 12 rejected for low signal&lt;br /&gt;
 83 rejected due to poor correlation&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This is followed by a histograms of the unit cell distribution, and the merging table:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
---------------------------------------------------------------------------------&lt;br /&gt;
                                     &amp;lt;asu   &amp;lt;obs&lt;br /&gt;
Bin  Resolution Range  Completeness redun&amp;gt; redun&amp;gt; n_meas   &amp;lt;I&amp;gt;    &amp;lt;I/sig(I)&amp;gt;&lt;br /&gt;
---------------------------------------------------------------------------------&lt;br /&gt;
  1 -1.0000 -  6.4633     [306/309]  67.61  68.28  20893    35621    27.044&lt;br /&gt;
  2  6.4633 -  5.1299     [285/285]  43.18  43.18  12305    19272    12.490&lt;br /&gt;
  3  5.1299 -  4.4814     [275/275]  46.77  46.77  12862    24391    14.261&lt;br /&gt;
  4  4.4814 -  4.0716     [269/269]  43.38  43.38  11670    29436    14.819&lt;br /&gt;
  5  4.0716 -  3.7798     [249/249]  35.50  35.50   8840    29811    12.716&lt;br /&gt;
  6  3.7798 -  3.5569     [267/267]  32.07  32.07   8562    24212    10.523&lt;br /&gt;
  7  3.5569 -  3.3787     [274/274]  20.99  20.99   5750    23626     8.171&lt;br /&gt;
  8  3.3787 -  3.2317     [256/256]  15.96  15.96   4085    24168     6.746&lt;br /&gt;
  9  3.2317 -  3.1072     [263/264]  12.16  12.20   3209    23936     5.859&lt;br /&gt;
 10  3.1072 -  3.0000     [263/263]   8.74   8.74   2298    20613     4.556&lt;br /&gt;
&lt;br /&gt;
All                     [2707/2711]  33.37  33.42  90474    25594    11.978&lt;br /&gt;
----------------------------------------------------------------------------------&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
In this case, the overall completeness to 3.0 Å is 2,707 / 2,711, or approximately 100%, and each observed reflection is measured 33.42 times on average (&amp;lt;code&amp;gt;&amp;lt;obs redun&amp;gt;&amp;lt;/code&amp;gt;).  In total 90,474 observations, with an average scaled and integrated intensity of 25,594 analog-to-digital units (ADU), were merged and the mean &amp;lt;i&amp;gt;I&amp;lt;/i&amp;gt; / σ(&amp;lt;i&amp;gt;I&amp;lt;/i&amp;gt;) was determined to be 11.978.&lt;br /&gt;
&lt;br /&gt;
== Additional merging statistics ==&lt;br /&gt;
&#039;&#039;cxi.xmerge&#039;&#039; retrieves the scaled, unmerged intensities from the database back end, and calculates the &amp;lt;i&amp;gt;CC&amp;lt;/i&amp;gt;&amp;lt;sub&amp;gt;1/2&amp;lt;/sub&amp;gt;&amp;lt;ref&amp;gt;[http://dx.doi.org/10.1126/science.1218231 Karplus, P. A. &amp;amp; Diederichs, K. Linking Crystallographic Model and Data Quality. &amp;lt;i&amp;gt;Science&amp;lt;/i&amp;gt; &amp;lt;b&amp;gt;336&amp;lt;/b&amp;gt;, 1030–1033 (2012).]&amp;lt;/ref&amp;gt; and &amp;lt;i&amp;gt;CC&amp;lt;/i&amp;gt;&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt; statistics.  &amp;lt;i&amp;gt;CC&amp;lt;/i&amp;gt;&amp;lt;sub&amp;gt;1/2&amp;lt;/sub&amp;gt; is defined as Pearson&#039;s correlation coefficient between two sets, such that for each ￼unique reflection the average intensities of two randomly chosen halves of its ￼independent observations are assigned to different set.  &amp;lt;i&amp;gt;CC&amp;lt;/i&amp;gt;&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt; is the correlation coefficient between the merged data and the isomorphous scaling reference.  Both statistics are computed in each resolution bin, as well as for the full set of reflections.&lt;br /&gt;
&lt;br /&gt;
Once the database has been populated using &#039;&#039;cxi.merge&#039;&#039;, &#039;&#039;cxi.xmerge&#039;&#039; can be run, using the parameters defined in a &#039;&#039;phil&#039;&#039;-file, &amp;lt;code&amp;gt;Ls-04-lysozyme-xmerge.phil&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;$ cxi.xmerge Ls04-lysozyme-xmerge.phil&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The options used in this tutorial not already described in [[#Merging a set of integration files|Merging a set of integration files]] are explained below.&lt;br /&gt;
; scaling.mtz_file&lt;br /&gt;
: mtz-file containing experimentally determined reference structure factors, such as synchrotron measurements, to be used for CC&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt;.  Experimental measurements, when available, can be downloaded from the PDB using &amp;lt;code&amp;gt;phenix.fetch_pdb –-mtz [pdb_code]&amp;lt;/code&amp;gt;. &lt;br /&gt;
; scaling.mtz_column_F&lt;br /&gt;
: In the experimental measurements mtz-file, the column name containing the reference data; can be either amplitudes or intensities.  The column name should be given &#039;&#039;&#039;in lower case&#039;&#039;&#039;. An MTZ-format file can be inspected to see which columns it contains with &amp;lt;code&amp;gt;phenix.mtz.dump [code].mtz&amp;lt;/code&amp;gt;.  Quick tip:  if experimental measurements are unavailable, mock experimental structure factors can be generated with &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;phenix.fmodel &amp;lt;pdb file&amp;gt; high_resolution=&amp;lt;value&amp;gt; output.type=real&amp;lt;/code&amp;gt; in which case one would use &amp;lt;code&amp;gt;scaling.mtz_column_F=fmodel&amp;lt;/code&amp;gt;.&lt;br /&gt;
; scaling.log_cutoff&lt;br /&gt;
: Intensities less than &amp;lt;i&amp;gt;e&amp;lt;/i&amp;gt;&amp;lt;sup&amp;gt;&amp;lt;code&amp;gt;scaling.log_cutoff&amp;lt;/code&amp;gt;&amp;lt;/sup&amp;gt; will not be included in  the calculation of CC&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt; and R&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt; (however, these measurements will still be included in the final merged data). &lt;br /&gt;
&lt;br /&gt;
The results are printed on standard output and conclude with a table including the &amp;lt;i&amp;gt;CC&amp;lt;/i&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
---------------------------------------------------------------------------------------&lt;br /&gt;
                                      CC            CC            R     R   Scale Scale&lt;br /&gt;
Bin  Resolution Range  Completeness  int     N     iso     N     int   iso   int   iso&lt;br /&gt;
---------------------------------------------------------------------------------------&lt;br /&gt;
  1 -1.0000 -  6.4633     [233/309] 45.1%     233 56.3%     142 57.5% 45.6% 0.749 3.084&lt;br /&gt;
  2  6.4633 -  5.1299     [184/285] 22.5%     184 56.7%      62 57.2% 31.5% 0.862 2.841&lt;br /&gt;
  3  5.1299 -  4.4814     [203/275] 43.7%     203 57.6%      85 55.3% 37.0% 0.830 2.977&lt;br /&gt;
  4  4.4814 -  4.0716     [220/269] 39.0%     220 59.7%     101 51.4% 30.3% 0.805 3.296&lt;br /&gt;
  5  4.0716 -  3.7798     [187/249] 77.5%     187 33.6%      63 54.3% 39.4% 0.775 4.243&lt;br /&gt;
  6  3.7798 -  3.5569     [198/267] 35.4%     198 47.2%      56 56.8% 27.5% 0.903 3.587&lt;br /&gt;
  7  3.5569 -  3.3787     [198/274] 32.0%     198 70.7%      40 59.9% 31.4% 0.814 3.846&lt;br /&gt;
  8  3.3787 -  3.2317     [163/256] 30.6%     163 24.5%      28 63.9% 49.1% 0.734 4.278&lt;br /&gt;
  9  3.2317 -  3.1072     [164/264] 40.6%     164 53.6%       7 80.4% 32.1% 0.622 5.543&lt;br /&gt;
 10  3.1072 -  3.0000     [137/261]  8.2%     137 93.9%       5 85.6% 33.4% 0.221 4.372&lt;br /&gt;
&lt;br /&gt;
All                                 34.7%    1887 47.7%     589 62.5% 39.5% 0.754 3.157&lt;br /&gt;
---------------------------------------------------------------------------------------&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
In this case the overall &amp;lt;i&amp;gt;CC&amp;lt;/i&amp;gt;&amp;lt;sub&amp;gt;1/2&amp;lt;/sub&amp;gt; (&amp;lt;code&amp;gt;CC int&amp;lt;/code&amp;gt;) is 34.7%, and the correlation coefficient to the isomorphous reference, &amp;lt;i&amp;gt;CC&amp;lt;/i&amp;gt;&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt; (&amp;lt;code&amp;gt;CC iso&amp;lt;/code&amp;gt;) is 47.7%.&lt;br /&gt;
Note that the completeness for the cxi.xmerge output appears lower than that for the cxi.merge output. This is because the cxi.xmerge final table shows the completeness for the data used in the calculation of correlation coefficients, and so the completeness in the previous table should be used for general statistics.&lt;br /&gt;
&lt;br /&gt;
== Merging the tutorial data ==&lt;br /&gt;
&lt;br /&gt;
Compared to indexing and integration, merging is a relatively quick procedure.  However, particularly for large datasets, it may significantly strain computational resources.  Therefore, it is recommended to merge data on SLAC&#039;s interactive nodes.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ ssh psanacs.slac.stanford.edu&lt;br /&gt;
$ cd myrelease&lt;br /&gt;
$ cp /reg/g/cctbx/tutorials/merging/Ls04-lysozyme-*merge.phil .&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Before running the merging programs, the &#039;&#039;phil&#039;&#039;-files may need to be edited.  In particular, the location of the directories containing pickle files with the integrated intensities may need to be adjusted.  Since both &amp;lt;code&amp;gt;cxi.merge&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;cxi.xmerge&amp;lt;/code&amp;gt; log to standard output, it is advisable to redirect the stream to a file.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ cxi.merge Ls04-lysozyme-merge.phil &amp;gt; merge.out&lt;br /&gt;
$ cxi.xmerge Ls04-lysozyme-xmerge.phil &amp;gt; xmerge.out&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The merged reflections, suitable for further processing, are written &amp;lt;code&amp;gt;Ls04-lysozyme.mtz&amp;lt;/code&amp;gt;. Note that although the data for this tutorial extends to 2.2 Å, the statistics become exceedingly poor around 3.0 Å.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Aaron</name></author>
	</entry>
	<entry>
		<id>http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Maintaining_an_installation&amp;diff=1744</id>
		<title>Maintaining an installation</title>
		<link rel="alternate" type="text/html" href="http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Maintaining_an_installation&amp;diff=1744"/>
		<updated>2026-08-18T23:12:46Z</updated>

		<summary type="html">&lt;p&gt;Aaron: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Archived}}&lt;br /&gt;
&lt;br /&gt;
== Keeping up to date with PSDM releases==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- XXX Separate installation and maintenance instructions are provided by the PSDM project at [https://confluence.slac.stanford.edu/display/PSDM/Software+Distribution PSDM software distribution].  XXX Also missing bit on how to update cctbx for non-developers.  --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Since the &#039;&#039;cctbx.xfel&#039;&#039; modules do not critically depend on any particular version of &#039;&#039;pyana&#039;&#039;, it is generally safe to closely track the latest version of the PSDM software distribution.  To upgrade to the current PSDM release,&lt;br /&gt;
 $ cd &amp;lt;b&amp;gt;&amp;lt;i&amp;gt;/path/to/test/release&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;&lt;br /&gt;
 $ relupgrade ana-current&lt;br /&gt;
where &amp;lt;code&amp;gt;&amp;lt;b&amp;gt;&amp;lt;i&amp;gt;/path/to/test/release&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;&amp;lt;/code&amp;gt; must be substituted for path of the test release.  The &#039;&#039;cctbx.xfel&#039;&#039; modules should then be rebuilt using&lt;br /&gt;
 $ scons -c&lt;br /&gt;
 $ scons&lt;br /&gt;
It is possible to manually edit &amp;lt;code&amp;gt;&amp;lt;b&amp;gt;&amp;lt;i&amp;gt;/path/to/test/release&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;/.sit_release&amp;lt;/code&amp;gt; to contain &amp;lt;code&amp;gt;ana-current&amp;lt;/code&amp;gt; instead of a particular version number.  This ensures that the latest version of the PSDM software distribution is used during each session.&lt;br /&gt;
&lt;br /&gt;
== Keeping a developer installation up to date ==&lt;br /&gt;
&lt;br /&gt;
Given the rapid development of the &#039;&#039;PHENIX&#039;&#039; suite, it is recommended to update the sources and rebuild often. Certain changes may require the configure command (or &amp;lt;code&amp;gt;libtbx.refresh&amp;lt;/code&amp;gt;) to be rerun.&lt;br /&gt;
 $ cd &amp;lt;b&amp;gt;&amp;lt;i&amp;gt;/path/to/cctbx/sources&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;&lt;br /&gt;
 $ ./allsvn update&lt;br /&gt;
 $ cd &amp;lt;b&amp;gt;&amp;lt;i&amp;gt;/path/to/cctbx/build&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;&lt;br /&gt;
 $ make&lt;br /&gt;
&amp;lt;!-- XXX How often should one do something about the hot tarballs (i.e. annlib_hot.tar.gz, boost_hot.tar.gz, and scons_hot.tar.gz)? XXX See also Nick’s note at the end of document about the New framework for specifying crystal targets. --&amp;gt;&lt;/div&gt;</summary>
		<author><name>Aaron</name></author>
	</entry>
	<entry>
		<id>http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=LB67_Thermolysin&amp;diff=1743</id>
		<title>LB67 Thermolysin</title>
		<link rel="alternate" type="text/html" href="http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=LB67_Thermolysin&amp;diff=1743"/>
		<updated>2026-08-18T23:12:04Z</updated>

		<summary type="html">&lt;p&gt;Aaron: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Archived}}&lt;br /&gt;
&lt;br /&gt;
A short tutorial for processing thermolysin data from LB67 with a gain mask applied.  The data for this tutorial is at /reg/d/psdm/cxi/cxi84914/xtc/e350.  Config files and phil files are available at /reg/d/psdm/cxi/cxi84914/scratch/cctbx-tutorial/lb67thermolysin.&lt;br /&gt;
&lt;br /&gt;
IMPORTANT.  Throughout this tutorial and in the config and phil files referenced, we are using $USER to represent your username.  This will substitute your username in the command line, but not in the phil or config files.  Be sure to replace $USER with your username in the config and phil files.&lt;br /&gt;
&lt;br /&gt;
== Dark average ==&lt;br /&gt;
&lt;br /&gt;
First off, use mod_average to make a dark from LB67 run 24.  Copy dark.cfg from /reg/d/psdm/cxi/cxi84914/scratch/cctbx-tutorial/lb67thermolysin into your myrelease folder.  Then, from the myrelease folder, submit the averaging job: &lt;br /&gt;
 cxi.lsf -c dark.cfg -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages -x cxi84914 -r 24 -s -q psanacsq -p 6 -i /reg/d/psdm/cxi/cxi84914/xtc/e350&lt;br /&gt;
&lt;br /&gt;
You can track the progress of your job using a command like this:&lt;br /&gt;
 tail -f /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/r0024/000/stdout/sNN.out&lt;br /&gt;
&lt;br /&gt;
When the average is complete, you can inspect them thusly:&lt;br /&gt;
 cctbx.image_viewer /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/r0024/000/out/*&lt;br /&gt;
&lt;br /&gt;
Nine images are created, 3 for each of the front CSPAD (Ds1), the back CSPAD (Dsd) and the XES spectrometer that was attached to this experiment (Sc1).  For each detector the average (avg), standard deviation (stddev) and maximum projection (max) are created.&lt;br /&gt;
&lt;br /&gt;
== Gain map ==&lt;br /&gt;
&lt;br /&gt;
As is likely clear from examining the averages for the Ds1 detector, during this experiment a gain mask was applied.  At high resolution, the individual pixels were set in high gain mode (more sensitive to photons) and the low resolution pixels were set to low gain mode (low sensitivity to photons).   This allows more accurate recording of low resolution reflections without saturating the pixels, while preserving the ability to record weak data at high resolution.&lt;br /&gt;
&lt;br /&gt;
We treat this data by multiplying the low gain pixels by a constant factor to put them on the same scale as the high gain pixels.  To do this we apply a mask.  To generate this mask, we need to convert the raw mask used by the beamline operator to a format usable to cctbx.xfel.  First, let&#039;s extract some useful information from one of the dark averages:&lt;br /&gt;
&lt;br /&gt;
 cxi.print_pickle /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/r0024/000/out/avg-Ds1-r0024.pickle&lt;br /&gt;
&lt;br /&gt;
 Detector format version: CXI 8.2&lt;br /&gt;
 DISTANCE 378.0042&lt;br /&gt;
 DETECTOR_ADDRESS CxiDs1-0|Cspad-0&lt;br /&gt;
 SIZE1 1765&lt;br /&gt;
 SIZE2 1765&lt;br /&gt;
 TIMESTAMP 2014-03-06T00:05Z19.502&lt;br /&gt;
 CCD_IMAGE_SATURATION 16383&lt;br /&gt;
 SATURATED_VALUE 16383&lt;br /&gt;
 64 active areas, first one:  [715, 439, 909, 624]&lt;br /&gt;
 PIXEL_SIZE 0.11&lt;br /&gt;
 BEAM_CENTER_Y 96.965825&lt;br /&gt;
 BEAM_CENTER_X 96.99305&lt;br /&gt;
 WAVELENGTH 1.75860511344&lt;br /&gt;
 xtal_target None&lt;br /&gt;
 DATA len=3115225 max=16383.000000 min=0.000000&lt;br /&gt;
 SEQUENCE_NUMBER 0&lt;br /&gt;
&lt;br /&gt;
We will use some of the information here to convert the gain mask to cctbx.xfel format.  Copy the file cxib6714_1.gain from /reg/d/psdm/cxi/cxi84914/scratch/cctbx-tutorial/lb67thermolysin to your myrelease folder, then run:&lt;br /&gt;
 cxi.gain_map -o cxib6714_1.pickle -d 378 -w 1.75860511344 cxib6714_1.gain -f &amp;quot;CXI 8.2&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Here -o is the output file name, -d is the distance, -w is the wavelength and -f is the detector format version.  You can view the resultant cxib6714_1.pickle with cctbx.image_viewer&lt;br /&gt;
&lt;br /&gt;
Finally, we test the map is working using a light average.  Copy average.cfg from /reg/d/psdm/cxi/cxi84914/scratch/cctbx-tutorial/lb67thermolysin to your myrelease directory.  Make sure the paths to the dark average and standard deviation are correct, as well as the gain maak pickle file.  Submit the averaging job:&lt;br /&gt;
 cxi.lsf -c cxi84914/average.cfg -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages -x cxi84914 -r 25 -s -q psanacsq -p 8 -i /reg/d/psdm/cxi/cxi84914/xtc/e350&lt;br /&gt;
&lt;br /&gt;
Again, you can follow the log file and view the result as describe above.&lt;br /&gt;
&lt;br /&gt;
== Indexing ==&lt;br /&gt;
&lt;br /&gt;
Now that the darks and gain mask are in place, the data is indexed straightforwardly.  Copy all the phil files and LB67-thermolysin.cfg to your myrelease folder, then submit the indexing job:&lt;br /&gt;
&lt;br /&gt;
 cxi.lsf -c LB67-thermolysin.cfg -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/thermolysin -p 16 -q psanacsq -r 25 -x cxi84914 -i /reg/d/psdm/cxi/cxi84914/xtc/e350&lt;br /&gt;
&lt;br /&gt;
You can follow the log of one of the streams using&lt;br /&gt;
 tail -f /reg/d/psdm/cxi/cxi84914/scratch/$USER/thermolysin/r0024/000/stdout/s00.out&lt;br /&gt;
&lt;br /&gt;
Individual indexed frames will be deposited in /reg/d/psdm/cxi/cxi84914/scratch/$USER/thermolysin/r0024/000/out and the integrated results will be in /reg/d/psdm/cxi/cxi84914/scratch/$USER/thermolysin/r0024/000/integration.  For the parameters provided, around 1923 indexed images are expected.&lt;br /&gt;
&lt;br /&gt;
== Discovery ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;UNDER CONSTRUCTION&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The indexing results above present already optimized processing parameters.  The user will need to explore their data, testing a variety of parameters to extract the best reduced signal.  Over the next few sections, techniques for discovering necessary parameters are presented.&lt;br /&gt;
&lt;br /&gt;
=== Detector distance ===&lt;br /&gt;
&lt;br /&gt;
The best way to be sure your detz offset is correct is through a series of trials, testing different values.  Create a dist_trials directory in your myrelease folder.  cd into it, then generate config files with different candidate detz offsets, thusly:&lt;br /&gt;
&lt;br /&gt;
 for i in `seq 565 580`; do vi -c &amp;quot;%s/578/$i/g&amp;quot; -c &amp;quot;w LB67-thermolysin_$i.cfg&amp;quot; \&lt;br /&gt;
 -c q\! ../LB67-thermolysin.cfg ; done&lt;br /&gt;
&lt;br /&gt;
Here, a vi command is executed repeatedly that searches for the number 578 in your config file and replaces it with a number from 565 to 580, then writes out the new file with an appropriate file name.  If this seems like a poor window to search, note that the number was originally 572, and has already been optimized to 578 by the authors.&lt;br /&gt;
&lt;br /&gt;
Next, submit indexing jobs for each candidate detz offset from your myrelease folder:&lt;br /&gt;
&lt;br /&gt;
 for i in `seq 565 580`; do cxi.lsf -c dist_trials/LB67-thermolysin_$i.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxib6714/ftc/$USER/dist_trials/ -x cxib6714 -r 30 -q psanacsq -p 8 -t $i; done&lt;br /&gt;
&lt;br /&gt;
When complete, go to your results directory:&lt;br /&gt;
 cd /reg/d/psdm/cxi/cxib6714/scratch/$USER/dist_trials/r0025&lt;br /&gt;
&lt;br /&gt;
Then determine which detz offset is best:&lt;br /&gt;
 for i in `ls`; do echo -n &amp;quot;$i &amp;quot;; ls $i/out | wc -l; done&lt;br /&gt;
&lt;br /&gt;
=== Find candidate hits ===&lt;br /&gt;
&lt;br /&gt;
=== Spotfinding grid searches ===&lt;/div&gt;</summary>
		<author><name>Aaron</name></author>
	</entry>
	<entry>
		<id>http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=L498_Thermolysin&amp;diff=1742</id>
		<title>L498 Thermolysin</title>
		<link rel="alternate" type="text/html" href="http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=L498_Thermolysin&amp;diff=1742"/>
		<updated>2026-08-18T23:11:51Z</updated>

		<summary type="html">&lt;p&gt;Aaron: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Archived}}&lt;br /&gt;
&lt;br /&gt;
In this tutorial, we assume that we are handed an SFX dataset containing thermolysin diffraction, but are not told anything else.  We will have to go through all the data runs, figure out which one is to be used for dark subtraction, and account for untrusted pixels and detector metrology.  At this point, we will be prepared to integrate and merge the data.  Finally, we will perform simple molecular replacement and ask whether there is any Zn signal in the anomalous difference Fourier. &lt;br /&gt;
&lt;br /&gt;
=Discovery of data collection parameters=&lt;br /&gt;
Log in to pslogin.slac.stanford.edu, and then to psana.  Carry through flags so that X-windows will work&lt;br /&gt;
&lt;br /&gt;
 ssh -YAC $USER@pslogin.slac.stanford.edu&lt;br /&gt;
 ssh -YAC psana&lt;br /&gt;
&lt;br /&gt;
Go in to the working directory and source the package manager:&lt;br /&gt;
&lt;br /&gt;
 cd ~/myrelease&lt;br /&gt;
 sit_setup&lt;br /&gt;
&lt;br /&gt;
Create a subdirectory for the 2014 tutorial files if not already done:&lt;br /&gt;
 mkdir -p cxi84914&lt;br /&gt;
&lt;br /&gt;
List out the thermolysin XTC files:&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/xtc/e157&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Notice that there are numerous runs in the directory.  Now we will create composite averages for each run.  Grab this configuration file: [[mkdark.cfg]] and put it in your cxi84914 directory.  For one run only:&lt;br /&gt;
&lt;br /&gt;
 cxi.lsf -c ~/myrelease/cxi84914/mkdark.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e157/ \&lt;br /&gt;
 -i /reg/d/psdm/cxi/cxi84914/xtc/e157 -q psanacsq -s -p 8 -x 157 -r 16 -t 0&lt;br /&gt;
Take note:&lt;br /&gt;
* -c configuration file&lt;br /&gt;
* -o output directory (will be created)&lt;br /&gt;
* -i input files (directory containing the XTC streams)&lt;br /&gt;
* -q which batch queue to use&lt;br /&gt;
* -s funnel all streams for the run into one node (takes longer, but necessary for averaging)&lt;br /&gt;
* -p number of cores to use on the node&lt;br /&gt;
* -x which experiment number&lt;br /&gt;
* -r which run number&lt;br /&gt;
* -t which processing trial (auto increments from 0 if not given)&lt;br /&gt;
&lt;br /&gt;
For all the runs in the thermolysin data set:&lt;br /&gt;
 kinit&lt;br /&gt;
 aklog&lt;br /&gt;
 for m in 16 17 18 19 20 21 22 23 24 25 26 27 31 71 72 73; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkdark.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e157/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e157 -q psanacsq -s -p 8 -x 157 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
bjobs lists all your batch jobs; use this form for more information including other-user load:&lt;br /&gt;
 bjobs -w -u all -q psanacsq&lt;br /&gt;
 bkill [number] # stops unwanted job&lt;br /&gt;
&lt;br /&gt;
Some runs take up to 2 hrs wall time to average.  Find the averages, view the max-composites, and list out header information:&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e157/r*/000/out/*.pickle&lt;br /&gt;
 cctbx.image_viewer `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e157/r*/000 -name &amp;quot;max*.pickle&amp;quot;`&lt;br /&gt;
 for m in `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e157/r*/000 -name &amp;quot;max*.pickle&amp;quot;`; &lt;br /&gt;
  do echo $m; cxi.print_pickle $m; echo; done&lt;br /&gt;
&lt;br /&gt;
Let&#039;s make a table of the results:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Run&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Distance&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Wavelength&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Diffraction&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Comments&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Events&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Wall clock &amp;lt;br&amp;gt; 000 psanacsq &amp;lt;br&amp;gt; 6 cores&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Wall clock &amp;lt;br&amp;gt; 001 psanaq &amp;lt;br&amp;gt; 6 cores&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 16&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 271.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.2686&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 39313&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 60:36&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 36:20&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 17&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 221.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.2686&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 66647&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 72:32&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 62:16 &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 18&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 221.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.2686&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 47297&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 77:21&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 45:28&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 19&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 221.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.2686&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 20&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 221.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.2686&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 21&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 171.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.2686&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| shadow&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 22&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 171.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.2686&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| shadow&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 23&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 171.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.2686&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| shadow&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 24&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 171.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.2686&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| shadow&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 25&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 171.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.2686&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| shadow&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 26&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 171.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.2686&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| shadow&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 27&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 171.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.2686&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| shadow&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 31&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 570.9&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.2686&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 71&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 271.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.2966&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 72&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 131.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.2966&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| shadow&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 73&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 131&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.2966&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| shadow&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Some conclusions: &lt;br /&gt;
&lt;br /&gt;
* Run 31 was the dark run.  We&#039;ll use the average and standard deviation for further processing.  Tutorial students can take result from the instructor&#039;s directory:&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/nksauter/initial_dark/e157/r0031/000/out/avg-r0031.pickle&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/nksauter/initial_dark/e157/r0031/000/out/stddev-r0031.pickle&lt;br /&gt;
&lt;br /&gt;
* We are interested in getting the Zn anomalous signal from thermolysin, therefore we&#039;ll discard runs 71-73 collected at 1.2966 Angstroms, lower energy than the Zn K-edge at 9659 eV or 1.2836 Angstroms.  See the [http://xdb.lbl.gov  X-ray handbook].&lt;br /&gt;
&lt;br /&gt;
* We&#039;ll also discard run 16 as the diffraction was relatively weak and the unique detector distance would require separate detector calibration.  &lt;br /&gt;
&lt;br /&gt;
* We&#039;ll accept runs 17-20 (&amp;quot;calibration17&amp;quot;), and runs 21-27 (&amp;quot;calibration21&amp;quot;).&lt;br /&gt;
&lt;br /&gt;
=Prepare to mask out the untrusted pixels=&lt;br /&gt;
We&#039;ll now calculate dark-subtracted averages.  &lt;br /&gt;
 for m in 17 18 19 20 21 22 23 24 25 26 27; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkavg_e157.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e157/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e157 -q psanacsq -s -p 8 -x 157 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
This repeats exactly the same averaging calculations as before, except the dark average from run 31 is subtracted.  &lt;br /&gt;
The dark image to be subtracted (along with its std deviation) is defined in the configuration file [[mkavg_e157.cfg]].&lt;br /&gt;
&lt;br /&gt;
Now we&#039;ll figure out which pixels are untrusted, and thus should not be integrated.  Three criteria will be used:&lt;br /&gt;
* Hot pixels--on the average-dark the pixel values exceed 1350 (should be fine tuned by inspecting the dark &amp;amp; using trial and error)&lt;br /&gt;
* Hot pixels--on the standard deviation-dark the stddev exceeds 5 and therefore unreliable (also should be fine tuned by trial and error)&lt;br /&gt;
* Cold pixels or shadows--on a maximum-composite data image, inspect values and set a minimum threshold value (we choose 20 here)&lt;br /&gt;
&lt;br /&gt;
 cxi.make_mask -v --maxproj_min 20 --avg_max 1350 --stddev_max 5 --output mask_base.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e157/r0031/000/out/avg-r0031.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e157/r0031/000/out/stddev-r0031.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e157/r0020/000/out/max-r0020.pickle&lt;br /&gt;
&lt;br /&gt;
Inspect the mask:&lt;br /&gt;
 cctbx.image_viewer mask_base.pickle show_untrusted=true&lt;br /&gt;
&lt;br /&gt;
Simple thresholding wasn&#039;t sufficient for capturing some shadow areas and also an apparent untrusted region in one of the ASICs.  Calculate some additional masks using the polygon feature; tied to our current metrology.  Reading off polygon vertices from the cctbx.image_viewer, be sure to read coordinates as fast,slow (reverse order).&lt;br /&gt;
&lt;br /&gt;
 cxi.make_mask -v --poly_mask=1258,83,1148,9,1258,9 --output=mask_inactive.pickle -a 3000 -s 100 -m 0 \&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e157/r0031/000/out/avg-r0031.pickle \&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e157/r0031/000/out/stddev-r0031.pickle \&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e157/r0020/000/out/max-r0020.pickle&lt;br /&gt;
&lt;br /&gt;
Shadow on runs 17-20:&lt;br /&gt;
&lt;br /&gt;
 cxi.make_mask -v --poly_mask=915,1696,712,1719,506,1750,915,1750 --output=mask_shadow17.pickle -a 3000 -s 100 -m 0 \&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e157/r0031/000/out/avg-r0031.pickle \&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e157/r0031/000/out/stddev-r0031.pickle \&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e157/r0020/000/out/max-r0020.pickle&lt;br /&gt;
&lt;br /&gt;
Shadow on runs 21-27:&lt;br /&gt;
 cxi.make_mask -v  --output=mask_shadow21.pickle -a 3000 -s 100 -m 0 \&lt;br /&gt;
  --poly_mask=1741,1536,1540,1518,1331,1506,1120,1505,918,1515,712,1550,496,1576,286,1629,86,1685,86,1754,1741,1754 \&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e157/r0031/000/out/avg-r0031.pickle \&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e157/r0031/000/out/stddev-r0031.pickle \&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e157/r0021/000/out/max-r0021.pickle&lt;br /&gt;
&lt;br /&gt;
Combine three masks together for runs 17-20:&lt;br /&gt;
 cxi.or_mask mask_base.pickle mask_inactive.pickle mask_shadow17.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e157/mask_calibrate17.pickle&lt;br /&gt;
&lt;br /&gt;
Combine three masks together for runs 21-27:&lt;br /&gt;
 cxi.or_mask mask_base.pickle mask_inactive.pickle mask_shadow21.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e157/mask_calibrate21.pickle&lt;br /&gt;
&lt;br /&gt;
=Correct the detector metrology=&lt;br /&gt;
Accurate data integration requires highly precise knowledge of pixel positions in laboratory space (metrology).  Gaining this knowledge is especially difficult due to the [[CSPAD Pattern | segmented nature of the CSPAD detector]], which is tiled into 64 application-specific integrated circuits (ASICs).  The 64 ASICs are arranged in quadrants that are approximately 4-fold rotationally symmetric, with 8 sensors per quadrant and 2 ASICs per sensor.   The sensors are field-serviceable, and may therefore change from Run to Run.     &lt;br /&gt;
&lt;br /&gt;
We thus need to determine positions and rotations for all 64 tiles, ideally down to an accuracy on order of 10 microns. As a general overview, cctbx takes the following steps:&lt;br /&gt;
&lt;br /&gt;
* Tile placement in physical space is measured by the beamline operators optically using electron microscopy.  This is done at the per-sensor level (2 ASICs per sensor).  This is already hard-coded; nothing for the user to do.&lt;br /&gt;
&lt;br /&gt;
* Relative positions of the quadrants are determined coarsely by considering powder rings.  &lt;br /&gt;
&lt;br /&gt;
* Sensor positions are refined based on Bragg spot diffraction, allowing for whole-pixel translations in x and y.&lt;br /&gt;
&lt;br /&gt;
* ASIC positions are refined to subpixel accuracy based on Bragg diffraction, allow for sub-pixel translations and rotations.&lt;br /&gt;
&lt;br /&gt;
==Quadrant positions==&lt;br /&gt;
The electron microscopy step above determines only the sensor positions relative to the frames of reference of each quadrant; but not the absolute position of each quadrant in space.  At the CXI instrument, the forward detector DS1 has rail-mounted quadrants to allow re-sizing of the central hole.  The quadrant placement should be assessed for both the forward and back (DS2) detectors.  &lt;br /&gt;
&lt;br /&gt;
For thermolysin we examine one of the strong images (maximum composite).  Students may use the instructor&#039;s files ($USER=nksauter).  We first determine that our image has a timestamp that identifies it within cctbx as being from run 5 (2011):&lt;br /&gt;
&lt;br /&gt;
 cxi.print_pickle /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e157/r0021/000/out/max-r0021.pickle &lt;br /&gt;
  &amp;gt; Detector format version: CXI 5.1&lt;br /&gt;
 cxi.detector_format_versions&lt;br /&gt;
 cxi.detector_format_versions &amp;quot;CXI 5.1&amp;quot;&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e157/r0021/000/out/max-r0021.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 5.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=94,94,130.8,90,90,120 viewer.calibrate_unitcell.spacegroup=P6122&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;Settings&amp;quot; GUI panel shows detector distance as well as the hard-coded quadrant positions corresponding to &amp;quot;CXI 5.1&amp;quot;, namely -3,-1,-1,-5,-13,2,-7,-4.  Tile translations have been zeroed out in the code. The settings can be changed in the panel, or alternately given as a separate command line parameter (distl.quad_translations=-3,-1,-1,-5,-13,2,-7,-4).  The object is to align the powder pattern with the predicted rings (red circles) based on the unit cell parameters.  It can be seen that the alignment is not quite perfect.&lt;br /&gt;
&lt;br /&gt;
Since we have well-formed powder rings, we can run the automatic quadrant positioning tool:&lt;br /&gt;
&lt;br /&gt;
 cspad.quadrants /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e157/r0021/000/out/max-r0021.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 5.1&amp;quot;&lt;br /&gt;
 &amp;gt; The NEW QUAD translations are: [-4, -4, -1, -7, -13, 1, -7, -6]&lt;br /&gt;
&lt;br /&gt;
Try a few different max-composites from runs 21-24:&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [-4, -5, -2, -7, -12, 0, -7, -5]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [-3, -4, -1, -7, -12, 0, -7, -5]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [-3, -3, -4, -6, -12, 0, -7, -5]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [-3, -3, -1, -7, -11, 0, -6, -3]&lt;br /&gt;
&lt;br /&gt;
These can be pasted on to the command line for graphical review:&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e157/r0021/000/out/max-r0021.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 5.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=94,94,130.8,90,90,120 viewer.calibrate_unitcell.spacegroup=P6122 \&lt;br /&gt;
  distl.quad_translations=-3,-4,-3,-7,-12,0,-7,-5&lt;br /&gt;
&lt;br /&gt;
This looks slightly better.  From the GUI it also appears that distance=176 fits better than distance=171; meaning that the detz_offset for the configuration file should be 576, not 571.&lt;br /&gt;
&lt;br /&gt;
==Unit-pixel tile positions==&lt;br /&gt;
Now we will index the data to derive model lattices.  [The configuration file [[L498-thermolysin-17.cfg]] names our phil parameter file [[L498-thermolysin-t000.phil]] (t000 means trial 0)].  We&#039;ll then compare model and observation, from which we can deduce better metrology.&lt;br /&gt;
&lt;br /&gt;
 for m in 17 18 19 20; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/L498-thermolysin-17.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e157/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e157 -q psanacsq -p 8 -x 157 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
 for m in 21 22 23 24 25 26 27; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/[[L498-thermolysin-21.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e157/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e157 -q psanacsq -p 8 -x 157 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
 bkill 0 # stop all jobs; wrong file path&lt;br /&gt;
&lt;br /&gt;
A quick command to count how many integration files there are:&lt;br /&gt;
 for m in `seq 17 27`; \&lt;br /&gt;
 do echo $m `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e157/r00$m/000/integration -name &amp;quot;int*.pickle&amp;quot;|wc -l` ; done; \&lt;br /&gt;
 find /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e157/*/000/integration -name &amp;quot;int*.pickle&amp;quot;|wc -l&lt;br /&gt;
&lt;br /&gt;
Determine whole-pixel translations for all sensors on the CSPAD.  &lt;br /&gt;
 cspad.metrology data=/reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e157/r*/000/integration bravais_setting_id=12 max_frames=1000 min_count=25 detector_format_version=&amp;quot;CXI 5.1&amp;quot; cxi84914/L498-thermolysin-t000.phil | tee L498-17-t000.unit&lt;br /&gt;
List out the new unit translations:&lt;br /&gt;
 cat L498-17-t000.unit |grep -A21 &amp;quot;Unit translations&amp;quot;&lt;br /&gt;
Results from three refinement cycles are listed; capture the last one and incorporate it into a new version of the integration phil file, [[L498-thermolysin-t001.phil]].  Also in this phil file, for the next integration round we&#039;ll increase our integration limits (3 places) to 1.8 Angstroms.  After editing the configuration file to use this new phil file, submit the new round of integration jobs.&lt;br /&gt;
&lt;br /&gt;
For the purpose of the tutorial, we&#039;ll drop runs 17-20 since they contribute only 1095 lattices compared with &amp;gt;18000 for runs 21-27.  Fine-tuning of the metrology for runs 17-20 would have to be performed separately since the detector is at a different distance.&lt;br /&gt;
&lt;br /&gt;
 for m in 21 22 23 24 25 26 27; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/L498-thermolysin-21.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e157/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e157 -q psanacsq -p 8 -x 157 -r ${m} -t 1; done&lt;br /&gt;
&lt;br /&gt;
Another round of metrology refinement, this time using trial 001 as the basis:&lt;br /&gt;
 cspad.metrology data=/reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e157/r002[1-7]/001/integration bravais_setting_id=12 max_frames=1000 min_count=25 detector_format_version=&amp;quot;CXI 5.1&amp;quot; cxi84914/L498-thermolysin-t001.phil | tee L498-21-t001.unit&lt;br /&gt;
&lt;br /&gt;
…proving we have not yet converged.  Take this output and construct trial 002: [[L498-thermolysin-t002.phil]]; edit the *.cfg file. Submit another round of integration jobs:&lt;br /&gt;
 for m in 21 22 23 24 25 26 27; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/L498-thermolysin-21.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e157/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e157 -q psanacsq -p 8 -x 157 -r ${m} -t 2; done&lt;br /&gt;
&lt;br /&gt;
Evaluate metrology again:&lt;br /&gt;
 cspad.metrology data=/reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e157/r002[1-7]/002/integration bravais_setting_id=12 max_frames=1500 min_count=25 detector_format_version=&amp;quot;CXI 5.1&amp;quot; cxi84914/L498-thermolysin-t002.phil | tee L498-21-t002.unit&lt;br /&gt;
&lt;br /&gt;
==Add sub-pixel corrections== &lt;br /&gt;
There are negligible changes in the unit-translations (non-zero only at large radius), and the rmsd is now 0.96 pixels.  We&#039;ll leave the unit-translations exactly where they are now, and add subpixel translations and rotations to the phil file.  These are taken from the very end of the log file (L498-21-t002.unit).  Incorporate these into [[L498-thermolysin-t003.phil]].&lt;br /&gt;
&lt;br /&gt;
=Integrate the data=&lt;br /&gt;
We&#039;re ready for the final integration trial, which will be t003.  Again edit the configuration file L498-thermolysin-21.cfg so that it points to the latest phil file, L498-thermolysin-t003.phil.  Submit integration jobs:&lt;br /&gt;
 for m in 21 22 23 24 25 26 27; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/L498-thermolysin-21.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e157/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e157 -q psanacsq -p 8 -x 157 -r ${m} -t 3; done&lt;br /&gt;
&lt;br /&gt;
…19980 lattices indexed and integrated.  If the second lattice is desired (about 10% of images have two) set indexing.outlier_detection.switch=True in the phil file, and integrate again &amp;lt;em&amp;gt; under a new trial number (-t 4)&amp;lt;/em&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Trial 005: Try first-lattice again, correcting an omission of the mask_pixel_value=-2 phil parameter in trial 003.&lt;br /&gt;
&lt;br /&gt;
…19987 lattices indexed and integrated in trial 005.&lt;br /&gt;
&lt;br /&gt;
=Merge the data=&lt;br /&gt;
on pslogin, download the reference structure 2tli from the pdb (must be done on pslogin, the only outward-facing host).  2tli.pdb will be used for per-image scaling; 2tli.mtz will be used for reporting correlation to isomorphous synchrotron data.&lt;br /&gt;
&lt;br /&gt;
 phenix.fetch_pdb --mtz 2tli&lt;br /&gt;
&lt;br /&gt;
back to psana.  Get the command file [[mergethermo.csh]]. &lt;br /&gt;
 mkdir /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/e157&lt;br /&gt;
 cd /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/e157&lt;br /&gt;
 ./mergethermo.csh&lt;br /&gt;
&lt;br /&gt;
[[mergethermo.log | Log file]]&lt;br /&gt;
&lt;br /&gt;
[[mergethermo005.log | Better log file from trial 005--using untrusted pixel mask]]&lt;br /&gt;
&lt;br /&gt;
=Solve the structure=&lt;br /&gt;
&lt;br /&gt;
Some quick commands to evaluate the data.  Here the result *.mtz files must be moved back to your $HOME directory and transferred to your laptop to run PHENIX:&lt;br /&gt;
&lt;br /&gt;
 cp /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/e157/thermoanom_2tli_s0_mark0.mtz $HOME&lt;br /&gt;
 cp /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/e157/thermonoanom_2tli_s0_mark0.mtz $HOME&lt;br /&gt;
&lt;br /&gt;
Always use the &amp;quot;s0&amp;quot; files; &amp;quot;s1&amp;quot; and &amp;quot;s2&amp;quot; are the semi-datasets used only to calculate CC1/2.&lt;br /&gt;
 phenix.fetch_pdb --mtz 2tli&lt;br /&gt;
 phenix.xtriage thermonoanom_2tli_s0_mark0.mtz scaling.input.xray_data.obs_labels=Iobs &amp;gt; triage_noanom.log&lt;br /&gt;
&lt;br /&gt;
Wilson B factor:14.8&lt;br /&gt;
&lt;br /&gt;
 phenix.automr 2tli.pdb thermonoanom_2tli_s0_mark0.mtz seq_file=2tli.fa identity=100 copies=1 build=False&lt;br /&gt;
&lt;br /&gt;
The MR-placed model is in ./AutoMR_run_1_/MR.1.pdb.&lt;br /&gt;
&lt;br /&gt;
Obtain the set of R-free-flags used in the Nature Methods paper&lt;br /&gt;
 wget http://cci.lbl.gov/publications/download/4ow3_original_iobs_flags.mtz&lt;br /&gt;
&lt;br /&gt;
Refine the model&lt;br /&gt;
 phenix.refine ./AutoMR_run_1_/MR.1.pdb refinement.output.prefix=001 \&lt;br /&gt;
  xray_data.file_name=thermonoanom_2tli_s0_mark0.mtz \&lt;br /&gt;
  xray_data.r_free_flags.file_name=4ow3_original_iobs_flags.mtz \&lt;br /&gt;
  xray_data.r_free_flags.label=R-free-flags \&lt;br /&gt;
  main.number_of_macro_cycles=6 optimize_xyz_weight=True \&lt;br /&gt;
  optimize_adp_weight=True nproc=20 refinement.input.xray_data.labels=IMEAN \&lt;br /&gt;
  ordered_solvent=true ordered_solvent.mode=every_macro_cycle&lt;br /&gt;
trial 003: RWORK = 23.1% RFREE = 26.5% out to 2.1 Angstrom&lt;br /&gt;
&lt;br /&gt;
trial 005: RWORK = 22.0% RFREE = 26.3% out to 2.1 Angstrom (taking untrusted pixels into account)&lt;br /&gt;
&lt;br /&gt;
Run an ersatz script (provided by Nat Echols) to measure the peak heights of the anomalous scatterers.&lt;br /&gt;
&lt;br /&gt;
 libtbx.python [[map_height_at_atoms.py]] \&lt;br /&gt;
  001_001.pdb thermoanom_2tli_s0_mark0.mtz \&lt;br /&gt;
  input.xray_data.labels=Iobs \&lt;br /&gt;
  xray_data.r_free_flags.file_name=4ow3_original_iobs_flags.mtz \&lt;br /&gt;
  xray_data.r_free_flags.label=R-free-flags&lt;br /&gt;
&lt;br /&gt;
Promising results for the Zn and one Ca:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pdb=&amp;quot;ZN    ZN A 317 &amp;quot; :   5.97 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 318 &amp;quot; :   0.93 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 319 &amp;quot; :   2.74 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 320 &amp;quot; :   1.08 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 321 &amp;quot; :   0.20 sigma&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Better results from trial 005:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pdb=&amp;quot;ZN    ZN A 317 &amp;quot; :   7.66 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 318 &amp;quot; :   1.10 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 319 &amp;quot; :   2.52 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 320 &amp;quot; :   1.40 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 321 &amp;quot; :   1.01 sigma&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Aaron</name></author>
	</entry>
	<entry>
		<id>http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Installation&amp;diff=1741</id>
		<title>Installation</title>
		<link rel="alternate" type="text/html" href="http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Installation&amp;diff=1741"/>
		<updated>2026-08-18T23:11:37Z</updated>

		<summary type="html">&lt;p&gt;Aaron: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Archived}}&lt;br /&gt;
&lt;br /&gt;
Incoming!&lt;/div&gt;</summary>
		<author><name>Aaron</name></author>
	</entry>
</feed>