Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ingestion of segmentation masks #15

Merged
merged 6 commits into from
Feb 23, 2024
Merged

Conversation

uermel
Copy link
Contributor

@uermel uermel commented Feb 23, 2024

Fixing chanzuckerberg/cryoet-data-portal#502

  1. The labels in segmentation masks were not correctly separated because pyramid_to_mrc in common/image.py took the original data, not the one from the pyramid (only the pyramid data is processed)

  2. AnnotationSource classes in importers/annotation.py expected the keyword argument is_viz_default, but the YAML dict has is_visualization_default

  3. Import of Point annotations failed due to faulty indenting in Point.load in importers/annotation.py

  4. Voxel spacing of the ingested segmentation masks was not correct, because scale_maskfile in common/image.py was not yet using the new override mechanism for the voxel_spacing (the correct voxel_spacing was actually passed inside AnnotationImporter.import_annotations, but not taken into account in the SemanticSegmentationMaskFile.convert method.

…, as this is the point where the labels are split.
- is_viz_default -> is_visualization_default to be conformant with yaml name

- indent correctly for context manager
@uermel uermel requested a review from manasaV3 February 23, 2024 01:20
@@ -71,7 +71,7 @@ def pyramid_to_mrc(
mrcfiles.append(os.path.basename(filename))

if write:
newfile = mrcfile.new(filename, self.data, overwrite=True)
newfile = mrcfile.new(filename, pyramid[0], overwrite=True)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using the processed mask data instead of original data.

Comment on lines +173 to +182
if skip_header:
next(points)
for coord in points:
annotation_set.append(
self.point(
float(coord[coord_order[0]]),
float(coord[coord_order[1]]),
float(coord[coord_order[2]]),
),
)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix indentation so the file is actually open.

@@ -120,7 +120,8 @@ def __init__(

def convert(self, fs: FileSystemApi, input_prefix: str, output_prefix: str, voxel_spacing: float = None):
input_file = self.get_source_file(fs, input_prefix)
return scale_maskfile(fs, self.get_output_filename(output_prefix), input_file, self.label, write=True)
return scale_maskfile(fs, self.get_output_filename(output_prefix), input_file, self.label, write=True,
voxel_spacing=voxel_spacing)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add voxel_spacing override for segmentation masks.

):
self.glob_string = glob_string.format(**glob_vars)
self.file_format = file_format
self.shape = shape
self.is_viz_default = is_viz_default
self.is_viz_default = is_visualization_default
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we also rename the class variable to is_visualization_default for consistency?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done with the last commit.

Copy link
Contributor

@manasaV3 manasaV3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@uermel uermel merged commit 5f48715 into main Feb 23, 2024
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants