pycortex
pycortex copied to clipboard
problem in lanczos sampler
I try to produce a flatmap with Lanczos sampling:
cortex.quickflat.make_png('test.png', cortex.Volume(data=np.random.rand(32,100,100), subject=subject, xfmname=xfmname), sampler='lanczos')
Pycortex creates a pool of 48 processes and it never ends processing. I kill it by keyboard interrupt. The following is the traceback I get:
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
~/Projs/bilPype/venv/lib/python3.5/site-packages/cortex/mp.py in map(func, iterable, procs)
41 try:
---> 42 progress = pb.ProgressBar(widgets=[pb.Percentage(), pb.Bar()], maxval=iterlen)
43 progress.start()
NameError: name 'pb' is not defined
During handling of the above exception, another exception occurred:
KeyboardInterrupt Traceback (most recent call last)
<ipython-input-84-6ed4544576a7> in <module>()
4 mask='thick',
5 vmax = 200),
----> 6 sampler='lanczos')
~/Projs/bilPype/venv/lib/python3.5/site-packages/cortex/quickflat/view.py in make_png(fname, braindata, recache, pixelwise, sampler, height, bgcolor, dpi, **kwargs)
257 sampler=sampler,
258 height=height,
--> 259 **kwargs)
260
261 imsize = fig.get_axes()[0].get_images()[0].get_size()
~/Projs/bilPype/venv/lib/python3.5/site-packages/cortex/quickflat/view.py in make_figure(braindata, recache, pixelwise, thick, sampler, height, dpi, depth, with_rois, with_sulci, with_labels, with_colorbar, with_borders, with_dropout, with_curvature, extra_disp, with_connected_vertices, linewidth, linecolor, roifill, shadow, labelsize, labelcolor, cutout, curvature_brightness, curvature_contrast, curvature_threshold, fig, extra_hatch, colorbar_ticks, colorbar_location, roi_list, **kwargs)
103 # Add data
104 data_im, extents = composite.add_data(fig, dataview, pixelwise=pixelwise, thick=thick, sampler=sampler,
--> 105 height=height, depth=depth, recache=recache)
106
107 layers = dict(data=data_im)
~/Projs/bilPype/venv/lib/python3.5/site-packages/cortex/quickflat/composite.py in add_data(fig, braindata, height, thick, depth, pixelwise, sampler, recache)
162 # Generate image (2D array, maybe 3D array)
163 im, extents = make_flatmap_image(dataview, recache=recache, pixelwise=pixelwise, sampler=sampler,
--> 164 height=height, thick=thick, depth=depth)
165 # Check whether dataview has a cmap instance
166 cmapdict = _has_cmap(dataview)
~/Projs/bilPype/venv/lib/python3.5/site-packages/cortex/quickflat/utils.py in make_flatmap_image(braindata, height, recache, **kwargs)
57 height=height,
58 recache=recache,
---> 59 **kwargs)
60 if isinstance(braindata, dataset.Volume2D):
61 data = braindata.raw.volume
~/Projs/bilPype/venv/lib/python3.5/site-packages/cortex/quickflat/utils.py in get_flatcache(subject, xfmname, pixelwise, thick, sampler, recache, height, depth)
141 print("Generating a flatmap cache")
142 if pixelwise and xfmname is not None:
--> 143 pixmap = _make_pixel_cache(subject, xfmname, height=height, sampler=sampler, thick=thick, depth=depth)
144 else:
145 pixmap = _make_vertex_cache(subject, height=height)
~/Projs/bilPype/venv/lib/python3.5/site-packages/cortex/quickflat/utils.py in _make_pixel_cache(subject, xfmname, height, thick, depth, sampler)
395
396 for t in np.linspace(0, 1, thick+2)[1:-1]:
--> 397 i, j, data = sampclass(piacoords[valid]*t + wmcoords[valid]*(1-t), xfm.shape)
398 mapper = mapper + sparse.csr_matrix((data / float(thick), (vidx[i], j)),
399 shape=mapper.shape)
~/Projs/bilPype/venv/lib/python3.5/site-packages/cortex/mapper/samplers.py in lanczos(coords, shape, window, **kwargs)
97 return out
98
---> 99 return distance_func(lanczos, coords, shape, **kwargs)
~/Projs/bilPype/venv/lib/python3.5/site-packages/cortex/mapper/samplers.py in distance_func(func, coords, shape, renorm, mp)
76 if mp:
77 from .. import mp
---> 78 ijdata = mp.map(func, range(len(coords)))
79 else:
80 #ijdata = map(func, range(len(coords)))
~/Projs/bilPype/venv/lib/python3.5/site-packages/cortex/mp.py in map(func, iterable, procs)
49 except NameError:
50 for _ in range(iterlen):
---> 51 idx, result = output.get()
52 data[idx] = result
53
/usr/local/lib/python3.5/multiprocessing/queues.py in get(self, block, timeout)
92 if block and timeout is None:
93 with self._rlock:
---> 94 res = self._recv_bytes()
95 self._sem.release()
96 else:
/usr/local/lib/python3.5/multiprocessing/connection.py in recv_bytes(self, maxlength)
214 if maxlength is not None and maxlength < 0:
215 raise ValueError("negative maxlength")
--> 216 buf = self._recv_bytes(maxlength)
217 if buf is None:
218 self._bad_message_length()
/usr/local/lib/python3.5/multiprocessing/connection.py in _recv_bytes(self, maxsize)
405
406 def _recv_bytes(self, maxsize=None):
--> 407 buf = self._recv(4)
408 size, = struct.unpack("!i", buf.getvalue())
409 if maxsize is not None and size > maxsize:
/usr/local/lib/python3.5/multiprocessing/connection.py in _recv(self, size, read)
377 remaining = size
378 while remaining > 0:
--> 379 chunk = read(handle, remaining)
380 n = len(chunk)
381 if n == 0:
I suspect it enters an infinite recursion but I cannot figure out how and where.