Medial Code Documentation
Loading...
Searching...
No Matches
DoCalcFeatProcessor.h
1#ifndef __DO_CALC_FEAT_PROCESSOR_H__
2#define __DO_CALC_FEAT_PROCESSOR_H__
3
5#include <MedProcessTools/MedProcessTools/MedFeatures.h>
6
12public:
13 int serial_id;
16
19
20 vector<string> source_feature_names;
21
23 vector<string> parameters;
24
26 string calc_type;
27
30
32 vector<float> weights;
33
35 vector<string> tags;
36
37 // Functions
38 DoCalcFeatProcessor() : FeatureProcessor() { serial_id = ++MedFeatures::global_serial_id_cnt; init_defaults(); }
40
41 void init_defaults();
42
45 int init(map<string, string>& mapper);
46
47 int _apply(MedFeatures& features, unordered_set<int>& ids);
48
49 // Specific Functions
50 void sum(vector<float*> p_sources, float *p_out, int n_samples);
51 void chads2(vector<float*> p_sources, float *p_out, int n_samples, int vasc_flag, int max_flag);
52 void has_bled(vector<float*> p_sources, float *p_out, int n_samples, int max_flag);
53 void fragile(vector<float*> p_sources, float *p_out, int n_samples);
54 void framingham_chd(vector<float*> p_sources, float *p_out, int n_samples);
55 void do_boolean_condition(vector<float*> p_sources, float *p_out, int n_samples);
56 void do_boolean_condition_ignore_missing(vector<float*> p_sources, float *p_out, int n_samples);
57 void do_not(vector<float*> p_sources, float *p_out, int n_samples);
58
59 // Single Input Functions
60 void _log(vector<float*> p_sources, float *p_out, int n_samples);
61 void do_threshold(vector<float*> p_sources, float *p_out, int n_samples);
62
64 bool are_features_affected(unordered_set<string>& out_req_features);
65
67 void update_req_features_vec(unordered_set<string>& out_req_features, unordered_set<string>& in_req_features);
68
69 // Copy
70 virtual void copy(FeatureProcessor *processor) { *this = *(dynamic_cast<DoCalcFeatProcessor *>(processor)); }
71
72 // Serialization
73 ADD_CLASS_NAME(DoCalcFeatProcessor)
75
76private:
77 virtual void resolve_feature_names(MedFeatures &features);
78 void prepare_feature(MedFeatures& features, int samples_size) const;
79
80 void max(vector<float*> p_sources, float *p_out, int n_samples) const;
81 void min(vector<float*> p_sources, float *p_out, int n_samples) const;
82};
83
85
86#endif
A virtual class of processes on MedFeatures; E.g.
#define ADD_SERIALIZATION_FUNCS(...)
Definition SerializableObject.h:122
#define MEDSERIALIZE_SUPPORT(Type)
Definition SerializableObject.h:108
User defined calculations on other features.
Definition DoCalcFeatProcessor.h:11
vector< string > tags
Tags - for defining labels or groups. may be used later for filtering for example.
Definition DoCalcFeatProcessor.h:35
void update_req_features_vec(unordered_set< string > &out_req_features, unordered_set< string > &in_req_features)
update sets of required as input according to set required as output to processor
Definition DoCalcFeatProcessor.cpp:195
vector< float > weights
for sum
Definition DoCalcFeatProcessor.h:32
vector< string > raw_source_feature_names
source_feature_names as specified by the user, will be resolved to decorated names
Definition DoCalcFeatProcessor.h:18
string raw_target_feature_name
target_feature_name as specified by the user, will be decorated for uniqueness and extra information
Definition DoCalcFeatProcessor.h:15
string calc_type
user function selector (e.g. sum, ratio)
Definition DoCalcFeatProcessor.h:26
float missing_value
when a source_feature == missing_value, the calculation would also be missing_value
Definition DoCalcFeatProcessor.h:29
bool are_features_affected(unordered_set< string > &out_req_features)
check if a set of features is affected by the current processor
Definition DoCalcFeatProcessor.cpp:180
int init(map< string, string > &mapper)
The parsed fields from init command.
Definition DoCalcFeatProcessor.cpp:23
vector< string > parameters
general-purpose parameters which can be used by the calc
Definition DoCalcFeatProcessor.h:23
Definition FeatureProcess.h:51
string feature_name
Feature name ( + name as appears in MedFeatures) ;.
Definition FeatureProcess.h:55
A class for holding features data as a virtual matrix
Definition MedFeatures.h:47
static int global_serial_id_cnt
A global counter used to prevent identical names for two features by adding FTR_::_ before generated ...
Definition MedFeatures.h:73