""" Pipeline to convert mff format EEG data to others."""

import logging

from almirah import index
from almirah import Layout
from almirah import Specification
from almirah.utils.convert import convert

logging.basicConfig(filename="logs/convert_eeg_to_bvcf.log", level=logging.DEBUG)
logging.getLogger().addHandler(logging.StreamHandler())

SRC = ""
DST = ""

source_spec = Specification.create_from_file("configs/specifications/sourcedata.yaml")
src_lay = Layout(root=SRC, specification_name="sourcedata")

bids_spec = Specification.create_from_file("configs/specifications/bids.yaml")
dst_lay = Layout(root=DST, specification_name="bids")

src_lay.index(f"{SRC}/eeg")
index.commit()

files = src_lay.query(sourcetype="eeg", extension=".mff")

tag_map = {
    "subject": "subject",
    "session": "session",
    "acquisition": "acquisition",
    "task": "task",
    "datatype": "datatype",
    "run": "run",
    "suffix": "suffix",
}

anonymize = {"daysback": "", "keep_his": False, "keep_source": False}

convert(
    files,
    "BrainVision",
    dst_lay,
    logging="DEBUG",
    line_freq=50,
    tag_map=tag_map,
    anonymize=anonymize,
)
