stringGenericSigVec::get_type_generic_spec(SigTypet){switch(t){caseT_Value:return"V(f)";// 0caseT_DateVal:return"T(i),V(f)";// 1caseT_TimeVal:return"T(l),V(f),p,p,p,p";// 2caseT_DateRangeVal:return"T(i,i),V(f)";// 3caseT_TimeStamp:return"T(l)";// 4caseT_TimeRangeVal:return"T(l,l),V(f),p,p,p,p";// 5caseT_DateVal2:return"T(i),V(f,us),p,p";// 6caseT_TimeLongVal:return"T(l),V(l)";// 7caseT_DateShort2:return"T(i),V(s,s)";// 8caseT_ValShort2:return"V(s,s)";// 9caseT_ValShort4:return"V(s,s,s,s)";// 10caseT_CompactDateVal:return"T(us),V(us)";// 11caseT_DateRangeVal2:return"T(i,i),V(f,f)";// 12caseT_DateFloat2:return"T(i),V(f,f)";// 13caseT_TimeRange:return"T(l,l)";// 14caseT_TimeShort4:return"T(i),p,p,p,p,V(s,s,s,s)";//15default:MTHROW_AND_ERR("Cannot get generic spec of signal type %d\n",t);}return0;}
When defining C structs, compilers may add padding bytes to align fields for optimal memory access. For certain types (like T_TimeVal, T_TimeRangeVal, T_DateVal2, and T_TimeShort4), padding was added to maintain compatibility with older C structures.
For example, T_TimeRangeVal corresponds to the GSV string "T(l,l),V(f),p,p,p,p", meaning each record contains two long long time channels, one float value channel, and four padding bytes.
GSV Declarations in .signal Files
In repository .signal files, you can specify a signal’s type using either the legacy numeric code or a GSV string specification.
If multiple signals share the same type, you can define a type alias to avoid repetition and improve clarity.
Define an alias using: GENERIC_SIGNAL_TYPE [type_alias] [GSV_string_spec]
(Remember: .signal files are tab-separated.)
GENERIC_SIGNAL_TYPE mytype0 V(f)
GENERIC_SIGNAL_TYPE mytype1 T(i),V(f)
SIGNAL GENDER 100 16:mytype0 Male=1,Female=2 0
SIGNAL BMI 902 16:mytype1 0
SIGNAL ICD9_Hospitalization 2300 T(i,i),V(f) 1
SIGNAL RBC 1001 1 0
...
In this example:
The first two lines define type aliases (mytype0, mytype1).
The next two lines use these aliases for the GENDER and BMI signals.
The following lines show direct type specification and use of a legacy type code.
Using GSV
The GenericSigVec class implements GSVs, replacing the old USV system. You can still use UniversalSigVec as an alias for GenericSigVec for backward compatibility:
The string specification replaces the old SigType. You can also initialize from a SignalInfo object for better performance, as it avoids runtime parsing.
This template function retrieves values (defaulting to float, but other types are supported).
It calculates the value’s location using val_channel_offsets.
The correct type cast is chosen based on val_channel_types.
Changes for GSV Support
MedConvert now supports GSVs when creating new repositories.
MedPyExport can export GSVs to Python. Exported field names are now time0, time1, ..., val0, val1, ...
Virtual signals now support the new type specification strings.
Performance
Performance testing shows a slight improvement over the old implementation, likely because the new approach avoids C function callbacks, allowing better compiler optimization.