Visualizing slice of nifti image

487 views
Skip to first unread message

Robert L Cloud

unread,
Jul 25, 2011, 3:55:07 PM7/25/11
to NiPy Users
Hey, I'm a doctoral student and just started working in a neuroimaging
lab. I'm building a python application for the analysis of some
scans, and I would like there to be a part of the window to view
slices of the scan. I'm using wxPython and the Enthought python
distribution. I can successfully load in the nifti images, and I can
access the data, but I'm a bit unsure about how to display it as an
image. I just want a 2d representation of a slice. Any suggestions
would be very helpful.

Thanks,
Robert Cloud

Gael Varoquaux

unread,
Jul 25, 2011, 4:06:55 PM7/25/11
to nipy...@googlegroups.com

If you just want non interactive visualization, have a look at:
http://nipy.sourceforge.net/nipy/stable/neurospin/viz.html
The documentation is a bit old, so just replace 'neurospin' by 'labs'
everywhere, as we have changed the import paths.

If you cannot depend on nipy, which is not released yet, just look at the
source code of the corresponding function to find some inspiration.

If you want interactive displays in 2D, I am afraid but I think that we
do not have anything handy.

HTH,

Ga�l

Robert L Cloud

unread,
Jul 25, 2011, 7:28:11 PM7/25/11
to NiPy Users
Strangely enough, in nipy 0.1.2.dev(gotten through git) there is no
nipy.labs available
I browse the sources and find the directory there, but it was not
apparently installed.

Any suggestions?

Secondly, perhaps I could interact with the slices by creating a
matplotlib window in my application?
Does anyone have experience with matplotlib and neuroimaging?
Any other recommendations?

Thanks
On Jul 25, 3:06 pm, Gael Varoquaux <gael.varoqu...@normalesup.org>
wrote:

Yaroslav Halchenko

unread,
Jul 25, 2011, 7:36:40 PM7/25/11
to NiPy Users
hm, that one installs for me just fine:

$> ls install/lib/python2.6/site-packages/nipy/labs
__init__.py bindings/ glm/ mask.py setup.py spatial_models/ statistical_mapping.pyc utils/ viz.pyc viz3d.pyc
__init__.pyc datasets/ group/ mask.pyc setup.pyc statistical_mapping.py tests/ viz.py viz3d.py viz_tools

what git snapshot your are using? (output of git describe should suffice)
how do you install it?

are you running any Debian-based distribution? (then just add
http://neuro.debian.net/ repository and sudo apt-get install python-nipy)

> Does anyone have experience with matplotlib and neuroimaging?

Well... quite a broad question ;-) probably nearly everyone on this list
has experience with neuroimaging and I bet everyone has experience with
matplotlib ;-)

On Mon, 25 Jul 2011, Robert L Cloud wrote:

> Strangely enough, in nipy 0.1.2.dev(gotten through git) there is no
> nipy.labs available
> I browse the sources and find the directory there, but it was not
> apparently installed.

> Any suggestions?

> Secondly, perhaps I could interact with the slices by creating a
> matplotlib window in my application?
> Does anyone have experience with matplotlib and neuroimaging?
> Any other recommendations?

--
=------------------------------------------------------------------=
Keep in touch www.onerussian.com
Yaroslav Halchenko www.ohloh.net/accounts/yarikoptic

Robert L Cloud

unread,
Jul 25, 2011, 7:45:50 PM7/25/11
to NiPy Users
Strange, I also have

ls /home/rcloud/epd-7.1-1-rh5-x86_64/lib/python2.7/site-packages/nipy/
labs/
bindings group mask.py setup.pyc
statistical_mapping.pyc viz3d.py viz.pyc
datasets __init__.py mask.pyc spatial_models
tests viz3d.pyc viz_tools
glm __init__.pyc setup.py statistical_mapping.py
utils viz.py


it wasn't showing up in tab completion of nipy so I thought I didn't
have it.
I'm still rather a novice to python, so forgive any idiocy.

however labs.viz is not working:

In [1]: import nipy

In [2]: import nipy.labs

In [3]: nipy.labs.viz
---------------------------------------------------------------------------
AttributeError Traceback (most recent call
last)
/home/rcloud/<ipython-input-3-24d4250e1784> in <module>()
----> 1 nipy.labs.viz

AttributeError: 'module' object has no attribute 'viz'

and I can't get past that.

Thanks for the replies.

Robert



On Jul 25, 6:36 pm, Yaroslav Halchenko <yarikop...@gmail.com> wrote:
> hm, that one installs for me just fine:
>
> $> ls install/lib/python2.6/site-packages/nipy/labs
> __init__.py   bindings/  glm/    mask.py   setup.py   spatial_models/         statistical_mapping.pyc  utils/  viz.pyc   viz3d.pyc
> __init__.pyc  datasets/  group/  mask.pyc  setup.pyc  statistical_mapping.py  tests/                   viz.py  viz3d.py  viz_tools
>
> what git snapshot your are using? (output of git describe should suffice)
> how do you install it?
>
> are you running any Debian-based distribution? (then just addhttp://neuro.debian.net/repository and sudo apt-get install python-nipy)

Yaroslav Halchenko

unread,
Jul 25, 2011, 9:11:34 PM7/25/11
to NiPy Users
depending on developers view of things, in Python

import module

doesn't necessarily imports all submodules, e.g. module.submodule1 etc

so in this case you just need

import nipy.labs.viz

explicitly if you want to use it

On Mon, 25 Jul 2011, Robert L Cloud wrote:

> In [3]: nipy.labs.viz
> ---------------------------------------------------------------------------
> AttributeError Traceback (most recent call
> last)
> /home/rcloud/<ipython-input-3-24d4250e1784> in <module>()
> ----> 1 nipy.labs.viz

> AttributeError: 'module' object has no attribute 'viz'

> and I can't get past that.

> Thanks for the replies.

> Robert

Reply all
Reply to author
Forward
0 new messages