Skip to content

Commit

Permalink
v1.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Patrick Nicodemus committed Aug 22, 2024
1 parent 98182ac commit 12d86f4
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 15 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ The ```-p``` flag controls the port number on local host. For example, writing `
## Documentation
Extensive documentation, including several tutorials, can be found in [CAJAL's readthedocs.io website](https://cajal.readthedocs.io/en/latest/index.html). This website is under development and will continue to be substantially updated during the coming months.

## New in this release (v1.0.2, 8/22/2024)
## New in this release (v1.0.3, 8/22/2024)
- Released on PyPI
- Included a fix in cell segmentation contributed by @YuchenXiangEMBL
- Wheels are available on the Github Release page
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "cajal"
version = "1.0.2"
version = "1.0.3"
description="A library for multi-modal cell morphology analyses using Gromov-Wasserstein (GW) distance."
readme="./README.md"
requires-python=">=3.9"
Expand Down
30 changes: 17 additions & 13 deletions src/cajal/sample_seg.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,18 @@
from pathos.pools import ProcessPool
from .utilities import write_csv_block

def _filter_to_cells(segmask: npt.NDArray[np.int_], background: int) -> list[int]:
"""
Return a list of identifiers for cells in the interior of the image.
"""
cell_ids = set(np.unique(segmask))
remove_cells = set()
remove_cells.add(background)
remove_cells.update(np.unique(segmask[0, :]))
remove_cells.update(np.unique(segmask[-1, :]))
remove_cells.update(np.unique(segmask[:, 0]))
remove_cells.update(np.unique(segmask[:, -1]))
return list(cell_ids.difference(remove_cells))

def cell_boundaries(
imarray: npt.NDArray[np.int_],
Expand Down Expand Up @@ -40,18 +52,9 @@ def cell_boundaries(
containing points sampled from the contours.
"""

cell_ids = set(np.unique(imarray))
remove_cells = set()
remove_cells.update(np.unique(imarray[0, :]))
remove_cells.update(np.unique(imarray[-1, :]))
remove_cells.update(np.unique(imarray[:, 0]))
remove_cells.update(np.unique(imarray[:, -1]))
cell_id_list = list(cell_ids.difference(remove_cells))

outlist: List[npt.NDArray[np.float64]] = []
cell_id_list = _filter_to_cells(imarray, background)
outlist: List[Tuple[int, npt.NDArray[np.float64]]] = []
for cell in cell_id_list:
if cell == background: # Don't draw a boundary around background
continue
cell_imarray = (imarray == cell) * 1
boundary_pts_list = measure.find_contours(
cell_imarray, 0.5, fully_connected="high"
Expand All @@ -73,8 +76,9 @@ def cell_boundaries(
+ str(cell)
)
indices = np.linspace(0, boundary_pts.shape[0] - 1, n_sample)
outlist.append(boundary_pts[indices.astype("uint32")])
return list(enumerate(outlist))
outlist.append((cell, boundary_pts[indices.astype("uint32")]))
return list(outlist)



def _compute_intracell_all(
Expand Down

0 comments on commit 12d86f4

Please sign in to comment.