Skip to content

add loaders#9

Open
MikeLippincott wants to merge 2 commits intoWayScience:mainfrom
MikeLippincott:loaders
Open

add loaders#9
MikeLippincott wants to merge 2 commits intoWayScience:mainfrom
MikeLippincott:loaders

Conversation

@MikeLippincott
Copy link
Copy Markdown
Member

Description

This PR adds the loaders needed for ZedProfiler's featurization process

What kind of change(s) are included?

  • Documentation (changes docs or other related content)
  • Bug fix (fixes an issue).
  • Enhancement (adds functionality).
  • Breaking change (these changes would cause existing functionality to not work as expected).

Checklist

Please ensure that all boxes are checked before indicating that this pull request is ready for review.

  • I have read and followed the CONTRIBUTING.md guidelines.
  • I have searched for existing content to ensure this is not a duplicate.
  • I have performed a self-review of these additions (including spelling, grammar, and related).
  • These changes pass all pre-commit checks.
  • I have added comments to my code to help provide understanding
  • I have added a test which covers the code changes found within this PR
  • I have deleted all non-relevant text in this pull request template.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Comment thread src/zedprofiler/IO/__init__.py Outdated
Comment thread src/zedprofiler/IO/feature_writing_utils.py
Comment thread src/zedprofiler/IO/feature_writing_utils.py
Comment thread src/zedprofiler/IO/feature_writing_utils.py
Comment thread src/zedprofiler/IO/feature_writing_utils.py
Comment thread src/zedprofiler/IO/loading_classes.py Outdated
Comment thread src/zedprofiler/IO/loading_classes.py Outdated
Comment thread src/zedprofiler/IO/loading_classes.py Outdated
Comment thread tests/IO/feature_writing_utils_test.py Outdated
Comment thread src/zedprofiler/IO/loading_classes.py Outdated
@MikeLippincott MikeLippincott requested a review from d33bs April 27, 2026 22:57
Copy link
Copy Markdown
Member

@d33bs d33bs left a comment

Choose a reason for hiding this comment

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

Great job - thanks for addressing the changes! I feel this LGTM.

def _coerce_dataframe_column_names_to_strings(
dataframe: pandas.DataFrame,
) -> pandas.DataFrame:
"""Ensure DataFrame column labels are string-typed before writing."""
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

For this and other functions consider documenting all parameters and return types.

Comment on lines +45 to +61
FEATURE_OUTPUT_SCHEMA = pa.DataFrameSchema(
columns={},
strict=False,
parsers=[pa.Parser(_coerce_dataframe_column_names_to_strings)],
)


FEATURE_NAME_COMPONENT_SCHEMA = pa.DataFrameSchema(
columns={
"compartment": pa.Column(object, nullable=False, coerce=True),
"channel": pa.Column(object, nullable=False, coerce=True),
"feature_type": pa.Column(object, nullable=False, coerce=True),
"measurement": pa.Column(object, nullable=False, coerce=True),
},
strict=True,
parsers=[pa.Parser(_coerce_feature_name_components)],
)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Consider moving all globals to the top of the module.

return string


@beartype
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

🐾 !

numpy.ndarray
Image returned
"""
image = bioio.BioImage(str(image_path)) # selects the first scene found
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Instead of relying on this thin function could you rely on the bioio method directly where needed? This might save you the strain of needing to maintain this.

Image returned
"""
image = bioio.BioImage(str(image_path)) # selects the first scene found
return image.get_image_data("ZYX")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should this be configurable in terms of dimensions where applied?

Comment thread src/zedprofiler/IO/loading_classes.py
"""Test creating FeatureMetadata instance."""
metadata = FeatureMetadata(
compartment="nucleus",
@pytest.mark.parametrize(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

🙌

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.

3 participants