xini
no way to compare when less than two revisions
Differences
This shows you the differences between two versions of the page.
| — | xini [2011/04/04 20:00] (current) – created jochen | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ====== xini (ini/ | ||
| + | ===== Motivation ===== | ||
| + | Storing configuration settings in .MAT-files makes it sometimes more cumbersome to change those settings (particularly when trying to compare a prior set to the currently used one). In such cases, it can be helpful to store the settings in a text file. | ||
| + | |||
| + | However, as Matlab does not have builtin support for storing multiple variables in structured textfiles, I decided to implement a class that would handle such files. The class has the following main features: | ||
| + | |||
| + | * reading/ | ||
| + | * accessing " | ||
| + | * grandfathering settings (or sections) from another object | ||
| + | |||
| + | ===== Requirements ===== | ||
| + | The [[any2ascii]] function must be properly working (e.g. if user-defined classes are used, it must be overloaded). | ||
| + | |||
| + | ===== Reference ('help xini') ===== | ||
| + | < | ||
| + | |||
| + | creates an object for ini-file handling | ||
| + | |||
| + | Input: for meaningful object construction, | ||
| + | |||
| + | ___ Constructor methods: ___ | ||
| + | ---------------------------- | ||
| + | |||
| + | xini returns a handle to an xini object | ||
| + | FORMAT: IniFileObject = xini(Filename [, | ||
| + | FORMAT: NewObject = xini(' | ||
| + | FORMAT: FactoryObject = xini; | ||
| + | |||
| + | ReleaseAllFiles | ||
| + | ReloadAllFiles | ||
| + | ResetClass | ||
| + | SetIniString | ||
| + | |||
| + | ___ NOTES: ___ | ||
| + | -------------- | ||
| + | |||
| + | | ||
| + | of this toolbox to write non-character variables to disk; | ||
| + | when not active, only valid one-line char arrays are allowed! | ||
| + | |||
| + | | ||
| + | is requested and maintained by the singleton object itself, thus | ||
| + | only little memory is needed for argument handling, even with | ||
| + | bigger ini file, plus multiple functions can share one ini file!</ | ||
| + | |||
| + | ===== ini file format ===== | ||
| + | Information in these ini files is stored as follows | ||
| + | |||
| + | * a free-text header of variable length can be stored (any text prior to the first occurrence of the '' | ||
| + | * a free-text footer of variable length can be stored (any text following the line that reads '' | ||
| + | * information is grouped into " | ||
| + | * individual settings are stored as numbers, with support for cell arrays and logical values | ||
| + | |||
| + | As an example, here is the '' | ||
| + | |||
| + | < | ||
| + | ClusterTableAdd=[false] | ||
| + | ExtractOnSelect=[true] | ||
| + | InterpMethod=linear | ||
| + | JoinMaps=[true] | ||
| + | LocalMax=[true] | ||
| + | LocalMaxSrfNeigh=[4] | ||
| + | LookupCoord=peak | ||
| + | RobustVOICondAvg=[false] | ||
| + | ShowThreshBars=[true] | ||
| + | ThreshBarPos=[0.93, | ||
| + | Thresholds=[0.05, | ||
| + | |||
| + | As you can see, both text-based tokens ('' | ||
| + | |||
| + | ===== ini object access ===== | ||
| + | To access the contents of an object, the filename is passed into the xini constructor: | ||
| + | |||
| + | <code matlab xini_readfile.m> | ||
| + | neuroelf_ini = xini([neuroelf_path '/ | ||
| + | |||
| + | Sections and settings can then be accessed with the overloaded [[@xini/ | ||
| + | <code matlab xini_getset.m> | ||
| + | neuroelf_ini.Statistics.Thresholds(end+1) = 0.1 * neuroelf_ini.Statistics.Thresholds(end);</ | ||
| + | |||
| + | And to write a file back to disk, the [[xini.Save]] method can be used: | ||
| + | <code matlab xini_save.m> | ||
| + | neuroelf_ini.Save;</ | ||
xini.txt · Last modified: 2011/04/04 20:00 by jochen
