Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,25 @@ For further information please have a look at our [Jupyter Notebook tutorials](h



## Citation

> [!IMPORTANT]
> If you use `brainles-preprocessing` in your research, please cite it to support the development!

<!-- TODO citation -->
Kofler, F., Rosier, M., Astaraki, M., Möller, H., Mekki, I. I., Buchner, J. A., Schmick, A., Pfiffer, A., Oswald, E., Zimmer, L., Rosa, E. de la, Pati, S., Canisius, J., Piffer, A., Baid, U., Valizadeh, M., Linardos, A., Peeken, J. C., Shit, S., … Menze, B. (2025). *BrainLesion Suite: A Flexible and User-Friendly Framework for Modular Brain Lesion Image Analysis* [arXiv preprint arXiv:2507.09036](https://doi.org/10.48550/arXiv.2507.09036)


```
@misc{kofler2025brainlesionsuiteflexibleuserfriendly,
title={BrainLesion Suite: A Flexible and User-Friendly Framework for Modular Brain Lesion Image Analysis},
author={Florian Kofler and Marcel Rosier and Mehdi Astaraki and Hendrik Möller and Ilhem Isra Mekki and Josef A. Buchner and Anton Schmick and Arianna Pfiffer and Eva Oswald and Lucas Zimmer and Ezequiel de la Rosa and Sarthak Pati and Julian Canisius and Arianna Piffer and Ujjwal Baid and Mahyar Valizadeh and Akis Linardos and Jan C. Peeken and Surprosanna Shit and Felix Steinbauer and Daniel Rueckert and Rolf Heckemann and Spyridon Bakas and Jan Kirschke and Constantin von See and Ivan Ezhov and Marie Piraud and Benedikt Wiestler and Bjoern Menze},
year={2025},
eprint={2507.09036},
archivePrefix={arXiv},
primaryClass={cs.CV},
url={https://arxiv.org/abs/2507.09036},
}
```

## Documentation
We provide a (WIP) documentation. Have a look [here](https://brainles-preprocessing.readthedocs.io/en/latest/?badge=latest)
Expand Down
2 changes: 2 additions & 0 deletions brainles_preprocessing/preprocessor/preprocessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
)
from brainles_preprocessing.registration import ANTsRegistrator
from brainles_preprocessing.registration.registrator import Registrator
from brainles_preprocessing.utils.citation_reminder import citation_reminder
from brainles_preprocessing.utils.logging_utils import LoggingManager

logging_man = LoggingManager(name=__name__)
Expand All @@ -45,6 +46,7 @@ class BasePreprocessor(ABC):

"""

@citation_reminder
def __init__(
self,
center_modality: CenterModality,
Expand Down
2 changes: 1 addition & 1 deletion brainles_preprocessing/registration/ANTs/ANTs.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ def inverse_transform(
fixed_image_path (str or Path): Path to the fixed image.
moving_image_path (str or Path): Path to the moving image.
transformed_image_path (str or Path): Path to the transformed image (output).
matrix_path (str or Path or List[str | Path]): Path to the transformation matrix or a list of matrices.
matrix_path (str or Path or List[str | Path]): Path to the transformation matrix or a list of matrices.
log_file_path (str or Path): Path to the log file.
interpolator (str): Interpolator to use for the transformation. Default is 'nearestNeighbor'.
**kwargs: Additional transformation parameters to update the instantiated defaults.
Expand Down
41 changes: 41 additions & 0 deletions brainles_preprocessing/utils/citation_reminder.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import functools
import os

from rich.console import Console

CITATION_LINK = "https://github.com/BrainLesion/preprocessing#citation"


def citation_reminder(func):
"""
Decorator to remind users to cite brainles-preprocessing.

The reminder is shown when the environment variable
`BRAINLES_PREPROCESSING_CITATION_REMINDER` is set to "true" (default).
To disable the reminder, set the environment variable to "false".

Environment variable used:
- BRAINLES_PREPROCESSING_CITATION_REMINDER: Controls whether the reminder is shown.
"""

@functools.wraps(func)
def wrapper(*args, **kwargs):
if (
os.environ.get("BRAINLES_PREPROCESSING_CITATION_REMINDER", "true").lower()
Copy link

Copilot AI Jul 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The environment variable name is quite long and could be simplified to something like 'BRAINLES_CITE_REMINDER' for better usability while maintaining clarity.

Suggested change
os.environ.get("BRAINLES_PREPROCESSING_CITATION_REMINDER", "true").lower()
os.environ.get("BRAINLES_CITE_REMINDER", "true").lower()

Copilot uses AI. Check for mistakes.
== "true"
):
Comment on lines +23 to +26
Copy link

Copilot AI Jul 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The environment variable is checked on every function call. Consider caching this value at module level or checking it only once to avoid repeated environment variable lookups.

Suggested change
if (
os.environ.get("BRAINLES_PREPROCESSING_CITATION_REMINDER", "true").lower()
== "true"
):
if CITATION_REMINDER_ENABLED:

Copilot uses AI. Check for mistakes.
console = Console()
Copy link

Copilot AI Jul 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Creating a new Console instance on every function call is inefficient. Consider creating a module-level Console instance to reuse across calls.

Suggested change
console = Console()

Copilot uses AI. Check for mistakes.
console.rule("Thank you for using [bold]brainles-preprocessing[/bold]")
console.print(
"Please support our development by citing",
justify="center",
)
console.print(
f"{CITATION_LINK} -- Thank you!",
justify="center",
)
console.rule()
console.line()
Copy link

Copilot AI Jul 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The console.line() call adds unnecessary whitespace. Consider removing it or making it conditional based on user preference, as it may clutter the output when the reminder is shown frequently.

Suggested change
console.line()
if os.environ.get("BRAINLES_PREPROCESSING_EXTRA_LINE", "false").lower() == "true":
console.line()

Copilot uses AI. Check for mistakes.
return func(*args, **kwargs)

return wrapper