"""Pipeline to convert DICOM to NIfTY."""

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_mri_to_NIfTI.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}/mri")
index.commit()

files = src_lay.query(sourcetype="mri", extension=".dcm")
convert(
    files,
    "NIfTI",
    dst_lay,
    logging="DEBUG",
    config="configs/converters/dcm2bids.json",
)
