Medial Code Documentation
Loading...
Searching...
No Matches
FeatureGenExtractTable.h
1#ifndef _FTR_FEATURE_GEN_EXTRACT_TABLE_H_
2#define _FTR_FEATURE_GEN_EXTRACT_TABLE_H_
3#include "FeatureGenerator.h"
4
5typedef enum
6{
7 SET,
8 AGE_RANGE
9} Rule_Type;
10
15private:
16 float parsed_min_range;
17 float parsed_max_range;
18 vector<char> lut; //lut for the specific rule
19
20 void parse_rule();
21public:
22 string rep_signal;
23 //maybe in the future support more complex rule to accept feature_generator init to generate feature and than
24 // use the _generate of this feature on each sample to calculate the range - not for now!
25 Rule_Type type;
26 string rule_value;
27
28 KeyRule() {};
29
30 KeyRule(const string &signal, const string &type_str, const string &value);
31
34
36 bool test_rule(float val) const;
37
38 ADD_CLASS_NAME(KeyRule)
39 ADD_SERIALIZATION_FUNCS(rep_signal, type, rule_value, parsed_min_range, parsed_max_range)
40};
41
48public:
49 vector<KeyRule> rules;
50 vector<float> values;
51
53 bool join(const vector<float> &join_vals) const;
54
55 ADD_CLASS_NAME(MapRules)
57};
58
65private:
66 vector<MapRules> key_rules;
67 vector<string> extracted_names;
68
76 void read_rule_table_files();
77 int missing_values_cnt;
78public:
80 string table_file;
83 //object uses also req_signals, req_signals_ids - calculates from key_rules when set_signal_ids is called
84
87 missing_val = MED_MAT_MISSING_VALUE;
88 missing_values_cnt = 0;
89 table_nice_name = "";
90 table_file = "";
92 reverse_rule_order = false;
93 }
94
95 void copy(FeatureGenerator *generator) { *this = *(dynamic_cast<FeatureGenExtractTable *>(generator)); }
96
99 int init(map<string, string>& mapper);
100
101 void set_signal_ids(MedSignals& sigs);
102 void init_tables(MedDictionarySections& dict);
103 void set_names();
104
105 void prepare(MedFeatures &features, MedPidRepository& rep, MedSamples& samples);
106
107 int _generate(PidDynamicRec& in_rep, MedFeatures& features, int index, int num, vector<float *> &_p_data);
108
109 int filter_features(unordered_set<string>& validFeatures);
110
111 void get_required_signal_categories(unordered_map<string, vector<string>> &signal_categories_in_use) const;
112
113 void make_summary();
114
115 ADD_CLASS_NAME(FeatureGenExtractTable)
117};
118
122
123#endif
FeatureGenerator : creating features from raw signals.
@ FTR_GEN_EXTRACT_TBL
"extract_tbl" - extract values from table with keys and rules to join with each patient....
Definition FeatureGenerator.h:44
#define ADD_SERIALIZATION_FUNCS(...)
Definition SerializableObject.h:122
#define MEDSERIALIZE_SUPPORT(Type)
Definition SerializableObject.h:108
A Feature generatoor that join population properties like Age, Gender, Race with extrenal table with ...
Definition FeatureGenExtractTable.h:64
string table_nice_name
nice name for printing
Definition FeatureGenExtractTable.h:82
bool reverse_rule_order
if true will reverse the rule order for priority
Definition FeatureGenExtractTable.h:81
int init(map< string, string > &mapper)
The parsed fields from init command.
Definition FeatureGenExtractTable.cpp:206
string rules_config_file
path to rules config file
Definition FeatureGenExtractTable.h:79
void get_required_signal_categories(unordered_map< string, vector< string > > &signal_categories_in_use) const
returns for each used signal it's used categories
Definition FeatureGenExtractTable.cpp:292
int filter_features(unordered_set< string > &validFeatures)
summary> prints summary of generator job.
Definition FeatureGenExtractTable.cpp:396
string table_file
path to table file with numbers
Definition FeatureGenExtractTable.h:80
Definition FeatureGenerator.h:53
int iGenerateWeights
Feature/Weights generator.
Definition FeatureGenerator.h:72
vector< string > tags
Tags - for defining labels or groups. may be used later for filtering for example.
Definition FeatureGenerator.h:69
FeatureGeneratorTypes generator_type
Type.
Definition FeatureGenerator.h:57
float missing_val
Missing value.
Definition FeatureGenerator.h:66
vector< string > names
Feature name.
Definition FeatureGenerator.h:60
A class that represent a simple rule to calculate when "joining" with patient sample.
Definition FeatureGenExtractTable.h:14
string rep_signal
the repository target signal
Definition FeatureGenExtractTable.h:22
void init_lut(MedDictionarySections &dict)
function to store lut
Definition FeatureGenExtractTable.cpp:57
bool test_rule(float val) const
tests the value condition with the rule
Definition FeatureGenExtractTable.cpp:306
string rule_value
the rule value to match
Definition FeatureGenExtractTable.h:26
Rule_Type type
the rule type
Definition FeatureGenExtractTable.h:25
A class that represents set of rules with AND condition to join with each sample.
Definition FeatureGenExtractTable.h:47
bool join(const vector< float > &join_vals) const
test for full join condition with the rules
Definition FeatureGenExtractTable.cpp:320
vector< float > values
the matched values for each "join". the names are in different file
Definition FeatureGenExtractTable.h:50
vector< KeyRule > rules
the rules with AND condition. the rules are prioritories by order the more specific to less specific
Definition FeatureGenExtractTable.h:49
Definition MedDictionary.h:87
A class for holding features data as a virtual matrix
Definition MedFeatures.h:47
Definition MedPidRepository.h:87
MedSamples represent a collection of samples per different id The data is conatined in a vector of ...
Definition MedSamples.h:129
Definition MedSignals.h:719
Definition MedPidRepository.h:127
Definition SerializableObject.h:32