In [1]:
import irtk
patient_id = '2159'
img = irtk.imread( patient_id + "_img.nii.gz" )
seg = irtk.imread( patient_id + "_seg.nii.gz" )
In [2]:
from IPython.html.widgets import interact, interactive, fixed
from IPython.html import widgets
from IPython.display import display
def f(z,y,x):
display( irtk.imshow(img,seg,index=(z,y,x)) )
interact( f,
z=widgets.IntSliderWidget(min=0,max=img.shape[0]-1,step=1,value=img.shape[0]/2),
y=widgets.IntSliderWidget(min=0,max=img.shape[1]-1,step=1,value=img.shape[1]/2),
x=widgets.IntSliderWidget(min=0,max=img.shape[2]-1,step=1,value=img.shape[2]/2) )
The sliders disappear when the notebook is saved as HTML, here are some hints for preserving the interactivity through JavaScript (though this is probably not the best approach for an image viewer).
Ideally, a medical image viewer integrated within the IPython notebook would use XTK, but there is still works to be done before it provides a working solution, see github/fperez and github/richstoner for proofs of concept.
The example notebooks of SimpleITK use the same interact function to browse the Z dimension of 3d volumes and render the image using matplotlib:
ReplyDeletehttps://github.com/SimpleITK/SimpleITK-Notebooks/blob/master/myshow.py
Thanks for this post. I get "TypeError: imshow() got an unexpected keyword argument 'index'" and when referring to the irk documentation it seems that there no argument as index. Could you please clarify?
ReplyDeleteHi Arman,
ReplyDeleteSorry for the delay in replying to your post.
As explained in the following email:
http://mailman.ic.ac.uk/pipermail/doc-biomedic-irtk/2015-February/000008.html
you can now install python-irtk on Linux through conda.
Alternatively, you can browse the latest version of the code on github. The answer to your question is thus:
https://github.com/BioMedIA/python-irtk/blob/master/irtk/image.py#L1122
Please note that at present, you cannot compile the code of the python-irtk module using the IRTK code which is on github. Hopefully, this will be fixed in the future.
Kind regards,
Kevin
Your positivity shines through thank you. This profile has more great insights Emotional Intelligence Test, including a section on the Emotional Intelligence Test for self-awareness.
ReplyDelete