[pymvpa] pynifti ref-count bugs?

Gael Varoquaux gael.varoquaux at normalesup.org
Wed Oct 8 09:26:43 UTC 2008


On Wed, Oct 08, 2008 at 11:14:14AM +0200, Michael Hanke wrote:
> Nah, that is fine. I usually refer people to

> pkg-exppsy-pymvpa at lists.alioth.debian.org

> which is not just for pynifti, but a place with a public archive and
> usually preferable to private emails (in the long run) ;-)

OK, I sw that and wondered....

> The file should be correct, but the way you access the array causes
> trouble. getDataArray() simply returns a pointer to the data allocated
> by the nifti library. As you do not store the nifti image itself, that
> data is destroyed immediately, hence segfault when accessing it.

Ha, OK. It did seem that the data was being derefenced, but it wasn't
clear to me that this was the expected behavior.

> Just replace getDataArray() (or simply .data) with asarray(), which has
> a parameter 'copy' that is True by default.

Why is the copy necessary? It seems that this should simply be a refcount
increment, rather than the copy. Travis Oliphant has a nice blog post on
a cool way to do this:
http://blog.enthought.com/?p=62

If you do this, than you can encourage people not to use the data
pointer, which is imho fairly dangerous.

I think getDataArray should be renamed to getDataPointer because this is
really a trap :). Obviously that will break everybodys code, so you can
force them to move to using asarray :). OK, this is not a way to treate
users.

> > I am running a git latest version of pynifti. As far as I can tell, I am
> > running a 1.1.0 version of nifticlib (I can't find an obvious indication
> > of the version number, but the last entry in the Updates.txt is 1.1.0),
> > compiled from source. The system is a Mandriva (I don't have an option,
> > there :( ).
> I recently started compiling RPM packages with the OpenSUSE build
> service. I am a total novice to RPM, but I also have them for Mandriva
> 2007 and 2008 -- including packages for nifticlibs. I'd be glad, if you
> could try them and tell me if they work

> http://download.opensuse.org/repositories/home:/hankem/

> or

> http://software.opensuse.org/search?baseproject=Mandriva%3A2008&p=1&q=python-nifti

Nice, very useful. You should point this out to Lev Givon who is doing a
phD in neuro-sciences, uses scipy a lot, and is a Mandriva packager.

It unfortunately doesn't solve my instal problems, because we can't
deploy packages on the machines here, we need to build them on an NFS
drive (yes, we have some infrastructure problems, but we don't control
them).

Thanks,

Gaël



More information about the Pkg-ExpPsy-PyMVPA mailing list