Skip to content

Commit

Permalink
Merge pull request #167 from MannLabs/fix_165
Browse files Browse the repository at this point in the history
fix some small bugs
  • Loading branch information
sophiamaedler authored Feb 10, 2025
2 parents 5c1fb71 + a1740a1 commit 5352903
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/scportrait/pipeline/featurization.py
Original file line number Diff line number Diff line change
Expand Up @@ -1161,7 +1161,7 @@ def _generate_column_names(
column_names = []

if n_masks == 1:
self.project._check_sdata_status()
self.project.get_project_status()

if self.project.nuc_seg_status:
mask_name = self.MASK_NAMES[0]
Expand Down
2 changes: 1 addition & 1 deletion src/scportrait/pipeline/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -1125,7 +1125,7 @@ def featurize(

# check that prerequisits are fullfilled to featurize cells
assert self.featurization_f is not None, "No featurization method defined."
assert not (
assert (
self.nuc_seg_status or self.cyto_seg_status
), "No nucleus or cytosol segmentation loaded. Please load a segmentation first."
assert self.extraction_status, "No single cell data extracted. Please extract single cell data first."
Expand Down
16 changes: 8 additions & 8 deletions src/scportrait/pipeline/segmentation/workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -1477,15 +1477,15 @@ def cellpose_segmentation(self, input_image):
np.max(input_image) - np.min(input_image)
) # min max normalize to 0-1 range as cellpose expects this

masks, _, _, _ = model.eval(
masks = model.eval(
[input_image],
rescale=self.rescale,
normalize=self.normalize,
diameter=self.diameter,
flow_threshold=self.flow_threshold,
cellprob_threshold=self.cellprob_threshold,
channels=[1, 0],
)
)[0]
masks = np.array(masks) # convert to array

# ensure all edge classes are removed
Expand Down Expand Up @@ -1587,15 +1587,15 @@ def cellpose_segmentation(self, input_image):
np.max(input_image) - np.min(input_image)
) # min max normalize to 0-1 range as cellpose expects this

masks_nucleus, _, _, _ = model.eval(
masks_nucleus = model.eval(
[input_image],
rescale=self.rescale,
normalize=self.normalize,
diameter=self.diameter,
flow_threshold=self.flow_threshold,
cellprob_threshold=self.cellprob_threshold,
channels=[1, 0],
)
)[0]
masks_nucleus = np.array(masks_nucleus) # convert to array

# manually delete model and perform gc to free up memory on GPU
Expand All @@ -1610,15 +1610,15 @@ def cellpose_segmentation(self, input_image):

model = self._load_model(model_type="cytosol", gpu=self.use_GPU, device=self.device)

masks_cytosol, _, _, _ = model.eval(
masks_cytosol = model.eval(
[input_image],
rescale=self.rescale,
normalize=self.normalize,
diameter=self.diameter,
flow_threshold=self.flow_threshold,
cellprob_threshold=self.cellprob_threshold,
channels=[2, 1],
)
)[0]
masks_cytosol = np.array(masks_cytosol) # convert to array

# manually delete model and perform gc to free up memory on GPU
Expand Down Expand Up @@ -1852,15 +1852,15 @@ def cellpose_segmentation(self, input_image):
np.max(input_image) - np.min(input_image)
) # min max normalize to 0-1 range as cellpose expects this

masks_cytosol, _, _, _ = model.eval(
masks_cytosol = model.eval(
[input_image],
rescale=self.rescale,
normalize=self.normalize,
diameter=self.diameter,
flow_threshold=self.flow_threshold,
cellprob_threshold=self.cellprob_threshold,
channels=[2, 1],
)
)[0]
masks_cytosol = np.array(masks_cytosol) # convert to array

# manually delete model and perform gc to free up memory on GPU
Expand Down
2 changes: 2 additions & 0 deletions src/scportrait/pipeline/selection.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ def _setup_selection(self):
except KeyError:
Warning("No name provided for the selection. Will use default name.")
name = "selected_cells"
else:
name = self.name

# create savepath
savename = name.replace(" ", "_") + ".xml"
Expand Down

0 comments on commit 5352903

Please sign in to comment.