nd2reader
nd2reader copied to clipboard
Plotting ROI's from nd2 files
Hi!
Im trying to extract from ROI metadata from the nd2 files which i kind of drew like this.
And after extracting the ROI metadata the output is in a format im not familiar with.
Is there a way to plot the ROI so that it preserves the overall shape and position? Thanks for the help??
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.
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
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..."
@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