diff --git a/setup.py b/setup.py index ebdf5df..87cfbcd 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ setup( name="temmeta", - version="0.0.4", + version="0.0.6", description=("TEMMETA is a library for transmission electron microscopy " "(TEM) (meta)data manipulation"), url='https://github.com/din14970/TEMMETA', @@ -27,12 +27,9 @@ 'openpyxl', 'pandas', 'scipy', - 'jupyter', 'hyperspy', 'matplotlib_scalebar', 'tqdm', 'Pillow', - 'opencv-python', - 'PyQt5' ], ) diff --git a/temmeta/algebrautils.py b/temmeta/algebrautils.py index 905dd9f..f48b3b8 100644 --- a/temmeta/algebrautils.py +++ b/temmeta/algebrautils.py @@ -19,3 +19,14 @@ def distance(x1, y1, x2, y2): """Get the euclidian distance between two points""" le = np.sqrt((x2-x1)**2+(y2-y1)**2) return le + + +def get_center_and_radius(x1, y1, x2, y2, x3, y3): + """Get the coordinates of the center and radius of + a circle defined by 3 points p_i=(x_i, y_i)""" + cx = (((x1**2-x3**2+y1**2-y3**2)*(y2-y1) - + (x1**2-x2**2+y1**2-y2**2)*(y3-y1)) / + (2*((x2-x1)*(y3-y1)-(x3-x1)*(y2-y1)))) + cy = (-(x1**2-x2**2+y1**2-y2**2)-2*(x2-x1)*cx)/(2*(y2-y1)) + r = ((x1-cx)**2+(y1-cy)**2)**0.5 + return (cx, cy), r diff --git a/temmeta/data_io.py b/temmeta/data_io.py index 9899604..9546a1f 100644 --- a/temmeta/data_io.py +++ b/temmeta/data_io.py @@ -23,15 +23,15 @@ from PIL import Image # My own modules -from . import plottingtools as pl -from . import image_filters as imf -from ._decorators import timeit -from .guitools import file_dialog as fdo -from . import processing as proc -from . import metadata as mda -from . import jsontools as jt -from . import algebrautils as algutil -from .roi import line +from temmeta import plottingtools as pl +from temmeta import image_filters as imf +from temmeta._decorators import timeit +from temmeta.guitools import file_dialog as fdo +from temmeta import processing as proc +from temmeta import metadata as mda +from temmeta import jsontools as jt +from temmeta import algebrautils as algutil +from temmeta.roi import line import concurrent.futures as cf from multiprocessing import Pool, cpu_count @@ -3188,13 +3188,11 @@ def get_frame(self, frame_index): process) return nimg + @property def average(self): """Average the frames, return GeneralImage object""" # Sum becomes a uint64 image - dt = self.data.dtype - data = self.data.sum(axis=0) - # Rescale to turn it back into the same datatype as before - data = imf.normalize_convert(data, dtype=dt) + data = self.data.mean(axis=0) process = "Averaged all frames in stack" nimg = create_new_image(data, self.pixelsize, self.pixelunit, self, process) diff --git a/temmeta/roi/__init__.py b/temmeta/roi/__init__.py new file mode 100644 index 0000000..e69de29