Import and export tasks
Gaussian smoothing task
plantseg.tasks.dataprocessing_tasks.gaussian_smoothing_task(image: PlantSegImage, sigma: float) -> PlantSegImage
Apply Gaussian smoothing to a PlantSegImage object.
Parameters:
-
image
(PlantSegImage
) –input image
-
sigma
(float
) –standard deviation of the Gaussian kernel
Source code in plantseg/tasks/dataprocessing_tasks.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
|
Image cropping task
plantseg.tasks.dataprocessing_tasks.image_cropping_task(image: PlantSegImage, rectangle=None, crop_z: tuple[int, int] = (0, 100)) -> PlantSegImage
Crop the image based on the given rectangle and z-slices.
Parameters:
-
image
(PlantSegImage
) –The image to be cropped.
-
rectangle
(Optional
, default:None
) –Rectangle defining the region to crop.
-
crop_z
(tuple[int, int]
, default:(0, 100)
) –Z-slice range for cropping.
Returns:
-
PlantSegImage
(PlantSegImage
) –The cropped image.
Source code in plantseg/tasks/dataprocessing_tasks.py
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
|
Image rescale to shape task
plantseg.tasks.dataprocessing_tasks.image_rescale_to_shape_task(image: PlantSegImage, new_shape: tuple[int, ...], order: int = 0) -> PlantSegImage
Rescale an image to a new shape.
Parameters:
-
image
(PlantSegImage
) –input image
-
new_shape
(tuple[int, ...]
) –new shape of the image
-
order
(int
, default:0
) –order of the interpolation
Source code in plantseg/tasks/dataprocessing_tasks.py
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 |
|
Image rescale to voxel size task
plantseg.tasks.dataprocessing_tasks.image_rescale_to_voxel_size_task(image: PlantSegImage, new_voxel_size: VoxelSize, order: int = 0) -> PlantSegImage
Rescale an image to a new voxel size.
If the voxel size is not defined in the input image, use the set voxel size task to set the voxel size.
Parameters:
-
image
(PlantSegImage
) –input image
-
new_voxel_size
(VoxelSize
) –new voxel size
-
order
(int
, default:0
) –order of the interpolation
Source code in plantseg/tasks/dataprocessing_tasks.py
177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 |
|
Set image voxel size task
plantseg.tasks.dataprocessing_tasks.set_voxel_size_task(image: PlantSegImage, voxel_size: tuple[float, float, float]) -> PlantSegImage
Set the voxel size of an image.
Parameters:
Source code in plantseg/tasks/dataprocessing_tasks.py
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
|
Label Postprocessing
Remove false positives task
plantseg.tasks.dataprocessing_tasks.remove_false_positives_by_foreground_probability_task(segmentation: PlantSegImage, foreground: PlantSegImage, threshold: float) -> PlantSegImage
Remove false positives from a segmentation based on the foreground probability.
Parameters:
-
segmentation
(PlantSegImage
) –input segmentation
-
foreground
(PlantSegImage
) –input foreground probability
-
threshold
(float
) –threshold value
Source code in plantseg/tasks/dataprocessing_tasks.py
207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 |
|
Fix Over/Under segmentation task
plantseg.tasks.dataprocessing_tasks.fix_over_under_segmentation_from_nuclei_task(cell_seg: PlantSegImage, nuclei_seg: PlantSegImage, threshold_merge: float = 0.33, threshold_split: float = 0.66, quantiles_nuclei: tuple[float, float] = (0.3, 0.99), boundary: PlantSegImage | None = None) -> PlantSegImage
Task function to fix over- and under-segmentation in cell segmentation based on nuclear segmentation.
This function is used to run the over- and under-segmentation correction within a task management system.
It uses the segmentation arrays and nuclear information to merge and split cell regions. This task ensures
that the provided cell_seg
and nuclei_seg
have matching shapes and processes the data accordingly.
Parameters:
-
cell_seg
(PlantSegImage
) –Input cell segmentation as a
PlantSegImage
object. -
nuclei_seg
(PlantSegImage
) –Input nuclear segmentation as a
PlantSegImage
object. -
threshold_merge
(float
, default:0.33
) –Threshold for merging cells based on the overlap with nuclei. Default is 0.33.
-
threshold_split
(float
, default:0.66
) –Threshold for splitting cells based on the overlap with nuclei. Default is 0.66.
-
quantiles_nuclei
(tuple[float, float]
, default:(0.3, 0.99)
) –Quantiles used to filter nuclei by size. Default is (0.3, 0.99).
-
boundary
(PlantSegImage | None
, default:None
) –Optional boundary probability map. If not provided, a constant map is used.
Returns:
-
PlantSegImage
(PlantSegImage
) –A new
PlantSegImage
object containing the corrected cell segmentation.
Source code in plantseg/tasks/dataprocessing_tasks.py
229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 |
|
Set biggest object as background task
plantseg.tasks.dataprocessing_tasks.set_biggest_instance_to_zero_task(image: PlantSegImage, instance_could_be_zero: bool = False) -> PlantSegImage
Task to set the largest segment in a segmentation image to zero.
Parameters:
-
image
(PlantSegImage
) –Segmentation image to process.
-
instance_could_be_zero
(bool
, default:False
) –If True, 0 might be an instance label, add 1 to all labels before processing.
Returns:
-
PlantSegImage
(PlantSegImage
) –New segmentation image with largest instance set to 0.
Source code in plantseg/tasks/dataprocessing_tasks.py
271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 |
|
Relabel task
plantseg.tasks.dataprocessing_tasks.relabel_segmentation_task(image: PlantSegImage, background: int | None = None) -> PlantSegImage
Task to relabel a segmentation image contiguously, ensuring non-touching segments with the same ID are relabeled.
Parameters:
-
image
(PlantSegImage
) –Segmentation image to process.
Returns:
-
PlantSegImage
(PlantSegImage
) –New segmentation image with relabeled instances.
Source code in plantseg/tasks/dataprocessing_tasks.py
292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 |
|