XDF_SET_CHCONF(3)

✨ XDF_SET_CHCONF(3) ✨

xdffileio library manual πŸ¦‹ β€” yes bestie, it's the page for xdf_set_chconf and xdf_get_chconf, aka the two functions that let you set and get the configuration of a channel descriptor handle. let's get into it πŸ’…


πŸ’– NAME πŸ’–

xdf_set_chconf, xdf_get_chconf β€” set or get the configuration of a channel descriptor handle πŸŽ€


🌸 SYNOPSIS 🌸

#include <xdfio.h>

int xdf_set_chconf(struct xdfch* ch, enum xdffield field, ...);
int xdf_get_chconf(const struct xdfch* ch, enum xdffield field, ...);

πŸŽ€ DESCRIPTION πŸŽ€

okay so xdf_set_chconf() sets the configuration of the channel that ch points at, according to the variable list of arguments you hand it. and the way that list works is so specific: it's made of successive couples, and each couple is one variable of type enum xdffield (that's the feature you wanna set) plus a value whose type depends on the field type that came right before it. and bestie, the list must finish with XDF_NOF. no exceptions, that's the vibe check 😀

xdf_get_chconf() gets the configuration of the channel referenced by ch, same deal with the variable list β€” literally the same list terminated by XDF_NOF as for xdf_set_chconf(), except the second part of the couple isn't the value itself, it's a pointer to the value. that's it, that's the difference 🫢

both functions process the argument list from left to right. which means: if some field request throws an error, none of the field requests to its right get processed. and the order of processing lowkey matters for field requests that influence the value of other fields β€” like XDF_CF_STOTYPE. so, order = main character energy here πŸ‘‘

here's the list of admissible values. the expected type of value is in parentheses (that's the expected type for xdf_set_chconf(), or a pointer to that type for xdf_get_chconf()). the default value of each field is in square brackets β€” however, these defaults can be overridden by a call to xdf_set_conf(3) if the file is open for writing. if the file is opened for reading, the defaults are meaningful only for the XDF_CF_ARR* fields. and if a list of data formats shows up in curly brackets, that field is supported only in those formats (no list = all formats support it) ✨

πŸ“ the field menu (every single XDF_CF_*, no skips) πŸ“

  • XDF_CF_ARRINDEX (int) [0] β€” specify the array from/to which the channel value should be transfered. if the mode of the file is XDF_READ and the value is negative, the channel will not be read. if the mode is XDF_WRITE and the value is negative, the function will fail. πŸ™ˆ
  • XDF_CF_ARROFFSET (int) [0 for channel 0, packed channels for the rest] β€” specify the offset in the array from/to which the channel value should be transfered.
  • XDF_CF_ARRDIGITAL (int) [0 if writing, 1 if reading] β€” indicate that the data in the array from/to which the channel value should be transfered is provided in digital unit. in practice this means no scaling is performed during the transfer from/to the disk (non zero indicates no scaling).
  • XDF_CF_ARRTYPE (enum xdftype) [same as XDF_CF_STOTYPE] β€” specify the type in the channel should casted to/from when accessed in the array.
  • XDF_CF_PMIN (double) [min of XDF_CF_ARRTYPE] β€” set/get the minimal value that a physical value can get. cannot be set if XDF_READ.
  • XDF_CF_PMAX (double) [max of XDF_CF_ARRTYPE] β€” set/get the maximal value that a physical value can get. cannot be set if XDF_READ.
  • XDF_CF_STOTYPE (enum xdftype) [any datatype supported by file type] β€” specify the type stored in the file of the channel value. if the XDF file has been opened in XDF_READ, this field cannot be set. and if this field is successfully set, it will set as well the digital minimum (XDF_CF_DMIN) and the digital maximum (XDF_CF_MAX) to the minimum and maximum values allowed by the data type. icon of setting three things at once, honestly πŸ‘‘
  • XDF_CF_DMIN (double) [min of XDF_CF_STOTYPE] β€” set/get the minimal value that a digital value can get. cannot be set if XDF_READ. this is also automatically set by XDF_CF_STOTYPE.
  • XDF_CF_DMAX (double) [min of XDF_CF_STOTYPE] β€” set/get the maximal value that a digital value can get. cannot be set if XDF_READ. this is also automatically set by XDF_CF_STOTYPE.
  • XDF_CF_LABEL (const char*) [""] β€” set/get the label of the channel. cannot be set if XDF_READ.
  • XDF_CF_UNIT (const char*) [""] {EDF BDF GDF} β€” set/get the unit of the channel. cannot be set if XDF_READ.
  • XDF_CF_TRANSDUCTER (const char*) [""] {EDF BDF GDF} β€” set/get the type of sensor used for this channel. cannot be set if XDF_READ.
  • XDF_CF_PREFILTERING (const char*) [""] {EDF BDF GDF} β€” set/get the information about the filters already applied on channel data. cannot be set if XDF_READ.
  • XDF_CF_ELECPOS (double[3]) [0,0,0] {GDF} β€” position of the sensor/electrode expressed in X,Y,Z components. cannot be set if XDF_READ.
  • XDF_CF_IMPEDANCE (double) [0] {GDF} β€” impedance of the sensor/electrode. cannot be set if XDF_READ.

🫢 RETURN VALUE 🫢

the two functions return 0 in case of success. otherwise -1 is returned and errno is set appropriately. that's the whole story πŸ’œ


πŸ’€ ERROR πŸ’€

  • EINVAL β€” ch is NULL or field is not a proper value of the enumeration xdffield.
  • EPERM β€” the request submitted to xdf_set_chconf() is not allowed for this channel, or is forbidden for a file opened with the mode XDF_READ.
  • EDOM β€” the value set in xdf_set_chconf() as digital or physical min/max (fields XDF_CF_{D/P}{MIN/MAX}) goes beyond the limits of, respectively, the stored or array data type.

πŸ”₯ EXAMPLES πŸ”₯

example of usage of xdf_set_chconf():

/* Assume xdf referenced an XDF file opened for writing */
unsigned int iarray = 2, offset = 0;
const char label[] = "Channel EEG";

hchxdf ch = xdf_add_channel(xdf);
xdf_set_chconf(ch, XDF_CF_ARRINDEX, iarray,
                        XDF_CF_ARROFFSET, offset,
                        XDF_CF_LABEL, label,
                        XDF_NOF);

example of usage of xdf_get_chconf():

/* Assume xdf referenced an XDF file opened for reading */
unsigned int iarray, offset;
const char label[128];

hchxdf ch = xdf_get_channel(xdf, 1);
xdf_get_chconf(ch, XDF_CF_ARRINDEX, &iarray,
                        XDF_CF_ARROFFSET, &offset,
                        XDF_CF_LABEL, &label,
                        XDF_NOF);

printf("iarray = %u\n", iarray);
printf("offset = %u\n", offset);
printf("label = %s\n", label);

see how the set one passes the values raw and the get one passes &-pointers? that's the couple rule in action, bestie, no cap 🧚


🌈 SEE ALSO 🌈


and that's the page!! this one came from the fine folks at EPFL, dated 2010, and it lives in the xdffileio library manual. mwah, slay, go configure some channels πŸ’…βœ¨πŸŽ€