You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thank you for the tutorial! I was just running through the example data, and encountered this error at:
# calculate features for different scales (higher value means more context)
for scale in [1.0, 2.0]:
feature_name = f"features_summary_scale{scale}"
sq.im.calculate_image_features(
adata2,
img2.compute(),
features="summary",
key_added=feature_name,
n_jobs=4,
scale=scale,
)
/opt/homebrew/Caskroom/mambaforge/base/lib/python3.10/site-packages/anndata/_core/anndata.py:1113: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
if not is_categorical_dtype(df_full[k]):
/opt/homebrew/Caskroom/mambaforge/base/lib/python3.10/site-packages/anndata/_core/anndata.py:1113: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
if not is_categorical_dtype(df_full[k]):
/opt/homebrew/Caskroom/mambaforge/base/lib/python3.10/site-packages/anndata/_core/anndata.py:1113: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
if not is_categorical_dtype(df_full[k]):
/opt/homebrew/Caskroom/mambaforge/base/lib/python3.10/site-packages/anndata/_core/anndata.py:1113: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
if not is_categorical_dtype(df_full[k]):
�/opt/homebrew/Caskroom/mambaforge/base/lib/python3.10/site-packages/anndata/_core/anndata.py:1113: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
if not is_categorical_dtype(df_full[k]):
/opt/homebrew/Caskroom/mambaforge/base/lib/python3.10/site-packages/anndata/_core/anndata.py:1113: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
if not is_categorical_dtype(df_full[k]):
/opt/homebrew/Caskroom/mambaforge/base/lib/python3.10/site-packages/anndata/_core/anndata.py:1113: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
if not is_categorical_dtype(df_full[k]):
{
"name": "ValueError",
"message": "applied function returned data with unexpected number of dimensions. Received 4 dimension(s) but expected 0 dimensions with names: ()",
"stack": "---------------------------------------------------------------------------
_RemoteTraceback Traceback (most recent call last)
_RemoteTraceback:
"""
Traceback (most recent call last):
File "/opt/homebrew/Caskroom/mambaforge/base/lib/python3.10/site-packages/joblib/externals/loky/process_executor.py", line 463, in _process_worker
r = call_item()
File "/opt/homebrew/Caskroom/mambaforge/base/lib/python3.10/site-packages/joblib/externals/loky/process_executor.py", line 291, in call
return self.fn(*self.args, **self.kwargs)
File "/opt/homebrew/Caskroom/mambaforge/base/lib/python3.10/site-packages/joblib/parallel.py", line 589, in call
return [func(*args, **kwargs)
File "/opt/homebrew/Caskroom/mambaforge/base/lib/python3.10/site-packages/joblib/parallel.py", line 589, in
return [func(*args, **kwargs)
File "/opt/homebrew/Caskroom/mambaforge/base/lib/python3.10/site-packages/squidpy/im/_feature.py", line 119, in _calculate_image_features_helper
for crop in img.generate_spot_crops(
File "/opt/homebrew/Caskroom/mambaforge/base/lib/python3.10/site-packages/squidpy/im/_container.py", line 830, in generate_spot_crops
crop = self.crop_center(y=y, x=x, radius=radius, library_id=obs_library_ids[i], **kwargs)
File "/opt/homebrew/Caskroom/mambaforge/base/lib/python3.10/site-packages/squidpy/im/_container.py", line 661, in crop_center
return self.crop_corner( # type: ignore[no-any-return]
File "/opt/homebrew/Caskroom/mambaforge/base/lib/python3.10/site-packages/squidpy/im/_container.py", line 568, in crop_corner
self._post_process(
File "/opt/homebrew/Caskroom/mambaforge/base/lib/python3.10/site-packages/squidpy/im/_container.py", line 602, in _post_process
data = data.map(_rescale).assign_coords({"z": library_ids})
File "/opt/homebrew/Caskroom/mambaforge/base/lib/python3.10/site-packages/xarray/core/dataset.py", line 6818, in map
variables = {
File "/opt/homebrew/Caskroom/mambaforge/base/lib/python3.10/site-packages/xarray/core/dataset.py", line 6819, in
k: maybe_wrap_array(v, func(v, *args, **kwargs))
File "/opt/homebrew/Caskroom/mambaforge/base/lib/python3.10/site-packages/squidpy/im/_container.py", line 597, in _rescale
return xr.DataArray(scaling_fn(arr).astype(dtype), dims=arr.dims)
File "/opt/homebrew/Caskroom/mambaforge/base/lib/python3.10/site-packages/skimage/_shared/utils.py", line 328, in fixed_func
return func(*args, **kwargs)
File "/opt/homebrew/Caskroom/mambaforge/base/lib/python3.10/site-packages/skimage/transform/_warps.py", line 289, in rescale
return resize(image, output_shape, order=order, mode=mode, cval=cval,
File "/opt/homebrew/Caskroom/mambaforge/base/lib/python3.10/site-packages/skimage/transform/_warps.py", line 188, in resize
_clip_warp_output(image, out, mode, cval, clip)
File "/opt/homebrew/Caskroom/mambaforge/base/lib/python3.10/site-packages/skimage/transform/_warps.py", line 692, in _clip_warp_output
np.clip(output_image, min_val, max_val, out=output_image)
File "<array_function internals>", line 180, in clip
File "/opt/homebrew/Caskroom/mambaforge/base/lib/python3.10/site-packages/numpy/core/fromnumeric.py", line 2152, in clip
return _wrapfunc(a, 'clip', a_min, a_max, out=out, **kwargs)
File "/opt/homebrew/Caskroom/mambaforge/base/lib/python3.10/site-packages/numpy/core/fromnumeric.py", line 57, in _wrapfunc
return bound(*args, **kwds)
File "/opt/homebrew/Caskroom/mambaforge/base/lib/python3.10/site-packages/numpy/core/_methods.py", line 159, in _clip
return _clip_dep_invoke_with_casting(
File "/opt/homebrew/Caskroom/mambaforge/base/lib/python3.10/site-packages/numpy/core/_methods.py", line 113, in _clip_dep_invoke_with_casting
return ufunc(*args, out=out, **kwargs)
File "/opt/homebrew/Caskroom/mambaforge/base/lib/python3.10/site-packages/xarray/core/arithmetic.py", line 86, in array_ufunc
return apply_ufunc(
File "/opt/homebrew/Caskroom/mambaforge/base/lib/python3.10/site-packages/xarray/core/computation.py", line 1197, in apply_ufunc
return apply_dataarray_vfunc(
File "/opt/homebrew/Caskroom/mambaforge/base/lib/python3.10/site-packages/xarray/core/computation.py", line 304, in apply_dataarray_vfunc
result_var = func(*data_vars)
File "/opt/homebrew/Caskroom/mambaforge/base/lib/python3.10/site-packages/xarray/core/computation.py", line 786, in apply_variable_ufunc
raise ValueError(
ValueError: applied function returned data with unexpected number of dimensions. Received 4 dimension(s) but expected 0 dimensions with names: ()
"""
The above exception was the direct cause of the following exception:
File /opt/homebrew/Caskroom/mambaforge/base/lib/python3.10/site-packages/squidpy/_utils.py:168, in parallelize..wrapper(*args, **kwargs)
165 else:
166 pbar, queue, thread = None, None, None
--> 168 res = jl.Parallel(n_jobs=n_jobs, backend=backend)(
169 jl.delayed(runner if use_runner else callback)(
170 *((i, cs) if use_ixs else (cs,)),
171 *args,
172 **kwargs,
173 queue=queue,
174 )
175 for i, cs in enumerate(collections)
176 )
178 if thread is not None:
179 thread.join()
File /opt/homebrew/Caskroom/mambaforge/base/lib/python3.10/site-packages/joblib/parallel.py:1952, in Parallel.call(self, iterable)
1946 # The first item from the output is blank, but it makes the interpreter
1947 # progress until it enters the Try/Except block of the generator and
1948 # reach the first yield statement. This starts the aynchronous
1949 # dispatch of the tasks to the workers.
1950 next(output)
-> 1952 return output if self.return_generator else list(output)
File /opt/homebrew/Caskroom/mambaforge/base/lib/python3.10/site-packages/joblib/parallel.py:1595, in Parallel._get_outputs(self, iterator, pre_dispatch)
1592 yield
1594 with self._backend.retrieval_context():
-> 1595 yield from self._retrieve()
1597 except GeneratorExit:
1598 # The generator has been garbage collected before being fully
1599 # consumed. This aborts the remaining tasks if possible and warn
1600 # the user if necessary.
1601 self._exception = True
File /opt/homebrew/Caskroom/mambaforge/base/lib/python3.10/site-packages/joblib/parallel.py:1699, in Parallel._retrieve(self)
1692 while self._wait_retrieval():
1693
1694 # If the callback thread of a worker has signaled that its task
1695 # triggered an exception, or if the retrieval loop has raised an
1696 # exception (e.g. GeneratorExit), exit the loop and surface the
1697 # worker traceback.
1698 if self._aborting:
-> 1699 self._raise_error_fast()
1700 break
1702 # If the next job is not ready for retrieval yet, we just wait for
1703 # async callbacks to progress.
File /opt/homebrew/Caskroom/mambaforge/base/lib/python3.10/site-packages/joblib/parallel.py:1734, in Parallel._raise_error_fast(self)
1730 # If this error job exists, immediatly raise the error by
1731 # calling get_result. This job might not exists if abort has been
1732 # called directly or if the generator is gc'ed.
1733 if error_job is not None:
-> 1734 error_job.get_result(self.timeout)
File /opt/homebrew/Caskroom/mambaforge/base/lib/python3.10/site-packages/joblib/parallel.py:736, in BatchCompletionCallBack.get_result(self, timeout)
730 backend = self.parallel._backend
732 if backend.supports_retrieve_callback:
733 # We assume that the result has already been retrieved by the
734 # callback thread, and is stored internally. It's just waiting to
735 # be returned.
--> 736 return self._return_or_raise()
738 # For other backends, the main thread needs to run the retrieval step.
739 try:
File /opt/homebrew/Caskroom/mambaforge/base/lib/python3.10/site-packages/joblib/parallel.py:754, in BatchCompletionCallBack._return_or_raise(self)
752 try:
753 if self.status == TASK_ERROR:
--> 754 raise self._result
755 return self._result
756 finally:
ValueError: applied function returned data with unexpected number of dimensions. Received 4 dimension(s) but expected 0 dimensions with names: ()"
}
Could you please let us know the environment.yml you used? Thank you!
Sincerely,
Estella
The text was updated successfully, but these errors were encountered:
Hi there,
Thank you for the tutorial! I was just running through the example data, and encountered this error at:
/opt/homebrew/Caskroom/mambaforge/base/lib/python3.10/site-packages/anndata/_core/anndata.py:1113: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
if not is_categorical_dtype(df_full[k]):
/opt/homebrew/Caskroom/mambaforge/base/lib/python3.10/site-packages/anndata/_core/anndata.py:1113: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
if not is_categorical_dtype(df_full[k]):
/opt/homebrew/Caskroom/mambaforge/base/lib/python3.10/site-packages/anndata/_core/anndata.py:1113: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
if not is_categorical_dtype(df_full[k]):
/opt/homebrew/Caskroom/mambaforge/base/lib/python3.10/site-packages/anndata/_core/anndata.py:1113: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
if not is_categorical_dtype(df_full[k]):
100%|██████████| 2688/2688 [00:14<00:00, 179.80/s]
�/opt/homebrew/Caskroom/mambaforge/base/lib/python3.10/site-packages/anndata/_core/anndata.py:1113: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
if not is_categorical_dtype(df_full[k]):
/opt/homebrew/Caskroom/mambaforge/base/lib/python3.10/site-packages/anndata/_core/anndata.py:1113: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
if not is_categorical_dtype(df_full[k]):
/opt/homebrew/Caskroom/mambaforge/base/lib/python3.10/site-packages/anndata/_core/anndata.py:1113: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
if not is_categorical_dtype(df_full[k]):
{
"name": "ValueError",
"message": "applied function returned data with unexpected number of dimensions. Received 4 dimension(s) but expected 0 dimensions with names: ()",
"stack": "---------------------------------------------------------------------------
_RemoteTraceback Traceback (most recent call last)
_RemoteTraceback:
"""
Traceback (most recent call last):
File "/opt/homebrew/Caskroom/mambaforge/base/lib/python3.10/site-packages/joblib/externals/loky/process_executor.py", line 463, in _process_worker
r = call_item()
File "/opt/homebrew/Caskroom/mambaforge/base/lib/python3.10/site-packages/joblib/externals/loky/process_executor.py", line 291, in call
return self.fn(*self.args, **self.kwargs)
File "/opt/homebrew/Caskroom/mambaforge/base/lib/python3.10/site-packages/joblib/parallel.py", line 589, in call
return [func(*args, **kwargs)
File "/opt/homebrew/Caskroom/mambaforge/base/lib/python3.10/site-packages/joblib/parallel.py", line 589, in
return [func(*args, **kwargs)
File "/opt/homebrew/Caskroom/mambaforge/base/lib/python3.10/site-packages/squidpy/im/_feature.py", line 119, in _calculate_image_features_helper
for crop in img.generate_spot_crops(
File "/opt/homebrew/Caskroom/mambaforge/base/lib/python3.10/site-packages/squidpy/im/_container.py", line 830, in generate_spot_crops
crop = self.crop_center(y=y, x=x, radius=radius, library_id=obs_library_ids[i], **kwargs)
File "/opt/homebrew/Caskroom/mambaforge/base/lib/python3.10/site-packages/squidpy/im/_container.py", line 661, in crop_center
return self.crop_corner( # type: ignore[no-any-return]
File "/opt/homebrew/Caskroom/mambaforge/base/lib/python3.10/site-packages/squidpy/im/_container.py", line 568, in crop_corner
self._post_process(
File "/opt/homebrew/Caskroom/mambaforge/base/lib/python3.10/site-packages/squidpy/im/_container.py", line 602, in _post_process
data = data.map(_rescale).assign_coords({"z": library_ids})
File "/opt/homebrew/Caskroom/mambaforge/base/lib/python3.10/site-packages/xarray/core/dataset.py", line 6818, in map
variables = {
File "/opt/homebrew/Caskroom/mambaforge/base/lib/python3.10/site-packages/xarray/core/dataset.py", line 6819, in
k: maybe_wrap_array(v, func(v, *args, **kwargs))
File "/opt/homebrew/Caskroom/mambaforge/base/lib/python3.10/site-packages/squidpy/im/_container.py", line 597, in _rescale
return xr.DataArray(scaling_fn(arr).astype(dtype), dims=arr.dims)
File "/opt/homebrew/Caskroom/mambaforge/base/lib/python3.10/site-packages/skimage/_shared/utils.py", line 328, in fixed_func
return func(*args, **kwargs)
File "/opt/homebrew/Caskroom/mambaforge/base/lib/python3.10/site-packages/skimage/transform/_warps.py", line 289, in rescale
return resize(image, output_shape, order=order, mode=mode, cval=cval,
File "/opt/homebrew/Caskroom/mambaforge/base/lib/python3.10/site-packages/skimage/transform/_warps.py", line 188, in resize
_clip_warp_output(image, out, mode, cval, clip)
File "/opt/homebrew/Caskroom/mambaforge/base/lib/python3.10/site-packages/skimage/transform/_warps.py", line 692, in _clip_warp_output
np.clip(output_image, min_val, max_val, out=output_image)
File "<array_function internals>", line 180, in clip
File "/opt/homebrew/Caskroom/mambaforge/base/lib/python3.10/site-packages/numpy/core/fromnumeric.py", line 2152, in clip
return _wrapfunc(a, 'clip', a_min, a_max, out=out, **kwargs)
File "/opt/homebrew/Caskroom/mambaforge/base/lib/python3.10/site-packages/numpy/core/fromnumeric.py", line 57, in _wrapfunc
return bound(*args, **kwds)
File "/opt/homebrew/Caskroom/mambaforge/base/lib/python3.10/site-packages/numpy/core/_methods.py", line 159, in _clip
return _clip_dep_invoke_with_casting(
File "/opt/homebrew/Caskroom/mambaforge/base/lib/python3.10/site-packages/numpy/core/_methods.py", line 113, in _clip_dep_invoke_with_casting
return ufunc(*args, out=out, **kwargs)
File "/opt/homebrew/Caskroom/mambaforge/base/lib/python3.10/site-packages/xarray/core/arithmetic.py", line 86, in array_ufunc
return apply_ufunc(
File "/opt/homebrew/Caskroom/mambaforge/base/lib/python3.10/site-packages/xarray/core/computation.py", line 1197, in apply_ufunc
return apply_dataarray_vfunc(
File "/opt/homebrew/Caskroom/mambaforge/base/lib/python3.10/site-packages/xarray/core/computation.py", line 304, in apply_dataarray_vfunc
result_var = func(*data_vars)
File "/opt/homebrew/Caskroom/mambaforge/base/lib/python3.10/site-packages/xarray/core/computation.py", line 786, in apply_variable_ufunc
raise ValueError(
ValueError: applied function returned data with unexpected number of dimensions. Received 4 dimension(s) but expected 0 dimensions with names: ()
"""
The above exception was the direct cause of the following exception:
ValueError Traceback (most recent call last)
/Users/estelladong/Downloads/tutorial_visium_hne.ipynb Cell 13 line 4
2 for scale in [1.0, 2.0]:
3 feature_name = f"features_summary_scale{scale}"
----> 4 sq.im.calculate_image_features(
5 adata2,
6 img2.compute(),
7 features="summary",
8 key_added=feature_name,
9 n_jobs=4,
10 scale=scale,
11 )
File /opt/homebrew/Caskroom/mambaforge/base/lib/python3.10/site-packages/squidpy/im/_feature.py:91, in calculate_image_features(adata, img, layer, library_id, features, features_kwargs, key_added, copy, n_jobs, backend, show_progress_bar, **kwargs)
88 n_jobs = _get_n_cores(n_jobs)
89 start = logg.info(f"Calculating features
{list(features)}
using{n_jobs}
core(s)")---> 91 res = parallelize(
92 _calculate_image_features_helper,
93 collection=adata.obs_names,
94 extractor=pd.concat,
95 n_jobs=n_jobs,
96 backend=backend,
97 show_progress_bar=show_progress_bar,
98 )(adata, img, layer=layer, library_id=library_id, features=features, features_kwargs=features_kwargs, **kwargs)
100 if copy:
101 logg.info("Finish", time=start)
File /opt/homebrew/Caskroom/mambaforge/base/lib/python3.10/site-packages/squidpy/_utils.py:168, in parallelize..wrapper(*args, **kwargs)
165 else:
166 pbar, queue, thread = None, None, None
--> 168 res = jl.Parallel(n_jobs=n_jobs, backend=backend)(
169 jl.delayed(runner if use_runner else callback)(
170 *((i, cs) if use_ixs else (cs,)),
171 *args,
172 **kwargs,
173 queue=queue,
174 )
175 for i, cs in enumerate(collections)
176 )
178 if thread is not None:
179 thread.join()
File /opt/homebrew/Caskroom/mambaforge/base/lib/python3.10/site-packages/joblib/parallel.py:1952, in Parallel.call(self, iterable)
1946 # The first item from the output is blank, but it makes the interpreter
1947 # progress until it enters the Try/Except block of the generator and
1948 # reach the first
yield
statement. This starts the aynchronous1949 # dispatch of the tasks to the workers.
1950 next(output)
-> 1952 return output if self.return_generator else list(output)
File /opt/homebrew/Caskroom/mambaforge/base/lib/python3.10/site-packages/joblib/parallel.py:1595, in Parallel._get_outputs(self, iterator, pre_dispatch)
1592 yield
1594 with self._backend.retrieval_context():
-> 1595 yield from self._retrieve()
1597 except GeneratorExit:
1598 # The generator has been garbage collected before being fully
1599 # consumed. This aborts the remaining tasks if possible and warn
1600 # the user if necessary.
1601 self._exception = True
File /opt/homebrew/Caskroom/mambaforge/base/lib/python3.10/site-packages/joblib/parallel.py:1699, in Parallel._retrieve(self)
1692 while self._wait_retrieval():
1693
1694 # If the callback thread of a worker has signaled that its task
1695 # triggered an exception, or if the retrieval loop has raised an
1696 # exception (e.g.
GeneratorExit
), exit the loop and surface the1697 # worker traceback.
1698 if self._aborting:
-> 1699 self._raise_error_fast()
1700 break
1702 # If the next job is not ready for retrieval yet, we just wait for
1703 # async callbacks to progress.
File /opt/homebrew/Caskroom/mambaforge/base/lib/python3.10/site-packages/joblib/parallel.py:1734, in Parallel._raise_error_fast(self)
1730 # If this error job exists, immediatly raise the error by
1731 # calling get_result. This job might not exists if abort has been
1732 # called directly or if the generator is gc'ed.
1733 if error_job is not None:
-> 1734 error_job.get_result(self.timeout)
File /opt/homebrew/Caskroom/mambaforge/base/lib/python3.10/site-packages/joblib/parallel.py:736, in BatchCompletionCallBack.get_result(self, timeout)
730 backend = self.parallel._backend
732 if backend.supports_retrieve_callback:
733 # We assume that the result has already been retrieved by the
734 # callback thread, and is stored internally. It's just waiting to
735 # be returned.
--> 736 return self._return_or_raise()
738 # For other backends, the main thread needs to run the retrieval step.
739 try:
File /opt/homebrew/Caskroom/mambaforge/base/lib/python3.10/site-packages/joblib/parallel.py:754, in BatchCompletionCallBack._return_or_raise(self)
752 try:
753 if self.status == TASK_ERROR:
--> 754 raise self._result
755 return self._result
756 finally:
ValueError: applied function returned data with unexpected number of dimensions. Received 4 dimension(s) but expected 0 dimensions with names: ()"
}
Could you please let us know the environment.yml you used? Thank you!
Sincerely,
Estella
The text was updated successfully, but these errors were encountered: