nd2reader icon indicating copy to clipboard operation
nd2reader copied to clipboard

Improving metadata: Add X and Y stage coordinates in Metadata.

Open joaomamede opened this issue 4 years ago • 3 comments

Adding this to the code seems to do the trick. *same as z_coordinates"

    def get_parsed_metadata(self):
        """Returns the parsed metadata in dictionary form.

        Returns:
            dict: the parsed metadata
        """

        if self._metadata_parsed is not None:
            return self._metadata_parsed

        frames_per_channel = self._parse_total_images_per_channel()
        self._metadata_parsed = {
            "height": parse_if_not_none(self.image_attributes, self._parse_height),
            "width": parse_if_not_none(self.image_attributes, self._parse_width),
            "date": parse_if_not_none(self.image_text_info, self._parse_date),
            "fields_of_view": self._parse_fields_of_view(),
            "frames": self._parse_frames(),
            "z_levels": self._parse_z_levels(),
            "z_coordinates": parse_if_not_none(self.z_data, self._parse_z_coordinates),
            "x_coordinates":  parse_if_not_none(self.x_data, self._parse_x_coordinates),
            "y_coordinates":  parse_if_not_none(self.y_data, self._parse_y_coordinates),
            "total_images_per_channel": frames_per_channel,
            "channels": self._parse_channels(),
            "pixel_microns": parse_if_not_none(self.image_calibration, self._parse_calibration)
        }

    def _parse_x_coordinates(self):
        """The coordinate in micron for all x.

        Returns:
            list: the x coordinates in micron
        """
        return self.x_data.tolist()

    def _parse_y_coordinates(self):
        """The coordinate in micron for all y.

        Returns:
            list: the y coordinates in micron
        """
        return self.y_data.tolist()
        

Any chance we can add this to the main branch code?

joaomamede avatar Nov 08 '21 04:11 joaomamede

Hi @joaomamede thank you for your contribution! Could you turn it into a pull request? Then I'll look at it in more detail and incorporate it. Thanks!

rbnvrw avatar Nov 08 '21 18:11 rbnvrw

Will try doing it this week. I already had a fork trying to make the "live" version of the reader and surprisingly github doesn't let me do two forks!

joaomamede avatar Nov 08 '21 19:11 joaomamede

Thank you for the PR, awesome!

If you want to work on multiple changes, you can fork once and create multiple branches in your fork, for which you can submit PRs ;-)

rbnvrw avatar Nov 10 '21 19:11 rbnvrw