Scheduled service maintenance on November 22


On Friday, November 22, 2024, between 06:00 CET and 18:00 CET, GIN services will undergo planned maintenance. Extended service interruptions should be expected. We will try to keep downtimes to a minimum, but recommend that users avoid critical tasks, large data uploads, or DOI requests during this time.

We apologize for any inconvenience.

export_traces_template.py 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. import view
  2. import pandas as pd
  3. import logging
  4. import pathlib as pl
  5. # this tells view all settings including the folder structure of your project
  6. # On Windows, if you copy paths from the file explorer, make sure the string below is always of the form r"......"
  7. from view.python_core.gdm_generation.gdm_data_classes import GDMFile
  8. ymlfile = r""
  9. # any manual changes to flags, add to dictionary as required
  10. flags_to_update = {
  11. "RM_ROITrace": 3, # set to 0 for .coor files, 3 for .roi files and 4 for .roi.tif
  12. # Other flag changes can be included, for example:
  13. # CTV_scalebar: True,
  14. # mv_individualScale: 2,
  15. # .....
  16. }
  17. # list of animals for which traces are to be exported
  18. animals = [
  19. "",
  20. ""
  21. ]
  22. if __name__ == '__main__':
  23. # create a view object
  24. view_obj = view.VIEW()
  25. # load flags from yml file
  26. view_obj.update_flags_from_ymlfile(ymlfile)
  27. # update flags specified locally
  28. view_obj.update_flags(flags_to_update)
  29. # iterate over animals
  30. for animal in animals:
  31. # initialize view object with animal
  32. view_obj.initialize_animal(animal=animal)
  33. # get ROI information for this animal
  34. roi_data_dict, roi_file = view_obj.get_roi_info_for_current_animal()
  35. # initialize and empty data frame to accumulate data
  36. gdm_file = GDMFile()
  37. # iterate over measurements of the animal
  38. for measu in view_obj.get_measus_for_current_animal(analyze_values_to_use=(1,)):
  39. # load a measurement for the animal
  40. view_obj.load_measurement_data_from_current_animal(measu)
  41. # calculate signals
  42. view_obj.calculate_signals()
  43. # create glodatamix for the loaded measurement
  44. gdm_file_this_measu, _ = view_obj.get_gdm_file_for_current_measurement(roi_data_dict)
  45. # accumulate
  46. gdm_file.append_from_a_gdm_file(gdm_file_this_measu)
  47. # compose output file name and create parent directory if needed
  48. output_file = view_obj.flags.get_gloDatamix_file_for_current_animal()
  49. pl.Path(output_file).parent.mkdir(exist_ok=True)
  50. # save gloDatamix file
  51. gdm_file.write_to_csv(output_file)
  52. logging.getLogger("VIEW").info(f"Wrote gloDatamix to {output_file}")
  53. # backup this script and the yml file used next to the created GDMs
  54. view_obj.backup_script_flags_configs_for_GDMs(files=[__file__, ymlfile])