mirror of
https://github.com/13hannes11/situr.git
synced 2024-09-03 20:50:58 +02:00
remove filterreg registration function as it did not work well
This commit is contained in:
1
setup.py
1
setup.py
@@ -12,7 +12,6 @@ setup(name='situr',
|
||||
'numpy>=1.21.0',
|
||||
'open3d>=0.13.0',
|
||||
'Pillow>=8.3.1',
|
||||
'probreg>=0.3.4',
|
||||
'scikit-image>=0.18.2',
|
||||
'scikit-learn>=0.24.2',
|
||||
'scipy>=1.7.0'
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from .registration import Registration, RegistrationFunction, IcpRegistrationFunction, FilterregRegistrationFunction
|
||||
from .registration import Registration, RegistrationFunction, IcpRegistrationFunction
|
||||
from .channel_registration import SituImageChannelRegistration, ChannelRegistration, AcrossRoundChannelRegistration
|
||||
from .round_registration import RoundRegistration, AllChannelRoundRegistration
|
||||
from .tile_registration import CombinedRegistration
|
||||
|
||||
@@ -4,7 +4,7 @@ from situr.image import situ_image
|
||||
from situr.image.situ_tile import Tile
|
||||
from situr.registration.peak_finder import PeakFinder, PeakFinderDifferenceOfGaussian
|
||||
from situr.image.situ_image import SituImage
|
||||
from situr.registration import Registration, RegistrationFunction, FilterregRegistrationFunction
|
||||
from situr.registration import Registration, RegistrationFunction, IcpRegistrationFunction
|
||||
|
||||
|
||||
class SituImageChannelRegistration(Registration):
|
||||
|
||||
@@ -5,7 +5,7 @@ from probreg import filterreg
|
||||
import numpy as np
|
||||
|
||||
from situr.image import extend_dim
|
||||
from situr.transformation import Transform, ScaleRotateTranslateTransform
|
||||
from situr.transformation import Transform, RotateTranslateTransform
|
||||
|
||||
|
||||
class RegistrationFunction:
|
||||
@@ -28,46 +28,29 @@ class RegistrationFunction:
|
||||
"""
|
||||
raise NotImplementedError(self.__class__.__name__ + '.do_registration')
|
||||
|
||||
|
||||
class FilterregRegistrationFunction(RegistrationFunction):
|
||||
def do_registration(self,
|
||||
data_peaks: np.ndarray,
|
||||
reference_peaks: np.ndarray) -> ScaleRotateTranslateTransform:
|
||||
"""Method that uses filterregregistration to register the data_peaks.
|
||||
|
||||
Args:
|
||||
data_peaks (np.ndarray): The peaks to be registered to the reference
|
||||
reference_peaks (np.ndarray): The reference peaks
|
||||
|
||||
Returns:
|
||||
ScaleRotateTranslateTransform: the resulting transformaton from the registration
|
||||
"""
|
||||
source = o3.geometry.PointCloud()
|
||||
source.points = o3.utility.Vector3dVector(extend_dim(data_peaks))
|
||||
target = o3.geometry.PointCloud()
|
||||
target.points = o3.utility.Vector3dVector(extend_dim(reference_peaks))
|
||||
|
||||
registration_method = filterreg.registration_filterreg
|
||||
tf_param, _, _ = filterreg.registration_filterreg(source, target)
|
||||
|
||||
return ScaleRotateTranslateTransform(transform_matrix=tf_param.rot[0:2, 0:2],
|
||||
scale=tf_param.scale, offset=tf_param.t[0:2])
|
||||
|
||||
|
||||
class IcpRegistrationFunction(RegistrationFunction):
|
||||
def __init__(self, max_correspondence_distance=50) -> None:
|
||||
self.max_distance = max_correspondence_distance
|
||||
|
||||
def do_registration(self,
|
||||
data_peaks: np.ndarray,
|
||||
reference_peaks: np.ndarray) -> ScaleRotateTranslateTransform:
|
||||
reference_peaks: np.ndarray) -> RotateTranslateTransform:
|
||||
"""Method that uses ICP to register the data_peaks.
|
||||
|
||||
Args:
|
||||
data_peaks (np.ndarray): The peaks to be registered to the reference
|
||||
reference_peaks (np.ndarray): The reference peaks
|
||||
|
||||
Returns:
|
||||
RotateTranslateTransform: the resulting transformaton from the registration
|
||||
"""
|
||||
source = o3.geometry.PointCloud()
|
||||
source.points = o3.utility.Vector3dVector(extend_dim(data_peaks))
|
||||
target = o3.geometry.PointCloud()
|
||||
target.points = o3.utility.Vector3dVector(extend_dim(reference_peaks))
|
||||
reg_p2p = o3.pipelines.registration.registration_icp(
|
||||
source, target, self.max_distance)
|
||||
return ScaleRotateTranslateTransform(
|
||||
return RotateTranslateTransform(
|
||||
reg_p2p.transformation[0:2, 0:2],
|
||||
offset=reg_p2p.transformation[[1, 0], 3])
|
||||
|
||||
@@ -76,13 +59,13 @@ class Registration:
|
||||
__metaclass__ = abc.ABCMeta
|
||||
|
||||
def __init__(self,
|
||||
registration_function: RegistrationFunction() = FilterregRegistrationFunction(),
|
||||
registration_function: RegistrationFunction() = IcpRegistrationFunction(),
|
||||
peak_finder=PeakFinderDifferenceOfGaussian()):
|
||||
"""Initialize channel registration and tell which registration function to use.
|
||||
|
||||
Args:
|
||||
registration_function (RegistrationFunction, optional): Registration function.
|
||||
Defaults to FilterregRegistrationFunction().
|
||||
Defaults to IcpRegistrationFunction().
|
||||
peak_finder (PeakFinder, optional): The peak finder to be used for the registration.
|
||||
Defaults to PeakFinderDifferenceOfGaussian().
|
||||
"""
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from situr.image.situ_tile import Tile
|
||||
import numpy as np
|
||||
|
||||
from situr.registration import Registration, RegistrationFunction, FilterregRegistrationFunction
|
||||
from situr.registration import Registration, RegistrationFunction, IcpRegistrationFunction
|
||||
|
||||
|
||||
class RoundRegistration(Registration):
|
||||
|
||||
@@ -1 +1 @@
|
||||
from .transformation import Transform, IdentityTransform, ScaleRotateTranslateTransform
|
||||
from .transformation import Transform, IdentityTransform, RotateTranslateTransform
|
||||
|
||||
@@ -23,7 +23,7 @@ class IdentityTransform(Transform):
|
||||
return img
|
||||
|
||||
|
||||
class ScaleRotateTranslateTransform(Transform):
|
||||
class RotateTranslateTransform(Transform):
|
||||
def __init__(self,
|
||||
transform_matrix: np.ndarray,
|
||||
scale: int = 1,
|
||||
|
||||
Reference in New Issue
Block a user