Re: [Numpy-discussion] Loading large NIfTI file - MemoryError
Hi, On Tue, Dec 31, 2013 at 1:29 PM, Julian Taylor jtaylor.deb...@googlemail.com wrote: On 31.12.2013 14:13, Amira Chekir wrote: Hello together, I try to load a (large) NIfTI file (DMRI from Human Connectome Project, about 1 GB) with NiBabel. import nibabel as nib img = nib.load(dmri.nii.gz) data = img.get_data() The program crashes during img.get_data() with an MemoryError (having 4 GB of RAM in my machine). Any suggestions? are you using a 64 bit operating system? which version of numpy? I think you want the nipy-devel mailing list for this question : http://nipy.org/nibabel/ I'm guessing that the reader is loading the raw data which is - say - int16 - and then multiplying by the scale factors to make a float64 image, which is 4 times larger. We're working on an iterative load API at the moment that might help loading the image slice by slice : https://github.com/nipy/nibabel/pull/211 It should be merged in a week or so - but it would be very helpful if you would try out the proposal to see if it helps, Best, Matthew ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
[Numpy-discussion] Padding An Array Along A Single Axis
Hi all, This should be an easy one but I can not come up with a good solution. Given an ndarray with a shape of (..., X) I wish to zero-pad it to have a shape of (..., X + K), presumably obtaining a new array in the process. My best solution this far is to use np.zeros(curr.shape[:-1] + (curr.shape[-1] + K,)) followed by an assignment. However, this seems needlessly cumbersome. I looked at np.pad but it does not seem to provide a means of just padding a single axis easily. Regards, Freddie. signature.asc Description: OpenPGP digital signature ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Padding An Array Along A Single Axis
You can use np.pad for this: In [1]: import numpy as np In [2]: x = np.ones((3, 3)) In [3]: np.pad(x, [(0, 0), (0, 1)], mode='constant') Out[3]: array([[ 1., 1., 1., 0.], [ 1., 1., 1., 0.], [ 1., 1., 1., 0.]]) Each item of the pad_width (second) argument is a tuple of before, after for each axis. I've only padded the end of the last axis, but if you wanted to pad both sides of it: In [4]: np.pad(x, [(0, 0), (1, 1)], mode='constant') Out[4]: array([[ 0., 1., 1., 1., 0.], [ 0., 1., 1., 1., 0.], [ 0., 1., 1., 1., 0.]]) Hope that helps, -Joe On Fri, Jan 3, 2014 at 6:58 AM, Freddie Witherden fred...@witherden.orgwrote: Hi all, This should be an easy one but I can not come up with a good solution. Given an ndarray with a shape of (..., X) I wish to zero-pad it to have a shape of (..., X + K), presumably obtaining a new array in the process. My best solution this far is to use np.zeros(curr.shape[:-1] + (curr.shape[-1] + K,)) followed by an assignment. However, this seems needlessly cumbersome. I looked at np.pad but it does not seem to provide a means of just padding a single axis easily. Regards, Freddie. ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Quaternion type @ rosettacode.org
Thanks Anthony and Paul! OlyDLG ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion