Skip to content

Commit ce4307d

Browse files
MMathisLabC-Achard
andauthored
Update pyproject.toml; minimal conda for m1 (#38)
* Update pyproject.toml - make itk and pyqt5 "optional dependency, as for m1 they cause issues! * conda file for m1 - then run: `conda install -c anaconda pyqt` in the env * Added "Save location" tooltip * Packaging fixes - Remove dask and itk requirements - Comment duplicate sections in setup.cfg * Reduced duplicates in setup .cfg * Clean up pyproject * Update requirements.txt * Update README.md * Update README.md * Latest pre-commit hooks * Run full suite of pre-commit checks --------- Co-authored-by: C-Achard <[email protected]>
1 parent ec94453 commit ce4307d

File tree

15 files changed

+85
-83
lines changed

15 files changed

+85
-83
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ repos:
99
rev: 5.12.0
1010
hooks:
1111
- id: isort
12-
args: ["--profile", "black", --line-length=72]
12+
args: ["--profile", "black", --line-length=79]
1313
- repo: https://github.com/charliermarsh/ruff-pre-commit
1414
# Ruff version.
1515
rev: 'v0.0.262'

README.md

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,27 +29,41 @@ A napari plugin for 3D cell segmentation: training, inference, and data review.
2929

3030
## Installation
3131

32-
Note : we recommend using conda to create a new environment for the plugin.
32+
**Note** : we recommend using conda to create a new environment for the plugin.
33+
**M1 Mac users, please see the [M1 install section](#m1-mac-users)**
3334

3435
conda create --name napari-cellseg3d python=3.8
3536
conda activate napari-cellseg3d
3637

3738
You can install `napari-cellseg3d` via [pip]:
3839

39-
pip install napari-cellseg3d
40+
pip install napari-cellseg3d[all]
4041

4142
OR directly via [napari-hub]:
4243

4344
- Install napari from pip with `pip install "napari[all]"`,
4445
then from the “Plugins” menu within the napari application, select “Install/Uninstall Package(s)...”
4546
- Copy `napari-cellseg3d` and paste it where it says “Install by name/url…”
4647
- Click “Install”
48+
- Restart napari
49+
50+
### M1 Mac users
51+
52+
Create a new conda env using the provided conda/napari_cellseg3d_m1.yml file :
53+
54+
conda env create -f conda/napari_cellseg3d_m1.yml
55+
conda activate napari_cellseg3d_m1
56+
57+
Then install PyQt5 from conda separately :
58+
59+
conda install -c anaconda PyQt5
60+
4761

4862
## Documentation
4963

5064
Available at https://AdaptiveMotorControlLab.github.io/CellSeg3d
5165

52-
You can also generate docs by running ``make html`` in the docs folder.
66+
You can also generate docs by running ``make html`` in the docs/ folder.
5367

5468
## Usage
5569

conda/napari_cellseg3d_m1.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: napari_cellseg3d_m1
2+
channels:
3+
- anaconda
4+
- conda-forge
5+
- defaults
6+
dependencies:
7+
- python=3.8
8+
- pip
9+
- pip:
10+
- numpy
11+
- napari>=0.4.14
12+
- QtPy
13+
- opencv-python>=4.5.5
14+
- scikit-image>=0.19.2
15+
- matplotlib>=3.4.1
16+
- tifffile>=2022.2.9
17+
- imageio-ffmpeg>=0.4.5
18+
- torch>=1.11
19+
- monai[nibabel,einops]>=0.9.0
20+
- tqdm
21+
- nibabel
22+
- scikit-image
23+
- pillow
24+
- tqdm
25+
- matplotlib
26+
- vispy>=0.9.6

napari_cellseg3d/code_models/model_workers.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,7 @@ def model_output(
457457
# self.config.model_info.get_model().get_output(model, inputs)
458458
# )
459459

460+
460461
def model_output(inputs):
461462
return post_process_transforms(
462463
self.config.model_info.get_model().get_output(model, inputs)

napari_cellseg3d/code_plugins/plugin_base.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ def show_menu(_, event):
118118

119119
def _build_io_panel(self):
120120
self.io_panel = ui.GroupedWidget("Data")
121+
self.save_label = ui.make_label("Save location :", parent=self)
121122

122123
# self.io_panel.setToolTip("IO Panel")
123124

@@ -130,6 +131,7 @@ def _build_io_panel(self):
130131
self.filetype_choice,
131132
self.image_filewidget,
132133
self.labels_filewidget,
134+
self.save_label,
133135
self.results_filewidget,
134136
],
135137
)

napari_cellseg3d/code_plugins/plugin_crop.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -440,8 +440,8 @@ def _add_crop_sliders(
440440
for i in range(len(crop_sizes)):
441441
if crop_sizes[i] > im1_stack.shape[i]:
442442
crop_sizes[i] = im1_stack.shape[i]
443-
warnings.warn(
444-
f"WARNING : Crop dimension in axis {i} was too large at {crop_sizes[i]}, it was set to {im1_stack.shape[i]}"
443+
logger.warning(
444+
f"Crop dimension in axis {i} was too large at {crop_sizes[i]}, it was set to {im1_stack.shape[i]}"
445445
)
446446

447447
cropx, cropy, cropz = crop_sizes

napari_cellseg3d/dev_scripts/convert.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import os
33

44
import numpy as np
5-
from dask_image.imread import imread
5+
from tifffile import imread
66
from tifffile import imwrite
77

88
# input_seg_path = "C:/Users/Cyril/Desktop/Proj_bachelor/code/pytorch-test3dunet/cropped_visual/train/lab"
@@ -19,8 +19,8 @@
1919
filenames.append(os.path.basename(filename))
2020
# print(os.path.basename(filename))
2121
for file in paths:
22-
img = imread(file)
23-
image = img.compute()
22+
image = imread(file)
23+
# image = img.compute()
2424

2525
image[image >= 1] = 1
2626
image = image.astype(np.uint16)

napari_cellseg3d/dev_scripts/view_brain.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import napari
2-
from dask_image.imread import imread
2+
from tifffile import imread
33

44
y = imread("/Users/maximevidal/Documents/3drawdata/wholebrain.tif")
55

napari_cellseg3d/dev_scripts/view_sample.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import napari
2-
from dask_image.imread import imread
2+
from tifffile import imread
33

44
# Visual
55
x = imread(

napari_cellseg3d/utils.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
from pathlib import Path
55

66
import numpy as np
7-
from dask_image.imread import imread as dask_imread
87
from pandas import DataFrame
98
from pandas import Series
109
from skimage import io
@@ -301,7 +300,7 @@ def check_csv(project_path, ext):
301300
filename_pattern_original = Path(project_path) / Path(
302301
f"dataset/Original_size/Original/*{ext}"
303302
)
304-
images_original = dask_imread(filename_pattern_original)
303+
images_original = tfl_imread(filename_pattern_original)
305304
z, y, x = images_original.shape
306305
record = Series(
307306
[
@@ -426,7 +425,9 @@ def get_time_filepath():
426425
return "{:%H_%M_%S}".format(datetime.now())
427426

428427

429-
def load_images(dir_or_path, filetype="", as_folder: bool = False):
428+
def load_images(
429+
dir_or_path, filetype="", as_folder: bool = False
430+
): # TODO(cyril):refactor w/o as_folder
430431
"""Loads the images in ``directory``, with different behaviour depending on ``filetype`` and ``as_folder``
431432
432433
* If ``as_folder`` is **False**, will load the path as a single 3D **.tif** image.
@@ -446,7 +447,7 @@ def load_images(dir_or_path, filetype="", as_folder: bool = False):
446447
as_folder (bool): Whether to load a folder of images as stack or a single 3D image
447448
448449
Returns:
449-
dask.array.Array: dask array with loaded images
450+
np.array: array with loaded images
450451
"""
451452

452453
if not as_folder:
@@ -459,7 +460,12 @@ def load_images(dir_or_path, filetype="", as_folder: bool = False):
459460
raise ValueError("If loading as a folder, filetype must be specified")
460461

461462
if as_folder:
462-
images_original = dask_imread(filename_pattern_original)
463+
try:
464+
images_original = tfl_imread(filename_pattern_original)
465+
except ValueError:
466+
LOGGER.error(
467+
"Loading a stack this way is no longer supported. Use napari to load a stack."
468+
)
463469
else:
464470
images_original = tfl_imread(
465471
filename_pattern_original

0 commit comments

Comments
 (0)