Iterate Module

The iterate module manages the state for each EMC iteration.

This class is usually used in conjunction with the EMCRecon class.

Configuration

Initialize from a configuration file:

from dragonfly.iterate import Iterate

itr = Iterate('config.ini', section_name='emc')
class dragonfly.iterate.Iterate(config_fname='', section_name='emc', resume=False)

Bases: object

Class managing state for each EMC iteration.

Handles loading configuration, data, model, and quaternion data for iterative reconstruction.

Parameters:
  • config_fname (str) – Path to configuration file. Default ‘’.

  • section_name (str) – Section name. Default ‘emc’.

  • resume (bool) – Resume from last iteration. Default False.

beta

Per-frame beta values.

beta_start

Initial per-frame beta values.

bgscale

Per-frame background scale factors.

blacklist

Frame blacklist mask (1=blacklisted, 0=good).

calc_beta(self, setval=None)

Calculate beta values for each frame.

Parameters:

setval (float) – Set all betas to this value. Default None.

static calculate_size(qmax)

Calculate model size from qmax.

Parameters:

qmax (float) – Maximum q value.

Returns:

Model grid size.

Return type:

int

data

Dataset.

det_mapping

Mapping from frames to detectors.

dets

List of detector objects.

fcounts

Frame photon counts.

finalize_blacklist(self)

Finalize local blacklist-derived counters after any distribution.

free(self)

Free allocated iteration memory.

from_config(self, config_fname, section_name='emc', resume=False)

Load configuration and initialize from file.

Parameters:
  • config_fname (str) – Path to configuration file.

  • section_name (str) – Section name. Default ‘emc’.

  • resume (bool) – Resume from last iteration. Default False.

initialize_last_selected(self, fname='')

Initialize or load stochastic coverage sampling history.

initialize_stochastic_scale(self)

Mark fresh stochastic-EMC scale factors as not yet estimated.

last_selected

Last iteration where each frame was selected for stochastic EMC.

likelihood

Current log-likelihood value.

load_active_data(self, update_powder=False)

Load currently active sparse binary frames for lazy_data mode.

load_previous_blacklist(self, fname)

Load held dynamic blacklist when resuming within a data fraction period.

mean_count

Mean photon count per detector.

model

Current model.

mutual_info

Current mutual information value.

normalize_scale(self)

Normalize scale factors.

num_det

Number of unique detectors.

num_dfiles

Number of data files.

params

Parameters.

parse_blacklist(self, fname, sel_string=None, refresh=False)

Generate or update blacklist.

Blacklist file contains one number (0 or 1) per frame indicating whether the frame is blacklisted (1) or good (0).

Parameters:
  • fname (str) – Path to blacklist file.

  • sel_string (str) – Selection string (‘odd_only’ or ‘even_only’). Default None.

  • refresh (bool) – Refresh the blacklist. Default False.

parse_scale(self, fname, bg=False)

Parse or initialize scale factors.

Parameters:
  • fname (str) – Path to scale file or empty string for defaults.

  • bg (bool) – Parse background scale. Default False.

quat

Quaternion orientations.

refresh_data_stats(self, update_powder=True)

Recalculate eager data statistics after changing the blacklist.

rescale

Per-detector rescale factors.

rms_change

RMS change between iterations.

scale

Per-frame scale factors.

set_data(self, CDataset in_dset)

Set the data with a new dataset.

Parameters:

in_dset (CDataset) – Dataset to use.

set_model(self, Model model)

Set the model.

Parameters:

model (Model) – Model object.

set_params(self, EMCParams param)

Set the parameters.

Parameters:

param (EMCParams) – Parameters object.

set_quat(self, Quaternion quaternion)

Set the quaternion orientations.

Parameters:

quaternion (Quaternion) – Quaternion object.

static_blacklist

Static frame blacklist mask before stochastic sampling.

tot_num_data

Total number of frames.

update_blacklist(self, force=False, finalize=True)

Update active blacklist for the current iteration.

update_data(self, CDataset in_dset)

Update the data with a new dataset.

Parameters:

in_dset (CDataset) – New dataset to use.