From 4c346f77655710645deb27501f46599082e2caf3 Mon Sep 17 00:00:00 2001 From: Ethan Blackwood Date: Fri, 7 Jun 2024 10:55:39 -0400 Subject: [PATCH] Save output paths as strings --- mesmerize_core/algorithms/cnmf.py | 13 +++++++------ mesmerize_core/algorithms/cnmfe.py | 5 +++-- mesmerize_core/algorithms/mcorr.py | 14 +++++++------- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/mesmerize_core/algorithms/cnmf.py b/mesmerize_core/algorithms/cnmf.py index 3c6696d..18ebe7d 100644 --- a/mesmerize_core/algorithms/cnmf.py +++ b/mesmerize_core/algorithms/cnmf.py @@ -7,7 +7,7 @@ import numpy as np import pandas as pd import traceback -from pathlib import Path +from pathlib import Path, PurePosixPath from shutil import move as move_file import os import time @@ -116,13 +116,14 @@ def run_algo(batch_path, uuid, data_path: str = None): Yr._mmap.close() # accessing private attr but windows is annoying otherwise move_file(fname_new, cnmf_memmap_path) - cnmf_hdf5_path = output_path.relative_to(output_dir.parent) - cnmf_memmap_path = cnmf_memmap_path.relative_to(output_dir.parent) - corr_img_path = corr_img_path.relative_to(output_dir.parent) + # save paths as realative path strings with forward slashes + cnmf_hdf5_path = str(PurePosixPath(output_path.relative_to(output_dir.parent))) + cnmf_memmap_path = str(PurePosixPath(cnmf_memmap_path.relative_to(output_dir.parent))) + corr_img_path = str(PurePosixPath(corr_img_path.relative_to(output_dir.parent))) for proj_type in proj_paths.keys(): - d[f"{proj_type}-projection-path"] = proj_paths[proj_type].relative_to( + d[f"{proj_type}-projection-path"] = str(PurePosixPath(proj_paths[proj_type].relative_to( output_dir.parent - ) + ))) d.update( { diff --git a/mesmerize_core/algorithms/cnmfe.py b/mesmerize_core/algorithms/cnmfe.py index 9f75e5a..aaf393a 100644 --- a/mesmerize_core/algorithms/cnmfe.py +++ b/mesmerize_core/algorithms/cnmfe.py @@ -5,7 +5,7 @@ from caiman.source_extraction.cnmf.params import CNMFParams import psutil import traceback -from pathlib import Path +from pathlib import Path, PurePosixPath from shutil import move as move_file import os import time @@ -107,7 +107,8 @@ def run_algo(batch_path, uuid, data_path: str = None): Yr._mmap.close() # accessing private attr but windows is annoying otherwise move_file(fname_new, cnmf_memmap_path) - cnmfe_memmap_path = cnmf_memmap_path.relative_to(output_dir.parent) + # save path as realative path strings with forward slashes + cnmfe_memmap_path = str(PurePosixPath(cnmf_memmap_path.relative_to(output_dir.parent))) d.update( { diff --git a/mesmerize_core/algorithms/mcorr.py b/mesmerize_core/algorithms/mcorr.py index eb86dbe..5e77165 100644 --- a/mesmerize_core/algorithms/mcorr.py +++ b/mesmerize_core/algorithms/mcorr.py @@ -7,7 +7,7 @@ import psutil import pandas as pd import os -from pathlib import Path +from pathlib import Path, PurePosixPath import numpy as np from shutil import move as move_file import time @@ -124,14 +124,14 @@ def run_algo(batch_path, uuid, data_path: str = None): shift_path = output_dir.joinpath(f"{uuid}_shifts.npy") np.save(str(shift_path), shifts) - # relative paths - cn_path = cn_path.relative_to(output_dir.parent) - mcorr_memmap_path = mcorr_memmap_path.relative_to(output_dir.parent) - shift_path = shift_path.relative_to(output_dir.parent) + # save paths as realative path strings with forward slashes + cn_path = str(PurePosixPath(cn_path.relative_to(output_dir.parent))) + mcorr_memmap_path = str(PurePosixPath(mcorr_memmap_path.relative_to(output_dir.parent))) + shift_path = str(PurePosixPath(shift_path.relative_to(output_dir.parent))) for proj_type in proj_paths.keys(): - d[f"{proj_type}-projection-path"] = proj_paths[proj_type].relative_to( + d[f"{proj_type}-projection-path"] = str(PurePosixPath(proj_paths[proj_type].relative_to( output_dir.parent - ) + ))) d.update( {