From b6e30f3a817310651f5e02a0aa7c234e449d15a2 Mon Sep 17 00:00:00 2001 From: sarthakpati Date: Thu, 28 Mar 2024 11:33:56 -0400 Subject: [PATCH 1/8] added the need --- README.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 2cc1f20..db908a8 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,10 @@ -# eReg +# eReg - A Simple Registration Tool + +## Need + +Because of security concerns, users in clinical environments do not have access to virtualization and containerization technologies such as Docker and Singularity. This becomes a problem, because most research code (especially for image registration) is built around the need to have access to these technologies. Alternatively, some tools only work on a Linux environment, or they need specific hardware resources (such as a DL accelerator card), which are not always available in clinical settings. + +eReg is a simple registration tool that can be used in clinical environments without the need for virtualization or containerization technologies. And it works on all platforms across various hardware configurations. ## Installation From 1b704118a14570c6a5c3aaeb14f50db15265bb31 Mon Sep 17 00:00:00 2001 From: sarthakpati Date: Thu, 28 Mar 2024 11:35:34 -0400 Subject: [PATCH 2/8] added note on customization --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index db908a8..013fafc 100644 --- a/README.md +++ b/README.md @@ -99,4 +99,6 @@ registration_obj.register( ) ``` -## TODO +## Customization + +eReg can be customized using a configuration file. The configuration file is a YAML file that contains the parameters for the registration. The default configuration file is present [here](https://github.com/BrainLesion/eReg/blob/main/ereg/configurations/sample_config.yaml). More details on the parameters and their options can be found in the configuration file itself. From 6ddd4c6e852ad6969018146df08fa29a6be8b07a Mon Sep 17 00:00:00 2001 From: neuronflow Date: Thu, 28 Mar 2024 22:47:31 +0100 Subject: [PATCH 3/8] also return SSIM such as the functional wrapper Signed-off-by: neuronflow --- ereg/registration.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ereg/registration.py b/ereg/registration.py index acf0c31..d3e0dea 100644 --- a/ereg/registration.py +++ b/ereg/registration.py @@ -220,7 +220,7 @@ def resample_image( transform_file: str = None, log_file: str = None, **kwargs, - ) -> None: + ) -> float: """ Resample the moving image to the target image. @@ -269,6 +269,8 @@ def resample_image( ) logging.shutdown() + return self.ssim_score + def _get_transform_wrapper(self, transform: str, dim: int) -> sitk.Transform: """ Get the transform class. From d5242c6756eabd6c810a5362ed80441dfded40f3 Mon Sep 17 00:00:00 2001 From: neuronflow Date: Thu, 28 Mar 2024 22:50:03 +0100 Subject: [PATCH 4/8] soften wording Signed-off-by: neuronflow --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 013fafc..b8ac25f 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Because of security concerns, users in clinical environments do not have access to virtualization and containerization technologies such as Docker and Singularity. This becomes a problem, because most research code (especially for image registration) is built around the need to have access to these technologies. Alternatively, some tools only work on a Linux environment, or they need specific hardware resources (such as a DL accelerator card), which are not always available in clinical settings. -eReg is a simple registration tool that can be used in clinical environments without the need for virtualization or containerization technologies. And it works on all platforms across various hardware configurations. +eReg is a simple registration tool that can be used in clinical environments without the need for virtualization or containerization technologies. It supports most platforms across various hardware configurations. ## Installation From 17ea966f936ce97a6e775759f28386f89faad116 Mon Sep 17 00:00:00 2001 From: neuronflow Date: Thu, 28 Mar 2024 22:50:25 +0100 Subject: [PATCH 5/8] wording and refinements Signed-off-by: neuronflow --- README.md | 37 +++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index b8ac25f..0463f4d 100644 --- a/README.md +++ b/README.md @@ -66,39 +66,56 @@ options: ``` ### Pythonic Interface +The `ereg` package provides two Python interfaces, an object-oriented interface, as well as convenience functions. -The Pythonic interface is available via the `ereg` package, and can be used in two ways: as a functional interface or as an object-oriented interface. +#### Object-Oriented Interface -#### Functional Interface +The `register` method represents the core-of the object-oriented interface: ```python -from ereg import registration_function +from ereg.registration import RegistrationClass -ssim = registration_function( +registration_obj = RegistrationClass(configuration_file) # the configuration file to use to customize the registration, and is optional +registration_obj.register( target_image=target_image_file, # the target image, which can be either a file or SimpleITK.Image object moving_image=moving_image_file, # the moving image, which can be either a file or SimpleITK.Image object output_image=output_file, # the output image to save the registered image to transform_file=transform_file, # the transform file to save the transform to; if already present, will use this transform instead of computing a new one log_file=log_file, # the log file to write to - configuration=configuration_file, # the configuration file to use to customize the registration, and is optional ) ``` -#### Object-Oriented Interface +Further, a resample method is available for explicitly calling transformations: +```python +registration_obj.resample_image( + target_image=target_image_file, + moving_image=moving_image_file, + output_image=output_file, + transform_file=transform_file, + log_file=log_file, +) +``` + + +#### Functional Interface + +Additionally, eReg provides functional wrappers for convenience. ```python -from ereg.registration import RegistrationClass +from ereg import registration_function -registration_obj = RegistrationClass(configuration_file) # the configuration file to use to customize the registration, and is optional -registration_obj.register( +ssim = registration_function( target_image=target_image_file, # the target image, which can be either a file or SimpleITK.Image object moving_image=moving_image_file, # the moving image, which can be either a file or SimpleITK.Image object output_image=output_file, # the output image to save the registered image to transform_file=transform_file, # the transform file to save the transform to; if already present, will use this transform instead of computing a new one log_file=log_file, # the log file to write to + configuration=configuration_file, # the configuration file to use to customize the registration, and is optional ) ``` ## Customization -eReg can be customized using a configuration file. The configuration file is a YAML file that contains the parameters for the registration. The default configuration file is present [here](https://github.com/BrainLesion/eReg/blob/main/ereg/configurations/sample_config.yaml). More details on the parameters and their options can be found in the configuration file itself. +eReg's registration and transformation parameters can be customized using a configuration file. The configuration file is a YAML file that contains the parameters for the registration. The default configuration file is present [here](https://github.com/BrainLesion/eReg/blob/main/ereg/configurations/sample_config.yaml). More details on the parameters and their options can be found in the configuration file itself. + + From 57b25ea606032883db3d25923281fc5530d53e41 Mon Sep 17 00:00:00 2001 From: sarthakpati Date: Fri, 29 Mar 2024 09:01:05 -0400 Subject: [PATCH 6/8] minor formatting updates --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 0463f4d..1a7b9b0 100644 --- a/README.md +++ b/README.md @@ -4,11 +4,11 @@ Because of security concerns, users in clinical environments do not have access to virtualization and containerization technologies such as Docker and Singularity. This becomes a problem, because most research code (especially for image registration) is built around the need to have access to these technologies. Alternatively, some tools only work on a Linux environment, or they need specific hardware resources (such as a DL accelerator card), which are not always available in clinical settings. -eReg is a simple registration tool that can be used in clinical environments without the need for virtualization or containerization technologies. It supports most platforms across various hardware configurations. +**eReg** is a simple registration tool that can be used in clinical environments without the need for virtualization or containerization technologies. It supports most platforms across various hardware configurations. ## Installation -With a Python 3.8+ environment, you can install eReg from [pypi.org](https://pypi.org/project/eReg/). +With a Python 3.8+ environment, you can install **eReg** from [pypi.org](https://pypi.org/project/eReg/). 1. Create a virtual environment @@ -32,7 +32,7 @@ pip install ereg ## Extending eReg -To extend eReg, you first need to install eReg from source. Clone the repository and install the package: +To extend eReg, you first need to install **eReg** from source. Clone the repository and install the package: ```sh git clone https://github.com/BrainLesion/eReg.git @@ -42,7 +42,7 @@ pip install -e . ## Usage -eReg can be used via the command line or as a Python package. +**eReg** can be used via the command line or as a Python package. ### Command Line Interface @@ -99,7 +99,7 @@ registration_obj.resample_image( #### Functional Interface -Additionally, eReg provides functional wrappers for convenience. +Additionally, **eReg** provides functional wrappers for convenience. ```python from ereg import registration_function From d0a210dcc4947cfa9bdaa4aa989b750064ac2534 Mon Sep 17 00:00:00 2001 From: sarthakpati Date: Fri, 29 Mar 2024 09:01:45 -0400 Subject: [PATCH 7/8] wording updates --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 1a7b9b0..eaf65dc 100644 --- a/README.md +++ b/README.md @@ -85,7 +85,8 @@ registration_obj.register( ) ``` -Further, a resample method is available for explicitly calling transformations: +Further, a resample method is available to use previously computed transforms to resample a moving image: + ```python registration_obj.resample_image( target_image=target_image_file, From 2d160e051c7e618bd801ecf5f5b9ba5ba7f8d2a3 Mon Sep 17 00:00:00 2001 From: neuronflow Date: Fri, 29 Mar 2024 22:15:45 +0100 Subject: [PATCH 8/8] move extending down Signed-off-by: neuronflow --- README.md | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index eaf65dc..504c278 100644 --- a/README.md +++ b/README.md @@ -30,16 +30,6 @@ source venv_ereg/bin/activate ## using native python venv pip install ereg ``` -## Extending eReg - -To extend eReg, you first need to install **eReg** from source. Clone the repository and install the package: - -```sh -git clone https://github.com/BrainLesion/eReg.git -cd eReg -pip install -e . -``` - ## Usage **eReg** can be used via the command line or as a Python package. @@ -119,4 +109,15 @@ ssim = registration_function( eReg's registration and transformation parameters can be customized using a configuration file. The configuration file is a YAML file that contains the parameters for the registration. The default configuration file is present [here](https://github.com/BrainLesion/eReg/blob/main/ereg/configurations/sample_config.yaml). More details on the parameters and their options can be found in the configuration file itself. + +## Extending eReg + +To extend eReg, you first need to install **eReg** from source. Clone the repository and install the package: + +```sh +git clone https://github.com/BrainLesion/eReg.git +cd eReg +pip install -e . +``` +