Giter VIP home page Giter VIP logo

Comments (10)

haesleinhuepf avatar haesleinhuepf commented on July 29, 2024 1

It's fun cropping a dataset like this!

crop.mp4

from stackview.

haesleinhuepf avatar haesleinhuepf commented on July 29, 2024

Hey @paxcalpt ,

great idea! Could you try out the very basic prototype in this notebook? I'm wondering if it works as expected.

image

If not, a PR on this notebook is very welcome!

also get those values?

You mean, like asking widget.get_start_x() or similar?

from stackview.

paxcalpt avatar paxcalpt commented on July 29, 2024

Beautiful!! Exactly what I needed.
As always, thank you for the lightening fast reply Robert

from stackview.

paxcalpt avatar paxcalpt commented on July 29, 2024

Hit a possible bug, will check if it might be on my side...

Running code:

from ipywidgets import IntSlider
import stackview

print(dataset.shape, dataset.dtype)

def crop(image, min_z:int, max_z:int, min_y:int, max_y:int, min_x:int, max_x:int):
    try:
        return image[min_z:max_z,min_y:max_y,min_x:max_x]
    except:
        return image

stackview.interact(crop,
                   dataset,
                   min_z=IntSlider(value=0, min=0, max=dataset.shape[0]-1),
                   max_z=IntSlider(value=dataset.shape[0]-1, min=0, max=dataset.shape[0]-1),
                   min_y=IntSlider(value=0, min=0, max=dataset.shape[1]-1),
                   max_y=IntSlider(value=dataset.shape[1]-1, min=0, max=dataset.shape[1]-1),
                   min_x=IntSlider(value=0, min=0, max=dataset.shape[2]),
                   max_x=IntSlider(value=dataset.shape[2]-1, min=0, max=dataset.shape[2]-1),
                  )

Output:

(500, 128, 128) uint16


TypeError Traceback (most recent call last)
File ~/Documents/Code/NanoPyx/.venv/lib/python3.10/site-packages/traitlets/traitlets.py:2395, in CInt.validate(self, obj, value)
2394 try:
-> 2395 value = int(value)
2396 except Exception:

TypeError: int() argument must be a string, a bytes-like object or a real number, not 'NoneType'

During handling of the above exception, another exception occurred:

TraitError Traceback (most recent call last)
Cell In[15], line 12
9 except:
10 return image
---> 12 stackview.interact(crop,
13 dataset,
14 min_z=IntSlider(value=0, min=0, max=dataset.shape[0]-1),
15 max_z=IntSlider(value=dataset.shape[0]-1, min=0, max=dataset.shape[0]-1),
16 min_y=IntSlider(value=0, min=0, max=dataset.shape[1]-1),
17 max_y=IntSlider(value=dataset.shape[1]-1, min=0, max=dataset.shape[1]-1),
18 min_x=IntSlider(value=0, min=0, max=dataset.shape[2]),
19 max_x=IntSlider(value=dataset.shape[2]-1, min=0, max=dataset.shape[2]-1),
20 )
23 # stackview.slice(dataset, continuous_update=True, zoom_factor=2, zoom_spline_order=0)
...
842 describe("the", value),
843 )
--> 844 raise TraitError(e)

TraitError: The 'step' trait of an IntText instance expected an int, not the NoneType None.

from stackview.

paxcalpt avatar paxcalpt commented on July 29, 2024

Confirmed to work =)... previous issue was solved by updating the package

image

from stackview.

haesleinhuepf avatar haesleinhuepf commented on July 29, 2024

Wait. We just played with the prototype ;-) This will now be refactored to be useful also for others ;-)

from stackview.

paxcalpt avatar paxcalpt commented on July 29, 2024

from stackview.

haesleinhuepf avatar haesleinhuepf commented on July 29, 2024

Alright, @paxcalpt, if you have some time for testing another prototype, please install

pip install stackview==0.5.1

It will come with a new crop function that looks like this:

crop2.mp4

I also updated the demo notebook. I would like to know from you if the capabilities for reading the range and/or cropping the image fulfills your use-case. Let me know if that works for you.

Btw. I was thinking of this crop widget earlier and wasn't sure how it should look like. Thus, thanks for the input! That was fun! 🌞

from stackview.

paxcalpt avatar paxcalpt commented on July 29, 2024

It's working perfectly! Bonus points for being VSCode rendering compatible

image

from stackview.

haesleinhuepf avatar haesleinhuepf commented on July 29, 2024

Awesome. Thanks again for triggering creative activities! 🥂

from stackview.

Related Issues (15)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.