convert_eeg_mff_to_bvcf.py 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. """ Pipeline to convert mff format EEG data to others."""
  2. import logging
  3. from almirah import index
  4. from almirah import Layout
  5. from almirah import Specification
  6. from almirah.utils.convert import convert
  7. logging.basicConfig(filename="logs/convert_eeg_to_bvcf.log", level=logging.DEBUG)
  8. logging.getLogger().addHandler(logging.StreamHandler())
  9. SRC = ""
  10. DST = ""
  11. source_spec = Specification.create_from_file("configs/specifications/sourcedata.yaml")
  12. src_lay = Layout(root=SRC, specification_name="sourcedata")
  13. bids_spec = Specification.create_from_file("configs/specifications/bids.yaml")
  14. dst_lay = Layout(root=DST, specification_name="bids")
  15. src_lay.index(f"{SRC}/eeg")
  16. index.commit()
  17. files = src_lay.query(sourcetype="eeg", extension=".mff")
  18. tag_map = {
  19. "subject": "subject",
  20. "session": "session",
  21. "acquisition": "acquisition",
  22. "task": "task",
  23. "datatype": "datatype",
  24. "run": "run",
  25. "suffix": "suffix",
  26. }
  27. anonymize = {"daysback": "", "keep_his": False, "keep_source": False}
  28. convert(
  29. files,
  30. "BrainVision",
  31. dst_lay,
  32. logging="DEBUG",
  33. line_freq=50,
  34. tag_map=tag_map,
  35. anonymize=anonymize,
  36. )