Guide to accessing flags - galizia-lab/pyview GitHub Wiki

Flags are managed by an object of class view.python_core.flags.FlagsManager. This class is just a wrapper around a dictionary that can contains the actual flag name-value key-pairs. Editing values in this dictionary is only possible via the method "update_flags". Access to flag values is exactly like a dictionary: if the object of the class FlagsManager above is called flags, then the flag "view_calcMethod" can be accessed as flags["view_calcMethod"]. Once could also iterate over the flags using the itemsmethod of classFlagsManager`, exactly the same as with a dictionary.

Within the code of most modules, an instance of the class FlagsManager called flags or view_flags is available.

An object of the class FlagsManager is also available in an object of class view.python_core.view_object.VIEW as the attribute flags.

Example Code:

from view import VIEW

yml_file = .....
animal = ....

# create a view object
vo = VIEW()

# update flags from a yml file
vo.update_flags_from_ymlfile(yml_filename=yml_file)

# update more flags additional to those from yml file
if isinstance(local_flags, dict):
    vo.update_flags(local_flags)

# initialize which animal to use
vo.initialize_animal(animal=animal)

# access flags
print("LE_loadExp=", vo.flags["LE_loadExp"])

# iterate over measurements of this animal
for measu in vo.get_measus_for_current_animal(analyze_values_to_use=(1, 2)):
   
    print(f"Doing animal={animal}, measu={measu}")
    
    # load data for this measurement
    vo.load_measurement_data_from_current_animal(measu=measu)

    # calculate signals for this measurement
    vo.calculate_signals()