Medial Code Documentation
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Data Fields
SimpleCalculator Class Reference

RepCalcSimpleSignals is a rep processor containing several calculators to calculate new signals. More...

#include <RepProcess.h>

Inheritance diagram for SimpleCalculator:
SerializableObject ConstantValueCalculator EmptyCalculator ExistsCalculator KfreCalculator MultiplyCalculator RangeCalculator RatioCalculator SetCalculator SumCalculator eGFRCalculator logCalculator

Public Member Functions

virtual int init (map< string, string > &mapper)
 init function of calculator
 
virtual void validate_arguments (const vector< string > &input_signals, const vector< string > &output_signals) const
 validates correctness of inputs
 
virtual bool do_calc (const vector< float > &vals, float &res) const
 the calc option
 
virtual void list_output_signals (const vector< string > &input_signals, vector< pair< string, string > > &_virtual_signals, const string &output_type)
 list output signals with default naming
 
virtual void init_tables (MedDictionarySections &dict, MedSignals &sigs, const vector< string > &input_signals)
 init operator based on repo if needed
 
virtual void get_required_signal_categories (unordered_map< string, vector< string > > &signal_categories_in_use) const
 
virtual void fit_for_repository (MedPidRepository &rep, vector< pair< string, string > > &_virtual_signals)
 
void * new_polymorphic (string derived_class_name)
 for polymorphic classes that want to be able to serialize/deserialize a pointer * to the derived class given its type one needs to implement this function to return a new to the derived class given its type (as in my_type)
 
- Public Member Functions inherited from SerializableObject
virtual int version () const
 Relevant for serializations.
 
virtual string my_class_name () const
 For better handling of serializations it is highly recommended that each SerializableObject inheriting class will implement the next method.
 
virtual void serialized_fields_name (vector< string > &field_names) const
 The names of the serialized fields.
 
virtual void pre_serialization ()
 
virtual void post_deserialization ()
 
virtual size_t get_size ()
 Gets bytes sizes for serializations.
 
virtual size_t serialize (unsigned char *blob)
 Serialiazing object to blob memory. return number ob bytes wrote to memory.
 
virtual size_t deserialize (unsigned char *blob)
 Deserialiazing blob to object. returns number of bytes read.
 
size_t serialize_vec (vector< unsigned char > &blob)
 
size_t deserialize_vec (vector< unsigned char > &blob)
 
virtual size_t serialize (vector< unsigned char > &blob)
 
virtual size_t deserialize (vector< unsigned char > &blob)
 
virtual int read_from_file (const string &fname)
 read and deserialize model
 
virtual int write_to_file (const string &fname)
 serialize model and write to file
 
virtual int read_from_file_unsafe (const string &fname)
 read and deserialize model without checking version number - unsafe read
 
int init_from_string (string init_string)
 Init from string.
 
int init_params_from_file (string init_file)
 
int init_param_from_file (string file_str, string &param)
 
int update_from_string (const string &init_string)
 
virtual int update (map< string, string > &map)
 Virtual to update object from parsed fields.
 
virtual string object_json () const
 

Static Public Member Functions

static SimpleCalculatormake_calculator (const string &calc_type)
 

Data Fields

vector< string > output_signal_names
 
float missing_value = (float)MED_MAT_MISSING_VALUE
 missing value
 
string calculator_name = ""
 just for debuging
 
int work_channel = 0
 the working channel
 
bool need_time = false
 if needed time
 
bool keep_only_in_range = false
 keeps only in range values
 

Detailed Description

RepCalcSimpleSignals is a rep processor containing several calculators to calculate new signals.

It supports an internal list of calculators, and the user can select one of them.

Each calculator can create one or more new virtual signals. Each of these has a specific type. The user can configure the virtual signal names, and can also pass a list of float parameters to the calculator, making it parametric.

When adding a new calculator make sure to : (1) fill in the calc2defs map (as explained below), to define the calculator name, type, req signals, default virual names and their types, and default parameters. (2) add the new calculator type to the enum (3) write the matching _apply function for the specific calculator and make sure the general _apply calls it .

NOTE: in RepCalcSimpleSignals there is NO learning. Calculated signals that have a learning stage should be implmented in a separate class that will also have space to keep the learning process results.

supported signals calculated (this will be also the virtual signal name):

calc_eGFR : calculating EGFR (CKD_EPI formula) at each point in which Creatinine is available Abstract class for calculator - has do_calc which recieves vector for values to calculate

Member Function Documentation

◆ do_calc()

virtual bool SimpleCalculator::do_calc ( const vector< float > &  vals,
float &  res 
) const
inlinevirtual

◆ init()

virtual int SimpleCalculator::init ( map< string, string > &  mapper)
inlinevirtual

◆ init_tables()

virtual void SimpleCalculator::init_tables ( MedDictionarySections dict,
MedSignals sigs,
const vector< string > &  input_signals 
)
inlinevirtual

init operator based on repo if needed

Reimplemented in SetCalculator.

◆ list_output_signals()

virtual void SimpleCalculator::list_output_signals ( const vector< string > &  input_signals,
vector< pair< string, string > > &  _virtual_signals,
const string &  output_type 
)
inlinevirtual

◆ make_calculator()

SimpleCalculator * SimpleCalculator::make_calculator ( const string &  calc_type)
static
if (calc_type == "ratio" || calc_type == "calc_ratio")
return new RatioCalculator();
else if (calc_type == "eGFR" || calc_type == "calc_eGFR")
return new eGFRCalculator();
else if (calc_type == "log" || calc_type == "calc_log")
return new logCalculator();
else if (calc_type == "sum" || calc_type == "calc_sum")
return new SumCalculator();
else if (calc_type == "range" || calc_type == "calc_range")
return new RangeCalculator();
else if (calc_type == "multiply" || calc_type == "calc_multiply")
return new MultiplyCalculator();
else if (calc_type == "set" || calc_type == "calc_set")
return new SetCalculator();
else if (calc_type == "exists" || calc_type == "calc_exists")
return new ExistsCalculator();
else if (calc_type == "empty")
return new EmptyCalculator();
else if (calc_type == "kfre" || calc_type == "calc_kfre")
return new KfreCalculator();
else if (calc_type == "constant" || calc_type == "constant_value")
else
HMTHROW_AND_ERR("Error: SimpleCalculator::make_calculator - unsupported calculator: %s\n",
calc_type.c_str());
Definition RepProcess.h:1296
Dummy top create empty virtual signal.
Definition RepProcess.h:1076
A is in as exists operation which return binary output res := in_range_val if signal exists otherwise...
Definition RepProcess.h:1278
KFRE calculator based on Age, Gender and eGFR (in that order)
Definition RepProcess.h:1113
A multiply operation with power on both arguments.
Definition RepProcess.h:1227
A simple Range check that return in_range_val if within range and returns out_range_val if outside ra...
Definition RepProcess.h:1205
Calcs ratio between 2 inputs signals.
Definition RepProcess.h:1092
A is in set operation which return binary output res := in_range_val if is in set otherwise out_range...
Definition RepProcess.h:1249
does linear sum with factors on vector of input signals, has b0 as constant res := b0 + sum_sigma(i=1...
Definition RepProcess.h:1185
eGFR calculator based on Creatinine, Gender and Age.
Definition RepProcess.h:1147
does log operation
Definition RepProcess.h:1166

[SimpleCalculator::make_calculator]

[SimpleCalculator::make_calculator]

◆ new_polymorphic()

void * SimpleCalculator::new_polymorphic ( string  derived_name)
virtual

for polymorphic classes that want to be able to serialize/deserialize a pointer * to the derived class given its type one needs to implement this function to return a new to the derived class given its type (as in my_type)

Reimplemented from SerializableObject.

◆ validate_arguments()

virtual void SimpleCalculator::validate_arguments ( const vector< string > &  input_signals,
const vector< string > &  output_signals 
) const
inlinevirtual

The documentation for this class was generated from the following files: