Skip to content

problem with notebook: Demo: Denoising of 2D cell images #85

@mocherry23

Description

@mocherry23

Dear all,
when trying to run the above notebook, cell 5
from csbdeep.data import no_background_patches, norm_percentiles, sample_percentiles

X, Y, XY_axes = create_patches (
raw_data = raw_data,
patch_size = (128,128),
patch_filter = no_background_patches(0),
n_patches_per_image = 2,
save_file = 'data/my_training_data.npz',
)

produces the following error:

0%| | 0/2457 [00:00<?, ?it/s]

ValueError Traceback (most recent call last)
Cell In[8], line 3
1 from csbdeep.data import no_background_patches, norm_percentiles, sample_percentiles
----> 3 X, Y, XY_axes = create_patches (
4 raw_data = raw_data,
5 patch_size = (128,128),
6 patch_filter = no_background_patches(0),
7 n_patches_per_image = 2,
8 save_file = 'data/my_training_data.npz',
9 )

File ~.conda\envs\jupyter_env\Lib\site-packages\csbdeep\data\generate.py:346, in create_patches(raw_data, patch_size, n_patches_per_image, patch_axes, save_file, transforms, patch_filter, normalization, shuffle, verbose)
343 (channel is None or (isinstance(channel,int) and 0<=channel<x.ndim)) or _raise(ValueError())
344 channel is None or patch_size[channel]==x.shape[channel] or _raise(ValueError('extracted patches must contain all channels.'))
--> 346 _Y,_X = sample_patches_from_multiple_stacks((y,x), patch_size, n_patches_per_image, mask, patch_filter)
348 s = slice(i*n_patches_per_image,(i+1)*n_patches_per_image)
349 X[s], Y[s] = normalization(_X,_Y, x,y,mask,channel)

File ~.conda\envs\jupyter_env\Lib\site-packages\csbdeep\data\generate.py:102, in sample_patches_from_multiple_stacks(datas, patch_size, n_samples, datas_mask, patch_filter, verbose)
99 if n_valid == 0:
100 raise ValueError("'patch_filter' didn't return any region to sample from")
--> 102 sample_inds = choice(range(n_valid), n_samples, replace=(n_valid < n_samples))
104 # valid_inds = [v + s.start for s, v in zip(border_slices, valid_inds)] # slow for large n_valid
105 # rand_inds = [v[sample_inds] for v in valid_inds]
106 rand_inds = [v[sample_inds] + s.start for s, v in zip(border_slices, valid_inds)]

File ~.conda\envs\jupyter_env\Lib\site-packages\csbdeep\utils\utils.py:263, in choice(population, k, replace)
260 try:
261 # save state of 'random' and set seed using 'np.random'
262 state = random.getstate()
--> 263 random.seed(np.random.randint(np.iinfo(int).min, np.iinfo(int).max))
264 if replace:
265 # sample with replacement
266 return random.choices(population, k=k)

File numpy\random\mtrand.pyx:796, in numpy.random.mtrand.RandomState.randint()

File numpy\random\_bounded_integers.pyx:2877, in numpy.random._bounded_integers._rand_int32()

ValueError: low is out of bounds for int32

What is wrong???
Thanks and best,
Matthias

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions