highspeed-heudiconv-anonymizer.py 1.3 KB

123456789101112131415161718192021222324252627282930
  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 - 2020
  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 path to the text file containg the subject IDs:
  20. path_sublist = os.path.join("/code", "highspeed-participant-list.txt")
  21. # retrieve the user input:
  22. ids_orig = open(path_sublist, "r").read().splitlines()
  23. # define the number of subjects:
  24. ids_new = ["%02d" % t for t in range(1, len(ids_orig)+1)]
  25. # create a dictionary mapping original ids to anonymized ids:
  26. subj_map = dict(zip(ids_orig, ids_new))
  27. # replace the original ids with zero-padded numbers:
  28. sid = sys.argv[-1]
  29. if sid in subj_map:
  30. print(subj_map[sid])