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

A Class which represent time ranges of label values based on registry and labeling method. More...

#include <MedLabels.h>

Public Member Functions

void prepare_from_registry (const vector< MedRegistryRecord > &reg_records, const vector< MedRegistryRecord > *censor_records=NULL)
 
bool has_censor_reg () const
 return true if censor registry was provided
 
bool has_censor_reg (int pid) const
 return true if found censor records for patient
 
void get_pids (vector< int > &pids) const
 return all availbel pids from registry
 
void get_records (int pid, vector< const MedRegistryRecord * > &reg_records, vector< const MedRegistryRecord * > &censor_records) const
 get all registry and censor records for patient
 
void calc_signal_stats (const string &repository_path, const string &signal_name, const string &signalHirerchyType, int ageBinValue, MedSamplingStrategy &sampler, const LabelParams &inc_labeling_params, map< float, map< float, vector< int > > > &maleSignalToStats, map< float, map< float, vector< int > > > &femaleSignalToStats, const string &debug_file="", const unordered_set< int > &debug_vals=default_empty_set) const
 calculates table statitics for interrsecting with registry of signal
 
void create_incidence_file (const string &file_path, const string &rep_path, int age_bin, int min_age, int max_age, bool use_kaplan_meir=false, const string &sampler_name="yearly", const string &sampler_args="day_jump=365;start_year=2007;end_year=2012;prediction_month_day=101", const string &debug_file="") const
 calculate incidence and writes the result into file with old and new format
 
SamplingRes get_samples (int pid, int time, vector< MedSample > &samples, bool show_conflicts=false) const
 returns label value for time point
 
SamplingRes get_samples (int pid, const vector< MedSample > &samples, vector< MedSample > &new_samples, bool show_conflicts=false) const
 update outcome and outcomeTime keeping everything else
 
SamplingRes get_samples (int pid, const vector< int > &times, vector< MedSample > &samples, bool show_conflicts=false) const
 returns label value for time points
 
void create_samples (const MedSamplingStrategy *sampler, MedSamples &samples, bool show_conflicts=true) const
 Creates MedSamples using MedSampling.
 
void relabel_samples (MedSamples &samples, bool show_conflicts=true) const
 relabels the samples besed on the labeler
 
 MedLabels (const LabelParams &params)
 Ctor with labling params.
 
 MedLabels (const string &labling_params)
 Ctor with labling params as string.
 

Data Fields

LabelParams labeling_params
 the labeling parameters - problem definition
 

Detailed Description

A Class which represent time ranges of label values based on registry and labeling method.

The main procedure is to quety label value using get_label method

Member Function Documentation

◆ calc_signal_stats()

void MedLabels::calc_signal_stats ( const string &  repository_path,
const string &  signal_name,
const string &  signalHirerchyType,
int  ageBinValue,
MedSamplingStrategy sampler,
const LabelParams inc_labeling_params,
map< float, map< float, vector< int > > > &  maleSignalToStats,
map< float, map< float, vector< int > > > &  femaleSignalToStats,
const string &  debug_file = "",
const unordered_set< int > &  debug_vals = default_empty_set 
) const

calculates table statitics for interrsecting with registry of signal

Parameters
repository_paththe repsitory path
signalCodethe signal code to calculate the stats of the registry with
signalHirerchyTypethe Hirerchy type: [None, RC, ATC, BNF] for signals with hirerchy
ageBinValuethe age bin size
time_window_fromthe minimal time before the event (registry start_time). may be negative to start after event
time_window_tothe maximal time before the event (registry start_time). may be negative to end after event start
samplerthe sampler for how to calc the non appearance of the signal with the registry. You may use MedSamplingAge for example to sample each patient once in each age in the registry dates
debug_fileIf provided the output path to write detailed results of the intersection of registry and signal
debug_valsIf not empty and has debug_file. will write the intersection(by the time window) of the registry with those values
Returns

maleSignalToStats The stats for males. the first key in the dictionary is the signal_value. the second key is age_bin and the vector is always of size 4: [signal_not_appear&registry_is_false, signal_not_appear&registry_is_true, signal_appears&registry_is_false, signal_appears&registry_is_true]

femaleSignalToStats The stats for the females. same format as males

◆ create_incidence_file()

void MedLabels::create_incidence_file ( const string &  file_path,
const string &  rep_path,
int  age_bin,
int  min_age,
int  max_age,
bool  use_kaplan_meir = false,
const string &  sampler_name = "yearly",
const string &  sampler_args = "day_jump=365;start_year=2007;end_year=2012;prediction_month_day=101",
const string &  debug_file = "" 
) const

calculate incidence and writes the result into file with old and new format

Parameters
file_paththe output file path to write the results
rep_paththe repository path to calculate the incidence
age_binthe age_bin for binning age groups for the incidence
min_agethe minimal age fro the incidence
max_agethe maximal age fro the incidence
use_kaplan_meirif True will calc using kaplan meier survivol rates
sampler_namethe sampler name for calculating incidence
sampler_argsthe sampler args for calculating incidence - may control trail years for example

◆ prepare_from_registry()

void MedLabels::prepare_from_registry ( const vector< MedRegistryRecord > &  reg_records,
const vector< MedRegistryRecord > *  censor_records = NULL 
)

prepare MedLabels from registry (and censor if provided) based on labeling rules


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