~ubuntu-branches/ubuntu/saucy/3depict/saucy

« back to all changes in this revision

Viewing changes to src/filters/clusterAnalysis.h

  • Committer: Package Import Robot
  • Author(s): D Haley
  • Date: 2013-05-17 00:52:39 UTC
  • mfrom: (3.1.4 experimental)
  • Revision ID: package-import@ubuntu.com-20130517005239-7bl4mnhkvrhc2ba6
Tags: 0.0.13-1
Upload to unstable 

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#ifndef CLUSTERANALYSIS_H
2
 
#define CLUSTERANALYSIS_H
3
 
#include "../filter.h"
4
 
#include "../translation.h"
5
 
 
6
 
//!Cluster analysis filter
7
 
class ClusterAnalysisFilter : public Filter
8
 
{
9
 
        private:
10
 
                //Clustering algorithm to use
11
 
                unsigned int algorithm;
12
 
        
13
 
                //Algorithm parameters
14
 
                //---   
15
 
                //Core-linkage "core" classification distance
16
 
                float coreDist;
17
 
                //Coring kNN maximum
18
 
                unsigned int coreKNN;
19
 
                //Link distance for core
20
 
                float linkDist;
21
 
                //Link distance for bulk
22
 
                float bulkLink;
23
 
                //Erosion distance for bulk from nonclustered bulk
24
 
                float dErosion;
25
 
                //---   
26
 
 
27
 
                //post processing options
28
 
                //Minimum/max number of "core" entires to qualify as,
29
 
                //well, a meaningful cluster
30
 
                bool wantCropSize;
31
 
                size_t nMin,nMax;
32
 
                bool sizeCountBulk;
33
 
                
34
 
                bool wantClusterSizeDist,logClusterSize;
35
 
 
36
 
                //Do we want the composition data for the cluster
37
 
                bool wantClusterComposition, normaliseComposition;
38
 
 
39
 
                //Do we want a morphological analysis
40
 
                bool wantClusterMorphology;
41
 
 
42
 
                //!Do we have range data to use 
43
 
                bool haveRangeParent;
44
 
                //!The names of the incoming ions
45
 
                std::vector<std::string > ionNames;
46
 
                
47
 
                //!Which ions are core/builk for a  particular incoming range?
48
 
                std::vector<bool> ionCoreEnabled,ionBulkEnabled;
49
 
 
50
 
                //Do cluster refresh using Link Algorithm (Core + max sep)
51
 
                unsigned int refreshLinkClustering(const std::vector<const FilterStreamData *> &dataIn,
52
 
                                std::vector< std::vector<IonHit> > &clusteredCore, 
53
 
                                std::vector<std::vector<IonHit>  > &clusteredBulk,ProgressData &progress,
54
 
                                                        bool (*callback)(bool));
55
 
 
56
 
 
57
 
                //Helper function to create core and bulk vectors of ions from input ionstreams
58
 
                void createRangedIons(const std::vector<const FilterStreamData *> &dataIn,
59
 
                                                std::vector<IonHit> &core,std::vector<IonHit> &bulk,
60
 
                                                        ProgressData &p,bool (*callback)(bool)) const;
61
 
 
62
 
 
63
 
                //Check to see if there are any core or bulk ions enabled respectively.
64
 
                void checkIonEnabled(bool &core, bool &bulk) const;
65
 
 
66
 
                void buildRangeEnabledMap(const RangeStreamData *r,
67
 
                                        map<size_t,size_t> &rangeEnabledMap) const;
68
 
 
69
 
                //Strip out clusters with a given number of elements
70
 
                bool stripClusterBySize(vector<vector<IonHit> > &clusteredCore,
71
 
                                                vector<vector<IonHit> > &clusteredBulk,
72
 
                                                        bool (*callback)(bool), ProgressData &p) const;
73
 
                //Build a plot that is the cluster size distribution as  afunction of cluster size
74
 
                PlotStreamData *clusterSizeDistribution(const vector<vector<IonHit> > &solutes, 
75
 
                                                const vector<vector<IonHit> > &matrix) const;
76
 
 
77
 
 
78
 
                //Build plots that are the cluster size distribution as
79
 
                // a function of cluster size, specific to each ion type.
80
 
                void genCompositionVersusSize(const vector<vector<IonHit> > &clusteredCore,
81
 
                                const vector<vector<IonHit> > &clusteredBulk, const RangeFile *rng,
82
 
                                                        vector<PlotStreamData *> &plots) const;
83
 
 
84
 
 
85
 
                //COmpute the singular values that area associated with each cluster
86
 
                void getSingularValues(const vector<vector<IonHit> > &clusteredCore,
87
 
                                const vector<vector<IonHit> > &clusteredBulk, vector<vector<float> > &singularValues) const;
88
 
#ifdef DEBUG
89
 
                bool paranoidDebugAssert(const std::vector<std::vector<IonHit > > &core, 
90
 
                                const std::vector<std::vector<IonHit> > &bulk) const;
91
 
#endif
92
 
        public:
93
 
                ClusterAnalysisFilter(); 
94
 
                //!Duplicate filter contents, excluding cache.
95
 
                Filter *cloneUncached() const;
96
 
 
97
 
                //!Initialise filter prior to tree propagation
98
 
                virtual void initFilter(const std::vector<const FilterStreamData *> &dataIn,
99
 
                                std::vector<const FilterStreamData *> &dataOut);
100
 
 
101
 
                //!Returns -1, as range file cache size is dependant upon input.
102
 
                virtual size_t numBytesForCache(size_t nObjects) const;
103
 
                //!Returns FILTER_TYPE_SPATIAL_ANALYSIS
104
 
                unsigned int getType() const { return FILTER_TYPE_CLUSTER_ANALYSIS;};
105
 
                //update filter
106
 
                unsigned int refresh(const std::vector<const FilterStreamData *> &dataIn,
107
 
                                        std::vector<const FilterStreamData *> &getOut, 
108
 
                                        ProgressData &progress, bool (*callback)(bool));
109
 
                //!Get the type string  for this fitler
110
 
                virtual std::string typeString() const { return std::string(TRANS("Cluster Analysis"));};
111
 
 
112
 
                std::string getErrString(unsigned int i) const;
113
 
 
114
 
                //!Get the properties of the filter, in key-value form. First vector is for each output.
115
 
                void getProperties(FilterProperties &propertyList) const;
116
 
 
117
 
                //!Set the properties for the nth filter
118
 
                bool setProperty(unsigned int set,unsigned int key, 
119
 
                                const std::string &value, bool &needUpdate);
120
 
                
121
 
                //!Dump state to output stream, using specified format
122
 
                bool writeState(std::ofstream &f,unsigned int format,
123
 
                                                unsigned int depth=0) const;
124
 
                //!Read the state of the filter from XML file. If this
125
 
                //fails, filter will be in an undefined state.
126
 
                bool readState(xmlNodePtr &node, const std::string &packDir);
127
 
                
128
 
                //!Get the stream types that will be dropped during ::refresh   
129
 
                unsigned int getRefreshBlockMask() const;
130
 
 
131
 
                //!Get the stream types that will be generated during ::refresh 
132
 
                unsigned int getRefreshEmitMask() const;        
133
 
                //!Set internal property value using a selection binding  (Disabled, this filter has no bindings)
134
 
                void setPropFromBinding(const SelectionBinding &b) {ASSERT(false);} ;
135
 
 
136
 
#ifdef DEBUG
137
 
                bool wantParanoidDebug;
138
 
                bool runUnitTests();
139
 
#endif
140
 
};
141
 
 
142
 
#endif