Skip to content

Commit

Permalink
Ran black
Browse files Browse the repository at this point in the history
  • Loading branch information
vianamp committed Apr 6, 2024
1 parent 3bb46e6 commit 15c02df
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
6 changes: 4 additions & 2 deletions aicscytoparam/alignment/generic_2d_shape.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
from skimage import measure as skmeasure


class Generic2DShape():
class Generic2DShape:
"""
Generic class for 2D shapes
"""

def __init__():
pass

Expand Down Expand Up @@ -112,8 +113,9 @@ def get_contour_from_3d_image(image, pad=5, center=True):

class ElongatedHexagonalShape(Generic2DShape):
"""
Elongated hexagonal shape
Elongated hexagonal shape
"""

def __init__(self, base, elongation, pad=5):
self._pad = pad
self._base = base
Expand Down
5 changes: 3 additions & 2 deletions aicscytoparam/alignment/shape_library_2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
from aicscytoparam.alignment.generic_2d_shape import Generic2DShape


class ShapeLibrary2D():
class ShapeLibrary2D:
"""
Define a library of 2D shapes
"""

def __init__(self):
pass

Expand Down Expand Up @@ -80,7 +81,7 @@ def display(self, xlim=[-150, 150], ylim=[-50, 50], contours_to_match=None):
axs[j, i].set_xlim(xlim[0], xlim[1])
axs[j, i].set_ylim(ylim[0], ylim[1])
if contours_to_match is not None:
for (cx, cy) in contours_to_match:
for cx, cy in contours_to_match:
pid, p, angle = self.find_best_match(cx, cy)
cxrot, cyrot = Generic2DShape.rotate_contour(cx, cy, angle)
axs[j, i].plot(cxrot, cyrot, color="magenta")
Expand Down
14 changes: 8 additions & 6 deletions aicscytoparam/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def load_image_and_align_based_on_shape_library(path, library, nuc_channel=1):
Returns
-------
image_rot: np.ndarray
aligned image
aligned image
"""
image = skio.imread(path)
(cx, cy) = Generic2DShape.get_contour_from_3d_image(image[0])
Expand All @@ -34,11 +34,12 @@ def load_image_and_align_based_on_shape_library(path, library, nuc_channel=1):
xpx = (x - x.mean()) * px / px.sum()
if xpx.sum() > 0:
image_rot = shtools.rotate_image_2d(image_rot, 180)
return image_rot
return image_rot


def get_voxelized_image_of_mean_shape(
vec: List, coeffs_mem: List, coeffs_nuc: List, return_meshes=False):
vec: List, coeffs_mem: List, coeffs_nuc: List, return_meshes=False
):
"""
Get the voxelized image of the mean shape
Parameters
Expand All @@ -59,8 +60,8 @@ def get_voxelized_image_of_mean_shape(
vec = np.array(vec).mean(axis=0)
df_coeffs_mem = pd.DataFrame(coeffs_mem)
df_coeffs_nuc = pd.DataFrame(coeffs_nuc)
df_coeffs_mem_avg = df_coeffs_mem.select_dtypes(include='number').mean(axis=0)
df_coeffs_nuc_avg = df_coeffs_nuc.select_dtypes(include='number').mean(axis=0)
df_coeffs_mem_avg = df_coeffs_mem.select_dtypes(include="number").mean(axis=0)
df_coeffs_nuc_avg = df_coeffs_nuc.select_dtypes(include="number").mean(axis=0)
avg_coeffs_mem = shtools.convert_coeffs_dict_to_matrix(df_coeffs_mem_avg, lmax=32)
avg_coeffs_nuc = shtools.convert_coeffs_dict_to_matrix(df_coeffs_nuc_avg, lmax=32)
avg_mesh_mem, _ = shtools.get_reconstruction_from_coeffs(avg_coeffs_mem)
Expand All @@ -69,7 +70,8 @@ def get_voxelized_image_of_mean_shape(
# centroid relative to cell centroid
pts = vtknp.vtk_to_numpy(avg_mesh_nuc.GetPoints().GetData())
shtools.update_mesh_points(
avg_mesh_nuc, pts[:, 0] - vec[0], pts[:, 1] - vec[1], pts[:, 2] - vec[2])
avg_mesh_nuc, pts[:, 0] - vec[0], pts[:, 1] - vec[1], pts[:, 2] - vec[2]
)
# Convert average cell shape into an image
avg_image, _ = shtools.voxelize_meshes([avg_mesh_mem, avg_mesh_nuc])
if return_meshes:
Expand Down

0 comments on commit 15c02df

Please sign in to comment.