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

Roi #703

Merged
merged 9 commits into from
Dec 13, 2023
Merged

Roi #703

merged 9 commits into from
Dec 13, 2023

Conversation

bnmajor
Copy link
Collaborator

@bnmajor bnmajor commented Dec 6, 2023

itkwidgets/viewer.py Outdated Show resolved Hide resolved
itkwidgets/viewer.py Outdated Show resolved Hide resolved
x0, x1 = idxs['x']
y0, y1 = idxs['y']
z0, z1 = idxs['z']
return np.index_exp[z0:z1, y0:y1, x0:x1]
Copy link
Member

Choose a reason for hiding this comment

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

very cool!!

@thewtex
Copy link
Member

thewtex commented Dec 7, 2023

loving it!

Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@bnmajor
Copy link
Collaborator Author

bnmajor commented Dec 8, 2023

@thewtex @PaulHax A new example notebook has been added but if there is better data to use (maybe a large dataset that is typically stuck to a lower scale?) I'd be happy to update with a different example. This data was more or less selected at random.

Copy link
Member

thewtex commented Dec 9, 2023

@bnmajor awesome job!

A few requests inline.

This is a good dataset, but another to consider is:

https://data.kitware.com/#item/63476e0911dab81428208e27

for more scales / variety.

1 similar comment
Copy link
Member

thewtex commented Dec 9, 2023

@bnmajor awesome job!

A few requests inline.

This is a good dataset, but another to consider is:

https://data.kitware.com/#item/63476e0911dab81428208e27

for more scales / variety.

@@ -0,0 +1,350 @@
{
Copy link
Member

@thewtex thewtex Dec 9, 2023

Choose a reason for hiding this comment

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

This gif is wicked cool to have embedded in the notebook!! How did you do that? :-D


Reply via ReviewNB

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's just an html image tag in a markdown cell! Updated to use the full URL instead of the relative path though so it may appear broken in the review notebook now until these changes are merged in.

@@ -0,0 +1,350 @@
{
Copy link
Member

@thewtex thewtex Dec 9, 2023

Choose a reason for hiding this comment

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

Line #1.    loaded_scale

Let's make a note, provide a reminder on how the scales, are defined, i.e. "Zero is the highest resolution scale."


Reply via ReviewNB

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sounds good, updated 👍

@@ -0,0 +1,350 @@
{
Copy link
Member

@thewtex thewtex Dec 9, 2023

Choose a reason for hiding this comment

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

Line #1.    roi_region

Let's make a note / provide a reminder that these are in physical, world coordinates.


Reply via ReviewNB

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Got it!

@@ -0,0 +1,350 @@
{
Copy link
Member

@thewtex thewtex Dec 9, 2023

Choose a reason for hiding this comment

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

Line #3.    # Request the highest level explicitly in case that is not what is loaded.

To make the connection clearer, let's use loaded_scale here.


Reply via ReviewNB

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sounds good!

@@ -0,0 +1,350 @@
{
Copy link
Member

@thewtex thewtex Dec 9, 2023

Choose a reason for hiding this comment

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

Line #1.    roi_slice

Let's add another cell for illustration that calls viewer.get_roi_slice() (no argument) that demonstrates we get the same result since that is the current scale.


Reply via ReviewNB

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

Add support for being able to programmatically retrieve information about the
current region of interest.
Copy link
Member

thewtex commented Dec 12, 2023

Awesome!

@@ -0,0 +1,365 @@
{
Copy link
Member

@thewtex thewtex Dec 12, 2023

Choose a reason for hiding this comment

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

Line #2.    print(roi_slices, default_roi_slices)

We could make these two print statements so they are easier to compare.


Reply via ReviewNB

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Got it!

@bnmajor
Copy link
Collaborator Author

bnmajor commented Dec 12, 2023

@thewtex Two last items:

  • I did try the other dataset that you suggested but I did not use it because it appears to be missing spacing information?
    missing_spacing
  • When we grab the ROI for lower scales it seems that we lose the metadata or something... The resulting image is skewed (this does not happen at scale 0):
    skewed_lower_scales

@bnmajor bnmajor marked this pull request as ready for review December 12, 2023 13:45
@thewtex
Copy link
Member

thewtex commented Dec 12, 2023

@bnmajor what is your ngff_zarr.__version__?

@thewtex
Copy link
Member

thewtex commented Dec 12, 2023

Checking this branch out locally, I could not reproduce with ngff-Zarr 0.6.0.

@bnmajor
Copy link
Collaborator Author

bnmajor commented Dec 12, 2023

Checking this branch out locally, I could not reproduce with ngff-Zarr 0.6.0.

I was on 0.4.7... Sorry about that!

EDIT: Actually, still seeing it with 0.6.0...

@thewtex
Copy link
Member

thewtex commented Dec 12, 2023

I seem to recall an older version of itk-vtk-viewer causing this behavior -- is it possible that an old version is used locally?

@thewtex
Copy link
Member

thewtex commented Dec 12, 2023

I tried again with a fresh conda environment and repository checkout, the spacing was correct and consistent across scales.

@bnmajor
Copy link
Collaborator Author

bnmajor commented Dec 12, 2023

I'm not using a local instance of the itk-vtk-viewer and we're currently using the latest release...
skewed_lower_scale

@thewtex
Copy link
Member

thewtex commented Dec 12, 2023

Oh, I was just looking and viewer1 -- I do see that with viewer2 :-)

@thewtex
Copy link
Member

thewtex commented Dec 12, 2023

roi = multiscales.images[loaded_scale].data[roi_slices]

This is extracting only the array and discarding the metadata.

@thewtex
Copy link
Member

thewtex commented Dec 12, 2023

image

with:

# Create a new viewer using only the data in the ROI determined above
loaded_image = multiscales.images[loaded_scale]
roi_data = loaded_image.data[roi_slices]

from ngff_zarr import to_ngff_image

roi_image = to_ngff_image(roi_data, dims=loaded_image.dims, scale=loaded_image.scale, translation={'x': roi_region[0][0], 'y': roi_region[0][1], 'z': roi_region[0][2]})

from ngff_zarr import to_ngff_image
  1. update the notebook according to the above.
  2. could you please update get_roi_region to output a list of dictionaries, 'x', 'y', etc.

?

If we just grab the array we'll drop the metadata and get a skewed result.
@bnmajor
Copy link
Collaborator Author

bnmajor commented Dec 12, 2023

  1. update the notebook according to the above.
  2. could you please update get_roi_region to output a list of dictionaries, 'x', 'y', etc.

?

Updates have been pushed, thank you

@thewtex
Copy link
Member

thewtex commented Dec 13, 2023

Sorry, I was not too clear -- I will push a patch with a minor tweak.

@bnmajor
Copy link
Collaborator Author

bnmajor commented Dec 13, 2023

Sorry, I was not too clear -- I will push a patch with a minor tweak.

I see, sorry about my misunderstanding! Thanks for the fix!

@bnmajor
Copy link
Collaborator Author

bnmajor commented Dec 13, 2023

@thewtex This is good to go from my end if everything is looking good for you as well

@thewtex thewtex merged commit ec9b018 into InsightSoftwareConsortium:main Dec 13, 2023
5 checks passed
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.

2 participants