Hi, On Wed, Oct 08, 2008 at 11:26:43AM +0200, Gael Varoquaux wrote: > On Wed, Oct 08, 2008 at 11:14:14AM +0200, Michael Hanke wrote: > > 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 Good pointer! I guess the reason why it is not implemented like this is that the blog post is dated "September 9th, 2008" ;-)
> 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. This is the main reason why I kept it like this. This piece stems from a time where I had pynifti as my private puppet. It has still been like this when I first released it and since then users require something they call "backward-compatibility". ;-) This is also the reason for the class representing the nifti header being the parent for the NiftiImage class and not just a member of it ... > > > 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. Please do! If someone who actually knows how RPMs are supposed to work would take a look at them -- that would be great. If he has an OpenSUSE account (or gets one) he could tweak the stuff on his own (if necessary) -- it is all public. > 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). :( Michael -- GPG key: 1024D/3144BE0F Michael Hanke http://apsy.gse.uni-magdeburg.de/hanke ICQ: 48230050 _______________________________________________ Pkg-ExpPsy-PyMVPA mailing list [email protected] http://lists.alioth.debian.org/mailman/listinfo/pkg-exppsy-pymvpa

