View Javadoc
1   package com.github.celldynamics.quimp.filesystem;
2   
3   import java.util.ArrayList;
4   import java.util.List;
5   
6   import org.slf4j.Logger;
7   import org.slf4j.LoggerFactory;
8   
9   import com.github.celldynamics.quimp.CellStats;
10  import com.github.celldynamics.quimp.CellStatsEval;
11  
12  /**
13   * Keep statistics for cells.
14   * 
15   * <p>This class is used as storage of frame statistics in
16   * {@link com.github.celldynamics.quimp.filesystem.DataContainer}.
17   * 
18   * @author p.baniukiewicz
19   *
20   */
21  public class StatsCollection implements IQuimpSerialize {
22  
23    /**
24     * The Constant LOGGER.
25     */
26    static final Logger LOGGER = LoggerFactory.getLogger(StatsCollection.class.getName());
27  
28    /**
29     * List of statistic objects for separate cells.
30     */
31    public ArrayList<CellStats> sHs;
32  
33    /**
34     * Create <tt>size</tt> elements in store for {@link CellStats} objects.
35     * 
36     * <p>Size of the store usually equals to the number of cells in the image.
37     * 
38     * @param size Number of cells
39     */
40    public StatsCollection(int size) {
41      sHs = new ArrayList<>(size);
42    }
43  
44    /**
45     * Default constructor.
46     * 
47     * <p>Create empty store for {@link CellStats} objects.
48     */
49    public StatsCollection() {
50      sHs = new ArrayList<>();
51    }
52  
53    /*
54     * (non-Javadoc)
55     * 
56     * @see com.github.celldynamics.quimp.IQuimpSerialize#beforeSerialize()
57     */
58    @Override
59    public void beforeSerialize() {
60    }
61  
62    /*
63     * (non-Javadoc)
64     * 
65     * @see com.github.celldynamics.quimp.IQuimpSerialize#afterSerialize()
66     */
67    @Override
68    public void afterSerialize() throws Exception {
69    }
70  
71    /**
72     * Bridge method to maintain compatibility with old code. Copies statistics from CellStat
73     * objects into internal fields of StatsHandler.
74     * 
75     * @param in List of CellStat objects - size of this list equals to number of cells. Each
76     *        {@link CellStats} object maintain statistic for one cell along all frames.
77     */
78    public void copyFromCellStat(List<CellStatsEval> in) {
79      in.forEach(cl -> sHs.add(cl.getStatH()));
80    }
81  
82    /**
83     * Get stats collection object wrapped by this class.
84     * 
85     * @return the sHs
86     */
87    public ArrayList<CellStats> getStatCollection() {
88      return sHs;
89    }
90  
91    /**
92     * Set stats collection object wrapped by this class.
93     * 
94     * @param shs the sHs to set
95     */
96    public void setStatCollection(ArrayList<CellStats> shs) {
97      this.sHs = shs;
98    }
99  
100 }