1
#ifndef CLUSTERANALYSIS_H
2
#define CLUSTERANALYSIS_H
4
#include "../translation.h"
6
//!Cluster analysis filter
7
class ClusterAnalysisFilter : public Filter
10
//Clustering algorithm to use
11
unsigned int algorithm;
13
//Algorithm parameters
15
//Core-linkage "core" classification distance
19
//Link distance for core
21
//Link distance for bulk
23
//Erosion distance for bulk from nonclustered bulk
27
//post processing options
28
//Minimum/max number of "core" entires to qualify as,
29
//well, a meaningful cluster
34
bool wantClusterSizeDist,logClusterSize;
36
//Do we want the composition data for the cluster
37
bool wantClusterComposition, normaliseComposition;
39
//Do we want a morphological analysis
40
bool wantClusterMorphology;
42
//!Do we have range data to use
44
//!The names of the incoming ions
45
std::vector<std::string > ionNames;
47
//!Which ions are core/builk for a particular incoming range?
48
std::vector<bool> ionCoreEnabled,ionBulkEnabled;
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));
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;
63
//Check to see if there are any core or bulk ions enabled respectively.
64
void checkIonEnabled(bool &core, bool &bulk) const;
66
void buildRangeEnabledMap(const RangeStreamData *r,
67
map<size_t,size_t> &rangeEnabledMap) const;
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;
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;
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;
89
bool paranoidDebugAssert(const std::vector<std::vector<IonHit > > &core,
90
const std::vector<std::vector<IonHit> > &bulk) const;
93
ClusterAnalysisFilter();
94
//!Duplicate filter contents, excluding cache.
95
Filter *cloneUncached() const;
97
//!Initialise filter prior to tree propagation
98
virtual void initFilter(const std::vector<const FilterStreamData *> &dataIn,
99
std::vector<const FilterStreamData *> &dataOut);
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;};
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"));};
112
std::string getErrString(unsigned int i) const;
114
//!Get the properties of the filter, in key-value form. First vector is for each output.
115
void getProperties(FilterProperties &propertyList) const;
117
//!Set the properties for the nth filter
118
bool setProperty(unsigned int set,unsigned int key,
119
const std::string &value, bool &needUpdate);
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);
128
//!Get the stream types that will be dropped during ::refresh
129
unsigned int getRefreshBlockMask() const;
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);} ;
137
bool wantParanoidDebug;