Skip to content

Commit 8607f33

Browse files
committed
same for deepcell module
1 parent fb2dbe6 commit 8607f33

7 files changed

Lines changed: 51 additions & 43 deletions

File tree

File renamed without changes.

modules/sanger/bioinfotongli/deepcell/main.nf renamed to modules/sanger/imaging/deepcell/main.nf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
process BIOINFOTONGLI_DEEPCELL {
1+
process IMAGING_DEEPCELL {
22
tag "${meta.id}"
33
label 'process_medium'
44

@@ -33,7 +33,7 @@ process BIOINFOTONGLI_DEEPCELL {
3333
3434
cat <<-END_VERSIONS > versions.yml
3535
"${task.process}":
36-
bioinfotongli: \$(deepcell_helper.py version)
36+
imaging: \$(deepcell_helper.py version)
3737
END_VERSIONS
3838
"""
3939

@@ -45,7 +45,7 @@ process BIOINFOTONGLI_DEEPCELL {
4545
4646
cat <<-END_VERSIONS > versions.yml
4747
"${task.process}":
48-
bioinfotongli: \$(deepcell_helper.py version)
48+
imaging: \$(deepcell_helper.py version)
4949
END_VERSIONS
5050
"""
5151
}

modules/sanger/bioinfotongli/deepcell/meta.yml renamed to modules/sanger/imaging/deepcell/meta.yml

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
---
22
# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/meta-schema.json
3-
name: "bioinfotongli_deepcell"
3+
name: "imaging_deepcell"
44
description: This module runs deepcell on a crop of an image
55
keywords:
66
- image analysis
77
- image segmentation
88
- imaging
99
tools:
10-
- "bioinfotongli":
10+
- "imaging":
1111
description: "This module runs deepcell on a crop of an image"
1212
homepage: ""
1313
documentation: ""
1414
tool_dev_url: ""
1515
doi: ""
16-
licence:
17-
identifier:
16+
licence:
17+
identifier:
1818

1919
input:
2020
- - meta:
@@ -41,21 +41,21 @@ input:
4141

4242
output:
4343
- wkts:
44-
- meta:
45-
type: map
46-
description: |
47-
Groovy Map containing sample information
48-
e.g. `[ id:'sample1' ]`
49-
- "${output_name}":
50-
type: file
51-
description: WKT file
52-
pattern: "*.wkt"
53-
44+
- meta:
45+
type: map
46+
description: |
47+
Groovy Map containing sample information
48+
e.g. `[ id:'sample1' ]`
49+
- "${output_name}":
50+
type: file
51+
description: WKT file
52+
pattern: "*.wkt"
53+
5454
- versions:
55-
- "versions.yml":
56-
type: file
57-
description: File containing software versions
58-
pattern: "versions.yml"
55+
- "versions.yml":
56+
type: file
57+
description: File containing software versions
58+
pattern: "versions.yml"
5959

6060
authors:
6161
- "@BioinfoTongLI"

modules/sanger/bioinfotongli/deepcell/resources/usr/bin/deepcell_helper.py renamed to modules/sanger/imaging/deepcell/resources/usr/bin/deepcell_helper.py

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
# -*- coding: utf-8 -*-
33
# Copyright (c) 2025 Wellcome Sanger Institute
44

5-
"""
6-
"""
5+
""" """
76
import fire
87
from deepcell.applications import NuclearSegmentation
98
import numpy as np
@@ -18,6 +17,7 @@
1817
from imagetileprocessor import slice_and_crop_image
1918

2019
import logging
20+
2121
logger = logging.getLogger(__name__)
2222

2323

@@ -35,7 +35,7 @@ def get_largest_polygon(multi_polygon: MultiPolygon):
3535
largest_area = area
3636
largest_polygon = polygon
3737
if largest_polygon is None:
38-
return multi_polygon
38+
return multi_polygon
3939
else:
4040
return largest_polygon
4141

@@ -52,11 +52,9 @@ def get_shapely(label):
5252
continue
5353
cur_cell_label = i + 1
5454
msk = (label[bbox[0], bbox[1]] == cur_cell_label).astype(np.uint8).copy()
55-
cnts, _ = cv2.findContours(
56-
msk, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE
57-
)
55+
cnts, _ = cv2.findContours(msk, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
5856
# if len(cnts) > 1:
59-
# print(len(cnts), cur_cell_label)
57+
# print(len(cnts), cur_cell_label)
6058
current_polygons = [
6159
Polygon((cnt + [bbox[1].start, bbox[0].start]).squeeze())
6260
# else Point((cnt + [bbox[1].start, bbox[0].start]).squeeze())
@@ -72,12 +70,15 @@ def get_shapely(label):
7270

7371

7472
def main(
75-
image_path: str,
76-
x_min: int, x_max: int, y_min: int, y_max: int,
77-
output_name: str,
78-
C: int = 0,
79-
Z: int = 0,
80-
):
73+
image_path: str,
74+
x_min: int,
75+
x_max: int,
76+
y_min: int,
77+
y_max: int,
78+
output_name: str,
79+
C: int = 0,
80+
Z: int = 0,
81+
):
8182
model_dir = Path.home() / ".deepcell" / "models"
8283
# model_path = model_dir / MODEL_NAME
8384
model_path = model_dir / "NuclearSegmentation"
@@ -88,9 +89,16 @@ def main(
8889
# crop = img.get_image_dask_data("TYXC", Z=Z, T=T, C=C)[:, y_min:y_max, x_min:x_max, :]
8990

9091
crop = slice_and_crop_image(
91-
image_path, x_min, x_max, y_min, y_max, zs=np.array([Z]), channel=np.array([C]), resolution_level=0
92+
image_path,
93+
x_min,
94+
x_max,
95+
y_min,
96+
y_max,
97+
zs=np.array([Z]),
98+
channel=np.array([C]),
99+
resolution_level=0,
92100
)
93-
if crop.ndim == 2: # special channel setting required by deepcell
101+
if crop.ndim == 2: # special channel setting required by deepcell
94102
crop = np.expand_dims(crop, axis=[-1, 0])
95103
segmentation_predictions = app.predict(
96104
np.array(crop).astype(np.uint16), image_mpp=0.5
@@ -103,11 +111,11 @@ def main(
103111
translate(MultiPolygon(list(polys[1].values())), xoff=x_min, yoff=y_min)
104112
)
105113
)
106-
114+
107115

108116
if __name__ == "__main__":
109117
options = {
110118
"run": main,
111119
"version": "0.0.1",
112120
}
113-
fire.Fire(options)
121+
fire.Fire(options)

modules/sanger/bioinfotongli/deepcell/tests/main.nf.test renamed to modules/sanger/imaging/deepcell/tests/main.nf.test

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
// nf-core modules test bioinfotongli/deepcell
1+
// nf-core modules test imaging/deepcell
22
nextflow_process {
33

4-
name "Test Process BIOINFOTONGLI_DEEPCELL"
4+
name "Test Process IMAGING_DEEPCELL"
55
script "../main.nf"
6-
process "BIOINFOTONGLI_DEEPCELL"
6+
process "IMAGING_DEEPCELL"
77

88
tag "modules"
99
tag "modules_sanger"
10-
tag "bioinfotongli"
11-
tag "bioinfotongli/deepcell"
10+
tag "imaging"
11+
tag "imaging/deepcell"
1212

1313
test("mouse_heart - tiff") {
1414

modules/sanger/bioinfotongli/deepcell/tests/main.nf.test.snap renamed to modules/sanger/imaging/deepcell/tests/main.nf.test.snap

File renamed without changes.

modules/sanger/bioinfotongli/deepcell/tests/nextflow.config renamed to modules/sanger/imaging/deepcell/tests/nextflow.config

File renamed without changes.

0 commit comments

Comments
 (0)