# ResolVI Corrected Counts for Segmented Visium HD Data

**URL:** <https://discourse.scverse.org/t/resolvi-corrected-counts-for-segmented-visium-hd-data/3948>\
**Category:** scvi-tools\
**Tags:** scvi\
**Created:** [March 27, 2026, 3:15pm UTC](https://discourse.scverse.org/t/resolvi-corrected-counts-for-segmented-visium-hd-data/3948 "2026-03-27T15:15:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dow527](https://avatars.discourse-cdn.com/v4/letter/d/65b543/32.png) [@dow527](https://discourse.scverse.org/u/dow527)\
**Post date:** [March 27, 2026, 3:15pm UTC](https://discourse.scverse.org/t/resolvi-corrected-counts-for-segmented-visium-hd-data/3948/1 "2026-03-27T15:15:48Z")

</div>

Hi,

I’m trying to understand the correct method for running ResolVI on Visium HD data that has been segmented using proseg as opposed to 8μM bins used in the reproducibility jupyter notebooks.

I’m currently following the tutorial which creates the generated expression as follows:

> samples\_corr = resolvi.sample\_posterior(  
> model = resolvi.module.model\_corrected,  
> return\_sites = [‘px\_rate’],  
> summary\_fun = {‘post\_sample\_q50’: np.median},  
> num\_samples = 3,  
> summary\_frequency = 30,  
> )  
> samples\_corr = pd.DataFrame(samples\_corr).T

> samples = resolvi.sample\_posterior(  
> model = resolvi.module.model\_residuals,  
> return\_sites = [‘mixture\_proportions’],  
> summary\_fun = {‘post\_sample\_means’: np.mean},  
> num\_samples = 3,  
> summary\_frequency = 100,  
> )  
> samples = pd.DataFrame(samples).T

> adata.layers[“generated\_expression”] = samples\_corr.loc[“post\_sample\_q50”, “px\_rate”]

Is this the appropriate approach to take for cell segmented Visium HD data? Does this produce a ‘dense estimate of gene expression’ as opposed to counts that are corrected per cell? Also are the generated expression counts able to used with scran for normalization, and downstream spatial clustering approaches?

---

<div class="post-metadata">

**Author:** ![cane11](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.scverse.org/cane11/32/241_2.png) [@cane11](https://discourse.scverse.org/u/cane11)\
**Post date:** [April 23, 2026, 9:17am UTC](https://discourse.scverse.org/t/resolvi-corrected-counts-for-segmented-visium-hd-data/3948/2 "2026-04-23T09:17:24Z")

</div>

Hi, if you want to have an output that can be treated similar to original counts (such as using screen), use “obs” instead of “px\_rate”. “px\_rate” are the generated counts similar to what we propose to use in scVI. I wouldn’t feed those into scran. For spatial clustering you can use both of these counts, however I would usually recommend getting the latent representation and use this as replacement for steps such as PCA. You might want to check some of our scVI and scANVI tutorials to get a better overview of scvi-tools.

---

<div class="post-metadata">

**Author:** ![dow527](https://avatars.discourse-cdn.com/v4/letter/d/65b543/32.png) [@dow527](https://discourse.scverse.org/u/dow527)\
**Post date:** [April 23, 2026, 4:10pm UTC](https://discourse.scverse.org/t/resolvi-corrected-counts-for-segmented-visium-hd-data/3948/3 "2026-04-23T16:10:18Z")

</div>

> resolvae = resolvi  
> samples\_corr = resolvae.sample\_posterior(  
> model = resolvae.module.model\_corrected,  
> return\_sites = [“obs”],  
> summary\_fun = {“post\_sample\_q50”: np.median},  
> num\_samples = 3,  
> summary\_frequency = 30,  
> )  
> samples\_corr = pd.DataFrame(samples\_corr).T

If I run this the samples\_corr dataframe returned is empty. Is there something wrong with my input?

---

<div class="post-metadata">

**Author:** ![cane11](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.scverse.org/cane11/32/241_2.png) [@cane11](https://discourse.scverse.org/u/cane11)\
**Post date:** [April 23, 2026, 4:40pm UTC](https://discourse.scverse.org/t/resolvi-corrected-counts-for-segmented-visium-hd-data/3948/4 "2026-04-23T16:40:50Z")

</div>

Almost:

```auto
samples_corr = resolvae.sample_posterior(
    model=resolvae.module.model_corrected,
    return_sites=['obs'],
    num_samples=10, return_samples=False, batch_size=1000, summary_frequency=10, return_observed=True, summary_fun=summary_fun)

```

Will do the trick, so just setting return\_observed and it will output obs (this variable is observed during training - pyro computes a reconstruction loss and returning it has to be manually defined).
