export_movies_single_animal.py 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. import view
  2. # this tells view all settings including the folder structure of your project
  3. # On Windows, if you copy paths from the file explorer, make sure the string below is always of the form r"......"
  4. ymlfile = r""
  5. # any manual changes to flags, add to dictionary as required
  6. flags_to_update = {
  7. ## Example:
  8. # "CTV_scalebar": True,
  9. # "mv_xgap": 30,
  10. # "mv_ygap": 30,
  11. # "mv_exportFormat": "stack_tif",
  12. # .....
  13. }
  14. # specify the animal to use
  15. animal = ...
  16. # specify the measus for which movies are to be generated and corresponding flag value changes
  17. measu_flags_dict = {
  18. ## Example
  19. # 34:
  20. # {
  21. # "mv_FirstFrame": 40,
  22. # "mv_LastFrame": 160
  23. # },
  24. # 36:
  25. # {
  26. # "mv_FirstFrame": 30,
  27. # "mv_LastFrame": 140
  28. # },
  29. # 50:
  30. # {
  31. # "mv_FirstFrame": 160,
  32. # "mv_LastFrame": 270
  33. # },
  34. # 56: {},
  35. # 58:
  36. # {
  37. # "mv_FirstFrame": 80,
  38. # "mv_LastFrame": 260
  39. # }
  40. }
  41. if __name__ == '__main__':
  42. # iterate over measurements of the animal
  43. for measu, measu_flags in measu_flags_dict.items():
  44. # create a view object
  45. view_obj = view.VIEW()
  46. # load flags from yml file
  47. view_obj.update_flags_from_ymlfile(ymlfile)
  48. # update flags specified locally
  49. view_obj.update_flags(flags_to_update)
  50. # initialize view object with animal
  51. view_obj.initialize_animal(animal=animal)
  52. # load a measurement for the animal
  53. view_obj.load_measurement_data_from_current_animal(measu)
  54. # calculate signals
  55. view_obj.calculate_signals()
  56. # update movie flags for this measu
  57. view_obj.update_flags(measu_flags)
  58. # save movie for the loaded data
  59. view_obj.export_movie_for_current_measurement()
  60. if len(measu_flags_dict):
  61. # backup this script and the yml file used next to the created GDMs
  62. view_obj.backup_script_flags_configs_for_movies(files=[__file__, ymlfile])