Skip to content

Plotting ROI's from nd2 files #47

Description

@ninning

Hi!

Im trying to extract from ROI metadata from the nd2 files which i kind of drew like this.

Screen Shot 2021-02-22 at 6 05 00 PM

And after extracting the ROI metadata the output is in a format im not familiar with.

Screen Shot 2021-02-22 at 6 10 59 PM

Is there a way to plot the ROI so that it preserves the overall shape and position? Thanks for the help??

Activity

  1. rbnvrw commented on Mar 15, 2021

    @rbnvrw
    Member

    Thank you for your report @ninning! If this shape is stored in the ND2 file, there should of course be some way to implement this. I think that currently, only circular or rectangular ROIs are parsed correctly. This would be a nice improvement but I don't have the time myself to implement it. Of course PRs are very welcome.

  2. kkrucki commented on Jan 12, 2023

    @kkrucki

    Was there ever a fix added for this? I tried extracting the x,y values myself but am unsure on the conversion factor from m_vectBasePoints to image pixel units

  3. ninning commented on Jan 12, 2023

    @ninning
    Author

    Was there ever a fix added for this? I tried extracting the x,y values myself but am unsure on the conversion factor from m_vectBasePoints to image pixel units

    I dont think so, I just ended up saving the ROI's as a separate binary .tif file with the Nikon software. If you re-load your .nd2 file on the Nikon elements software that you used to take the image, there should be a option to "Save ROI's as..."

  4. kkrucki commented on Jan 13, 2023

    @kkrucki

    @rbnvrw @ninning if you add something like the following lines of code to _parse_vect_anim in raw_metadata.py then it will extract the shape in pixels

     x_dict = []
            y_dict = []
            f = animation_dict[six.b('m_sExtrudedShape')]
            for i in range(f[six.b('m_vectBasePoints_Size')]):
                x = f[six.b('m_vectBasePoints_%d' % i)][six.b('x')]
                x = 0.5 *(1+x+animation_dict[six.b('m_dCenterX')]) *self._metadata_parsed["width"]
                x_dict.append(x)
                y = f[six.b('m_vectBasePoints_%d' % i)][six.b('y')]
                y = 0.5  * (1+y+animation_dict[six.b('m_dCenterY')]) *self._metadata_parsed["height"]
                y_dict.append(y)            
            roi_dict["x"] = x_dict
            roi_dict["y"] = y_dict
            return `roi_dict`
    

    I am not the best or most efficient python coder so if you want to add this in a better format by all means add it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions