#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    13
    Rep Power
    0

    Multithreading and scipy arrays


    Hello all,

    I am fairly new to python and have been using it recently for scientific computing especially really liking the scipy and numpy libraries.

    One thing I do quite often is resample n-dimensional data on a uniform grid using scipy's ndimage map_coordinates method. An example usage of this method is:

    Code:
    ndimage.map_coordinates(input_3D_image, input_deformation_grid, output_3D_image, order=self.order, prefilter=False)
    So here I resample the input 3D data on the specified input grid and the interpolated result is written to the output_3D_image variable.

    Now, in theory each pixel/voxel can be processed independently and I am wondering what would be the right way to make this operation parallel.

    Any suggestions would be greatly appreciated.

    Thanks,
    Luca
  2. #2
  3. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,886
    Rep Power
    481
    I suppose you'd use the threading module with inputs to a function of

    n = input_deformation_grid.shape[0]
    m = n/NUMBER_OF_THREADS

    input_deformation_grid.shape[m*i:(m+1)*i]

    then reassemble the output with numpy.concatenate
    [code]Code tags[/code] are essential for python code and Makefiles!

IMN logo majestic logo threadwatch logo seochat tools logo