Skip to content

Commit 673f215

Browse files
anna-grimanna-grim
andauthored
Feat s3 img reader (#289)
* refactor: anistropy not hardcoded * refactor: anisotropy not built-in * refactor: simplified graph loader * refactor: simplified swc_util * refactor: image reader class --------- Co-authored-by: anna-grim <anna.grim@alleninstitute.org>
1 parent be72cea commit 673f215

File tree

5 files changed

+365
-293
lines changed

5 files changed

+365
-293
lines changed

src/deep_neurographs/config.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ class GraphConfig:
2323
----------
2424
anisotropy : list[float], optional
2525
Scaling factors applied to xyz coordinates to account for anisotropy
26-
of microscope. The default is [1.0, 1.0, 1.0].
26+
of microscope. Note this instance of "anisotropy" is only used while
27+
reading fragments (i.e. swcs). The default is [1.0, 1.0, 1.0].
2728
complex_bool : bool
2829
Indication of whether to generate complex proposals, meaning proposals
2930
between leaf and non-leaf nodes. The default is False.
@@ -74,12 +75,15 @@ class MLConfig:
7475
7576
Attributes
7677
----------
78+
anisotropy : list[float], optional
79+
Scaling factors applied to xyz coordinates to account for anisotropy
80+
of microscope. Note this instance of "anisotropy" is only used while
81+
generating features. The default is [1.0, 1.0, 1.0].
7782
batch_size : int
7883
The number of samples processed in one batch during training or
7984
inference. Default is 1000.
80-
downsample_factor : int
81-
Downsampling factor that accounts for which level in the image pyramid
82-
the voxel coordinates must index into. The default is 0.
85+
multiscale : int
86+
Level in the image pyramid that voxel coordinates must index into.
8387
high_threshold : float
8488
A threshold value used for classification, above which predictions are
8589
considered to be high-confidence. Default is 0.9.
@@ -89,14 +93,14 @@ class MLConfig:
8993
Type of machine learning model to use. Default is "GraphNeuralNet".
9094
9195
"""
92-
96+
anisotropy: List[float] = field(default_factory=list)
9397
batch_size: int = 2000
94-
downsample_factor: int = 1
9598
high_threshold: float = 0.9
9699
lr: float = 1e-3
97-
threshold: float = 0.6
98100
model_type: str = "GraphNeuralNet"
101+
multiscale: int = 1
99102
n_epochs: int = 1000
103+
threshold: float = 0.6
100104
validation_split: float = 0.15
101105
weight_decay: float = 1e-3
102106

src/deep_neurographs/inference.py

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def __init__(
6868
config,
6969
device="cpu",
7070
is_multimodal=False,
71-
label_path=None,
71+
labels_path=None,
7272
log_runtimes=True,
7373
save_to_s3_bool=False,
7474
s3_dict=None,
@@ -98,7 +98,7 @@ def __init__(
9898
...
9999
is_multimodal : bool, optional
100100
...
101-
label_path : str, optional
101+
labels_path : str, optional
102102
Path to the segmentation assumed to be stored on a GCS bucket. The
103103
default is None.
104104
log_runtimes : bool, optional
@@ -132,11 +132,12 @@ def __init__(
132132
self.model_path,
133133
self.ml_config.model_type,
134134
self.graph_config.search_radius,
135+
anisotropy=self.ml_config.anisotropy,
135136
batch_size=self.ml_config.batch_size,
136137
confidence_threshold=self.ml_config.threshold,
137138
device=device,
138-
downsample_factor=self.ml_config.downsample_factor,
139-
label_path=label_path,
139+
multiscale=self.ml_config.multiscale,
140+
labels_path=labels_path,
140141
is_multimodal=is_multimodal,
141142
)
142143

@@ -474,11 +475,12 @@ def __init__(
474475
model_path,
475476
model_type,
476477
radius,
478+
anisotropy=[1.0, 1.0, 1.0],
477479
batch_size=BATCH_SIZE,
478480
confidence_threshold=CONFIDENCE_THRESHOLD,
479481
device=None,
480-
downsample_factor=1,
481-
label_path=None,
482+
multiscale=1,
483+
labels_path=None,
482484
is_multimodal=False
483485
):
484486
"""
@@ -501,9 +503,9 @@ def __init__(
501503
confidence_threshold : float, optional
502504
Threshold on acceptance probability for proposals. The default is
503505
the global variable "CONFIDENCE_THRESHOLD".
504-
downsample_factor : int, optional
505-
Downsampling factor that accounts for which level in the image
506-
pyramid the voxel coordinates must index into. The default is 0.
506+
multiscale : int, optional
507+
Level in the image pyramid that voxel coordinates must index into.
508+
The default is 1.
507509
508510
Returns
509511
-------
@@ -520,8 +522,9 @@ def __init__(
520522
# Features
521523
self.feature_generator = FeatureGenerator(
522524
img_path,
523-
downsample_factor,
524-
label_path=label_path,
525+
multiscale,
526+
anisotropy=anisotropy,
527+
labels_path=labels_path,
525528
is_multimodal=is_multimodal
526529
)
527530

0 commit comments

Comments
 (0)