From 0b80bd6998742030be2b19306b58085d4c1fa11f Mon Sep 17 00:00:00 2001 From: Remi Gau Date: Thu, 14 Dec 2023 23:49:54 +0100 Subject: [PATCH 1/2] add badges to readme (#85) --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 7158740..93c7a54 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,10 @@ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![codecov](https://codecov.io/gh/SIMEXP/giga_connectome/branch/main/graph/badge.svg?token=P4EGV7NKZ8)](https://codecov.io/gh/SIMEXP/giga_connectome) +[![.github/workflows/test.yml](https://github.com/SIMEXP/giga_connectome/actions/workflows/test.yml/badge.svg)](https://github.com/SIMEXP/giga_connectome/actions/workflows/test.yml) +[![pre-commit](https://github.com/SIMEXP/giga_connectome/actions/workflows/run_precommit.yml/badge.svg)](https://github.com/SIMEXP/giga_connectome/actions/workflows/run_precommit.yml) [![Documentation Status](https://readthedocs.org/projects/giga-connectome/badge/?version=stable)](https://giga-connectome.readthedocs.io/en/latest/?badge=stable) +![https://github.com/psf/black](https://img.shields.io/badge/code%20style-black-000000.svg) + # giga_connectome This is a BIDS-App to extract signal from a parcellation with nilearn, From 241b2a3cce27b59678907bcd8d021dbf1ed356cb Mon Sep 17 00:00:00 2001 From: Remi Gau Date: Thu, 14 Dec 2023 23:51:46 +0100 Subject: [PATCH 2/2] [ENH] rerunning the app overrides old files and logs a warning (#83) * override old files and log a warning * update changelog --- docs/source/changes.md | 1 + giga_connectome/utils.py | 30 ++++++++---------------------- giga_connectome/workflow.py | 4 ++-- 3 files changed, 11 insertions(+), 24 deletions(-) diff --git a/docs/source/changes.md b/docs/source/changes.md index 8ad78f9..1d1802f 100644 --- a/docs/source/changes.md +++ b/docs/source/changes.md @@ -28,6 +28,7 @@ Released August 2023 ### Changes +- [EHN] If an output file already exists, it will be overwritten and warning is logged. (@Remi-Gau) - [EHN] Default atlas is now MIST. (@htwangtw) - [EHN] When using the `participant` analysis level, the output is one file per subject, rather than one file per scan. (@htwangtw) diff --git a/giga_connectome/utils.py b/giga_connectome/utils.py index 283db50..e439172 100644 --- a/giga_connectome/utils.py +++ b/giga_connectome/utils.py @@ -180,27 +180,13 @@ def get_subject_lists( def check_path(path: Path): - """Check if given path (file or dir) already exists, and if so returns a - new path with _ appended (n being the number of paths with the same name - that exist already). - """ - path = path.resolve() - ext = path.suffix - path_parent = path.parent + """Check if given path (file or dir) already exists. + If so, a warning is logged. + """ + path = path.absolute() if path.exists(): - similar_paths = [ - str(p).replace(ext, "") - for p in path_parent.glob(f"{path.stem}_*{ext}") - ] - existing_numbers = [ - int(p.split("_")[-1]) - for p in similar_paths - if p.split("_")[-1].isdigit() - ] - n = str(max(existing_numbers) + 1) if existing_numbers else "1" - path = path_parent / f"{path.stem}_{n}{ext}" - - gc_log.debug(f"Specified path already exists, using {path} instead.") - - return path + gc_log.warning( + f"Specified path already exists:\n\t{path}\n" + "Old file will be overwritten" + ) diff --git a/giga_connectome/workflow.py b/giga_connectome/workflow.py index 3b6e2e4..ebbe10f 100644 --- a/giga_connectome/workflow.py +++ b/giga_connectome/workflow.py @@ -79,7 +79,7 @@ def workflow(args): f"sub-{subject}_atlas-{atlas['name']}" f"_desc-{strategy['name']}.h5" ) - connectome_path = utils.check_path(connectome_path) + utils.check_path(connectome_path) gc_log.info(f"Generate subject level connectomes: sub-{subject}") @@ -106,7 +106,7 @@ def workflow(args): connectome_path = ( output_dir / f"atlas-{atlas['name']}_desc-{strategy['name']}.h5" ) - connectome_path = utils.check_path(connectome_path) + utils.check_path(connectome_path) gc_log.info(connectome_path) gc_log.info("Generate subject level connectomes")