ThreeB 1.1

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Hierarchy
- Class Members

Public Member Functions | Private Attributes
SampledMultispot::GibbsSampler2 Class Reference
Storm classes

Gibbs sampling class which masks spots to reduce computation. More...

`#include <sampled_multispot.h>`

List of all members.

## Public Member Functions
| GibbsSampler2 (const vector< vector< double > > &pixel_intensities_, const vector< vector< double > > &spot_intensities_, const vector< Vector< 4 > > &spots_, const vector< vector< int > > &spot_pixels_, const Matrix< 3 > A_, const Vector< 3 > pi_, double variance_, int sample_iterations_)
void | set_variance (double v)
void | reset ()
template<class T >
void | next (T &rng)
const vector< vector< State > > & | sample () const
const vector< vector< double > > & | sample_intensities () const
## Private Attributes
const vector< vector< double > > & | pixel_intensities
const vector< vector< double > > & | spot_intensities
const vector< Vector< 4 > > | spots
const std::vector< std::vector < int > > & | spot_pixels
const Matrix< 3 > | A
const Vector< 3 > | pi
const double | base_variance
double | variance
const int | sample_iterations
const int | num_frames
const int | num_pixels
const vector< int > | O
vector< vector< State > > | current_sample
vector< vector< double > > | current_sample_intensities
vector< double > | cutout_spot_intensities
vector< vector< double > > | cutout_pixel_intensities
vector< vector< double > > | cutout_current_sample_intensities

## Detailed Description

Gibbs sampling class which masks spots to reduce computation.

This draws samples from, the spot states given the spots positions and some data. It is very similar to GibbsSampler, except that it only computes probabilities in a mask around each spot to save on computation. Variable naming matches that in FitSpots.

Definition at line 323 of file sampled_multispot.h.

## Constructor & Destructor Documentation

SampledMultispot::GibbsSampler2::GibbsSampler2 | ( | const vector< vector< double > > & | pixel_intensities_,
|  | const vector< vector< double > > & | spot_intensities_,
|  | const vector< Vector< 4 > > & | spots_,
|  | const vector< vector< int > > & | spot_pixels_,
|  | const Matrix< 3 > | A_,
|  | const Vector< 3 > | pi_,
|  | double | variance_,
|  | int | sample_iterations_
| ) |  | `[inline]`

Definition at line 347 of file sampled_multispot.h.

References assert_same_size(), and spot_intensities.

        :pixel_intensities(pixel_intensities_), //pixel_intensities: [frame][pixels]
         spot_intensities(spot_intensities_),   //spot_intensities: [spot][pixel]
         spots(spots_),
         spot_pixels(spot_pixels_),
         A(A_),
         pi(pi_),
         base_variance(variance_),
         variance(variance_),
         sample_iterations(sample_iterations_),
         num_frames(pixel_intensities.size()),
         num_pixels(pixel_intensities[0].size()),
            //Observations vector. As usual for this application, the observations are just
            //numbered integers which refer to data held elsewhere.
         O(sequence(num_frames)),
            //Start all spots OFF, so the intensity is 0. OFF is 1 or 2, not 0!!!
            //sample_list: [sample][spot][frame]: list of samples drawn using Gibbs sampling
         current_sample(spots.size(), vector<State>(num_frames, 2)), //current sample [spot][frame]
            //pixel intensities assosciated with the current sample [frame][pixel]
         current_sample_intensities(num_frames, vector<double>(num_pixels)),
         cutout_pixel_intensities(num_frames),
         cutout_current_sample_intensities(num_frames)
        {
            //Check a bunch of stuff
            assert_same_size(pixel_intensities);
            assert_same_size(spot_intensities);
        }

## Member Function Documentation

void SampledMultispot::GibbsSampler2::set_variance | ( | double | v | ) | `[inline]`

Update the noide variance.

Used for adding thermal noise.

Parameters:

  v | noise variance.

Definition at line 384 of file sampled_multispot.h.

Referenced by NegativeFreeEnergy::compute_with_mask().

        {
            variance = v;
        }

void SampledMultispot::GibbsSampler2::reset | ( |  | ) | `[inline]`

Reset the gibbs sampler oro the initial state (all spots off)

Definition at line 391 of file sampled_multispot.h.

        {
            vector<State> off(num_frames, 2);
            fill(current_sample.begin(), current_sample.end(), off);

            vector<double> black(num_pixels);
            fill(current_sample_intensities.begin(), current_sample_intensities.end(), black);
            variance = base_variance;
        }

template<class T >

void SampledMultispot::GibbsSampler2::next | ( | T & | rng | ) | `[inline]`

Get the next sample.

Parameters:

  rng | Random number generator

Definition at line 403 of file sampled_multispot.h.

References SampledMultispot::add_spot(), SampledMultispot::remove_spot(), and spot_intensities.

Referenced by NegativeFreeEnergy::compute_with_mask(), FitSpots::optimize_each_spot_in_turn_for_several_passes(), and FitSpots::try_modifying_model().

        {

    //double remove=0;
    //double cut=0;
    //double swb=0;
    //double ff_masked=0;
    //double bs=0;
    //double add=0;
    //cvd_timer t;
        std::vector<array<double, 3> > delta3;
            for(int j=0; j < sample_iterations; j++)
                for(int k=0; k < (int) spots.size(); k++)
                {
    //t.reset();
                    //Subtract off the spot we're interested in.
                    remove_spot(current_sample_intensities, spot_intensities[k], current_sample[k], spot_pixels[k]);
    //remove+=t.reset();
    /*
                    //Cut out
                    //spot
                    cutout_spot_intensities.resize(spot_pixels[k].size());
                    for(unsigned int i=0; i < spot_pixels[k].size(); i++)
                        cutout_spot_intensities[i] = spot_intensities[k][spot_pixels[k][i]];

                    //others
                    for(int f=0; f < num_frames; f++)
                    {
                        cutout_current_sample_intensities[f].resize(spot_pixels[k].size());
                        cutout_pixel_intensities[f].resize(spot_pixels[k].size());
                        for(unsigned int i=0; i < spot_pixels[k].size();i++)
                        {
                            cutout_current_sample_intensities[f][i] = current_sample_intensities[f][spot_pixels[k][i]];
                            cutout_pixel_intensities[f][i] = pixel_intensities[f][spot_pixels[k][i]];
                        }
                    }*/
    //cut += t.reset();
                    //Now current_sample_intensities is the image value for every spot in every frame,
                    //except the current spot, which is always set to off. This allows us to add it in
                    //easily.

    //              SpotWithBackground B(current_sample_intensities, spot_intensities[k], pixel_intensities, variance);
    //              vector<array<double, 3> > delta = forward_algorithm_delta(A, pi, B, O);

    //ff+=t.reset();

    //              SpotWithBackground B2(cutout_current_sample_intensities, cutout_spot_intensities, cutout_pixel_intensities, variance);
    //              std::vector<array<double, 3> > delta2 = forward_algorithm_delta(A, pi, B2, O);
    //ff_cut+=t.reset();

                    SpotWithBackgroundMasked B3(current_sample_intensities, spot_intensities[k], pixel_intensities, variance, spot_pixels[k]);
    //swb += t.reset();
                    forward_algorithm_delta2<3>(A, pi, B3, O, delta3);
    //f_masked+=t.reset();
                    /*for(unsigned int i=0; i < delta.size(); i++)
                    {
                        cout.precision(20);
                        cout.setf(cout.scientific);
                        std::cout << delta[i][0] << " " << delta[i][1] << " " <<delta[i][2] << std::endl;
                        std::cout << delta2[i][0] << " " << delta2[i][1] << " " <<delta2[i][2] << std::endl;
                        cout << endl;
                    }
                    std::exit(1);

    */

                    current_sample[k] = backward_sampling<3,State, T>(A, delta3, rng);
    //bs += t.reset();
                    //Put the newly sampled spot in
                    add_spot(current_sample_intensities, spot_intensities[k], current_sample[k], spot_pixels[k]);
    //add += t.reset();
                }
    //      cout << "remove=" <<remove << " cut=" << cut << " swb=" << swb<< " ff_mask=" << ff_masked << " bs=" <<bs << " add="<<add << endl;
        }

const vector<vector<State> >& SampledMultispot::GibbsSampler2::sample | ( |  | ) | const`[inline]`

Retrieve the current sample.

Definition at line 484 of file sampled_multispot.h.

Referenced by FitSpots::optimize_each_spot_in_turn_for_several_passes(), and FitSpots::try_modifying_model().

        {
            return current_sample;
        }

const vector<vector<double> >& SampledMultispot::GibbsSampler2::sample_intensities | ( |  | ) | const`[inline]`

Retrieve the intensities for the current sample.

Definition at line 489 of file sampled_multispot.h.

Referenced by NegativeFreeEnergy::compute_with_mask(), FitSpots::optimize_each_spot_in_turn_for_several_passes(), and FitSpots::try_modifying_model().

        {
            return current_sample_intensities;
        }

## Member Data Documentation

const vector<vector<double> >& SampledMultispot::GibbsSampler2::pixel_intensities`[private]`

Definition at line 325 of file sampled_multispot.h.

const vector<vector<double> >& SampledMultispot::GibbsSampler2::spot_intensities`[private]`

Definition at line 326 of file sampled_multispot.h.

const vector<Vector<4> > SampledMultispot::GibbsSampler2::spots`[private]`

Definition at line 327 of file sampled_multispot.h.

const std::vector<std::vector<int> >& SampledMultispot::GibbsSampler2::spot_pixels`[private]`

Definition at line 328 of file sampled_multispot.h.

const Matrix<3> SampledMultispot::GibbsSampler2::A`[private]`

Definition at line 329 of file sampled_multispot.h.

const Vector<3> SampledMultispot::GibbsSampler2::pi`[private]`

Definition at line 330 of file sampled_multispot.h.

const double SampledMultispot::GibbsSampler2::base_variance`[private]`

Definition at line 331 of file sampled_multispot.h.

double SampledMultispot::GibbsSampler2::variance`[private]`

Definition at line 332 of file sampled_multispot.h.

const int SampledMultispot::GibbsSampler2::sample_iterations`[private]`

Definition at line 334 of file sampled_multispot.h.

const int SampledMultispot::GibbsSampler2::num_frames`[private]`

Definition at line 335 of file sampled_multispot.h.

const int SampledMultispot::GibbsSampler2::num_pixels`[private]`

Definition at line 335 of file sampled_multispot.h.

const vector<int> SampledMultispot::GibbsSampler2::O`[private]`

Definition at line 336 of file sampled_multispot.h.

vector<vector<State> > SampledMultispot::GibbsSampler2::current_sample`[private]`

Definition at line 338 of file sampled_multispot.h.

vector<vector<double> > SampledMultispot::GibbsSampler2::current_sample_intensities`[private]`

Definition at line 339 of file sampled_multispot.h.

vector<double> SampledMultispot::GibbsSampler2::cutout_spot_intensities`[private]`

Definition at line 341 of file sampled_multispot.h.

vector<vector<double> > SampledMultispot::GibbsSampler2::cutout_pixel_intensities`[private]`

Definition at line 342 of file sampled_multispot.h.

vector<vector<double> > SampledMultispot::GibbsSampler2::cutout_current_sample_intensities`[private]`

Definition at line 343 of file sampled_multispot.h.

The documentation for this class was generated from the following file:

- sampled_multispot.h