highspeed-heudiconv-anonymizer.py 1.5 KB

123456789101112131415161718192021222324252627282930313233
  1. #!/usr/bin/env python
  2. # ==============================================================================
  3. # SCRIPT INFORMATION:
  4. # ==============================================================================
  5. # SCRIPT: ANONYMIZE PARTICIPANT IDS DURING BIDS-CONVERSION WITH HEUDICONV
  6. # PROJECT: HIGHSPEED
  7. # WRITTEN BY LENNART WITTKUHN, 2018 - 2019
  8. # CONTACT: WITTKUHN AT MPIB HYPHEN BERLIN DOT MPG DOT DE
  9. # MAX PLANCK RESEARCH GROUP NEUROCODE
  10. # MAX PLANCK INSTITUTE FOR HUMAN DEVELOPMENT
  11. # MAX PLANCK UCL CENTRE FOR COMPUTATIONAL PSYCHIATRY AND AGEING RESEARCH
  12. # LENTZEALLEE 94, 14195 BERLIN, GERMANY
  13. # ==============================================================================
  14. # import relevant packages:
  15. import sys
  16. import os
  17. # define paths depending on the operating systen:
  18. if 'linux' in sys.platform:
  19. # define the root path:
  20. #path_root = os.path.join("/home", "mpib", "wittkuhn", "highspeed")
  21. #path_code = os.path.join(path_root, "highspeed_analysis", "code")
  22. # define the path to the text file containg the subject IDs:
  23. path_sublist = os.path.join("/code", "parameters", "highspeed_participant_list.txt")
  24. # retrieve the user input:
  25. ids_orig = open(path_sublist, "r").read().splitlines()
  26. # define the number of subjects:
  27. ids_new = ["%02d" % t for t in range(1, len(ids_orig)+1)]
  28. # create a dictionary mapping original ids to anonymized ids:
  29. subj_map = dict(zip(ids_orig, ids_new))
  30. # replace the original ids with zero-padded numbers:
  31. sid = sys.argv[-1]
  32. if sid in subj_map:
  33. print(subj_map[sid])