diff --git a/mriqc/data/config.py b/mriqc/data/config.py index 5cb2e6644..ddf3f1ec8 100644 --- a/mriqc/data/config.py +++ b/mriqc/data/config.py @@ -37,7 +37,7 @@ class GroupTemplate: def __init__(self): import jinja2 - self.template_str = Loader("mriqc")("data/reports/group.html") + self.template_str = Loader(__package__)("reports/group.html").absolute() self.env = jinja2.Environment( loader=jinja2.FileSystemLoader(searchpath="/"), trim_blocks=True, @@ -46,7 +46,7 @@ def __init__(self): def compile(self, configs): """Generates a string with the replacements""" - template = self.env.get_template(self.template_str) + template = self.env.get_template(str(self.template_str)) return template.render(configs) def generate_conf(self, configs, path): diff --git a/mriqc/interfaces/common/ensure_size.py b/mriqc/interfaces/common/ensure_size.py index 0ac4ae5c8..d90709ae4 100644 --- a/mriqc/interfaces/common/ensure_size.py +++ b/mriqc/interfaces/common/ensure_size.py @@ -147,7 +147,7 @@ def _run_interface(self, runtime): input_image=self.inputs.in_file, reference_image=REF_FILE_NAME, interpolation="LanczosWindowedSinc", - transforms=[load_data("data/itk_identity.tfm")], + transforms=[str(load_data("data/itk_identity.tfm").absolute())], output_image=out_file, ).run() @@ -168,7 +168,7 @@ def _run_interface(self, runtime): input_image=self.inputs.in_mask, reference_image=REF_MASK_NAME, interpolation="NearestNeighbor", - transforms=[load_data("data/itk_identity.tfm")], + transforms=[str(load_data("data/itk_identity.tfm").absolute())], output_image=out_mask, ).run() diff --git a/mriqc/reports/group.py b/mriqc/reports/group.py index d642dbc76..ba97d1a43 100644 --- a/mriqc/reports/group.py +++ b/mriqc/reports/group.py @@ -267,15 +267,15 @@ def gen_html(csv_file, mod, csv_failed=None, out_file=None): "version": ver, "csv_groups": csv_groups, "failed": failed, - "boxplots_js": open( - load_data("data/reports/embed_resources/boxplots.js"), - ).read(), - "d3_js": open( - load_data("data/reports/embed_resources/d3.min.js"), - ).read(), - "boxplots_css": open( - load_data("data/reports/embed_resources/boxplots.css"), - ).read(), + "boxplots_js": load_data( + "data/reports/embed_resources/boxplots.js" + ).read_text(), + "d3_js": load_data( + "data/reports/embed_resources/d3.min.js" + ).read_text(), + "boxplots_css": load_data( + "data/reports/embed_resources/boxplots.css" + ).read_text(), }, out_file, ) diff --git a/mriqc/testing.py b/mriqc/testing.py index 6eac654ac..fd775256d 100644 --- a/mriqc/testing.py +++ b/mriqc/testing.py @@ -36,7 +36,7 @@ def mock_config(): """Create a mock config for documentation and testing purposes.""" from . import config - filename = Path(_load_data("data/config-example.toml")) + filename = _load_data("data/config-example.toml") settings = loads(filename.read_text()) for sectionname, configs in settings.items(): if sectionname != "environment":