Skip to content
This repository has been archived by the owner on Jan 3, 2024. It is now read-only.

Update dependency (imlib -> brainglobe-utils) #182

Merged
merged 2 commits into from
Jun 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/python/black)
[![Imports: isort](https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat&labelColor=ef8336)](https://pycqa.github.io/isort/)
[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://github.com/pre-commit/pre-commit)
[![Contributions](https://img.shields.io/badge/Contributions-Welcome-brightgreen.svg)](https://docs.brainglobe.info/cellfinder/contributing)
[![Contributions](https://img.shields.io/badge/Contributions-Welcome-brightgreen.svg)](https://brainglobe.info/developers/index.html)
[![Twitter](https://img.shields.io/twitter/follow/brain_globe?style=social)](https://twitter.com/brain_globe)

# cellfinder-core
Expand Down Expand Up @@ -76,7 +76,7 @@ detected_cells = cellfinder_run(signal_array,background_array,voxel_sizes)
```

The output is a list of
[imlib Cell objects](https://github.com/adamltyson/imlib/blob/51ec5a8053e738776ceaa8d44e531b3c4b0e29d8/imlib/cells/cells.py#L15).
[brainglobe-utils Cell objects](https://github.com/brainglobe/brainglobe-utils/blob/044a735049c1323466d277f9df1c3abad8b2bb8d/brainglobe_utils/cells/cells.py#L19)
Each `Cell` has a centroid coordinate, and a type:

```python
Expand All @@ -88,7 +88,7 @@ Cell type 2 is a "real" cell, and Cell type 1 is a "rejected" object (i.e.
not classified as a cell):

```python
from imlib.cells.cells import Cell
from brainglobe_utils.cells.cells import Cell
print(Cell.CELL)
# 2

Expand All @@ -98,15 +98,15 @@ print(Cell.NO_CELL)

#### Saving the results
If you want to save the detected cells for use in other BrainGlobe software (e.g. the
[cellfinder napari plugin](https://docs.brainglobe.info/cellfinder-napari/introduction)),
[cellfinder napari plugin](https://brainglobe.info/documentation/cellfinder/user-guide/napari-plugin/index.html)),
you can save in the cellfinder XML standard:
```python
from imlib.IO.cells import save_cells
from brainglobe_utils.IO.cells import save_cells
save_cells(detected_cells, "/path/to/cells.xml")
```
You can load these back with:
```python
from imlib.IO.cells import get_cells
from brainglobe_utils.IO.cells import get_cells
cells = get_cells("/path/to/cells.xml")
```

Expand Down Expand Up @@ -210,7 +210,8 @@ if len(cell_candidates) > 0: # Don't run if there's nothing to classify
The training data needed are matched pairs (signal & background) of small
(usually 50 x 50 x 100um) images centered on the coordinate of candidate cells.
These can be generated however you like, but I recommend using the
[Napari plugin](https://docs.brainglobe.info/cellfinder-napari/user-guide/training-data-generation).
[Napari plugin](https://brainglobe.
info/documentation/cellfinder/user-guide/napari-plugin/training-data-generation.html).

`cellfinder-core` comes with a 50-layer ResNet trained on ~100,000 data points
from serial two-photon microscopy images of mouse brains
Expand Down Expand Up @@ -296,5 +297,5 @@ If you find this plugin useful, and use it in your research, please cite the pap
[https://doi.org/10.1371/journal.pcbi.1009074](https://doi.org/10.1371/journal.pcbi.1009074)

**If you use this, or any other tools in the brainglobe suite, please
[let us know](mailto:[email protected]?subject=cellfinder-core), and
[let us know](mailto:[email protected]?subject=cellfinder-core), and
we'd be happy to promote your paper/talk etc.**
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ requires-python = ">=3.8"
dependencies = [
"dask[array]",
"fancylog>=0.0.7",
"imlib>=0.0.26",
"brainglobe-utils",
"natsort",
"numba",
"numpy",
Expand Down Expand Up @@ -111,7 +111,7 @@ known-first-party = ["cellfinder_core"]
[[tool.mypy.overrides]]
module = [
"fancylog.*",
"imlib.*",
"brainglobe_utils.*",
"natsort.*",
"numba.*",
"tensorflow.*",
Expand Down
4 changes: 2 additions & 2 deletions src/cellfinder_core/classify/classify.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
from typing import Any, Callable, Dict, List, Optional, Tuple

import numpy as np
from imlib.cells.cells import Cell
from imlib.general.system import get_num_processes
from brainglobe_utils.cells.cells import Cell
from brainglobe_utils.general.system import get_num_processes
from tensorflow import keras

from cellfinder_core import logger, types
Expand Down
4 changes: 2 additions & 2 deletions src/cellfinder_core/classify/cube_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

import numpy as np
import tensorflow as tf
from imlib.cells.cells import Cell, group_cells_by_z
from imlib.general.numerical import is_even
from brainglobe_utils.cells.cells import Cell, group_cells_by_z
from brainglobe_utils.general.numerical import is_even
from scipy.ndimage import zoom
from skimage.io import imread
from tensorflow.keras.utils import Sequence
Expand Down
4 changes: 2 additions & 2 deletions src/cellfinder_core/detect/detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
from typing import Callable, List, Optional, Sequence, Tuple, TypeVar

import numpy as np
from imlib.cells.cells import Cell
from imlib.general.system import get_num_processes
from brainglobe_utils.cells.cells import Cell
from brainglobe_utils.general.system import get_num_processes

from cellfinder_core import logger, types
from cellfinder_core.detect.filters.plane import TileProcessor
Expand Down
2 changes: 1 addition & 1 deletion src/cellfinder_core/detect/filters/volume/volume_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from typing import Any, Callable, List, Optional, Tuple

import numpy as np
from imlib.cells.cells import Cell
from brainglobe_utils.cells.cells import Cell
from tifffile import tifffile
from tqdm import tqdm

Expand Down
4 changes: 2 additions & 2 deletions src/cellfinder_core/download/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import tarfile
import urllib.request

from imlib.general.config import get_config_obj
from imlib.general.system import disk_free_gb
from brainglobe_utils.general.config import get_config_obj
from brainglobe_utils.general.system import disk_free_gb

from cellfinder_core.tools.source_files import (
source_config_cellfinder,
Expand Down
2 changes: 1 addition & 1 deletion src/cellfinder_core/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from typing import Callable, List, Optional, Tuple

import numpy as np
from imlib.general.logging import suppress_specific_logs
from brainglobe_utils.general.logging import suppress_specific_logs

from cellfinder_core import logger
from cellfinder_core.download.models import model_type
Expand Down
2 changes: 1 addition & 1 deletion src/cellfinder_core/tools/IO.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
from typing import Tuple

import numpy as np
from brainglobe_utils.general.system import get_sorted_file_paths
from dask import array as da
from dask import delayed
from imlib.general.system import get_sorted_file_paths
from tifffile import TiffFile, imread


Expand Down
2 changes: 1 addition & 1 deletion src/cellfinder_core/tools/image_processing.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import numpy as np
from imlib.general.numerical import is_even
from brainglobe_utils.general.numerical import is_even


def crop_center_2d(img, crop_x=None, crop_y=None):
Expand Down
4 changes: 2 additions & 2 deletions src/cellfinder_core/tools/prep.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
from pathlib import Path
from typing import Optional

from imlib.general.config import get_config_obj
from imlib.general.system import get_num_processes
from brainglobe_utils.general.config import get_config_obj
from brainglobe_utils.general.system import get_num_processes

import cellfinder_core.tools.tf as tf_tools
from cellfinder_core import logger
Expand Down
2 changes: 1 addition & 1 deletion src/cellfinder_core/tools/system.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from pathlib import Path

from imlib.general.exceptions import CommandLineInputError
from brainglobe_utils.general.exceptions import CommandLineInputError


def get_subdirectories(directory, names_only=False):
Expand Down
2 changes: 1 addition & 1 deletion src/cellfinder_core/tools/tiff.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from os.path import isfile, join

import natsort
from imlib.cells.cells import Cell, UntypedCell
from brainglobe_utils.cells.cells import Cell, UntypedCell


class TiffList(object):
Expand Down
11 changes: 7 additions & 4 deletions src/cellfinder_core/train/train_yml.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,14 @@
from pathlib import Path
from typing import Dict, Literal

from brainglobe_utils.general.numerical import (
check_positive_float,
check_positive_int,
)
from brainglobe_utils.general.system import ensure_directory_exists
from brainglobe_utils.IO.cells import find_relevant_tiffs
from brainglobe_utils.IO.yaml import read_yaml_section
from fancylog import fancylog
from imlib.general.numerical import check_positive_float, check_positive_int
from imlib.general.system import ensure_directory_exists
from imlib.IO.cells import find_relevant_tiffs
from imlib.IO.yaml import read_yaml_section
from sklearn.model_selection import train_test_split

import cellfinder_core as program_for_log
Expand Down
4 changes: 2 additions & 2 deletions tests/tests/test_integration/test_detection.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import os
from math import isclose

import imlib.IO.cells as cell_io
import brainglobe_utils.IO.cells as cell_io
import numpy as np
import pytest
from imlib.general.system import get_num_processes
from brainglobe_utils.general.system import get_num_processes

from cellfinder_core.main import main
from cellfinder_core.tools.IO import read_with_dask
Expand Down
4 changes: 2 additions & 2 deletions tests/tests/test_unit/test_tools/test_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
from pathlib import Path

import pytest
from imlib.general.exceptions import CommandLineInputError
from imlib.general.system import ensure_directory_exists
from brainglobe_utils.general.exceptions import CommandLineInputError
from brainglobe_utils.general.system import ensure_directory_exists

import cellfinder_core.tools.system as system

Expand Down