\subsubsection{Proposed approach for $W\rightarrow\ell\nu$ analysis at 13~TeV}
\label{sec:bkg_mj_approach}

A possible solution to some of these problems is used in Ref. \cite{Andari:1976186}: several MJ-templates are defined slicing the lepton isolation variable for values greater than the one used in the SR and progressively farther from the SR lepton selection.
The MJ extraction fit on a kinematic variable is then repeated for each of the MJ-templates corresponding to each slice.
The result is a “scan” of the MJ extractions with templates closer and closer to the SR lepton selection.
It is then possible to linearly extrapolate the MJ estimate into the signal region.
This procedure addresses the following points:
\begin{itemize}
\item the MJ-template selection is not arbitrary any more, in fact ideally the MJ estimate coming from the extrapolation is the one with the SR selection;
\item the biases in the kinematic or in the composition of the MJ-template reduce as the MJ-selection gets closer to the SR selection;
\item different variables are used in the MJ-extraction fits, and the MJ extrapolation is repeated for each of them.
\end{itemize}

\todo{MJ fit formula here}

One not trivial point in the definition of the scan is the choice of the variable to slice on for the MJ-template building.
% We investigated the option of using Lepton-ID based variables, as the electron-ID likelihood value.
% However this was not feasible because of the need of low statistics pre-scaled support trigger for the MJ-template selection, the multi-dimensional optimization used to build the electron-ID likelihood selection, and the poor statistics available in the loose-not-medium electron sample.
% Therefore
We decided to invert the isolation selection for the construction of the MJ templates, keeping the rest of the selection cuts like the nominal signal selection.
This revealed not to be straightforward because this analysis uses the ``Gradient-Iso'' working point to define a lepton as isolated or not.
The Gradient-Iso selection is a $p_T - \eta$ dependent cut on both calorimeter and track relative isolation variables: ptvarcone20(30)/$p_T$ and topoetcone20/$p_T$ for electrons (muons).

We decided to scan both the isolation variables to cover for the different effects which may come from the inversion of the calorimeter or track isolation.
The scan slice size and interval have been identified by analysing the ptvarcone20(30)/$p_T$ versus topoetcone20/$p_T$ distributions for electrons (muons) in data for events passing or failing the Gradient-Iso selection.
The result is reported in Fig.\ref{fig:isolation_2D}.
The events passing the Gradient-Iso cut appear to be bounded in the regions:
\begin{equation}
  \label{eq:XvarConeSRCuts}
  \frac{ptvarcone20(30)}{p_T} <0.06~(0.11)~\&\&~\frac{topoetcone20}{p_T} <0.13~(0.09)
\end{equation}
for electrons (muons).
Given the particular phase-space defined by the Gradient isolation requirement, (the definition of the isolation criteria depends on $p_T$ and $\eta$ of the lepton) we decided to produce MJ-templates inverting the Gradient isolation requirement but only considering the events outside the area delimited by Eq. \ref{eq:XvarConeSRCuts}.
This forces the extrapolation from a region not immediately adjacent to the SR lepton selection, and is an intrinsic problem of the use of the Gradient-Iso selection.

\begin{figure}[htbp]
\centering
\includegraphics[width=0.4\textwidth]{figures/mj/plot2D-Data2015_SR-el_lep_0_iso_topoetcone20dPtVSel_lep_0_iso_ptvarcone20dPt-el.pdf}
\includegraphics[width=0.4\textwidth]{figures/mj/plot2D-Data2015_SR-mu_lep_0_iso_topoetcone20dPtVSmu_lep_0_iso_ptvarcone30dPt-mu.pdf}
\\
\includegraphics[width=0.4\textwidth]{figures/mj/plot2D-Data2015_MJ-el_lep_0_iso_topoetcone20dPtVSel_lep_0_iso_ptvarcone20dPt-el.pdf}
\includegraphics[width=0.4\textwidth]{figures/mj/plot2D-Data2015_MJ-mu_lep_0_iso_topoetcone20dPtVSmu_lep_0_iso_ptvarcone30dPt-mu.pdf}
\caption{
 Distribution of ptvarcone20(30)/$p_T$ versus topoetcone20/$p_T$ for electrons (left) and muons (right) for events passing (top) or failing (bottom) the Gradient-Iso selection in the data.
}
\label{fig:isolation_2D}
\end{figure}

As the Gradient-Iso phase space is only in a rectangular region of ptvarconeXX/$p_T$ versus topoetcone20/$p_T$, we decided to scan in slices of one isolation requirement at the time applying a fix cut on the other requirement to avoid biases from very non isolated events.
The distribution of events failing the Gradient-Iso selection shown in Fig. \ref{fig:isolation_2D} gives also indication of the possible scan range and statistics of the scan  slices.

The fit was performed in two separate regions (fir regions - FR’s) defined removing in one case the $m_T^W > 40$ GeV cut, and in the other case removing the $E_T^{miss} > 25$ GeV cut.
In each fit region, fits are performed on following four variables: $p_T^{\ell}$, $E_T^{miss}$, $m_T^{W}$ and $\Delta \varphi _{\ell,E_T^{miss}}$ for each of the scan points, and the fraction of MJ is estimated extrapolating back to the signal region (re-applying the $m_T^W > 40$ GeV cut in one case, and the $E_T^{miss} > 25$ GeV cut in the other).
The contamination in each of the template regions, coming from the signal and the EW+top backgrounds varies a lot depending on the scan region.
A detailed description of such contaminations is reported in Table \ref{tbl:mj_ewk_bkg_fraction} and \todo{54}.

The stability of the MJ extraction was checked in several ways: the width of the \todo{isolation scan slices was varied}, the variables were fit in \todo{reduced ranges of the histograms} to reduce the impact of mismodellings of the data/MC distributions, and the EW and top backgrounds were \todo{kept fixed} by considering a very small Gaussian constraint on them.
In all these tests, the MJ estimates scans \todo{resulted to be close to one another}, and significantly smaller than the spread in the extrapolation coming from the use of different fit variables.
The study corresponding to a variation of the normalisation constraint on the EWK and top background is documented in detail in \todo{Appendix K}.

\subsubsection{$W\rightarrow e\nu$ scan results}
\label{sec:bkg_mj_we_scan}

As discussed in Sec. \ref{sec:bkg_mj_approach}, the events passing the gradient isolation cut and the selection are confined in the region of ptvarcone20/$p_T$ < 0.06 and topoetcone20/$p_T$ < 0.13.
For this reason scans on the two variables,after inverting the gradient isolation, are performed for the values reported in Table \ref{tbl:mj_scan_binning_el}.

\begin{table}[htbp]
\small
\begin{center}
 \begin{tabular}{ | c | c | c | }
 \hline
 Scan variable & ptvarcone20/$p_T$ & topoetcone20/$p_T$ \\
 \hline
 Fixed cut & topoetcone20/$p_T$ < 0.13 & ptvarcone20/$p_T$ < 0.06 \\
 \hline
 Scan starting point & 0.06 & 0.13 \\
 Slice width & 0.09 & 0.045 \\
 Number of slices & 6 & 6 \\
 \hline
\end{tabular}
\caption{
Width of scan slices and boundaries used for $W\rightarrow e\nu$ channel.
}%
\label{tbl:mj_scan_binning_el}
\end{center}
\end{table}

The results for topoetcone20/$p_T$ and ptvarcone20/$p_T$ scans, and in the two fit regions, performed on $E_T^{miss}$, $m_T$, $p_T$ and $\Delta\varphi_{e,E_T^{miss}}$ are reported in Fig.\ref{fig:mj_extrapolation_wenu} for the $W\rightarrow e\nu$ channel.
Notice that the $\Delta\varphi_{e,E_T^{miss}}$ variable is missing $E_T^{miss}$-FR scans because returning often nonphysical negative or zero MJ yiels because of the poor discrimination power of such variable after the $m_T$>40 GeV cut is applied.
The errors on each of the scan points are the errors from the template fit, taking into account the discrimination power of the variables, as well as the statistics of the MJ template, \todo{multiplied by the $\sqrt(\chi^2/NDoF)$}, to account for eventual mismodelling in the considered variables.
More details on the extraction of the numbers are reported in Appendix \ref{sec:details_on_multijet_background_estimate_in_the_Wenu_channel}.

\begin{figure}[htbp]
\centering
\includegraphics[width=0.45\textwidth]{figures/mj/slicesScanFit_SR_M_T_ptvar_el.pdf}
\includegraphics[width=0.45\textwidth]{figures/mj/slicesScanFit_SR_M_T_topoet_el.pdf}
\\
\includegraphics[width=0.45\textwidth]{figures/mj/slicesScanFit_SR_met_reco_et_ptvar_el.pdf}
\includegraphics[width=0.45\textwidth]{figures/mj/slicesScanFit_SR_met_reco_et_topoet_el.pdf}
\caption{
 Plots of the scans for ptvarcone20/$p_T$ (left column) and topoetcone20/$p_T$ (right column) for the $W\rightarrow e\nu$ channel, $m_T$-FR (top raw), $E_T^{miss}$-FR (bottom row).
 The results relative to the scans of the different variables (fit in each slice and linear extrapolations) are shown in different colors: $E_T^{miss}$ (blue), $m_T$ (green), $p_T$ (red) and $\Delta\varphi_{e,E_T^{miss}}$ (black).
 Notice that the $\Delta\varphi_{e,E_T^{miss}}$ variable is missing $E_T^{miss}$-FR scans because
 returning often nonphysical negative or zero MJ yiels because of the poor discrimination power of such variable after the $m_T$>40 GeV cut is applied.
 The errors on each of the scan points are the error from the template fit \todo{multiplied by the $\sqrt(\chi^2/NDoF)$}.
}
\label{fig:mj_extrapolation_wenu}
\end{figure}

In the plots it is visible the different behaviour of the variables, and their spread close to the signal region.
The fits performed on the $E_T^{miss}$ distribution have large error, coming mainly from the poor discriminating power of the $E_T^{miss}$.
Because of this the MJ extraction relative to the $E_T^{miss}$ has very large errors and central value relatively far from the one obtained with the other variables.
% The fits performed in the $E_T^{miss}$-relaxed fit region tend to \todo{give a slightly lower MJ estimate} with respect to the corresponding ones performed in the $m_T$-relaxed fit region.

The SR point of extrapolation is extracted from the average value of the ptvarcone20/$p_T$ and topoetcone20/$p_T$ distributions passing the gradient isolation selection cut in data (X and Y average of top left subfigure of Figure \ref{fig:isolation_2D}).
These values are \todo{0.034} and \todo{0.034} respectively.
The extrapolated values for $W\rightarrow e\nu$ for the topoetcone20/$p_T$ and ptvarcone20/$p_T$ respectively are reported in Table \ref{tbl:bkg_mj_we_scan_topoet} and \ref{tbl:bkg_mj_we_scan_ptvar}.
For details on the choice of the extrapolation values see \todo{Appendix P}.

\begin{table}[htbp]
\scriptsize
\begin{center}
 \begin{tabular}{ c | c  c | c  c }
 \hline
Fit variable & MJ extrapolated SR\_met\_reco\_et-FR & $\chi^{2}$/NDoF of linear fit & MJ extrapolated SR\_M\_T-FR & $\chi^{2}$/NDoF of linear fit \\
\hline
\multicolumn{5}{c}{$W \rightarrow e \nu$} \\
\hline
$p_{T}$ & 741627.9 $\pm$ 34625.17 & 8.66/4 & 705913.9 $\pm$ 22912.59 & 3.99/4\\
$M_{T}(lep_{0},E^{miss}_{T})$ & 817560.7 $\pm$ 50581.89 & 5.95/4 & 621901.1 $\pm$ 18601.02 & 2.84/4\\
$d\phi (lep_{0}-MET)$ & - & -  & 594717.6 $\pm$ 17719.91 & 5.50/4\\
$MET E_{t}$ & 918511.4 $\pm$ 62436.09 & 8.67/4 & 869776.8 $\pm$ 37515.26 & 13.21/4\\
 \hline
\end{tabular}
\caption{
Results of the extrapolation to the $W\rightarrow e\nu$ signal region (topoetcone20/$p_T$ = \todo{0.034}).
The errors quoted come from the extrapolation at the SR points, varying in an anti-correlated way the $p_0$ and $p_1$ linear fit parameters of one $\sigma$.
}%
\label{tbl:bkg_mj_we_scan_topoet}
\end{center}
\end{table}

\begin{table}[htbp]
\scriptsize
\begin{center}
 \begin{tabular}{ c | c  c | c  c }
 \hline
Fit variable & MJ extrapolated SR\_met\_reco\_et-FR & $\chi^{2}$/NDoF of linear fit & MJ extrapolated SR\_M\_T-FR & $\chi^{2}$/NDoF of linear fit \\
\hline
\multicolumn{5}{c}{$W \rightarrow e \nu$} \\
\hline
$p_{T}$ & 1191011.7 $\pm$ 7675.67 & 1.64/4 & 957321.2 $\pm$ 5624.70 & 57.39/4\\
$M_{T}(lep_{0},E^{miss}_{T})$ & 1308570.5 $\pm$ 10281.96 & 14.57/4 & 943721.3 $\pm$ 5708.18 & 99.32/4\\
$d\phi (lep_{0}-MET)$ & - & -  & 962359.0 $\pm$ 5862.21 & 120.70/4\\
$MET E_{t}$ & 1413057.8 $\pm$ 13226.37 & 27.03/4 & 1240946.8 $\pm$ 11362.84 & 42.96/4\\
 \hline
\end{tabular}
\caption{
Results of the extrapolation to the $W\rightarrow e\nu$ signal region (ptvarcone20/$p_T$ = \todo{0.034}).
The errors quoted come from the extrapolation at the SR points, varying in an anti-correlated way the $p_0$ and $p_1$ linear fit parameters of one $\sigma$.
}%
\label{tbl:bkg_mj_we_scan_ptvar}
\end{center}
\end{table}

The final background yield and its systematic uncertainty are estimated from the spread of the extrapolated curves of the ptvarcone20/$p_T$ and topoetcone20/$p_T$ variables.
To obtain the central value of the estimate, the weighted averages of the extrapolated values are computed, separately for the topoetcone and ptvarcone scans, and each fitting region.
The weighted average is calculated taking into account as anti-correlated the uncertainties on the $p_0$ and $p_1$ parameters of the fitted lines.
The nominal MJ yield is taken as the average between the four weighted averages (from the different scan variables and FR’s), and is shown in Table \ref{tbl:bkg_mj_we_wa_total}.
Seven sources of uncertainties, detailed in Table \ref{tbl:bkg_mj_we_wa_total}, are considered on the method:
\begin{itemize}
\item four come from the weighted average calculation, and are reported in Table \ref{tbl:bkg_mj_we_wa_extrapolation};
\item one represents the difference between the choice of scan variables, averaged over FR;
\item one represents the difference between the choice of FR, averaged over the scan variable;
\item one shows the \todo{impact of the JES variation on the signal template} in the estimated MJ yield.
\end{itemize}

\begin{table}[htbp]
\scriptsize
\begin{center}
 \begin{tabular}{ | c | c | c | c | c | }
 \hline
Channel & \multicolumn{4}{|c|}{Weighted averages} \\
  & SR\_met\_reco\_et-FR, topoet Isol & SR\_met\_reco\_et-FR, ptvar Isol & SR\_M\_T-FR, topoet Isol & SR\_M\_T-FR, ptvar Isol \\
\hline
 $W \rightarrow e\nu$  & 792289.20 $\pm$ 25980.86 & 1265082.57 $\pm$ 5577.22 & 650620.41 $\pm$ 10727.11 & 976746.77 $\pm$ 3175.92 \\
  \hline
\end{tabular}
\caption{
Weighted average for $W\rightarrow e\nu$ in the two channels, for both scans and fit-regions (FR), with errors coming from the extrapolation.
}%
\label{tbl:bkg_mj_we_wa_extrapolation}
\end{center}
\end{table}

\begin{table}[htbp]
\scriptsize
\begin{center}
 \begin{tabular}{ | c | c | c | c | c | c | c | c | }
\hline
Channel & \textbf{MJ yield} & \multicolumn{6}{|c|}{Systematic uncertanty} \\
 &  & $E_T^{miss}$-FR, topoet & $E_T^{miss}$-FR, ptvar & $m_T$-FR, topoet & $m_T$-FR, ptvar & scan choice & FR choice \\
\hline
 $W \rightarrow e\nu$  & \textbf{921184.74} & $\pm$ 1790.69 & $\pm$ 5577.22 & $\pm$ 10727.11 & $\pm$ 3175.92 & $\pm$ 747675.53 & $\pm$ 133213.48 \\
  \hline
\end{tabular}
\caption{
MJ estimated yield, obtained from averaging the weighted averages from the different scan variables and fit regions, and systematic uncertainties taken into account.
The errors come from the extrapolations first four, the choice of scan variable, the choice of fit region, and \todo{shape variations} of the signal due to reconstruction systematics.
}%
\label{tbl:bkg_mj_we_wa_total}
\end{center}
\end{table}

The spread of the extrapolations from each scan is illustrated, in comparison with their weighted averages, and the final MJ estimated yield and total uncertainty, in Fig \ref{fig:mj_spread_extrapolations}.

\begin{figure}[htbp]
\centering
\includegraphics[width=0.75\textwidth]{figures/mj/spread_mj_el.pdf}
\caption{
 The spread of the extrapolations from each scan and their errors is illustrated with black empty markers, in comparison with their weighted averages, shown with red full markers, and the final MJ estimated yield (solid black line) and total uncertainty (yellow band), for each isolation scan variable, and fit region.
}
\label{fig:mj_spread_extrapolations}
\end{figure}

\subsubsection{$W\rightarrow\mu\nu$ scan results}
\label{sec:bkg_mj_wmu_scan}

As discussed in Sec. \ref{sec:bkg_mj_approach}, the events passing the gradient isolation cut and the selection are confined in the region of ptvarcone30/$p_T$ < 0.11 and topoetcone20/$p_T$ < 0.09.
For this reason scans on the two variables, after inverting the gradient isolation, are performed for the values reported in Table \ref{tbl:bkg_mj_wmu_scan}.
As for the electron channel, the scans in topoetcone20/$p_T$ are performed for a fixed range of ptvarcone30/$p_T$, so that the two sets of scans are orthogonal, the details are reported in Table \ref{tbl:bkg_mj_wmu_scan}.

\begin{table}[htbp]
\small
\begin{center}
 \begin{tabular}{ | c | c | c | }
 \hline
 Scan variable & ptvarcone30/$p_T$ & topoetcone20/$p_T$ \\
 \hline
 Fixed cut & topoetcone20/$p_T$ < 0.09 & ptvarcone30/$p_T$ < 0.11  \\
 \hline
 Scan starting point & 0.11 & 0.09 \\
 Slice width & 0.11 & 0.44 \\
 Number of slices & 4 & 5 \\
 \hline
\end{tabular}
\caption{
Width of scan slices and boundaries used for $W\rightarrow \mu\nu$ channel.
}%
\label{tbl:bkg_mj_wmu_scan}
\end{center}
\end{table}

The results for the scans, separated for the two variables and two fit regions, are shown in Fig.\ref{fig:mj_extrapolation_wmunu} for $W\rightarrow e\nu$ channel.
The errors on each of the scan points are the errors from the template fit, taking into account the discrimination power of the variables, as well as the statistics of the MJ template, multiplied by the $\sqrt(\chi^2/NDoF)$, to account for eventual mismodelling in the considered variables.
More details on the extraction of the numbers are reported in Appendix \ref{sec:details_on_multijet_background_estimate_in_the_Wmunu_channel}.

\begin{figure}[htbp]
\centering
\includegraphics[width=0.45\textwidth]{figures/intro/rdrds_summer18.png}
\includegraphics[width=0.45\textwidth]{figures/intro/rdrds_summer18.png}
\\
\includegraphics[width=0.45\textwidth]{figures/intro/rdrds_summer18.png}
\includegraphics[width=0.45\textwidth]{figures/intro/rdrds_summer18.png}
\caption{
 Plots of the scans for ptvarcone30/$p_T$ (left column) and topoetcone20/$p_T$ (right column) for the $W\rightarrow \mu\nu$ channel, $m_T$-FR (top raw), $E_T^{miss}$-FR (bottom row).
 The results relative to the scans of the different variables (fit in each slice and linear extrapolations) are shown in different colours: $E_T^{miss}$ (blue), $m_T$ (green), $p_T$ (red) and $\Delta\varphi_{\mu,E_T^{miss}}$ (black).
%  Notice that the $\Delta\varphi_{\mu,E_T^{miss}}$ variable is missing $E_T^{miss}$-FR scans because returning often nonphysical negative or zero MJ yiels because of the poor discrimination power of such variable after the $m_T$>40 GeV cut is applied.
 The errors on each of the scan points are the error from the template fit multiplied by the $\sqrt(\chi^2/NDoF)$.
}
\label{fig:mj_extrapolation_wmunu}
\end{figure}

The SR point of extrapolation is extracted from the average value of the ptvarcone30/$p_T$ and topoetcone20/$p_T$ distributions passing the gradient isolation selection cut in data (X and Y average of top right subfigure of Figure \ref{fig:isolation_2D}).
These values are \todo{0.045} and \todo{0.03} respectively.
The extrapolated values for $W\rightarrow e\nu$ for the topoetcone20/$p_T$ and ptvarcone20/$p_T$ respectively are reported in Table \ref{tbl:bkg_mj_wmu_scan_topoet} and \ref{tbl:bkg_mj_wmu_scan_ptvar}, together with the $\chi^2/NDoF$ for the linear extrapolations.
The errors quoted come from the extrapolation at the SR points, \todo{varying in an anti-correlated way} the $p_0$ and $p_1$ liner fit parameters of one $\sigma$.

\begin{table}[htbp]
\scriptsize
\begin{center}
 \begin{tabular}{ c | c  c | c  c }
 \hline
Fit variable & MJ extrapolated SR\_met\_reco\_et-FR & $\chi^{2}$/NDoF of linear fit & MJ extrapolated SR\_M\_T-FR & $\chi^{2}$/NDoF of linear fit \\
\hline
\multicolumn{5}{c}{$W \rightarrow \mu \nu$} \\
 \hline
 \hline
\end{tabular}
\caption{
Results of the extrapolation to the $W\rightarrow \mu\nu$ signal region (topoetcone20/$p_T$ = \todo{0.03}).
The errors quoted come from the extrapolation at the SR points, varying in an anti-correlated way the $p_0$ and $p_1$ linear fit parameters of one $\sigma$.
}%
\label{tbl:bkg_mj_wmu_scan_topoet}
\end{center}
\end{table}

\begin{table}[htbp]
\scriptsize
\begin{center}
 \begin{tabular}{ c | c  c | c  c }
 \hline
Fit variable & MJ extrapolated SR\_met\_reco\_et-FR & $\chi^{2}$/NDoF of linear fit & MJ extrapolated SR\_M\_T-FR & $\chi^{2}$/NDoF of linear fit \\
\hline
\multicolumn{5}{c}{$W \rightarrow \mu \nu$} \\
 \hline
 \hline
\end{tabular}
\caption{
Results of the extrapolation to the $W\rightarrow \mu\nu$ signal region (ptvarcone30/$p_T$ = \todo{0.045}).
The errors quoted come from the extrapolation at the SR points, varying in an anti-correlated way the $p_0$ and $p_1$ linear fit parameters of one $\sigma$.
}%
\label{tbl:bkg_mj_wmu_scan_ptvar}
\end{center}
\end{table}

The final background yield and its systematic uncertainty are estimated from the spread of the extrapolated curves at 0.045 and 0.03 value of the ptvarcone30/$p_T$ and topoetcone20/$p_T$ variables.
To obtain the central value of the estimate, the weighted averages of the extrapolated values are computed, separately for the topoetcone and ptvarcone scans, and each fitting region.
The weighted average is calculated taking into account as anti-correlated the uncertainties on the $p_0$ and $p_1$ parameters of the fitted lines.
The nominal MJ yield is taken as the average between the four weighted averages (from the different scan variables and FR’s), and is shown in Table \ref{tbl:bkg_mj_wmu_wa_total}.
Seven sources of uncertainties, detailed in Table \ref{tbl:bkg_mj_wmu_wa_total}, are considered on the method:
\begin{itemize}
\item four come from the weighted average calculation, and are reported in Table \ref{tbl:bkg_mj_wmu_wa_extrapolation};
\item one represents the difference between the choice of scan variables, averaged over FR;
\item one represents the difference between the choice of FR, averaged over the scan variable;
\item one shows the \todo{impact of the JES variation on the signal template} in the estimated MJ yield.
\end{itemize}

\begin{table}[htbp]
\scriptsize
\begin{center}
 \begin{tabular}{ | c | c | c | c | c | }
 \hline
Channel & \multicolumn{4}{|c|}{Weighted averages} \\
  & SR\_met\_reco\_et-FR, topoet Isol & SR\_met\_reco\_et-FR, ptvar Isol & SR\_M\_T-FR, topoet Isol & SR\_M\_T-FR, ptvar Isol \\
\hline

  \hline
\end{tabular}
\caption{
Weighted average for $W\rightarrow \mu\nu$ in the two channels, for both scans and fit-regions (FR), with errors coming from the extrapolation.
}%
\label{tbl:bkg_mj_wmu_wa_extrapolation}
\end{center}
\end{table}

\begin{table}[htbp]
\scriptsize
\begin{center}
 \begin{tabular}{ | c | c | c | c | c | c | c | c | }
\hline
Channel & \textbf{MJ yield} & \multicolumn{6}{|c|}{Systematic uncertanty} \\
 &  & $E_T^{miss}$-FR, topoet & $E_T^{miss}$-FR, ptvar & $m_T$-FR, topoet & $m_T$-FR, ptvar & scan choice & FR choice \\
\hline

  \hline
\end{tabular}
\caption{
MJ estimated yield, obtained from averaging the weighted averages from the different scan variables and fit regions, and systematic uncertainties taken into account.
The errors come from the extrapolations first four, the choice of scan variable, the choice of fit region, and \todo{shape variations} of the signal due to reconstruction systematics.
}%
\label{tbl:bkg_mj_wmu_wa_total}
\end{center}
\end{table}

\subsection{Treatment of correlations between $W^+$ and $W^-$ multijet estimates}
\label{sec:bkg_mj_WplusWminus}


\subsubsection{\lst{ConcreteCollection} operation (OpCode 131)}
\label{sec:serialization:operation:ConcreteCollection}

\noindent
\(\begin{tabularx}{\textwidth}{| l | l | l | X |}
    \hline
    \bf{Slot} & \bf{Format} & \bf{\#bytes} & \bf{Description} \\
    \hline
         $ numItems $ & \lst{VLQ(UShort)} & [1, *] & number of item in a collection of expressions \\
    \hline
           $ elementType $ & \lst{Type} & [1, *] & type of each expression in the collection \\
    \hline
          \multicolumn{4}{l}{\lst{for}~$i=1$~\lst{to}~$numItems$} \\
    \hline
             ~~ $ item_i $ & \lst{Expr} & [1, *] & expression in i-th position \\
    \hline
          \multicolumn{4}{l}{\lst{end for}} \\
\end{tabularx}\)

\subsubsection{\lst{ConcreteCollectionBooleanConstant} operation (OpCode 133)}
\label{sec:serialization:operation:ConcreteCollectionBooleanConstant}

\noindent
\(\begin{tabularx}{\textwidth}{| l | l | l | X |}
    \hline
    \bf{Slot} & \bf{Format} & \bf{\#bytes} & \bf{Description} \\
    \hline
         $ numBits $ & \lst{VLQ(UShort)} & [1, *] & number of items in a collection of Boolean values \\
    \hline
           $ bits $ & \lst{Bits} & [1, 1024] & Boolean values encoded as as bits (right most byte is zero-padded on the right) \\
    \hline

\end{tabularx}\)

\subsubsection{\lst{Tuple} operation (OpCode 134)}
\label{sec:serialization:operation:Tuple}

\noindent
\(\begin{tabularx}{\textwidth}{| l | l | l | X |}
    \hline
    \bf{Slot} & \bf{Format} & \bf{\#bytes} & \bf{Description} \\
    \hline
         $ numItems $ & \lst{UByte} & 1 & number of items in the tuple \\
    \hline
          \multicolumn{4}{l}{\lst{for}~$i=1$~\lst{to}~$numItems$} \\
    \hline
             ~~ $ item_i $ & \lst{Expr} & [1, *] & tuple's item in i-th position \\
    \hline
          \multicolumn{4}{l}{\lst{end for}} \\
\end{tabularx}\)

\subsubsection{\lst{SelectField} operation (OpCode 140)}
\label{sec:serialization:operation:SelectField}

Select tuple field by its 1-based index. E.g. \lst{input._1} is transformed to \lst{SelectField(input, 1)} See~\hyperref[sec:appendix:primops:SelectField]{\lst{selectField}}

\noindent
\(\begin{tabularx}{\textwidth}{| l | l | l | X |}
    \hline
    \bf{Slot} & \bf{Format} & \bf{\#bytes} & \bf{Description} \\
    \hline
         $ input $ & \lst{Expr} & [1, *] & tuple of items \\
    \hline
           $ fieldIndex $ & \lst{Byte} & 1 & index of an item to select \\
    \hline

\end{tabularx}\)

\subsubsection{\lst{LT} operation (OpCode 143)}
\label{sec:serialization:operation:LT}

Returns \lst{true} is the left operand is less then the right operand, \lst{false} otherwise. See~\hyperref[sec:appendix:primops:LT]{\lst{<}}

\noindent
\(\begin{tabularx}{\textwidth}{| l | l | l | X |}
    \hline
    \bf{Slot} & \bf{Format} & \bf{\#bytes} & \bf{Description} \\
    \hline
        \multicolumn{4}{l}{\lst{match}~$ (left, right) $} \\

    \multicolumn{4}{l}{~~\lst{otherwise} } \\
    \hline
            ~~~~ $ left $ & \lst{Expr} & [1, *] & left operand \\
    \hline
          ~~~~ $ right $ & \lst{Expr} & [1, *] & right operand \\
    \hline
          \multicolumn{4}{l}{\lst{end match}} \\
\end{tabularx}\)

\subsubsection{\lst{LE} operation (OpCode 144)}
\label{sec:serialization:operation:LE}

Returns \lst{true} is the left operand is less then or equal to the right operand, \lst{false} otherwise. See~\hyperref[sec:appendix:primops:LE]{\lst{<=}}

\noindent
\(\begin{tabularx}{\textwidth}{| l | l | l | X |}
    \hline
    \bf{Slot} & \bf{Format} & \bf{\#bytes} & \bf{Description} \\
    \hline
        \multicolumn{4}{l}{\lst{match}~$ (left, right) $} \\

    \multicolumn{4}{l}{~~\lst{otherwise} } \\
    \hline
            ~~~~ $ left $ & \lst{Expr} & [1, *] & left operand \\
    \hline
          ~~~~ $ right $ & \lst{Expr} & [1, *] & right operand \\
    \hline
          \multicolumn{4}{l}{\lst{end match}} \\
\end{tabularx}\)

\subsubsection{\lst{GT} operation (OpCode 145)}
\label{sec:serialization:operation:GT}

Returns \lst{true} is the left operand is greater then the right operand, \lst{false} otherwise. See~\hyperref[sec:appendix:primops:GT]{\lst{>}}

\noindent
\(\begin{tabularx}{\textwidth}{| l | l | l | X |}
    \hline
    \bf{Slot} & \bf{Format} & \bf{\#bytes} & \bf{Description} \\
    \hline
        \multicolumn{4}{l}{\lst{match}~$ (left, right) $} \\

    \multicolumn{4}{l}{~~\lst{otherwise} } \\
    \hline
            ~~~~ $ left $ & \lst{Expr} & [1, *] & left operand \\
    \hline
          ~~~~ $ right $ & \lst{Expr} & [1, *] & right operand \\
    \hline
          \multicolumn{4}{l}{\lst{end match}} \\
\end{tabularx}\)

\subsubsection{\lst{GE} operation (OpCode 146)}
\label{sec:serialization:operation:GE}

Returns \lst{true} is the left operand is greater then or equal to the right operand, \lst{false} otherwise. See~\hyperref[sec:appendix:primops:GE]{\lst{>=}}

\noindent
\(\begin{tabularx}{\textwidth}{| l | l | l | X |}
    \hline
    \bf{Slot} & \bf{Format} & \bf{\#bytes} & \bf{Description} \\
    \hline
        \multicolumn{4}{l}{\lst{match}~$ (left, right) $} \\

    \multicolumn{4}{l}{~~\lst{otherwise} } \\
    \hline
            ~~~~ $ left $ & \lst{Expr} & [1, *] & left operand \\
    \hline
          ~~~~ $ right $ & \lst{Expr} & [1, *] & right operand \\
    \hline
          \multicolumn{4}{l}{\lst{end match}} \\
\end{tabularx}\)

\subsubsection{\lst{EQ} operation (OpCode 147)}
\label{sec:serialization:operation:EQ}

Compare equality of \lst{left} and \lst{right} arguments See~\hyperref[sec:appendix:primops:EQ]{\lst{==}}

\noindent
\(\begin{tabularx}{\textwidth}{| l | l | l | X |}
    \hline
    \bf{Slot} & \bf{Format} & \bf{\#bytes} & \bf{Description} \\
    \hline
        \multicolumn{4}{l}{\lst{match}~$ (left, right) $} \\

    \multicolumn{4}{l}{~~\lst{otherwise} } \\
    \hline
            ~~~~ $ left $ & \lst{Expr} & [1, *] & left operand \\
    \hline
          ~~~~ $ right $ & \lst{Expr} & [1, *] & right operand \\
    \hline
          \multicolumn{4}{l}{\lst{end match}} \\
\end{tabularx}\)

\subsubsection{\lst{NEQ} operation (OpCode 148)}
\label{sec:serialization:operation:NEQ}

Compare inequality of \lst{left} and \lst{right} arguments See~\hyperref[sec:appendix:primops:NEQ]{\lst{!=}}

\noindent
\(\begin{tabularx}{\textwidth}{| l | l | l | X |}
    \hline
    \bf{Slot} & \bf{Format} & \bf{\#bytes} & \bf{Description} \\
    \hline
        \multicolumn{4}{l}{\lst{match}~$ (left, right) $} \\

    \multicolumn{4}{l}{~~\lst{otherwise} } \\
    \hline
            ~~~~ $ left $ & \lst{Expr} & [1, *] & left operand \\
    \hline
          ~~~~ $ right $ & \lst{Expr} & [1, *] & right operand \\
    \hline
          \multicolumn{4}{l}{\lst{end match}} \\
\end{tabularx}\)

\subsubsection{\lst{If} operation (OpCode 149)}
\label{sec:serialization:operation:If}

Compute condition, if true then compute trueBranch else compute falseBranch See~\hyperref[sec:appendix:primops:If]{\lst{if}}

\noindent
\(\begin{tabularx}{\textwidth}{| l | l | l | X |}
    \hline
    \bf{Slot} & \bf{Format} & \bf{\#bytes} & \bf{Description} \\
    \hline
         $ condition $ & \lst{Expr} & [1, *] & condition expression \\
    \hline
           $ trueBranch $ & \lst{Expr} & [1, *] & expression to execute when \lst{condition == true} \\
    \hline
           $ falseBranch $ & \lst{Expr} & [1, *] & expression to execute when \lst{condition == false} \\
    \hline

\end{tabularx}\)

\subsubsection{\lst{AND} operation (OpCode 150)}
\label{sec:serialization:operation:AND}

Returns true if \emph{all} the elements in collection are \lst{true}. See~\hyperref[sec:appendix:primops:AND]{\lst{allOf}}

\noindent
\(\begin{tabularx}{\textwidth}{| l | l | l | X |}
    \hline
    \bf{Slot} & \bf{Format} & \bf{\#bytes} & \bf{Description} \\
    \hline
         $ conditions $ & \lst{Expr} & [1, *] & a collection of conditions \\
    \hline

\end{tabularx}\)

\subsubsection{\lst{OR} operation (OpCode 151)}
\label{sec:serialization:operation:OR}

Returns true if \emph{any} the elements in collection are \lst{true}. See~\hyperref[sec:appendix:primops:OR]{\lst{anyOf}}

\noindent
\(\begin{tabularx}{\textwidth}{| l | l | l | X |}
    \hline
    \bf{Slot} & \bf{Format} & \bf{\#bytes} & \bf{Description} \\
    \hline
         $ conditions $ & \lst{Expr} & [1, *] & a collection of conditions \\
    \hline

\end{tabularx}\)

\subsubsection{\lst{AtLeast} operation (OpCode 152)}
\label{sec:serialization:operation:AtLeast}

 Logical threshold.
 AtLeast has two inputs: integer \lst{bound} and \lst{children} same as in AND/OR.
 The result is true if at least \lst{bound} children are proven.
         See~\hyperref[sec:appendix:primops:AtLeast]{\lst{atLeast}}

\noindent
\(\begin{tabularx}{\textwidth}{| l | l | l | X |}
    \hline
    \bf{Slot} & \bf{Format} & \bf{\#bytes} & \bf{Description} \\
    \hline
         $ bound $ & \lst{Expr} & [1, *] & required minimum of proven children \\
    \hline
           $ children $ & \lst{Expr} & [1, *] & proposition to be proven/validated \\
    \hline

\end{tabularx}\)

\subsubsection{\lst{Minus} operation (OpCode 153)}
\label{sec:serialization:operation:Minus}

Returns a result of subtracting second numeric operand from the first. See~\hyperref[sec:appendix:primops:Minus]{\lst{-}}

\noindent
\(\begin{tabularx}{\textwidth}{| l | l | l | X |}
    \hline
    \bf{Slot} & \bf{Format} & \bf{\#bytes} & \bf{Description} \\
    \hline
         $ left $ & \lst{Expr} & [1, *] & left operand \\
    \hline
           $ right $ & \lst{Expr} & [1, *] & right operand \\
    \hline

\end{tabularx}\)

\subsubsection{\lst{Plus} operation (OpCode 154)}
\label{sec:serialization:operation:Plus}

Returns a sum of two numeric operands See~\hyperref[sec:appendix:primops:Plus]{\lst{+}}

\noindent
\(\begin{tabularx}{\textwidth}{| l | l | l | X |}
    \hline
    \bf{Slot} & \bf{Format} & \bf{\#bytes} & \bf{Description} \\
    \hline
         $ left $ & \lst{Expr} & [1, *] & left operand \\
    \hline
           $ right $ & \lst{Expr} & [1, *] & right operand \\
    \hline

\end{tabularx}\)

\subsubsection{\lst{Xor} operation (OpCode 155)}
\label{sec:serialization:operation:Xor}

Byte-wise XOR of two collections of bytes See~\hyperref[sec:appendix:primops:Xor]{\lst{binary_|}}

\noindent
\(\begin{tabularx}{\textwidth}{| l | l | l | X |}
    \hline
    \bf{Slot} & \bf{Format} & \bf{\#bytes} & \bf{Description} \\
    \hline
         $ left $ & \lst{Expr} & [1, *] & left operand \\
    \hline
           $ right $ & \lst{Expr} & [1, *] & right operand \\
    \hline

\end{tabularx}\)

\subsubsection{\lst{Multiply} operation (OpCode 156)}
\label{sec:serialization:operation:Multiply}

Returns a multiplication of two numeric operands See~\hyperref[sec:appendix:primops:Multiply]{\lst{*}}

\noindent
\(\begin{tabularx}{\textwidth}{| l | l | l | X |}
    \hline
    \bf{Slot} & \bf{Format} & \bf{\#bytes} & \bf{Description} \\
    \hline
         $ left $ & \lst{Expr} & [1, *] & left operand \\
    \hline
           $ right $ & \lst{Expr} & [1, *] & right operand \\
    \hline

\end{tabularx}\)

\subsubsection{\lst{Division} operation (OpCode 157)}
\label{sec:serialization:operation:Division}

Integer division of the first operand by the second operand. See~\hyperref[sec:appendix:primops:Division]{\lst{/}}

\noindent
\(\begin{tabularx}{\textwidth}{| l | l | l | X |}
    \hline
    \bf{Slot} & \bf{Format} & \bf{\#bytes} & \bf{Description} \\
    \hline
         $ left $ & \lst{Expr} & [1, *] & left operand \\
    \hline
           $ right $ & \lst{Expr} & [1, *] & right operand \\
    \hline

\end{tabularx}\)

\subsubsection{\lst{Modulo} operation (OpCode 158)}
\label{sec:serialization:operation:Modulo}

Remainder from division of the first operand by the second operand. See~\hyperref[sec:appendix:primops:Modulo]{\lst{\%}}

\noindent
\(\begin{tabularx}{\textwidth}{| l | l | l | X |}
    \hline
    \bf{Slot} & \bf{Format} & \bf{\#bytes} & \bf{Description} \\
    \hline
         $ left $ & \lst{Expr} & [1, *] & left operand \\
    \hline
           $ right $ & \lst{Expr} & [1, *] & right operand \\
    \hline

\end{tabularx}\)

\subsubsection{\lst{Exponentiate} operation (OpCode 159)}
\label{sec:serialization:operation:Exponentiate}

Exponentiate this \lst{GroupElement} to the given number. Returns this to the power of k See~\hyperref[sec:type:GroupElement:exp]{\lst{GroupElement.exp}}

\noindent
\(\begin{tabularx}{\textwidth}{| l | l | l | X |}
    \hline
    \bf{Slot} & \bf{Format} & \bf{\#bytes} & \bf{Description} \\
    \hline
         $ this $ & \lst{Expr} & [1, *] & this instance \\
    \hline
           $ k $ & \lst{Expr} & [1, *] & The power \\
    \hline

\end{tabularx}\)

\subsubsection{\lst{MultiplyGroup} operation (OpCode 160)}
\label{sec:serialization:operation:MultiplyGroup}

Group operation. See~\hyperref[sec:type:GroupElement:multiply]{\lst{GroupElement.multiply}}

\noindent
\(\begin{tabularx}{\textwidth}{| l | l | l | X |}
    \hline
    \bf{Slot} & \bf{Format} & \bf{\#bytes} & \bf{Description} \\
    \hline
         $ this $ & \lst{Expr} & [1, *] & this instance \\
    \hline
           $ other $ & \lst{Expr} & [1, *] & other element of the group \\
    \hline

\end{tabularx}\)

\subsubsection{\lst{Min} operation (OpCode 161)}
\label{sec:serialization:operation:Min}

Minimum value of two operands. See~\hyperref[sec:appendix:primops:Min]{\lst{min}}

\noindent
\(\begin{tabularx}{\textwidth}{| l | l | l | X |}
    \hline
    \bf{Slot} & \bf{Format} & \bf{\#bytes} & \bf{Description} \\
    \hline
         $ left $ & \lst{Expr} & [1, *] & left operand \\
    \hline
           $ right $ & \lst{Expr} & [1, *] & right operand \\
    \hline

\end{tabularx}\)

\subsubsection{\lst{Max} operation (OpCode 162)}
\label{sec:serialization:operation:Max}

Maximum value of two operands. See~\hyperref[sec:appendix:primops:Max]{\lst{max}}

\noindent
\(\begin{tabularx}{\textwidth}{| l | l | l | X |}
    \hline
    \bf{Slot} & \bf{Format} & \bf{\#bytes} & \bf{Description} \\
    \hline
         $ left $ & \lst{Expr} & [1, *] & left operand \\
    \hline
           $ right $ & \lst{Expr} & [1, *] & right operand \\
    \hline

\end{tabularx}\)

\subsubsection{\lst{MapCollection} operation (OpCode 173)}
\label{sec:serialization:operation:MapCollection}

 Builds a new collection by applying a function to all elements of this collection.
 Returns a new collection of type \lst{Coll[B]} resulting from applying the given function
 \lst{f} to each element of this collection and collecting the results.
         See~\hyperref[sec:type:SCollection:map]{\lst{SCollection.map}}

\noindent
\(\begin{tabularx}{\textwidth}{| l | l | l | X |}
    \hline
    \bf{Slot} & \bf{Format} & \bf{\#bytes} & \bf{Description} \\
    \hline
         $ this $ & \lst{Expr} & [1, *] & this instance \\
    \hline
           $ f $ & \lst{Expr} & [1, *] & the function to apply to each element \\
    \hline

\end{tabularx}\)

\subsubsection{\lst{Exists} operation (OpCode 174)}
\label{sec:serialization:operation:Exists}

Tests whether a predicate holds for at least one element of this collection.
Returns \lst{true} if the given predicate \lst{p} is satisfied by at least one element of this collection, otherwise \lst{false}
         See~\hyperref[sec:type:SCollection:exists]{\lst{SCollection.exists}}

\noindent
\(\begin{tabularx}{\textwidth}{| l | l | l | X |}
    \hline
    \bf{Slot} & \bf{Format} & \bf{\#bytes} & \bf{Description} \\
    \hline
         $ this $ & \lst{Expr} & [1, *] & this instance \\
    \hline
           $ p $ & \lst{Expr} & [1, *] & the predicate used to test elements \\
    \hline

\end{tabularx}\)

\subsubsection{\lst{ForAll} operation (OpCode 175)}
\label{sec:serialization:operation:ForAll}

Tests whether a predicate holds for all elements of this collection.
Returns \lst{true} if this collection is empty or the given predicate \lst{p}
holds for all elements of this collection, otherwise \lst{false}.
         See~\hyperref[sec:type:SCollection:forall]{\lst{SCollection.forall}}

\noindent
\(\begin{tabularx}{\textwidth}{| l | l | l | X |}
    \hline
    \bf{Slot} & \bf{Format} & \bf{\#bytes} & \bf{Description} \\
    \hline
         $ this $ & \lst{Expr} & [1, *] & this instance \\
    \hline
           $ p $ & \lst{Expr} & [1, *] & the predicate used to test elements \\
    \hline

\end{tabularx}\)

\subsubsection{\lst{Fold} operation (OpCode 176)}
\label{sec:serialization:operation:Fold}

Applies a binary operator to a start value and all elements of this collection, going left to right. See~\hyperref[sec:type:SCollection:fold]{\lst{SCollection.fold}}

\noindent
\(\begin{tabularx}{\textwidth}{| l | l | l | X |}
    \hline
    \bf{Slot} & \bf{Format} & \bf{\#bytes} & \bf{Description} \\
    \hline
         $ this $ & \lst{Expr} & [1, *] & this instance \\
    \hline
           $ zero $ & \lst{Expr} & [1, *] & a starting value \\
    \hline
           $ op $ & \lst{Expr} & [1, *] & the binary operator \\
    \hline

\end{tabularx}\)

\subsubsection{\lst{SizeOf} operation (OpCode 177)}
\label{sec:serialization:operation:SizeOf}

The size of the collection in elements. See~\hyperref[sec:type:SCollection:size]{\lst{SCollection.size}}

\noindent
\(\begin{tabularx}{\textwidth}{| l | l | l | X |}
    \hline
    \bf{Slot} & \bf{Format} & \bf{\#bytes} & \bf{Description} \\
    \hline
         $ this $ & \lst{Expr} & [1, *] & this instance \\
    \hline

\end{tabularx}\)

\subsubsection{\lst{ByIndex} operation (OpCode 178)}
\label{sec:serialization:operation:ByIndex}

Return the element of collection if \lst{index} is in range \lst{0 .. size-1} See~\hyperref[sec:type:SCollection:getOrElse]{\lst{SCollection.getOrElse}}

\noindent
\(\begin{tabularx}{\textwidth}{| l | l | l | X |}
    \hline
    \bf{Slot} & \bf{Format} & \bf{\#bytes} & \bf{Description} \\
    \hline
         $ this $ & \lst{Expr} & [1, *] & this instance \\
    \hline
           $ index $ & \lst{Expr} & [1, *] & index of the element of this collection \\
    \hline
          \multicolumn{4}{l}{\lst{optional}~$default$} \\
    \hline
    ~~$tag$ & \lst{Byte} & 1 & 0 - no value; 1 - has value \\
    \hline
    \multicolumn{4}{l}{~~\lst{when}~$tag == 1$} \\
    \hline
             ~~~~ $ default $ & \lst{Expr} & [1, *] & value to return when \lst{index} is out of range \\
    \hline
          \multicolumn{4}{l}{\lst{end optional}} \\
\end{tabularx}\)

\subsubsection{\lst{Append} operation (OpCode 179)}
\label{sec:serialization:operation:Append}

Puts the elements of other collection after the elements of this collection (concatenation of 2 collections) See~\hyperref[sec:type:SCollection:append]{\lst{SCollection.append}}

\noindent
\(\begin{tabularx}{\textwidth}{| l | l | l | X |}
    \hline
    \bf{Slot} & \bf{Format} & \bf{\#bytes} & \bf{Description} \\
    \hline
         $ this $ & \lst{Expr} & [1, *] & this instance \\
    \hline
           $ other $ & \lst{Expr} & [1, *] & the collection to append at the end of this \\
    \hline

\end{tabularx}\)

\subsubsection{\lst{Slice} operation (OpCode 180)}
\label{sec:serialization:operation:Slice}

Selects an interval of elements.  The returned collection is made up
  of all elements \lst{x} which satisfy the invariant:
  \lst{
     from <= indexOf(x) < until
  }
         See~\hyperref[sec:type:SCollection:slice]{\lst{SCollection.slice}}

\noindent
\(\begin{tabularx}{\textwidth}{| l | l | l | X |}
    \hline
    \bf{Slot} & \bf{Format} & \bf{\#bytes} & \bf{Description} \\
    \hline
         $ this $ & \lst{Expr} & [1, *] & this instance \\
    \hline
           $ from $ & \lst{Expr} & [1, *] & the lowest index to include from this collection \\
    \hline
           $ until $ & \lst{Expr} & [1, *] & the lowest index to EXCLUDE from this collection \\
    \hline

\end{tabularx}\)

\subsubsection{\lst{ExtractAmount} operation (OpCode 193)}
\label{sec:serialization:operation:ExtractAmount}

Mandatory: Monetary value, in Ergo tokens (NanoErg unit of measure) See~\hyperref[sec:type:Box:value]{\lst{Box.value}}

\noindent
\(\begin{tabularx}{\textwidth}{| l | l | l | X |}
    \hline
    \bf{Slot} & \bf{Format} & \bf{\#bytes} & \bf{Description} \\
    \hline
         $ this $ & \lst{Expr} & [1, *] & this instance \\
    \hline

\end{tabularx}\)

\subsubsection{\lst{ExtractScriptBytes} operation (OpCode 194)}
\label{sec:serialization:operation:ExtractScriptBytes}

Serialized bytes of guarding script, which should be evaluated to true in order to
 open this box. (aka spend it in a transaction) See~\hyperref[sec:type:Box:propositionBytes]{\lst{Box.propositionBytes}}

\noindent
\(\begin{tabularx}{\textwidth}{| l | l | l | X |}
    \hline
    \bf{Slot} & \bf{Format} & \bf{\#bytes} & \bf{Description} \\
    \hline
         $ this $ & \lst{Expr} & [1, *] & this instance \\
    \hline

\end{tabularx}\)

\subsubsection{\lst{ExtractBytes} operation (OpCode 195)}
\label{sec:serialization:operation:ExtractBytes}

Serialized bytes of this box's content, including proposition bytes. See~\hyperref[sec:type:Box:bytes]{\lst{Box.bytes}}

\noindent
\(\begin{tabularx}{\textwidth}{| l | l | l | X |}
    \hline
    \bf{Slot} & \bf{Format} & \bf{\#bytes} & \bf{Description} \\
    \hline
         $ this $ & \lst{Expr} & [1, *] & this instance \\
    \hline

\end{tabularx}\)

\subsubsection{\lst{ExtractBytesWithNoRef} operation (OpCode 196)}
\label{sec:serialization:operation:ExtractBytesWithNoRef}

Serialized bytes of this box's content, excluding transactionId and index of output. See~\hyperref[sec:type:Box:bytesWithoutRef]{\lst{Box.bytesWithoutRef}}

\noindent
\(\begin{tabularx}{\textwidth}{| l | l | l | X |}
    \hline
    \bf{Slot} & \bf{Format} & \bf{\#bytes} & \bf{Description} \\
    \hline
         $ this $ & \lst{Expr} & [1, *] & this instance \\
    \hline

\end{tabularx}\)

\subsubsection{\lst{ExtractId} operation (OpCode 197)}
\label{sec:serialization:operation:ExtractId}

Blake2b256 hash of this box's content, basically equals to \lst{blake2b256(bytes)} See~\hyperref[sec:type:Box:id]{\lst{Box.id}}

\noindent
\(\begin{tabularx}{\textwidth}{| l | l | l | X |}
    \hline
    \bf{Slot} & \bf{Format} & \bf{\#bytes} & \bf{Description} \\
    \hline
         $ this $ & \lst{Expr} & [1, *] & this instance \\
    \hline

\end{tabularx}\)

\subsubsection{\lst{ExtractRegisterAs} operation (OpCode 198)}
\label{sec:serialization:operation:ExtractRegisterAs}

 Extracts register by id and type.
 Type param \lst{T} expected type of the register.
 Returns \lst{Some(value)} if the register is defined and has given type and \lst{None} otherwise
         See~\hyperref[sec:type:Box:getReg]{\lst{Box.getReg}}

\noindent
\(\begin{tabularx}{\textwidth}{| l | l | l | X |}
    \hline
    \bf{Slot} & \bf{Format} & \bf{\#bytes} & \bf{Description} \\
    \hline
         $ this $ & \lst{Expr} & [1, *] & this instance \\
    \hline
           $ regId $ & \lst{Byte} & 1 & zero-based identifier of the register. \\
    \hline
           $ type $ & \lst{Type} & [1, *] & expected type of the value in register \\
    \hline

\end{tabularx}\)

\subsubsection{\lst{ExtractCreationInfo} operation (OpCode 199)}
\label{sec:serialization:operation:ExtractCreationInfo}

 If \lst{tx} is a transaction which generated this box, then \lst{creationInfo._1}
 is a height of the tx's block. The \lst{creationInfo._2} is a serialized transaction
 identifier followed by box index in the transaction outputs.
         See~\hyperref[sec:type:Box:creationInfo]{\lst{Box.creationInfo}}

\noindent
\(\begin{tabularx}{\textwidth}{| l | l | l | X |}
    \hline
    \bf{Slot} & \bf{Format} & \bf{\#bytes} & \bf{Description} \\
    \hline
         $ this $ & \lst{Expr} & [1, *] & this instance \\
    \hline

\end{tabularx}\)

\subsubsection{\lst{CalcBlake2b256} operation (OpCode 203)}
\label{sec:serialization:operation:CalcBlake2b256}

Calculate Blake2b hash from \lst{input} bytes. See~\hyperref[sec:appendix:primops:CalcBlake2b256]{\lst{blake2b256}}

\noindent
\(\begin{tabularx}{\textwidth}{| l | l | l | X |}
    \hline
    \bf{Slot} & \bf{Format} & \bf{\#bytes} & \bf{Description} \\
    \hline
         $ input $ & \lst{Expr} & [1, *] & collection of bytes \\
    \hline

\end{tabularx}\)

\subsubsection{\lst{CalcSha256} operation (OpCode 204)}
\label{sec:serialization:operation:CalcSha256}

Calculate Sha256 hash from \lst{input} bytes. See~\hyperref[sec:appendix:primops:CalcSha256]{\lst{sha256}}

\noindent
\(\begin{tabularx}{\textwidth}{| l | l | l | X |}
    \hline
    \bf{Slot} & \bf{Format} & \bf{\#bytes} & \bf{Description} \\
    \hline
         $ input $ & \lst{Expr} & [1, *] & collection of bytes \\
    \hline

\end{tabularx}\)

\subsubsection{\lst{CreateProveDlog} operation (OpCode 205)}
\label{sec:serialization:operation:CreateProveDlog}

ErgoTree operation to create a new \lst{SigmaProp} value representing public key
 of discrete logarithm signature protocol.
         See~\hyperref[sec:appendix:primops:CreateProveDlog]{\lst{proveDlog}}

\noindent
\(\begin{tabularx}{\textwidth}{| l | l | l | X |}
    \hline
    \bf{Slot} & \bf{Format} & \bf{\#bytes} & \bf{Description} \\
    \hline
         $ value $ & \lst{Expr} & [1, *] & element of elliptic curve group \\
    \hline

\end{tabularx}\)

\subsubsection{\lst{CreateProveDHTuple} operation (OpCode 206)}
\label{sec:serialization:operation:CreateProveDHTuple}

 ErgoTree operation to create a new SigmaProp value representing public key
 of Diffie Hellman signature protocol.
 Common input: (g,h,u,v)
         See~\hyperref[sec:appendix:primops:CreateProveDHTuple]{\lst{proveDHTuple}}

\noindent
\(\begin{tabularx}{\textwidth}{| l | l | l | X |}
    \hline
    \bf{Slot} & \bf{Format} & \bf{\#bytes} & \bf{Description} \\
    \hline
         $ g $ & \lst{Expr} & [1, *] &  \\
    \hline
           $ h $ & \lst{Expr} & [1, *] &  \\
    \hline
           $ u $ & \lst{Expr} & [1, *] &  \\
    \hline
           $ v $ & \lst{Expr} & [1, *] &  \\
    \hline

\end{tabularx}\)

\subsubsection{\lst{SigmaPropBytes} operation (OpCode 208)}
\label{sec:serialization:operation:SigmaPropBytes}

Serialized bytes of this sigma proposition taken as ErgoTree. See~\hyperref[sec:type:SigmaProp:propBytes]{\lst{SigmaProp.propBytes}}

\noindent
\(\begin{tabularx}{\textwidth}{| l | l | l | X |}
    \hline
    \bf{Slot} & \bf{Format} & \bf{\#bytes} & \bf{Description} \\
    \hline
         $ this $ & \lst{Expr} & [1, *] & this instance \\
    \hline

\end{tabularx}\)

\subsubsection{\lst{BoolToSigmaProp} operation (OpCode 209)}
\label{sec:serialization:operation:BoolToSigmaProp}

Embedding of \lst{Boolean} values to \lst{SigmaProp} values.
 As an example, this operation allows boolean experessions
 to be used as arguments of \lst{atLeast(..., sigmaProp(boolExpr), ...)} operation.
 During execution results to either \lst{TrueProp} or \lst{FalseProp} values of \lst{SigmaProp} type.
         See~\hyperref[sec:appendix:primops:BoolToSigmaProp]{\lst{sigmaProp}}

\noindent
\(\begin{tabularx}{\textwidth}{| l | l | l | X |}
    \hline
    \bf{Slot} & \bf{Format} & \bf{\#bytes} & \bf{Description} \\
    \hline
         $ condition $ & \lst{Expr} & [1, *] & boolean value to embed in SigmaProp value \\
    \hline

\end{tabularx}\)

\subsubsection{\lst{DeserializeContext} operation (OpCode 212)}
\label{sec:serialization:operation:DeserializeContext}

Extracts context variable as \lst{Coll[Byte]}, deserializes it to script
 and then executes this script in the current context.
 The original \lst{Coll[Byte]} of the script is available as \lst{getVar[Coll[Byte]](id)}.
 Type parameter \lst{V} result type of the deserialized script.
 Throws an exception if the actual script type doesn't conform to T.
 Returns a result of the script execution in the current context
         See~\hyperref[sec:appendix:primops:DeserializeContext]{\lst{executeFromVar}}

\noindent
\(\begin{tabularx}{\textwidth}{| l | l | l | X |}
    \hline
    \bf{Slot} & \bf{Format} & \bf{\#bytes} & \bf{Description} \\
    \hline
         $ type $ & \lst{Type} & [1, *] & expected type of the deserialized script \\
    \hline
           $ id $ & \lst{Byte} & 1 & identifier of the context variable \\
    \hline

\end{tabularx}\)

\subsubsection{\lst{DeserializeRegister} operation (OpCode 213)}
\label{sec:serialization:operation:DeserializeRegister}

Extracts SELF register as \lst{Coll[Byte]}, deserializes it to script
 and then executes this script in the current context.
 The original \lst{Coll[Byte]} of the script is available as \lst{SELF.getReg[Coll[Byte]](id)}.
 Type parameter \lst{T} result type of the deserialized script.
 Throws an exception if the actual script type doesn't conform to \lst{T}.
 Returns a result of the script execution in the current context
         See~\hyperref[sec:appendix:primops:DeserializeRegister]{\lst{executeFromSelfReg}}

\noindent
\(\begin{tabularx}{\textwidth}{| l | l | l | X |}
    \hline
    \bf{Slot} & \bf{Format} & \bf{\#bytes} & \bf{Description} \\
    \hline
         $ id $ & \lst{Byte} & 1 & identifier of the register \\
    \hline
           $ type $ & \lst{Type} & [1, *] & expected type of the deserialized script \\
    \hline
          \multicolumn{4}{l}{\lst{optional}~$default$} \\
    \hline
    ~~$tag$ & \lst{Byte} & 1 & 0 - no value; 1 - has value \\
    \hline
    \multicolumn{4}{l}{~~\lst{when}~$tag == 1$} \\
    \hline
             ~~~~ $ default $ & \lst{Expr} & [1, *] & optional default value, if register is not available \\
    \hline
          \multicolumn{4}{l}{\lst{end optional}} \\
\end{tabularx}\)

\subsubsection{\lst{ValDef} operation (OpCode 214)}
\label{sec:serialization:operation:ValDef}

\noindent
\(\begin{tabularx}{\textwidth}{| l | l | l | X |}
    \hline
    \bf{Slot} & \bf{Format} & \bf{\#bytes} & \bf{Description} \\
    \hline
    % skipped OptionalScope(type arguments, ArrayBuffer())

\end{tabularx}\)

\subsubsection{\lst{FunDef} operation (OpCode 215)}
\label{sec:serialization:operation:FunDef}

\noindent
\(\begin{tabularx}{\textwidth}{| l | l | l | X |}
    \hline
    \bf{Slot} & \bf{Format} & \bf{\#bytes} & \bf{Description} \\
    \hline
    % skipped OptionalScope(type arguments, ArrayBuffer())

\end{tabularx}\)

\subsubsection{\lst{BlockValue} operation (OpCode 216)}
\label{sec:serialization:operation:BlockValue}

\noindent
\(\begin{tabularx}{\textwidth}{| l | l | l | X |}
    \hline
    \bf{Slot} & \bf{Format} & \bf{\#bytes} & \bf{Description} \\
    \hline
         $ numItems $ & \lst{VLQ(UInt)} & [1, *] & number of block items \\
    \hline
          \multicolumn{4}{l}{\lst{for}~$i=1$~\lst{to}~$numItems$} \\
    \hline
             ~~ $ item_i $ & \lst{Expr} & [1, *] & block's item in i-th position \\
    \hline
          \multicolumn{4}{l}{\lst{end for}} \\\hline
     $ result $ & \lst{Expr} & [1, *] & result expression of the block \\
    \hline

\end{tabularx}\)

\subsubsection{\lst{FuncValue} operation (OpCode 217)}
\label{sec:serialization:operation:FuncValue}

\noindent
\(\begin{tabularx}{\textwidth}{| l | l | l | X |}
    \hline
    \bf{Slot} & \bf{Format} & \bf{\#bytes} & \bf{Description} \\
    \hline
         $ numArgs $ & \lst{VLQ(UInt)} & [1, *] & number of function arguments \\
    \hline
          \multicolumn{4}{l}{\lst{for}~$i=1$~\lst{to}~$numArgs$} \\
    \hline
             ~~ $ id_i $ & \lst{VLQ(UInt)} & [1, *] & identifier of the i-th argument \\
    \hline
          ~~ $ type_i $ & \lst{Type} & [1, *] & type of the i-th argument \\
    \hline
          \multicolumn{4}{l}{\lst{end for}} \\\hline
     $ body $ & \lst{Expr} & [1, *] & function body, which is parameterized by arguments \\
    \hline

\end{tabularx}\)

\subsubsection{\lst{Apply} operation (OpCode 218)}
\label{sec:serialization:operation:Apply}

Apply the function to the arguments.  See~\hyperref[sec:appendix:primops:Apply]{\lst{apply}}

\noindent
\(\begin{tabularx}{\textwidth}{| l | l | l | X |}
    \hline
    \bf{Slot} & \bf{Format} & \bf{\#bytes} & \bf{Description} \\
    \hline
         $ func $ & \lst{Expr} & [1, *] & function which is applied \\
    \hline
           $ \#items $ & \lst{VLQ(UInt)} & [1, *] & number of items in the collection \\
    \hline
          \multicolumn{4}{l}{\lst{for}~$i=1$~\lst{to}~$\#items$} \\
    \hline
             ~~ $ args_i $ & \lst{Expr} & [1, *] & i-th item in the list of arguments \\
    \hline
          \multicolumn{4}{l}{\lst{end for}} \\
\end{tabularx}\)

\subsubsection{\lst{PropertyCall} operation (OpCode 219)}
\label{sec:serialization:operation:PropertyCall}

\noindent
\(\begin{tabularx}{\textwidth}{| l | l | l | X |}
    \hline
    \bf{Slot} & \bf{Format} & \bf{\#bytes} & \bf{Description} \\
    \hline
         $ typeCode $ & \lst{Byte} & 1 & type of the method (see Table~\ref{table:predeftypes}) \\
    \hline
           $ methodCode $ & \lst{Byte} & 1 & a code of the property \\
    \hline
           $ obj $ & \lst{Expr} & [1, *] & receiver object of this property call \\
    \hline

\end{tabularx}\)

\subsubsection{\lst{MethodCall} operation (OpCode 220)}
\label{sec:serialization:operation:MethodCall}

\noindent
\(\begin{tabularx}{\textwidth}{| l | l | l | X |}
    \hline
    \bf{Slot} & \bf{Format} & \bf{\#bytes} & \bf{Description} \\
    \hline
         $ typeCode $ & \lst{Byte} & 1 & type of the method (see Table~\ref{table:predeftypes}) \\
    \hline
           $ methodCode $ & \lst{Byte} & 1 & a code of the method \\
    \hline
           $ obj $ & \lst{Expr} & [1, *] & receiver object of this method call \\
    \hline
           $ \#items $ & \lst{VLQ(UInt)} & [1, *] & number of items in the collection \\
    \hline
          \multicolumn{4}{l}{\lst{for}~$i=1$~\lst{to}~$\#items$} \\
    \hline
             ~~ $ args_i $ & \lst{Expr} & [1, *] & i-th item in the arguments of the method call \\
    \hline
          \multicolumn{4}{l}{\lst{end for}} \\
\end{tabularx}\)

\subsubsection{\lst{GetVar} operation (OpCode 227)}
\label{sec:serialization:operation:GetVar}

Get context variable with given \lst{varId} and type. See~\hyperref[sec:appendix:primops:GetVar]{\lst{getVar}}

\noindent
\(\begin{tabularx}{\textwidth}{| l | l | l | X |}
    \hline
    \bf{Slot} & \bf{Format} & \bf{\#bytes} & \bf{Description} \\
    \hline
         $ varId $ & \lst{Byte} & 1 & \lst{Byte} identifier of context variable \\
    \hline
           $ type $ & \lst{Type} & [1, *] & expected type of context variable \\
    \hline

\end{tabularx}\)

\subsubsection{\lst{OptionGet} operation (OpCode 228)}
\label{sec:serialization:operation:OptionGet}

Returns the option's value. The option must be nonempty. Throws exception if the option is empty. See~\hyperref[sec:type:SOption:get]{\lst{SOption.get}}

\noindent
\(\begin{tabularx}{\textwidth}{| l | l | l | X |}
    \hline
    \bf{Slot} & \bf{Format} & \bf{\#bytes} & \bf{Description} \\
    \hline
         $ this $ & \lst{Expr} & [1, *] & this instance \\
    \hline

\end{tabularx}\)

\subsubsection{\lst{OptionGetOrElse} operation (OpCode 229)}
\label{sec:serialization:operation:OptionGetOrElse}

Returns the option's value if the option is nonempty, otherwise
return the result of evaluating \lst{default}.
         See~\hyperref[sec:type:SOption:getOrElse]{\lst{SOption.getOrElse}}

\noindent
\(\begin{tabularx}{\textwidth}{| l | l | l | X |}
    \hline
    \bf{Slot} & \bf{Format} & \bf{\#bytes} & \bf{Description} \\
    \hline
         $ this $ & \lst{Expr} & [1, *] & this instance \\
    \hline
           $ default $ & \lst{Expr} & [1, *] & the default value \\
    \hline

\end{tabularx}\)

\subsubsection{\lst{OptionIsDefined} operation (OpCode 230)}
\label{sec:serialization:operation:OptionIsDefined}

Returns \lst{true} if the option is an instance of \lst{Some}, \lst{false} otherwise. See~\hyperref[sec:type:SOption:isDefined]{\lst{SOption.isDefined}}

\noindent
\(\begin{tabularx}{\textwidth}{| l | l | l | X |}
    \hline
    \bf{Slot} & \bf{Format} & \bf{\#bytes} & \bf{Description} \\
    \hline
         $ this $ & \lst{Expr} & [1, *] & this instance \\
    \hline

\end{tabularx}\)

\subsubsection{\lst{SigmaAnd} operation (OpCode 234)}
\label{sec:serialization:operation:SigmaAnd}

Returns sigma proposition which is proven when \emph{all} the elements in collection are proven. See~\hyperref[sec:appendix:primops:SigmaAnd]{\lst{allZK}}

\noindent
\(\begin{tabularx}{\textwidth}{| l | l | l | X |}
    \hline
    \bf{Slot} & \bf{Format} & \bf{\#bytes} & \bf{Description} \\
    \hline
         $ \#items $ & \lst{VLQ(UInt)} & [1, *] & number of items in the collection \\
    \hline
          \multicolumn{4}{l}{\lst{for}~$i=1$~\lst{to}~$\#items$} \\
    \hline
             ~~ $ propositions_i $ & \lst{Expr} & [1, *] & i-th item in the a collection of propositions \\
    \hline
          \multicolumn{4}{l}{\lst{end for}} \\
\end{tabularx}\)

\subsubsection{\lst{SigmaOr} operation (OpCode 235)}
\label{sec:serialization:operation:SigmaOr}

Returns sigma proposition which is proven when \emph{any} of the elements in collection is proven. See~\hyperref[sec:appendix:primops:SigmaOr]{\lst{anyZK}}

\noindent
\(\begin{tabularx}{\textwidth}{| l | l | l | X |}
    \hline
    \bf{Slot} & \bf{Format} & \bf{\#bytes} & \bf{Description} \\
    \hline
         $ \#items $ & \lst{VLQ(UInt)} & [1, *] & number of items in the collection \\
    \hline
          \multicolumn{4}{l}{\lst{for}~$i=1$~\lst{to}~$\#items$} \\
    \hline
             ~~ $ propositions_i $ & \lst{Expr} & [1, *] & i-th item in the a collection of propositions \\
    \hline
          \multicolumn{4}{l}{\lst{end for}} \\
\end{tabularx}\)

\subsubsection{\lst{BinOr} operation (OpCode 236)}
\label{sec:serialization:operation:BinOr}

Logical OR of two operands See~\hyperref[sec:appendix:primops:BinOr]{\lst{||}}

\noindent
\(\begin{tabularx}{\textwidth}{| l | l | l | X |}
    \hline
    \bf{Slot} & \bf{Format} & \bf{\#bytes} & \bf{Description} \\
    \hline
        \multicolumn{4}{l}{\lst{match}~$ (left, right) $} \\

    \multicolumn{4}{l}{~~\lst{otherwise} } \\
    \hline
            ~~~~ $ left $ & \lst{Expr} & [1, *] & left operand \\
    \hline
          ~~~~ $ right $ & \lst{Expr} & [1, *] & right operand \\
    \hline
          \multicolumn{4}{l}{\lst{end match}} \\
\end{tabularx}\)

\subsubsection{\lst{BinAnd} operation (OpCode 237)}
\label{sec:serialization:operation:BinAnd}

Logical AND of two operands See~\hyperref[sec:appendix:primops:BinAnd]{\lst{&&}}

\noindent
\(\begin{tabularx}{\textwidth}{| l | l | l | X |}
    \hline
    \bf{Slot} & \bf{Format} & \bf{\#bytes} & \bf{Description} \\
    \hline
        \multicolumn{4}{l}{\lst{match}~$ (left, right) $} \\

    \multicolumn{4}{l}{~~\lst{otherwise} } \\
    \hline
            ~~~~ $ left $ & \lst{Expr} & [1, *] & left operand \\
    \hline
          ~~~~ $ right $ & \lst{Expr} & [1, *] & right operand \\
    \hline
          \multicolumn{4}{l}{\lst{end match}} \\
\end{tabularx}\)

\subsubsection{\lst{DecodePoint} operation (OpCode 238)}
\label{sec:serialization:operation:DecodePoint}

Convert \lst{Coll[Byte]} to \lst{GroupElement} using \lst{GroupElementSerializer} See~\hyperref[sec:appendix:primops:DecodePoint]{\lst{decodePoint}}

\noindent
\(\begin{tabularx}{\textwidth}{| l | l | l | X |}
    \hline
    \bf{Slot} & \bf{Format} & \bf{\#bytes} & \bf{Description} \\
    \hline
         $ input $ & \lst{Expr} & [1, *] & serialized bytes of some \lst{GroupElement} value \\
    \hline

\end{tabularx}\)

\subsubsection{\lst{LogicalNot} operation (OpCode 239)}
\label{sec:serialization:operation:LogicalNot}

Logical NOT operation. Returns \lst{true} if input is \lst{false} and \lst{false} if input is \lst{true}. See~\hyperref[sec:appendix:primops:LogicalNot]{\lst{unary_!}}

\noindent
\(\begin{tabularx}{\textwidth}{| l | l | l | X |}
    \hline
    \bf{Slot} & \bf{Format} & \bf{\#bytes} & \bf{Description} \\
    \hline
         $ input $ & \lst{Expr} & [1, *] & input \lst{Boolean} value \\
    \hline

\end{tabularx}\)

\subsubsection{\lst{Negation} operation (OpCode 240)}
\label{sec:serialization:operation:Negation}

Negates numeric value \lst{x} by returning \lst{-x}. See~\hyperref[sec:appendix:primops:Negation]{\lst{unary_-}}

\noindent
\(\begin{tabularx}{\textwidth}{| l | l | l | X |}
    \hline
    \bf{Slot} & \bf{Format} & \bf{\#bytes} & \bf{Description} \\
    \hline
         $ input $ & \lst{Expr} & [1, *] & value of numeric type \\
    \hline

\end{tabularx}\)

\subsubsection{\lst{BinXor} operation (OpCode 244)}
\label{sec:serialization:operation:BinXor}

Logical XOR of two operands See~\hyperref[sec:appendix:primops:BinXor]{\lst{^}}

\noindent
\(\begin{tabularx}{\textwidth}{| l | l | l | X |}
    \hline
    \bf{Slot} & \bf{Format} & \bf{\#bytes} & \bf{Description} \\
    \hline
        \multicolumn{4}{l}{\lst{match}~$ (left, right) $} \\

    \multicolumn{4}{l}{~~\lst{otherwise} } \\
    \hline
            ~~~~ $ left $ & \lst{Expr} & [1, *] & left operand \\
    \hline
          ~~~~ $ right $ & \lst{Expr} & [1, *] & right operand \\
    \hline
          \multicolumn{4}{l}{\lst{end match}} \\
\end{tabularx}\)

\subsubsection{\lst{XorOf} operation (OpCode 255)}
\label{sec:serialization:operation:XorOf}

Similar to \lst{allOf}, but performing logical XOR operation between all conditions instead of \lst{&&} See~\hyperref[sec:appendix:primops:XorOf]{\lst{xorOf}}

\noindent
\(\begin{tabularx}{\textwidth}{| l | l | l | X |}
    \hline
    \bf{Slot} & \bf{Format} & \bf{\#bytes} & \bf{Description} \\
    \hline
         $ conditions $ & \lst{Expr} & [1, *] & a collection of conditions \\
    \hline

\end{tabularx}\)

\subsubsection{\lst{SubstConstants} operation (OpCode 116)}
\label{sec:serialization:operation:SubstConstants}

Transforms serialized bytes of ErgoTree with segregated constants by replacing constants
 at given positions with new values. This operation allow to use serialized scripts as
 pre-defined templates.
 The typical usage is "check that output box have proposition equal to given script bytes,
 where minerPk (constants(0)) is replaced with currentMinerPk".
 Each constant in original scriptBytes have SType serialized before actual data (see ConstantSerializer).
 During substitution each value from newValues is checked to be an instance of the corresponding type.
 This means, the constants during substitution cannot change their types.

 Returns original scriptBytes array where only specified constants are replaced and all other bytes remain exactly the same.
         See~\hyperref[sec:appendix:primops:SubstConstants]{\lst{substConstants}}

\noindent
\(\begin{tabularx}{\textwidth}{| l | l | l | X |}
    \hline
    \bf{Slot} & \bf{Format} & \bf{\#bytes} & \bf{Description} \\
    \hline
         $ scriptBytes $ & \lst{Expr} & [1, *] & serialized ErgoTree with ConstantSegregationFlag set to 1. \\
    \hline
           $ positions $ & \lst{Expr} & [1, *] & zero based indexes in ErgoTree.constants array which should be replaced with new values \\
    \hline
           $ newValues $ & \lst{Expr} & [1, *] & new values to be injected into the corresponding positions in ErgoTree.constants array \\
    \hline

\end{tabularx}\)

\subsubsection{\lst{LongToByteArray} operation (OpCode 122)}
\label{sec:serialization:operation:LongToByteArray}

Converts \lst{Long} value to big-endian bytes representation. See~\hyperref[sec:appendix:primops:LongToByteArray]{\lst{longToByteArray}}

\noindent
\(\begin{tabularx}{\textwidth}{| l | l | l | X |}
    \hline
    \bf{Slot} & \bf{Format} & \bf{\#bytes} & \bf{Description} \\
    \hline
         $ input $ & \lst{Expr} & [1, *] & value to convert \\
    \hline

\end{tabularx}\)

\subsubsection{\lst{ByteArrayToBigInt} operation (OpCode 123)}
\label{sec:serialization:operation:ByteArrayToBigInt}

Convert big-endian bytes representation (Coll[Byte]) to BigInt value. See~\hyperref[sec:appendix:primops:ByteArrayToBigInt]{\lst{byteArrayToBigInt}}

\noindent
\(\begin{tabularx}{\textwidth}{| l | l | l | X |}
    \hline
    \bf{Slot} & \bf{Format} & \bf{\#bytes} & \bf{Description} \\
    \hline
         $ input $ & \lst{Expr} & [1, *] & collection of bytes in big-endian format \\
    \hline

\end{tabularx}\)

\subsubsection{\lst{ByteArrayToLong} operation (OpCode 124)}
\label{sec:serialization:operation:ByteArrayToLong}

Convert big-endian bytes representation (Coll[Byte]) to Long value. See~\hyperref[sec:appendix:primops:ByteArrayToLong]{\lst{byteArrayToLong}}

\noindent
\(\begin{tabularx}{\textwidth}{| l | l | l | X |}
    \hline
    \bf{Slot} & \bf{Format} & \bf{\#bytes} & \bf{Description} \\
    \hline
         $ input $ & \lst{Expr} & [1, *] & collection of bytes in big-endian format \\
    \hline

\end{tabularx}\)

\subsubsection{\lst{Downcast} operation (OpCode 125)}
\label{sec:serialization:operation:Downcast}

Cast this numeric value to a smaller type (e.g. Long to Int). Throws exception if overflow. See~\hyperref[sec:appendix:primops:Downcast]{\lst{downcast}}

\noindent
\(\begin{tabularx}{\textwidth}{| l | l | l | X |}
    \hline
    \bf{Slot} & \bf{Format} & \bf{\#bytes} & \bf{Description} \\
    \hline
         $ input $ & \lst{Expr} & [1, *] & value to cast \\
    \hline
           $ type $ & \lst{Type} & [1, *] & resulting type of the cast operation \\
    \hline

\end{tabularx}\)

\subsubsection{\lst{Upcast} operation (OpCode 126)}
\label{sec:serialization:operation:Upcast}

Cast this numeric value to a bigger type (e.g. Int to Long) See~\hyperref[sec:appendix:primops:Upcast]{\lst{upcast}}

\noindent
\(\begin{tabularx}{\textwidth}{| l | l | l | X |}
    \hline
    \bf{Slot} & \bf{Format} & \bf{\#bytes} & \bf{Description} \\
    \hline
         $ input $ & \lst{Expr} & [1, *] & value to cast \\
    \hline
           $ type $ & \lst{Type} & [1, *] & resulting type of the cast operation \\
    \hline

\end{tabularx}\)


\chapter{DCM for Induced Responses \label{Chap:data:dcm_ir}}

This chapter shows an example of Dynamic Causal Modelling for Induced Responses (DCM-IR) \cite{cc_induced}. The example is based on the analysis described by Chen et al. \cite{cc_asymm}. The purpose of the analysis is to look at the effective connectivity between cortical areas involved in the processing of faces and specifically at non-linearities in the connections expressed as cross-frequency coupling. DCM-IR is an example of a phenomenological rather than physiological DCM. The advantage of this approach is that it can directly model a particular feature extracted from the data, namely event-related spectral perturbations. This feature has been a popular object of study in the neuroscience literature. However, since computing event-related power involves discarding phase information, it is not possible to model this feaure with a physiologically realistic model such as the one used in DCM for evoked responses. An important feature of DCM for induced responses is that it models the full time-frequency spectrum. This differs from typical approaches, where a few specific frequency bands are selected \textit{a priori}. DCM-IR models spectral dynamics in terms of a mixture of frequency modes (obtained with singular value decomposition). The dynamics of each mode are encoded by the evolution of a state. It is this multi-state vector, for each source, that captures how the energy in different frequencies interacts, either linearly or non-linearly, among sources.

\section{Data}

We will use the epoched and merged MEG dataset from Chapter~\ref{multimodal:data:meg} saved in the files:

\begin{verbatim}
cdbespm8_SPM_CTF_MEG_example_faces1_3D.mat
cdbespm8_SPM_CTF_MEG_example_faces1_3D.dat
\end{verbatim}

See ~\ref{multimodal:data:meg:preproc} for the instructions for how to generate these files from raw MEG data. DCM-IR also requires a head model and coregistration. If you have performed ``Imaging'' reconstruction of differential power \ref{multimodal:data:meg:recon_pow} and saved the results, the head model should already be defined. Otherwise, you will be asked to define the head model while configuring the DCM (see below).

\section{Getting Started}

You need to start SPM and toggle ``EEG'' as the modality (bottom-right of SPM main window), or start SPM with \texttt{spm eeg}. In order for this to work you need to ensure that the main SPM directory is on your \matlab\ path.

\section{Setting up DCM}

After calling \texttt{spm eeg}, you see SPM's graphical user interface, the top-left window. The button for calling the DCM-GUI is found in the second partition from the top, on the right hand side. When pressing the button, the GUI pops up (Figure~\ref{dcm-ir:fig:1}). The GUI is partitioned into five parts, going from the top to the bottom. The first part is about loading and saving existing DCMs, and selecting the type of model. The second part is about selecting data, the third is for specification of the spatial forward model, the fourth is for specifying connectivity, and the last row of buttons allows you to estimate parameters and view results.

\begin{figure}
\begin{center}
\includegraphics[width=100mm]{dcm_ir/figures/irfigure1}
\caption{\em DCM window configured analysing induced responses and the FnBn model specified.\label{dcm-ir:fig:1}}
\end{center}
\end{figure}

You have to select the data first and specify the model in a fixed order (data selection $>$ spatial model $>$
connectivity model). This order is necessary, because there are dependencies among the three parts that would be hard to resolve
if the input could be entered in any order. At any time, you can switch back and forth from one part to the next. Also, within each part, you can specify information in any order you like.

\subsection{load, save, select model type}
At the top of the GUI, you can load an existing DCM or save the one you are currently working on. In general, you can \texttt{save} and \texttt{load} during model specification at any time. You can also switch between different DCM analyses (the left menu). The default is ``ERP'' which is DCM for evoked responses. You should switch to ``IND'' which is the option for DCM-IR. The menu on the right-hand side lets you choose the neuronal model. Once you switch to ``IND'', it will be disabled since neuronal models are not relevant for DCM-IR, which is a phenomenological DCM.

\subsection{Data and design}
In this part, you select the data and model between-trial effects. Press ``new data'' and select the data file \texttt{cdbespm8\_\-SPM\_\-CTF\_\-MEG\_\-example\_\-faces1\_\-3D.mat}.The data file will usually be an epoched file with multiple trials per condition. These data must be in SPM-format. On the right-hand side you can enter trial indices of the evoked responses in this SPM-file. For example, if you want to model the first and second condition contained within an SPM-file, specify
indices \texttt{1} and \texttt{2}. You can type:
\begin{verbatim}
D = spm_eeg_load(`cdbespm8_SPM_CTF_MEG_example_faces1_3D.mat');D.condlist
\end{verbatim}
in the command line to see the list of condition labels in the order that corresponds to these indices. This order is defined in the dataset and can be modified by selecting ``Sort Conditions'' from the ``Other'' submenu in main SPM window (\textit{spm\_eeg\_sort\_conditions}). SPM should echo:
\begin{verbatim}
ans =

    'faces'    'scrambled'
\end{verbatim}
meaning that index \texttt{1} corresponds to presentation of faces and index \texttt{2} - to presentation of scrambled faces. The box below the list of indices allows specifying experimental effects on connectivity. The specification can be quite generic as in the design matrix for a General Linear Model (GLM). Our case is quite simple though. We have a baseline condition which is ``scrambled'' and we would like to know how the condition of interest ``faces'' differs from it. We will therefore enter:
\begin{verbatim}
1 0
\end{verbatim}
in first row of the box, which means that there will be some additive modulation of connections that we will define later for ``faces''  (some coefficient multiplied by 1) and this modulation will not be there for ``scrambled'' (the same coefficient multiplied by 0). If we now click somewhere outside the box, a default name will be assigned to this effect - ``effect1''. It will appear in the small text box next to the coefficients box. It is possible to change this name to something else e.g. ``face''.

Now we can select the peristimulus time window we want to model. These are the two test boxes in the top left corner of the panel. Enter \texttt{-50} in the left box and \texttt{300} in the right box to select the segment \texttt{-50} to \texttt{300} ms relative to the presentation of the visual stimulus.

You can choose whether you want to remove low-frequency drifts of the data at sensor level. If you don't, select \texttt{1} for ``detrend'', to just remove the mean. Otherwise select the number of discrete cosine transform terms you want to remove. You can also subsample your data (prior to computing the time-frequency decomposition) using the ``subsample'' option. In general, it is advised to filter out drifts and downsample the data during preprocessing. The options here are just to \textit{play around} with, clean up or reduce the data to see what effect it might have without running additional processing steps outside DCM.

Press the ``Display'' button to look at the selected data. You will see the evoked responses for the two conditions (Figure~\ref{dcm-ir:fig:2}) which help you get some idea about your choice of time window. It is possible to change the ``detrend'' and ``subsample'' values or the time window and press ``Display' again to see what effect these changes have.

An important parameter for DCM-IR is the number of modes. These are the frequency modes mentioned above. The idea is that the main features of the time-frequency image can be represented by a small number of components with fixed frequency profiles that are modulated over time. These components can be determined automatically using ``Singular Value Decomposition'' (SVD). Generally SVD preserves information from the original time-frequency image and produces as many components as there are frequency bins. However, usually only the first few components are physiologically relevant and the rest are just noise. Using a small number of components will greatly speed-up DCM model inversion. You cannot know in advance what the optimal number of components for your data is. What you can do is try once with a relatively large number (e.g. 8) and then see from the time and frequency profile of the later components (in the Results view, see below) whether they are important. Then you can reduce the number and try again. For the example here it is sufficient to use 4 modes so change the number in ``modes'' from 8 to 4.

\begin{figure}
\begin{center}
\includegraphics[width=160mm]{dcm_ir/figures/irfigure2}
\caption{\em Averaged evoked responses after configuring the 'Data and design' section.\label{dcm-ir:fig:2}}
\end{center}
\end{figure}

If you are happy with your data selection, the subsampling and the detrending terms, you can click on the $>$ (forward) button, which will bring you to the next stage \textit{electromagnetic model}. From this part, you can press the red $<$ button to get back to the data and design part.

\subsection{Electromagnetic model}
With DCM-IR, you have two options for how to extract the source data for time-frequency analysis. Firstly, you can use 3 orthogonal single equivalent current dipoles (ECD) for each source and invert the resulting source model to get source waveforms. This option is suitable for multichannel EEG or MEG data. Alternatively, you can treat each channel as a source (LFP option). This is appropriate when the channels already contain source data either recorded directly with intracranial electrodes or extracted (e.g. using a beamformer).

Note that a difference with DCM for evoked responses is that the parameters of the spatial model are not optimized. This means that DCM-IR will project the data into source space using the spatial locations you provide.

We will use the ECD option. This requires specifying a list of source names in the left large text box and a list of MNI coordinates for the sources in the right large text box. Enter the following in the left box:

\begin{verbatim}
lOFA
rOFA
lFFA
rFFA
\end{verbatim}

Now enter in the right text box:

\begin{verbatim}
-39 -81 -15
 42 -81 -15
-39 -51 -24
 42 -45 -27
\end{verbatim}

These correspond to left Occipital Face Area, right Occipital Face Area, left Fusiform Face Area and right Fusiform Face Area respectively. See \cite{cc_induced} for more details.

The onset-parameter determines when the stimulus, presented at 0 ms peri-stimulus time, is assumed to trigger the cortical induced response. In DCM, we usually do not model the rather small early responses, but start modelling at the first large deflection. Because the propagation of the stimulus impulse through the input nodes causes a delay, we found that the default value of 60
ms onset time is a good value for many responses where the first large deflection is seen around 100 ms. However, this value is a
prior, i.e. the inversion routine can adjust it. The prior mean should be chosen according to the specific responses of interest. This is because the time until the first large deflection is dependent on the paradigm or the modality you are working in, e.g. audition or vision. You may also find that changing the onset prior has an effect on how your data are
fitted. This is because the onset time has strongly nonlinear effects (a delay) on the data, which might cause differences in the maximum found at convergence, for different prior values. Note, that it is possible to enter more than one number in the ``onset[s] (ms)'' box. This will add several inputs to the model. These inputs can then be connected to different nodes and/or their timing and frequency profiles can be optimized separately.

When you want to proceed to the next model specification stage, hit the $>$ (forward) button and proceed to the \textit{neuronal model}. If you have not used the input dataset for 3D source reconstruction before you will be asked to specify the parameters of the head model at this stage. See ~\ref{multimodal:data:meg:recon_pow}.

\section{Neuronal model}
There are 4 (or more) matrices which you need to specify by button presses. In the first row there are matrices that define the connectivity structure of the model and in the second row there are matrices that specify which connections are affected by experimental effects. All the matrices except one are square. In each of these square matrices you specify a connection \textit{from} a source area \textit{to} a target area. For example, switching on the element $(2,\;1)$ means that you specify a connection from area 1 to 2 (in our case from lOFA to rOFA). Some people find the meaning of each element slightly counter-intuitive, because the column index corresponds to the source area, and the row index to the target area. This convention is motivated by direct correspondence between the matrices of buttons in the GUI and connectivity matrices in DCM equations and should be clear to anyone familiar with matrix multiplication.

The leftmost matrix in the first row specifies the \textit{linear} connections. These are the connections where frequency dynamics in one source affects the dynamics at the same frequencies in another source. Note that all connections in the model should be at least linear, so if you think some connection should be present in the model, the corresponding button in this matrix should be on. Also the buttons on the leading diagonal of the matrix are always on because each node in the model has a linear  intrinsic connection with negative sign. This means that the activity has a tendency to dissipate. To the right of the linear connectivity matrix there is a \textit{nonlinear} connectivity matrix. The idea here is the same, just remember to enable the corresponding linear connection as well. When a connection is nonlinear, a frequency mode in the source node can affect all the frequency modes in the target node. Intrinsic connections can be made non-linear as well. It is actually recommended to always make the intrinsic connections non-linear unless there is a good theoretical reason not to do it. Since we are mainly interested in non-linearities in the extrinsic connections we would like to be over-conservative and first explain away anything that can be explained by non-linearities in the intrinsic connnections.

The rightmost matrix in the first row is the input matrix. It is usually not square, and in the case of a single input, as we have here, is reduced to a column vector. The entries of this vector specify which areas receive the external input (whose onset time we specified above). In the case of several inputs the input matrix will have several columns.

The matrix (matrices) in the second row specify which of the connections defined in the first row can be modified by experimental effects. A connection which is not modified will have the same value for all conditions. If you don't allow modification of any of the connections, then exactly the same model will be fitted to all conditions. For the purpose of allowing modification by experimental effects, it does not matter whether a connection is linear or non-linear. Hence, there is one modulation matrix per experimental effect (defined in the ``Data and design'' panel). In our case there is only one effect - faces vs. scrambled faces. Also self connections can be modified by experimental effects, thus the diagonal entries of the second row matrices can also be toggled.

Figure ~\ref{dcm-ir:fig:3} is taken from the paper of Chen et al. \cite{cc_asymm} and shows several alternative models that could apply to the data. We will start by specifying the model with nonlinear forward and backward connections (FnBn) and with effect of condition on these connections. The corresponding button configuration is shown in Figure ~\ref{dcm-ir:fig:4}. Compare the depiction of FnBn model in Figure~\ref{dcm-ir:fig:3}  with the specification in Figure~\ref{dcm-ir:fig:4}  to see the correspondence. Note that the effect of condition is not shown in Figure~\ref{dcm-ir:fig:3}. Now copy the specification to the DCM GUI.

\begin{figure}
\begin{center}
\includegraphics[width=160mm]{dcm_ir/figures/irfigure3}
\caption{\em Four different DCM-IR models proposed by Chen et al. \cite{cc_asymm} \label{dcm-ir:fig:3}}
\end{center}
\end{figure}

\begin{figure}
\begin{center}
\includegraphics[width=60mm]{dcm_ir/figures/irfigure4}
\caption{\em Connectivity configuration for the FnBn model.\label{dcm-ir:fig:4}}
\end{center}
\end{figure}

At the bottom of this panel there are additional radio buttons for options that are not relevant for DCM-IR. Below these buttons there are controls for specifying the parameters of the wavelet transform for computing the time-frequency decomposition. We will keep the default frequency window 4 to 48 Hz and increase the number of wavelet cycles to 7. You can press the \textit{Wavelet transform} button to preview the time-frequency plots and optimize the parameters if necessary before inverting the model.

\section{Estimation}
When you have finished model specification, you can hit the \textit{invert DCM} button in the lower left corner. DCM will now estimate the model parameters. You can follow the estimation process by observing the model fit in the output window. Note that in DCM-IR there is no difference between the hidden states and the predicted responses because the dynamics of the hidden states fit directly the time course of frequency modes (shown as dotted lines in the middle plot). This is different from DCM for ERP where the hidden states correspond to neural dynamics and a subset of the hidden states (activation of pyramidal cells) are projected via the forward model to generate predictions of sensor data. In the \matlab\ command window, you will see each iteration print an expectation-maximization iteration number, free energy $F$, and the predicted and actual change of $F$ following each iteration step. At convergence, DCM saves the results in a DCM file, by default named \texttt{DCM\_*.mat} where \texttt{*} corresponds to the name of the original SPM MEG file you specified. You can save to a different name, e.g. if you are estimating multiple models, by pressing 'save' at the top of the GUI and writing to a different name.

\section{Results}
After estimation is finished, you can assess the results by choosing from the pull-down menu at the bottom (middle).

\subsection{Frequency modes}
This will display the frequency profiles of the modes, identified using singular value decomposition of spectral dynamics in source space (over time and sources).

\subsection{Time modes}
This will display the observed time courses of the frequency modes (dashed lines) and the model predictions (solid lines). Here you can also see whether the activity picked up by the minor modes is noise, which is helpful for optimizing the number of modes.

\subsection{Time-Frequency}
This will display the observed time-frequency power data for all pre-specified sources (upper panel) and the fitted data features (lower panel).

\subsection{Coupling (A-Hz)}
This will display the coupling matrices representing the coupling strength from source to target frequencies. These matrices are obtained by multiplying the between-mode matrices estimated with the frequency profiles of the modes (see \cite{cc_induced}). The arrangement of the matrices corresponds to arrangements of the buttons in the connectivity matrices above.

\subsection{Coupling (B-Hz)}
This presentation of results is similar to the above and reports modification of coupling by condition (eg. in our example it shows which frequency couplings are different for faces as opposed to scrambled faces).

\subsection{Coupling (A-modes)}
This will display the coupling matrices between modes and the conditional probabilities that the coefficients are different from zero. This representation is useful for diagnostics when something is wrong with the inversion, but the physiological interpretation is less straightforward.

\subsection{Coupling (B-Hz)}
This presentation is similar to the above and reports the modification of coupling by condition.

\subsection{Input (C-Hz)}
This shows the frequency profiles of the inputs estimated. This is again a multiplication between the mode-specific coefficients and the frequency profiles of the modes.

\subsection{Input (u-ms)}
This shows the time courses of the inputs.

\subsection{Dipoles}
This shows the positions of the sources as specified in the ``Electromagnetic model'' section.

\subsection{Save as img}
Here you can save the cross-frequency coupling matrices as images. If you are analyzing a group of subjects you can then enter these images into parametric statistical tests to find common features in coupling and coupling changes accross subjects. The image names will include identifiers like ``A12'' or ``B31'' which relate to the source connection matrices; either the basic (A) or experimental effects (B).

\section{Model comparison}

You can now compare the fully nonlinear model with alternative models (eg. those shown in Figure~\ref{dcm-ir:fig:3}). You can start by saving the DCM you have already specified under a different name using the \textit{Save} button. Then just modify the connectivity matrices and reinvert the DCM by pressing the ``Estimated'' button (but not using previous posterior or prior estimates). As an exercise, you can specify the other models from Figure~\ref{dcm-ir:fig:3} yourself. If in doubt look at Figure~\ref{dcm-ir:fig:5} for the three alternative models. Once you have specified and inverted the three additional models, you can perform Bayesian model comparison.

\begin{figure}
\begin{center}
\includegraphics[width=40mm]{dcm_ir/figures/irfigure5_FlBl}
\includegraphics[width=40mm]{dcm_ir/figures/irfigure5_FlBn}
\includegraphics[width=40mm]{dcm_ir/figures/irfigure5_FnBl}
\caption{\em Connectivity configurations for the alternative models. Left to right: FlBl, FlBn, FnBl. \label{dcm-ir:fig:5}}
\end{center}
\end{figure}

Press the \textsc{BMS} button. This will open the SPM batch tool for model selection. Specify a directory to write the output file to.  For the ``Inference method'' select ``Fixed effects'' (see \cite{klaas_bms} for additional explanations). Then click on ``Data'' and in the box below click on ``New: Subject''. Click on ``Subject'' and in the box below on ``New: Session''. Click on models and in the selection window that comes up select the DCM mat files for all the models (remember the order in which you select the files as this is necessary for interpreting the results). Then run the model comparison by pressing the green ``Run'' button. You will see, at the top, a bar plot of the log-model evidences for all models ~\ref{dcm-ir:fig:6}. At the bottom, you will see the posterior probability, for each model, given the data. By convention, a model can be said to be the best among a selection of other models, with strong evidence, if its log-model evidence exceeds all other log-model evidences by at least 3. In our case the FnBn model is superior to the other models as was found in the original paper \cite{cc_asymm} for a different group of subjects.

\begin{figure}
\begin{center}
\includegraphics[width=50mm]{dcm_ir/figures/irfigure6}
\caption{\em Bayesian comparison of the four DCM-IR models shown in Figure~\ref{dcm-ir:fig:3}.\label{dcm-ir:fig:6}}
\end{center}
\end{figure}