Skip to content

Commit

Permalink
Merge pull request #51 from BrainLesion/added_details_in_readme
Browse files Browse the repository at this point in the history
Added details in readme
  • Loading branch information
neuronflow authored Mar 29, 2024
2 parents c0f75f1 + 2d160e0 commit e5127d0
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 24 deletions.
73 changes: 50 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
# 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. 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

Expand All @@ -24,19 +30,9 @@ 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.
**eReg** can be used via the command line or as a Python package.

### Command Line Interface

Expand All @@ -60,37 +56,68 @@ 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 to use previously computed transforms to resample a moving image:
```python
from ereg.registration import RegistrationClass
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,
)
```
registration_obj = RegistrationClass(configuration_file) # the configuration file to use to customize the registration, and is optional
registration_obj.register(
#### Functional Interface
Additionally, **eReg** provides functional wrappers for convenience.
```python
from ereg import registration_function

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
)
```
## TODO
## Customization
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 .
```
<!-- ## Citation TODO -->
4 changes: 3 additions & 1 deletion ereg/registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit e5127d0

Please sign in to comment.