## research papers

## Efficient data extraction from neutron time-of-flight spin-echo raw data

**P. A. Zolnierczuk,**

^{a}O. Holderer,^{b}S. Pasini,^{b}T. Kozielewski,^{c}L. R. Stingaciu^{d}and M. Monkenbusch^{c}^{*}^{a}Forschungszentrum Jülich GmbH, JCNS Outstation, Oak Ridge, Tennessee, USA, ^{b}Forschungszentrum Jülich GmbH, JCNS MLZ, Garching, Germany, ^{c}Forschungszentrum Jülich GmbH, JCNS-1, Jülich, Germany, and ^{d}NScD, Oak Ridge National Laboratory, Oak Ridge, TN 37831, USA^{*}Correspondence e-mail: m.monkenbusch@fz-juelich.de

Neutron spin-echo spectrometers with a position-sensitive detector and operating with extended time-of-flight-tagged wavelength frames are able to collect a comprehensive set of data covering a large range of wavevector and Fourier time space with only a few instrumental settings in a quasi-continuous way. Extracting all the information contained in the raw data and mapping them to a suitable physical space in the most efficient way is a challenge. This article reports algorithms employed in dedicated software, *DrSpine* (data reduction for spin echo), that achieves this goal and yields reliable representations of the intermediate scattering function *S*(*Q*, *t*) independent of the selected `binning'.

Keywords: neutron spin echo; NSE; spallation neutron sources; data reduction.

### 1. Introduction

High-resolution neutron spin-echo spectroscopy (NSE) was invented in the 1970s by Mezei (1972, 1980). The principle of the (various) NSE methods is to tag neutrons with a phase label (spin precession angle) in order to encode the individual velocity in the first arm of the spectrometer, and to reverse the phase manipulation in the second arm after the scattering from the sample (see Fig. 1). As NSE is a Fourier method, it yields the intermediate scattering function *S*(*Q*,*t*) = rather than *S*(*Q*, ω), where ℏω is the and *Q* is the magnitude of the scattering wavevector. This technique has become the only method that extends the energy resolution of neutron spectrometers significantly below 1 µeV, even down to neV. For example, a 1 neV energy resolution corresponds to a Fourier time of about 0.7 µs, and it can be pushed even further up to 1 µs in favorable cases. On the other hand, the accessible NSE Fourier times can reach down to a few picoseconds, which allows for the coverage of up to six orders of magnitude.

A remarkable feature of the spin-echo technique is that it is very sensitive to tiny neutron velocity changes despite a rather broad velocity spectrum of the incoming neutron beam, thereby providing sufficient scattering intensity even at the highest resolution. Thus, for a large part of applications, the NSE provides a dynamic window to the small-angle neutron scattering (SANS) regime, where by analyzing the quasi-elastic scattering one can measure the mobility of the structures that give rise to the corresponding intensity [see *e.g.* Richter *et al.* (2005)].

There are a number of NSE spectrometers at neutron sources around the world (Farago, 1997; Schleger *et al.*, 1999; Rosov *et al.*, 2000; Holderer *et al.*, 2008; Nagao *et al.*, 2006; Longeville *et al.*, 2003; Häussler *et al.*, 2007), typically now implementing position-sensitive area detectors. Some NSE instruments are installed at pulsed spallation sources, which implies operation with time-of-flight (TOF)-tagged variable-wavelength neutrons (Ohl *et al.*, 2012; Hino *et al.*, 2013). Both allow the collection of information to be boosted but require more sophisticated techniques for data reduction to efficiently arrive at the physically relevant scattering function. The discussion of these techniques is the topic of the present paper. *DrSpine*, a Fortran 2008 program that requires only minimal external dependencies, implements the procedures described here.

#### 1.1. Scattering intensities and scattering functions

The scattering intensity that is to be analyzed in order to infer the physics of the sample corresponds to the double differential ):

(Marshall & Lovesey, 1971with the scattering *N*_{a} atoms each with scattering length *b*_{a}, is given by ; alternatively, if the typical SANS description in terms of scattering length densities applies (as in most NSE applications) it rather is given by , with sample volume *V* and Φ the of the labeled (molecular) entities with scattering contrast Δρ with respect to the solvent or surrounding `matrix'. *k*_{i} and *k*_{f} are the magnitudes of the incoming and final wavevectors, **Q** = **k**_{f} − **k**_{i}, ℏω = *E*_{f} − *E*_{i} is the difference between final and incoming neutron energies, and θ is the scattering angle.

For typical NSE applications the velocity (and hence the wavevector) changes are negligible compared with the initial value, and thus the factor *k*_{f}/*k*_{i} ≃ 1 may be ignored and . The factor may have a more complicated form for complex molecular systems and is inferred from .

At full symmetry, *i.e.* exact equality of the coding/decoding field integrals before and after the sample (π-flipper), the combination of the velocity coding/decoding leads to a full recovery of the initial phase if the scattering did not change the velocity (see Fig. 1). This is called the `echo', in analogy to the Hahn spin echo first observed in nuclear magnetic resonance (Hahn, 1950). As soon as the velocity is modified in the course of the scattering process, a residual phase change is observed. Averaged over the distribution of many scattered neutrons, this results in a reduction of restored polarization [see *e.g.* Monkenbusch & Richter (2007)]:

where denotes the resolution function, is the magnetic field integral along a neutron path through the spin precession region, γ_{n} is the gyromagnetic ratio of the neutron, *m*_{n} is the neutron mass, *h* is Planck's constant and *t* is the Fourier time.

##### 1.1.1. The detector signal

The distribution of the neutron-velocity changes after the scattering from the sample is proportional to the spectral part of *S*(*Q*, ω). The related difference of accumulated (precession) angles in the coding and decoding sections of the NSE instrument in combination with the analyzer transmission finally introduces an intensity modulation with the cosine of the angle difference, leading to the detector signal

where

is the real part of the intermediate scattering function, *w*(λ − λ_{0}) is the incoming neutron wavelength distribution centered at the nominal wavelength λ_{0}, η is a factor that accounts for imperfect polarization efficiencies of the polarizer and analyzer and potential further depolarization due to imperfect flippers or sections with poor adiabaticity, and *W*(δ − Δ*J*) is the distribution of the field integral differences Δ*J* = *J*_{2} − *J*_{1} within the neutron trajectories. In other words *W* describes the field integral inhomogeneity, which is centered at the nominal field asymmetry δ. The latter is the primary parameter that is scanned during a phase scan. The width of this distribution determines the resolution and is in the range of a few µT m for a corrected (ultra)-high-resolution spectrometer. Even though the field integral deviations due to asymmetries and inhomogeneity and neutron wavelength distributions are typically not described by a Gaussian, it is instructive to approximate them as Gaussian distributions around their nominal values δ and λ_{0} with widths described by Σ and Λ, respectively: and . With these assumptions we arrive at analytical expressions that immediately reveal the salient features of the influence of these distributions on the NSE signal (for the full analysis we will go beyond that approximation). A detailed derivation of the resulting expressions is given in the supporting information. Here we quote the main results. The detector intensity *I*_{Det} depends on the (nominal) field integral *J*, the asymmetry parameter δ and the mean wavelength λ_{0}:

with the resolution function . Note that the dominant contribution to the width Σ is proportional to *J*!. Further integrating over the wavelength distribution yields

with *A* = [(2ΣΛγ_{n}*m*_{n}/*h*)^{2} + 1]^{1/2}, *Q*_{0} = *Q*(λ_{0}) and *t*_{0} = *t*(λ_{0}). For any practical purpose, *A* = 1 and thus is ignored in the *DrSpine* implementation. Under this condition [(2ΣΛγ_{n}*m*_{n}/*h*)^{2} ≪ 1] the echo shape can also be taken as the cosine Fourier transform (CFT) of the wavelength distribution *w*(λ − λ_{0}). In equation (7) the CFT for a narrow rectangular wavelength slice corresponding to a TOF bin will be used. 〈*S*(*Q*)〉 ≃ *S*[*Q*(θ, λ_{0})] denotes the average of *S*(*Q*) over the wavelength width. The higher-order terms result from the λ dependence of *t* and *Q*. Their contribution is normally very small. For the possible finer λ slicing at a pulsed source it can be further reduced to virtually zero.

##### 1.1.2. The challenges

Whereas the early spectrometers operated with only one detector (channel) and (for a given run) with a given wavelength λ_{0}, the more recent instruments are equipped with multichannel area detectors and – if situated at a pulsed source – allow for time-of-flight tagging of the wavelength. Thus, primarily, we collect raw data for a large number of detector pixels (*p*_{x}, *p*_{y}) with the effective scattering angle θ = θ(*p*_{x}, *p*_{y}) and an azimuthal angle ψ = ψ(*p*_{x}, *p*_{y}), and in addition each pixel contains counts from a range of wavelengths binned in time-of-flight channels *k*. To measure the intermediate scattering function it is further necessary to scan the coding (field integral) asymmetry δ around the symmetry point and collect counts for a number of `phase points' (δ = δ_{j}) and to extract the prefactor of , *i.e.* the echo amplitude, from it. This has to be performed for each *J*_{n} value from a list of *n* chosen values and for each value of the scattering arm θ_{m}(0, 0) and eventually for an additional selection of wavelength frames. After resolution correction and background subtraction, the thus obtained individual pixel–time-of-flight–bin bits of information have to be collected in a consistent way in order to yield the best representation of the desired intermediate scattering function *S*(*Q*, *t*) or the usual normalized form *S*(*Q*, *t*)/*S*(*Q*).

To achieve this, the appropriate contributions pertaining to a (*Q*, *t*) box must be collected and summed in a way that considers their individual information content. This ensures that a faithful representation of the *S*(*Q*, *t*)/*S*(*Q*) with the least possible error in the box range, as shown in Fig. 2, can be constructed.

A generic feature of the resolution properties is shown in Fig. 3. The echo signal from a resolution sample seen at different detector pixels, as well as the exact phase symmetry point, depends on both the value of the *J* parameter and the distance from the detector center. The loss of amplitude away from the center illustrates the limitation of the correction coils used to minimize Σ, in particular for the outskirts of the detector. At low field integrals nearly all detector pixels contain relevant information, whereas for increasing *J* the information content of the outer pixels diminishes. The goal of the presented evaluation scheme is to extract all of the available information.

Furthermore, we note that for different wavelength (bins) in the used time-of-flight-frame the single detector pixels correspond to different contributions to *S*(*Q*, *t*).

### 2. Methods

#### 2.1. Phase and resolution determination

A prerequisite to obtain the echo amplitude *a* = is the determination of the true symmetry point δ = 0 with respect to the asymmetry parameter of the instrument setting (*i.e.* the phase coil current). Furthermore, the resolution factor must be known in order to extract *S*(*Q*, *t*) from the echo amplitudes. For that purpose a reference experiment on a sample which effectively experiences only has to be performed. This serves to fix the true symmetry point, to determine the resolution and possibly also as a secondary calibration standard. The dependence of the echo oscillations on wavelength and asymmetry are illustrated in Fig. 4.

From equation (5) it is obvious that, for a single defined wavelength [*i.e.* *w*(λ − λ_{0}) = δ(λ − λ_{0})] and for a reference sample with *S*(*Q*, *t*) = *S*(*Q*) independent of *t*, the intensity variation after scanning the asymmetry (phase current) is proportional to a simple cosine function, . For such a very narrow wavelength band, the intensity modulation is simply along one horizontal line in Fig. 4. As an isolated observation this contains no clues about the actual maximum (minimum) of the true symmetry location. Considering several wavelengths, however, allows a unique identification of the symmetry location, which is characterized by the lack of dependence of the oscillation phase on λ. At continuous source experiments a 10–20% FWHM wavelength band is used. Integration thus reduces the modulation due to the obvious dephasing far from the symmetry (δ = 0). For a Gaussian wavelength distribution this leads to the echo-signal envelope factor [equation (6)] with . The latter is already a good approximation for the triangular wavelength distribution from a selector. Its exact form is given in the supporting material. At a pulsed source, the wavelength frame covered within one experimental setting is larger but with an intensity distribution far from Gaussian. Thus, for an exact representation of the envelope shape different approaches have to be used. The TOF-tagged λ distribution has a fixed absolute width limited by the frame overlap chopper system: Δλ = (*h*/*m*_{n})/(*Lf*), with *L* the source-to-detector distance and *f* the pulse repetition frequency. For the Spallation Neutron Source (SNS) NSE (Oak Ridge, TN, USA; Ohl *et al.*, 2012), depending on the chosen moderator detector distance (18, 21 or 24 m), the value is Δλ = 3.6–2.7 Å. These still comparatively small values are due to the high repetition frequency of 60 Hz. For smaller frequencies (*e.g.* at the new European Spallation Source, Lund, Sweden), Δλ ≃ 8 Å may be reached. Within the available Δλ frame one has the freedom to select arbitrary wavelength slices from the Δλ band in the frame. Thus various schemes to infer the correct symmetry location are imaginable, which utilize the fact that the location of the proper maximum must be independent of λ.

In practice, all determination schemes are limited by statistical counting errors, in particular since the determination has to be done pixel-wise. Thus the approach that proves most reliable here is to integrate over the whole frame and choose the best fit to the expected envelope. The shape of the echo signal *z*(ϕ) to be fitted reads as follows (Ohl *et al.*, 2012):

*N*_{bin} is the number of time-of-flight wavelength bins in any chosen wavelength (sub)-band, ϕλ is the phase angle with ϕ = (δ − δ_{0})γ_{n}(*m*_{n}/*h*) and the wavelength λ_{j} = λ_{min} + 2(*j* − 1)dλ. Thus Ω(ϕ) depends on the form of the normalized wavelength spectrum arriving at the detector, . This is just an implementation of the λ integration over the factor in equation (5). The intensity distribution within one TOF bin is assumed as constant and integrated, yielding the factor in equation (7). The time bin *j* nominally contains [λ_{j} − dλ, λ_{j} + dλ]. The wavelength-dependent intensity *I*_{j} is derived from the average of the detector intensity over the complete phase scan. This ensures that effects due to the implicit wavelength dependence of *S*[*Q*(λ)] are also accounted for. ϕ_{i} = *CI*_{phase,i} is proportional to the asymmetry (phase) current. Then, using the set of *N* ≥ 3 phase points ϕ_{i} and the corresponding counts *z*_{i} with statistical error δ*z*_{i}, the echo amplitude *a* can be readily computed for all λ bins for any choice of time-of-flight λ binnings after insertion of the symmetry phase Δ = δ_{0}γ_{n}(*m*_{n}/*h*), which has to be determined in a one-dimensional nonlinear optimization for Δ by minimizing the deviation

For the purpose of reliable determination of Δ it proved to be the best approach to use here data *z*_{i} that correspond to the sum over all valid TOF channels of the full wavelength frame with the associated echo-shape function Ω(ϕ). In that case the envelope of Ω(ϕ) is sufficiently peaked to discriminate the true symmetry point from solutions shifted by multiples of π in phase angle. By inserting the thus determined symmetry locations Δ, the amplitude for counts *z*_{i} obtained by any chosen wavelength binning then may readily be computed by

with the error

where ν stands for the denominator of equation (9). For the average *b*

with error

Fig. 5 illustrates how the various parameters are related to the data *z*_{i} from a phase scan and the echo shape Ω(ϕ). Note that in many cases the statistics in one pixel patch can be much worse and that the envelope modulation in λ sub-bands is less pronounced. We use the full bandwidth to determine the symmetry point because of the better definition due to the more pronounced envelope modulation and the better statistics due the inclusion of all time-of-flight channels.

The main source for the pixel-wise phase determination is the reference run. It should be performed such that the counting statistics are sufficient for phase determination and to yield resolution errors that are much smaller than the counting statistics due to the sample. The phase-map determination starts with a 4 × 4 pixel group in the center of the detector (controlled by the `r.center_size` program parameter) and then follows an outward spiral path toward the edges of the detector. Thus a smooth phase map is established, which is automatically included in the generated report (see supporting information). Subsequent echo amplitude extraction from sample and reference (and background) runs irrespective of the then possibly differently chosen TOF-channel binning rely on the thus determined phase map. This requires only direct computation using equations (9)–(12). As an option, the phase of the sample run can be checked and corrected by a global offset by minimizing the residual error (weighted sum) of all pixels as a function of an offset phase applied to the phase map as determined using the reference data. The values are always given in the automatic report. Examples are shown in Fig. 6.

For each setting of *J* and θ, detector pixels that exhibit too low a resolution or too few counts or cannot be fitted with equation (7) are flagged as `non-valid' and ignored in further steps. Note further for a reactor (steady-state) instrument the envelope width is fixed to the shape determined by the wavelength width as imposed on the incoming beam by a mechanical velocity selector (typically 10–20% FWHM). A velocity selector provides typically a triangular shaped envelope instead of a Gaussian. Both functions can be selected in the data evaluation program.

#### 2.2. Echo determination

In a first step, the pixelated reference (resolution) phase scan data have to be treated as described above to extract the exact symmetry offsets and echo amplitudes that lead to the resolution factors. Once the resolution factors and symmetry phases have been determined, the pixel- and time-of-flight-bin-wise determination of echo amplitudes *a*(*p*_{x}, *p*_{y}, *k*, θ_{0}, frame) according to equation (9) can be performed. For the SNS-NSE spectrometer, for example, the symmetry phases as determined from the reference experiment are stable and thus reliable because it has a magnetic shielding excluding external magnetic disturbance. For other instruments, such as the Jülich NSE (J-NSE), the change between reference and sample experiments is an issue and it may be necessary to readjust symmetry phases using the echo signals of the sample – as far as statistics allow. While the primary results of the symmetry scan are the echo amplitudes , the desired output in terms of *S*(*Q*, *t*) or *F*(*Q*, *t*) = *S*(*Q*, *t*)/*S*(*Q*)^{1} requires further treatment. For that purpose the maximum polarization obtainable is determined from counting results corresponding to direct scattering on the detector without any coding/decoding or polarization manipulation (`spin up'), but with the polarization analyzer in the beam, and then in the nominal blocking situation with only the π-flip (spin reversal) active (`spin down') (see *e.g.* Fig. 5). The obtained difference yields *I*_{up} − *I*_{down} ∝ η*S*(*Q*) and η = (*I*_{up} − *I*_{down})/(*I*_{up} + *I*_{down}). Thus for each pixel bin from the sample data we have

Applying this procedure to the reference sample, the corresponding resolution was obtained:

Then the resolution-corrected pixel-bin contributions and to *F*(*Q*, *t*) and *S*(*Q*, *t*) are

and

where denotes an optional (in future implementations) calibration factor (see Appendix *B*) and the sample transmission. Typically, the pixelized *f* and *s* values have sizeable statistical errors δ*f* and δ*s*. Finally, the scattering from a background sample may be subtracted pixel-bin-wise:

and

The background correction methods are discussed further in Appendix *A*.

#### 2.3. Data collection, harvesting results

After evaluation of all available NSE echo files pertaining to the sample under consideration, one can start to collect all results that contain information on *S*(*Q*, *t*) or *F*(*Q*, *t*) pertaining to specific (*Q*, *t*) pairs. For this purpose, a boxed grid for *S*(*Q*, *t*) may be defined, covering a number of *Q* and *t* slices and (see Fig. 8 among the *Examples* below).

To arrive at a representation of *S*(*Q*, *t*) with all information available, the *Q*, *t* values *Q*(*p*_{x}, *p*_{y}, *k*, θ_{0}, frame) and *t*(*p*_{x}, *p*_{y}, *k*, *J*, frame) of all available valid pixel bins are assigned to the corresponding grid box (*i*_{Q}, *j*_{t}) and the corresponding amplitude or normalized amplitude information *s* ± δ*s* or *f* ± δ*f* is added to the grid box. To do this in a way that preserves the significance of the individual contributions and does not explicitly depend on the number of contributions, we use the following scheme, which is a key method to preserve the data information content:

(1) If the grid cell is still empty, copy the value of any kind of elementary data *s*_{i} ± δ*s*_{i} derived from the contents of a contributing pixel–time-of-flight bin, *e.g.* typically *S*(*Q*, *t*) and its error, and put actual *Q* and *t* values in corresponding fields of the grid.

(2) If the grid cell already contains data *s*_{0}, δ*s*_{0} (where *s*_{i} here stands for any result in the bins to be combined, *e.g.* scattering function *s* or normalized scattering function *f* or other), insert the additional information *s*_{1}, δ*s*_{1} in the following way, where the relative weight of the added information is :

and for the errors

in parallel. Accordingly, the effective *Q* and *t* values of the grid cells are updated by adding the new values with the same weight factors as the *s* values. This weighting scheme ensures that compartmentalized counts *z*_{i} that are recombined to yield the appropriate combination factors α_{i} (*i.e.* the relative size of the compartment, *e.g.* time bin or pixel area) and the correct error, identical to what a plain summation of the original counts would yield for the resulting value and the counting-statistics-related error (see supporting information for a concise derivation). Using the same weights, the (*Q*_{i}, *t*_{i}) values of the bins are combined to yield effective centers (*Q*_{c}, *t*_{c}) associated with the corresponding histogram box. Finally a table containing the data from all nonzero grid cells can be generated and is provided as output. Examples for the resulting mapping are displayed in Fig. 8. It is obvious that the full power and validity of this method is only realized if all errors δ*s* are correctly computed and propagated from the initial count statistics.^{2}

### 3. Implementation

Basically *DrSpine* only requires a list of raw data run numbers for all relevant reference runs (flagged with role `reference'), all sample runs (role `sample') and, if present, background runs (role `background'). The data formats that can presently be read are those from SNS-NSE and J-NSE. Typically some pre-binning of detector pixels (from 1024 to 64) and (1–42) time-of-flight bins is performed during reading. The further matching of reference sample, background and evaluation to *S*(*Q*, *t*) is automatic. Within the (*Q*, *t*) regime covered by any available combination of wavelength, arm setting, pixel-dependent scattering angle and coding parameter *J*_{i}, a wide range of *Q* and *t* binning schemes can be chosen for data collection. Since the collection step typically requires not more than a few seconds, it is foreseen that in a normal procedure a selection of several (say five) standard different `default' histogramming options will be produced, reported and supplied as tables. Conversion of the report to a well formatted document requires the installation of TeX (Rahtz *et al.*, 2018).

#### 3.1. Paradigm for user support and information

Since the whole process including the generation of the report is done automatically in a few minutes even on a current personal computer with no further operator interference needed, a close monitoring of the progress of the experiment is enabled (provided the references are available). The user (novice or expert) will automatically be provided with a comprehensive report containing all references and auxiliary information of the processed files. The most important information is that on the experimental setup, the binning used and the selection of curves for *F*(*Q*, *t*) from the default histogramming schemes, which are generally fitted with general standard model curves (*e.g.* stretched exponential plus background), plus effective diffusion estimates as illustrated by Figs. 7 and 9, discussed in the next section. Only the display of the report requires TeX to be installed. Further and more sophisticated model comparisons or evaluation then have to rely on separate independent consideration of the tabulated *S*(*Q*, *t*) data in the simultaneously created (human readable) output files for all tried histogrammings.

### 4. Examples

Fig. 7 shows the results obtained for typical soft-matter samples. The curves shown are obtained for different final histogramming box settings, thus enabling us to focus on different aspects of the scattering function, for example trading statistical error versus number of different *Q* and/or *t* values, depending on the primary question to be answered. Normally this means simply choosing the results from one of the different automatically applied histogramming schemes. If needed, further custom histogramming schemes can easily be added to the evaluation.

The grouping into curves *F*(*Q*, *t*) with fixed *Q* and varying *t* is in accordance with the box histogramming. However, as Fig. 8 illustrates, the best value of *Q* may vary from the box centers. While for most applications the slight variations of *Q* with respect to the average is negligible, the most precise fitting to a model may be performed on the set {(*Q*_{i}, *t*_{j}), *F*(*Q*_{i}, *t*_{j})} with (*Q*_{i}, *t*_{j}) the star centers in Fig. 8, *i.e.* the importance-weighted (*Q*, *t*) points. This weighting is a genuine measure to ensure consistency and accuracy of the result irrespective of the details of the chosen binning.

For each of these schemes, the report contains tentative automatic fits to generic relaxation models and estimates for effective diffusion *D*_{eff}(*Q*) as an immediate guide for the user. This feature, however, depends on the applicability of the model to the actual problem. At the moment plain stretched exponentials are used with free or fixed parameters *A*, β and *B*. The lines in Fig. 7 are created by this automatic mechanism. The corresponding *D*_{eff}(*Q*) values are shown in Figs. 9 and 10. The data stem from typical soft-matter sample experiments at the SNS-NSE with time-of-flight-tagged wavelength bands (dendrimer solution) and at a continuous single-wavelength band-reactor instrument (J-NSE Phoenix, MLZ Garching; Pasini *et al.*, 2019) [sodium dodecyl sulfate (SDS) micelles in D_{2}O]. Figs. 9 and 10 display all results of the different (*Q*, *t*) binning schemes to show that all schemes yield consistent results.

The corresponding data are supplied in the output *S*(*Q*, *t*) tables.

### 5. Conclusion

With the algorithms and procedures as implemented in *DrSpine*, a unified approach to the extraction from multi-detector and multi-wavelength raw data from neutron spin-echo spectrometers at continuous and, in particular, at pulsed sources is described. The method of inverse-error-weighted (incremental) combination of results may also be applied to other raw data extractions that rely on the combination of experimental information from many bins with varying significance (sensitivity, illumination, resolution *etc.*). Using automatic matching and consistent binning, we have presented a streamlined procedure for a typical set of 10–20 raw data scans on resolution, background and sample covering several settings of nominal scattering angle and possibly subsets of the coding parameter *J* (*e.g.* from short-time and normal mode). Dynamic (error-weight-controlled) masking allows the use of each bit of information contained in the raw data sets.

### APPENDIX A

### Background subtraction

The choice of what exactly is to be considered as directly sample-related background contributions pertains to the nature of the sample and the scattering contribution that contains the desired information. Some prototypes of samples for which a corresponding distinction between signal and background can be made are, for example, macromolecular or colloidal solutions or polymer melts, where the polymer is protonated and has volume fractions ϕ between ∼2 and 20%. The majority component, *i.e.* the solvent or `matrix' polymer of the melt, is deuterated. In those cases the primary scattering signal to be analyzed is the coherent scattering function of the labeled polymer chains – as in the simple case is predicted by the Rouse dynamics (Doi & Edwards, 1994). For labeled macromolecules at low *Q* values the scattering intensity in the echo signal is dominated by the labeled (macro)molecules and conveys their dynamics. With increasing *Q*, the spin-incoherent proton scattering of the labeled compound, spin from a deuterated majority compound and multiple scattering involving large intermediate *Q* will start to significantly contribute to the echo signal. The latter certainly is to be considered as (fast) background. contributions are in principle part of the genuine scattering signal and carry dynamic information. Still, those from the solvent/matrix are background. Again their relative importance rises as *Q* increases, such that their typical contribution grows from a few percent at *Q* = 0.05 Å^{−1} to several tens of percent at *Q* = 0.2–0.3 Å^{−1}. They often have fast dynamics, most probably stemming from multiply scattered large *Q* contributions. As the source of this type of background scattering is considered to be the matrix, its contribution to the sample scattering scales with the of matrix polymer in the sample. The composition of the scattering signal containing the background described above is illustrated in Fig. 11. The fast dynamics relax the echo signal at times much lower than the smallest available NSE Fourier time (symbols indicate measured NSE points). It is obvious that extending the NSE range down by one or two orders of magnitude (short-time mode) may serve to determine the amount of fast background without additional measurement of a background sample, thus also eliminating any concerns about the actual background source.

The correction of only this type of background basically is the determination of the extrapolation of the echo intensity at τ → 0 by subtraction of the fast background component from the normalizing up–down intensity only. In the general expression for background correction, equation (17), the corresponding factor results from the modification in the denominator.

Depending on the nature of the background sample there may be scattering contributions that show a dynamic within the NSE-accessible range and/or slower components, *i.e.* a nonzero *a*_{bgr} term in the numerator of equation (17). In these cases there is a background contribution also to the echo signal.

A dynamic component with low intensity can always be attributed to the *e.g.* melt matrix or solvent). The echo-signal contribution is scaled by −1/3 and displays the dynamics of polymer segment or solvent molecule diffusion. These contributions are mostly only relevant at larger *Q* (> 0.2 Å^{−1}). The next possible source of background scattering is the sample container and possibly its immediate surroundings. Except for the subtle difference that the sample container is always present in full, it may be considered like the sample scattering. The subtle difference means that the container scattering should not be multiplied with the (1 − ϕ) factor. Note that, despite the fact that scattering from the sample environment, windows *etc*. is usually elastic, the corresponding background signal may nevertheless exhibit a kind of pseudo-dynamics, since the location of the scattering differs significantly from the nominal sample position and thus additional echo-signal loss will occur due to dephasing.

#### A1. Optimized counting time distribution

In order to determine the best distribution of a given counting time between sample and background experiments we use the following consideration: Assume that in any region of interest on the detector (and in some wavelength band) we observe counting rates *r*_{s,bgr} for the sample or background, respectively. There we will accumulate *N*_{s} = *r*_{s}*t*_{s} and *N*_{bgr} = *r*_{bgr}*t*_{bgr} counts during the sample experiment with counting time *t*_{s} and the background experiment with counting time *t*_{bgr}. Consequently, the statistical errors of these rates are

The final result of the corrected scattering rate after transmission and background subtraction follows from

and the corresponding error

After inserting δs and considering the squared error for simplicity, we find

where we set *t*_{c} as the total available counting time, distributed as *t*_{c} = *t*_{s} + *t*_{bgr} between sample and background experiment. For a coarse estimate at the time of planning the experiment, minimizing equation (24) with respect to *t*_{bgr} and assuming yields a good estimate of the optimum time fraction for background measurement:

For example, for a background amounting to 10% of the sample scattering (assuming nearly equal transmission), equation (25) yields *t*_{bgr} = *t*_{c}[(0.1)^{1/2} − 0.1]/(1 − 0.1) ≃ 0.25, *i.e.* in this case the available time for the sample and background experiments should be distributed as 3 (for sample):1 (for background) to obtain the best possible statistics within a given time slot *t*_{c} for sample and background scans.

### APPENDIX B

### Absolute calibration

As an extension, we are currently developing the procedures in which the reference samples may serve as secondary calibration standards such that the *DrSpine* program will be able to deliver in addition to the normalized *F*(*Q*, *t*) = *S*(*Q*, *t*)/*S*(*Q*) values also the *S*(*Q*, *t*) tables. The latter would have the advantage that combinations and background subtractions can be made across different experiments and even instruments. A set of well defined and preserved reference samples (needed anyway for resolution correction) may be used to serve as standards for absolute calibration. This requires a one-time measurement of dΣ(*Q*)/dΩ of these samples in absolute units on a SANS machine or diffractometer. Let us define sensitivity factors ζ_{(i, j), k(λ)} and flipping ratios (← polarization efficiencies) for each pixel and λ by using the corresponding monitor-normalized up and down intensities of the reference measurement and in order to get the pixel-bin calibration factors:

with *d*_{eff} the sample thickness and the transmission [depending on derivation of the *S*(*q*)_{Ref} data].

#### B1. Amplitude-derived *S*^{NSE}(*Q*, *t*)

In order to cope with general cases with some decoupling from the up–down normalization (*i.e.* coherent–incoherent combinations where *I*_{up} ≃ *I*_{down}) *etc*., *DrSpine* may yield an absolute calibrated

for soft-matter-type samples or

for paramagnetic samples. The collection of the pixel-bin contributions follows the same error-weighing scheme as used for the normalized NSE data. However, here we collect the calibrated and resolution-corrected amplitude values directly, which yields additional information on *S*_{coh}(*Q*, *t* = 0) and *S*_{inc}(*Q*, *t* = 0) as extracted from the up and down intensities. These values are obtained with the collected *S*^{NSE}(*Q*, *t*) spectra (for soft-matter-type problems). For paramagnetic-type samples, *S*_{paramag}(*Q*, *t* = 0) and *S*_{nuclear}(*Q*, *t* = 0) are supplied by a slightly different route.

*S*^{NSE}(*Q*, *t*) then is obtained via collection of the pixel-bin contributions:

where *a*(*i*, *j*, *k*) is the pixel-bin-associated echo amplitude and the resolution.

### APPENDIX C

### Program availability

Typical use of this front-end evaluation program is for extraction of *S*(*Q*, *t*) at the end of the experiment. For this purpose, web-based access is the standard mode of use at MLZ in Garching and at SNS in Oak Ridge. Thereby, a bundle containing a comprehensive set of tabulated *S*(*Q*, *t*) data together with a report containing all technical details of the experiment and evaluation is created, which allows for instrument-independent physical modeling and analysis. The associated report is a backup source with detailed technical information on the experiment and the role of potential disturbance by, for example, magnetic fluctuations in the environment *etc*. For an example see the supplementary material.

Offsite installation is usually not required. However, if desired it can easily be done on any modern Linux or Mac OSX system. To benefit from all possible diagnostics and plotting features, the installation of the freely available packages TeX, Python and GR-Framework (https://gr-framework.org) is required. A version that works without these packages may be built at the expense of a reduced amount of direct graphical information in the report or online plotting. Suitable Fortran and C compilers, *e.g.* the GNU suite GCC 4.8.5 or newer, are needed in order to build the executable program. The source code is available at https://jugit.fz-juelich.de/nse/drspine.

### APPENDIX D

### List of symbols

#### D1. List of symbols: main

*t*: time

ω: angular frequency

*Q*: scattering wavevector (length)

dσ/dΩd*E*_{f}: double differential scattering cross section

*b*_{a}: scattering length of atom

*N*_{a}: number of scattering atoms

*E*_{i,f}: initial or final neutron energy

*k*_{i,f}: initial or final neutron wavevector

*h* = 2πℏ: Planck constant

:

prefactor to yield the correct intensityΦ: of labeled molecules in SANS-type description of scattering

Δρ: scattering length density contrast

*S*(*Q*, ω): scattering function

*S*(*Q*, *t*): intermediate scattering function

*F*(*Q*, *t*): normalized intermediate scattering function *S*(*Q*, *t*)/*S*(*Q*)

: uncorrected pixel-bin contribution to *F*(*Q*, *t*)

: resolution-corrected pixel-bin contribution to *S*(*Q*, *t*) or *F*(*Q*, *t*)

λ, λ_{0}: neutron wavelength (actual, nominal)

*P*: neutron polarization

*B*: magnetic field

*J*: field integral along a neutron path

*m*_{n}: neutron mass

γ_{n}: gyromagnetic ratio of the neutron

: resolution (factor)

*I*_{Det}: detector (pixel, range of interest) intensity

δ: field integral asymmetry between primary and secondary arm ∝ phase coil current

δ*X*: used as prefix to *X*, δ indicates the (statistical) error of *X*

Δ*J*: field integral difference between paths in the neutron beam

*w*(λ − λ_{0}): normalized wavelength distribution of the considered neutron beam

*W*(δ − Δ*J*): distribution of field integral differences in the beam

Λ: width parameter of the λ distribution, Gaussian,

Σ: width parameter of the field integral distribution (inhomogeneity)

η: total efficiency of the polarization analysis

*A*: modification factor due to the λ dependence of ; it is set to 1 in later steps

*p*_{x}, *p*_{y}: detector pixel indices

λ_{k}: nominal wavelength of TOF channel *k*

Δλ: total width of used TOF wavelength frame

: envelope of echo shape

ϕ: phase angle/λ = (δ − δ_{0})γ_{n}*m*_{n}/*h*

Ω(ϕ): echo shape as a function of the phase variable ϕ

*z*(ϕ): count rate at phase setting ϕ

: echo amplitude

: average level of echo scan

*I*_{j}: average detector intensity for TOF channel *j*

*C*: factor between phase-coil current and field integral asymmetry (read from raw data files)

*z*_{i} = *z*(ϕ_{i}): count rate at phase scan point *i* for any pixel bin under consideration

δ*z*_{i}: statistical error of *z*_{i}

: transmission of *X* = sample, background *etc.*

: pixel-bin-related absolute calibration factor (future implementation)

#### D2. List of symbols: preliminary fitting

*D*_{eff}(*Q*): effective diffusion inferred from preliminary stretched exponential fits

β: stretching exponent in stretched exponential fits

*A*(*Q*): amplitude factor in stretched exponential fits

*B*(*Q*): constant base level in stretched exponential fits

#### D3. List of symbols: appendix

δ_{s,bgr}: statistical error for count rates from sample and background

*t*_{s,bgr}: counting time for sample and background

*t*_{c}: total (available) counting time

*R*_{corr}: resulting count rate after background subtraction

δ_{Rcorr}: error of resulting count rate after background subtraction

*d*_{eff}^{X}: thickness of *X* = sample, background *etc.*

### Supporting information

Example for an automatically generated report pertaining to the results shown in the lower part of Fig. 7. DOI: https://doi.org/10.1107/S1600576719010847/po5149sup1.pdf

Derivation of the echo expressions in Gaussian approximation, derivation of the data combination rule and comments on example report. DOI: https://doi.org/10.1107/S1600576719010847/po5149sup2.pdf

### Footnotes

^{1}In the following we use the notation *S*(*Q*, *t*) for *S*(*Q*, *t*) and *F*(*Q*, *t*), whatever applies in the context. Currently NSE evaluations are usually made to yield *F*(*Q*, *t*) = *S*(*Q*, *t*)/*S*(*Q*, 0). The *DrSpine* software has also provisions to yield *S*(*Q*, *t*).

^{2}Caveat: When combining normalized results from (binned) detector pixels to sum a quantity from pixel-wise-derived contributions over a larger detector, plain error propagation may overestimate the error. This pertains, for example, to the contribution due to statistics of the normalizing monitor values. Since monitor values are common to all detector pixels, their influence on the statistical fluctuation of normalized pixel data is correlated.

### Acknowledgements

We thank Margarita Kruteva and Albena Lederer for the permission to show data from their SNS-NSE experiment as an example.

### References

Doi, M. & Edwards, S. (1994). *The Theory of Polymer Dynamics*, International Series of Monographs on Physics, Vol. 73. Oxford University Press. Google Scholar

Farago, B. (1997). *Physica B*, **241–243**, 113–116. Web of Science CrossRef CAS Google Scholar

Hahn, E. L. (1950). *Phys. Rev.* **80**, 580–594. CrossRef Web of Science Google Scholar

Häussler, W., Gohla-Neudecker, B., Schwikowski, R., Streibl, D. & Böni, P. (2007). *Physica B*, **397**, 112–114. Google Scholar

Hino, M., Oda, T., Kitaguchi, M., Yamada, N. L., Sagehashi, H., Kawabata, Y. & Seto, H. (2013). *Phys. Proc.* **42**, 136–141. CrossRef CAS Google Scholar

Holderer, O., Monkenbusch, M., Schätzler, R., Kleines, H., Westerhausen, W. & Richter, D. (2008). *Meas. Sci. Technol.* **19**, 034022. Web of Science CrossRef Google Scholar

Lederer, A. & Kruteva, M. (2016). SNS-NSE experiment, proposal ipts-16300. Google Scholar

Longeville, S., Doster, W., Diehl, M., Gahler, R. & Petry, W. (2003). *Neutron Spin Echo Spectroscopy: Basics, Trends And Applications*, Lecture Notes in Physics, Vol. 601, pp. 325–335. Berlin, Heidelberg: Springer-Verlag. Google Scholar

Marshall, W. & Lovesey, S. W. (1971). *Theory of Thermal Neutron Scattering.* London: Oxford University Press. Google Scholar

Mezei, F. (1972). *Z. Phys.* **255**, 146–160. CrossRef CAS Web of Science Google Scholar

Mezei, F. (1980). *Neutron Spin Echo*, Lecture Notes in Physics, Vol. 128. Berlin, Heidelberg, New York: Springer. Google Scholar

Monkenbusch, M. & Richter, D. (2007). *C. R. Phys.* **8**, 845–864. Web of Science CrossRef CAS Google Scholar

Nagao, M., Yamada, N. L., Kawabata, Y., Seto, H., Yoshizawa, H. & Takeda, T. (2006). *Physica B*, **385–386**, 1118–1121. Web of Science CrossRef CAS Google Scholar

Ohl, M., Monkenbusch, M., Arend, N., Kozielewski, T., Vehres, G., Tiemann, C., Butzek, M., Soltner, H., Giesen, U., Achten, R., Stelzer, H., Lindenau, B., Budwig, A., Kleines, H., Drochner, M., Kaemmerling, P., Wagener, M., Moeller, R., Iverson, E. B., Sharp, M. & Richter, D. (2012). *Nucl. Instrum. Methods Phys. Res. Sect. A*, **696**, 85–99. Web of Science CrossRef CAS Google Scholar

Pasini, S., Holderer, O., Kozielewski, T., Richter, D. & Monkenbusch, M. (2019). *Rev. Sci. Instrum.* **90**, 043107. Web of Science CrossRef PubMed Google Scholar

Rosov, N., Rathgeber, S. & Monkenbusch, M. (2000). *Scattering From Polymers*, ACS Symposium Series, Vol. 739, pp. 103–116. Washington, DC: American Chemical Society. Google Scholar

Rahtz, S. *et al.* (2018). *TeX Live*. https://tug.org/texlive. Google Scholar

Richter, D., Monkenbusch, M., Arbe, A. & Colmenero, J. (2005). *Neutron Spin Echo in Polymer Systems*, Advances in Polymer Science, Vol. 174. Berlin: Springer. Google Scholar

Schleger, P., Ehlers, G., Kollmar, A., Alefeld, B., Barthelemy, J., Casalta, H., Farago, B., Giraud, P., Hayes, C., Lartigue, C., Mezei, F. & Richter, D. (1999). *Physica B*, **266**, 49–55. Web of Science CrossRef CAS Google Scholar

This is an open-access article distributed under the terms of the Creative Commons Attribution (CC-BY) Licence, which permits unrestricted use, distribution, and reproduction in any medium, provided the original authors and source are cited.