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

[feature] : Convert img_path to Path object when loading .topostats files #106

Closed
ns-rse opened this issue Jan 29, 2025 · 0 comments · Fixed by #108
Closed

[feature] : Convert img_path to Path object when loading .topostats files #106

ns-rse opened this issue Jan 29, 2025 · 0 comments · Fixed by #108
Assignees
Labels
enhancement New feature or request v0.1.0

Comments

@ns-rse
Copy link
Collaborator

ns-rse commented Jan 29, 2025

Is your feature request related to a problem?

In TopoStats #1082 we pull the data out of the returned tuple and build a dictionary with filename as key and the returned data as a topostats_object.

This required converting img_path which is part of the returned dictionary to Path() so that it is handled correctly (this is the expected type when processing end-to-end). See line 802 of io.py in the linked pull request.

Describe the solution you would like.

AFMReader should ensure the img_path field of the loaded dictionary is of type Path before returning the data.

We should add a line to AFMReader.topostats.load_topostats() to convert this field.

    try:
        with h5py.File(file_path, "r") as f:
            data = unpack_hdf5(open_hdf5_file=f, group_path="/")

            data["img_path"] = Path(data["img_path"])  # Convert img_path
            file_version = data["topostats_file_version"]
            logger.info(f"[{filename}] TopoStats file version : {file_version}")
            image = data["image"]
            pixel_to_nm_scaling = data["pixel_to_nm_scaling"]

Describe the alternatives you have considered.

Leave conversion in TopoStats and users to convert if required. 🤷

Sample Image

N/A

Additional context

No response

@ns-rse ns-rse added enhancement New feature or request v0.1.0 labels Jan 29, 2025
@ns-rse ns-rse self-assigned this Jan 29, 2025
ns-rse added a commit that referenced this issue Jan 29, 2025
Closes #106

Ensures that if fileversion >= 0.2 is being loaded that the `data["img_path"]` variable is of type `Path`.

Adds to the test suite a 0.2 sample file to check this (and expands on the keys of the dictionary).
@ns-rse ns-rse closed this as completed in 0135ec9 Jan 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request v0.1.0
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant