# Can we use Openslide or do we have a tool to open MRXS files from microscope?

**URL:** https://discourse.julialang.org/t/can-we-use-openslide-or-do-we-have-a-tool-to-open-mrxs-files-from-microscope/79936
**Category:** General Usage
**Created:** [April 24, 2022, 9:48am UTC](https://discourse.julialang.org/t/can-we-use-openslide-or-do-we-have-a-tool-to-open-mrxs-files-from-microscope/79936 "2022-04-24T09:48:33Z")
**Posts on this page:** 18
**Page:** 1

<div class="post-metadata">

### Author: ![YitaoCai](https://avatars.discourse-cdn.com/v4/letter/y/6bbea6/32.png) [@YitaoCai](https://discourse.julialang.org/u/YitaoCai)
#### Post date: [April 24, 2022, 9:48am UTC](https://discourse.julialang.org/t/can-we-use-openslide-or-do-we-have-a-tool-to-open-mrxs-files-from-microscope/79936/1 "2022-04-24T09:48:33Z")

</div>

I was thinking if there is a way we can open MRXS file in Julia, like Openslide in Python? I tried to install openslide using CondaPkg.jl, but when using PythonCall.jl to import openslide, it does not work. (it works for torch and other packages like rdkit…)

---

<div class="post-metadata">

### Author: ![jd-foster](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jd-foster/32/35824_2.png) [@jd-foster](https://discourse.julialang.org/u/jd-foster)
#### Post date: [April 24, 2022, 10:49am UTC](https://discourse.julialang.org/t/can-we-use-openslide-or-do-we-have-a-tool-to-open-mrxs-files-from-microscope/79936/2 "2022-04-24T10:49:11Z")

</div>

I think the easiest way to help is if you can elaborate on why it doesn’t work or show the error from the installation?  
This [advice](https://discourse.julialang.org/t/please-read-make-it-easier-to-help-you/14757) might be useful, particularly (4.).

---

<div class="post-metadata">

### Author: ![YitaoCai](https://avatars.discourse-cdn.com/v4/letter/y/6bbea6/32.png) [@YitaoCai](https://discourse.julialang.org/u/YitaoCai)
#### Post date: [April 24, 2022, 11:01am UTC](https://discourse.julialang.org/t/can-we-use-openslide-or-do-we-have-a-tool-to-open-mrxs-files-from-microscope/79936/3 "2022-04-24T11:01:18Z")

</div>

> [@jd-foster](#):
>
> advice

It would spit Module not found Error, but it was installed shown from `conda status`

```julia
o = pyimport("openslide") 
or @py import openslide

ERROR: Python: ModuleNotFoundError: No module named 'openslide'
Python stacktrace: none
Stacktrace:
 [1] pythrow()
   @ PythonCall ~/.julia/packages/PythonCall/XgP8G/src/err.jl:94
 [2] errcheck
   @ ~/.julia/packages/PythonCall/XgP8G/src/err.jl:10 [inlined]
 [3] pyimport(m::String)
   @ PythonCall ~/.julia/packages/PythonCall/XgP8G/src/concrete/import.jl:11
 [4] top-level scope
   @ ~/百度云同步盘/StudyResearch/AIforLS/AIforLS1.jl:12

```

```julia
conda status

```

```julia
Packages
  numpy v1.22.3
  openslide v3.4.1
  pytorch v1.11.0
  rdkit v2022.03.1

```

Is there julia package which can read MRXS files?

---

<div class="post-metadata">

### Author: ![jd-foster](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jd-foster/32/35824_2.png) [@jd-foster](https://discourse.julialang.org/u/jd-foster)
#### Post date: [April 24, 2022, 11:19am UTC](https://discourse.julialang.org/t/can-we-use-openslide-or-do-we-have-a-tool-to-open-mrxs-files-from-microscope/79936/4 "2022-04-24T11:19:53Z")

</div>

> [@YitaoCai](#):
>
> `openslide v3.4.1`

This is the C package. You probably want `openslide-python`:  
[https://anaconda.org/conda-forge/openslide-python](https://anaconda.org/conda-forge/openslide-python)

For example:

```julia
using CondaPkg
using PythonCall

pkg> conda add openslide-python

ops = pyimport("openslide")

```

---

<div class="post-metadata">

### Author: ![YitaoCai](https://avatars.discourse-cdn.com/v4/letter/y/6bbea6/32.png) [@YitaoCai](https://discourse.julialang.org/u/YitaoCai)
#### Post date: [April 24, 2022, 11:47am UTC](https://discourse.julialang.org/t/can-we-use-openslide-or-do-we-have-a-tool-to-open-mrxs-files-from-microscope/79936/5 "2022-04-24T11:47:23Z")

</div>

> [@jd-foster](#):
>
> `openslide-python`

Yeah, this works, thank you so much!!! 😀

BTW, why CondaPkg can install C package instead of python package?

---

<div class="post-metadata">

### Author: ![jd-foster](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jd-foster/32/35824_2.png) [@jd-foster](https://discourse.julialang.org/u/jd-foster)
#### Post date: [April 24, 2022, 11:55am UTC](https://discourse.julialang.org/t/can-we-use-openslide-or-do-we-have-a-tool-to-open-mrxs-files-from-microscope/79936/6 "2022-04-24T11:55:11Z")

</div>

> [@YitaoCai](#):
>
> BTW, why CondaPkg can install C package instead of python package?

Conda : [Conda — conda documentation](https://docs.conda.io/en/latest/)

_Package, dependency and environment management for any language—Python, R, Ruby, Lua, Scala, Java, JavaScript, C/ C++, Fortran, and more._

---

<div class="post-metadata">

### Author: ![YitaoCai](https://avatars.discourse-cdn.com/v4/letter/y/6bbea6/32.png) [@YitaoCai](https://discourse.julialang.org/u/YitaoCai)
#### Post date: [April 24, 2022, 12:00pm UTC](https://discourse.julialang.org/t/can-we-use-openslide-or-do-we-have-a-tool-to-open-mrxs-files-from-microscope/79936/7 "2022-04-24T12:00:24Z")

</div>

> [@jd-foster](#):
>
> Conda — Conda documentation

Thank you for your information! 👍

I am aware of that, I thought CondaPkg.jl was specifically for PythonCall.jl 😃

---

<div class="post-metadata">

### Author: ![jd-foster](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jd-foster/32/35824_2.png) [@jd-foster](https://discourse.julialang.org/u/jd-foster)
#### Post date: [April 24, 2022, 12:17pm UTC](https://discourse.julialang.org/t/can-we-use-openslide-or-do-we-have-a-tool-to-open-mrxs-files-from-microscope/79936/8 "2022-04-24T12:17:53Z")

</div>

For future reference, minimal working example for test data:

```julia
mkdir("test_data")
Base.download("https://openslide.cs.cmu.edu/download/openslide-testdata/Mirax/Mirax2-Fluorescence-1.zip", "./test_data/Mirax2-Fluorescence-1.zip")
run(`unzip ./test_data/Mirax2-Fluorescence-1.zip -d ./test_data`) # This may be system dependent
s = ops.OpenSlide("./test_data/Mirax2-Fluorescence-1.mrxs")
# Get metadata properties about the slide:
p = PyDict{String,String}(s.properties)

# Save image data:
im = PyDict{String, Py}(s.associated_images)
im["label"].save("label.png")

```

---

<div class="post-metadata">

### Author: ![YitaoCai](https://avatars.discourse-cdn.com/v4/letter/y/6bbea6/32.png) [@YitaoCai](https://discourse.julialang.org/u/YitaoCai)
#### Post date: [April 24, 2022, 1:00pm UTC](https://discourse.julialang.org/t/can-we-use-openslide-or-do-we-have-a-tool-to-open-mrxs-files-from-microscope/79936/9 "2022-04-24T13:00:24Z")

</div>

You are so kind!!! I appreciate your help 😃

---

<div class="post-metadata">

### Author: ![GunnarFarneback](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gunnarfarneback/32/1827_2.png) [@GunnarFarneback](https://discourse.julialang.org/u/GunnarFarneback)
#### Post date: [April 24, 2022, 6:31pm UTC](https://discourse.julialang.org/t/can-we-use-openslide-or-do-we-have-a-tool-to-open-mrxs-files-from-microscope/79936/10 "2022-04-24T18:31:07Z")

</div>

For what it’s worth you can also get the C library in Julia with

```julia
Pkg.add("OpenSlide_jll")

```

Then of course you’ll want wrapper functions which `ccall` into the library. Those are quite straightforward to implement except you need to decide how to handle the row-major nature of image patches, whether you want convenience functions which allocate buffers for you, and to what extent you want to integrate with `Images.jl`. I have written such a package at work but that code is proprietary.

---

<div class="post-metadata">

### Author: ![YitaoCai](https://avatars.discourse-cdn.com/v4/letter/y/6bbea6/32.png) [@YitaoCai](https://discourse.julialang.org/u/YitaoCai)
#### Post date: [April 24, 2022, 7:38pm UTC](https://discourse.julialang.org/t/can-we-use-openslide-or-do-we-have-a-tool-to-open-mrxs-files-from-microscope/79936/11 "2022-04-24T19:38:02Z")

</div>

Do you mean after using CondaPkg.jl to install the c library Openslide, we can add openslide\_jll binary binder to use the C library Openslide?  
How do we do that exactly?Could you show some examples? or could you point to some tutorial which explain how to do this in general? compare to just using openslide-python will it be faster?

Thank you!

---

<div class="post-metadata">

### Author: ![GunnarFarneback](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gunnarfarneback/32/1827_2.png) [@GunnarFarneback](https://discourse.julialang.org/u/GunnarFarneback)
#### Post date: [April 24, 2022, 7:56pm UTC](https://discourse.julialang.org/t/can-we-use-openslide-or-do-we-have-a-tool-to-open-mrxs-files-from-microscope/79936/12 "2022-04-24T19:56:20Z")

</div>

The `OpenSlide_jll` would be an alternative that involves neither `Conda` nor `Python` in any form. But as I wrote you would need to handle the interfacing with the library yourself.

Ok, here’s a minimal example you can try. After doing

```julia
using Pkg
Pkg.add("OpenSlide_jll")
using OpenSlide_jll
function openslide_get_version()
    return unsafe_string(ccall((:openslide_get_version, libopenslide), Cstring, ()))
end

```

you should be able to run

```julia
julia> openslide_get_version()
"3.4.1"

```

---

<div class="post-metadata">

### Author: ![YitaoCai](https://avatars.discourse-cdn.com/v4/letter/y/6bbea6/32.png) [@YitaoCai](https://discourse.julialang.org/u/YitaoCai)
#### Post date: [April 24, 2022, 8:17pm UTC](https://discourse.julialang.org/t/can-we-use-openslide-or-do-we-have-a-tool-to-open-mrxs-files-from-microscope/79936/13 "2022-04-24T20:17:23Z")

</div>

It sounds great 👍  
I got the following error:

```julia
ERROR: UndefVarError: libopenslide not defined

```

Should I install other things except openslide\_jll(already installed)?

---

<div class="post-metadata">

### Author: ![GunnarFarneback](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gunnarfarneback/32/1827_2.png) [@GunnarFarneback](https://discourse.julialang.org/u/GunnarFarneback)
#### Post date: [April 24, 2022, 8:31pm UTC](https://discourse.julialang.org/t/can-we-use-openslide-or-do-we-have-a-tool-to-open-mrxs-files-from-microscope/79936/14 "2022-04-24T20:31:55Z")

</div>

`libopenslide` is exported by `OpenSlide_jll` so if

```julia
using OpenSlide_jll
libopenslide

```

gives an error, something is badly broken.

---

<div class="post-metadata">

### Author: ![YitaoCai](https://avatars.discourse-cdn.com/v4/letter/y/6bbea6/32.png) [@YitaoCai](https://discourse.julialang.org/u/YitaoCai)
#### Post date: [April 24, 2022, 8:37pm UTC](https://discourse.julialang.org/t/can-we-use-openslide-or-do-we-have-a-tool-to-open-mrxs-files-from-microscope/79936/15 "2022-04-24T20:37:45Z")

</div>

Ok, thank you! then I will stick to openslide-python for now, will explore this track later.

---

<div class="post-metadata">

### Author: ![YitaoCai](https://avatars.discourse-cdn.com/v4/letter/y/6bbea6/32.png) [@YitaoCai](https://discourse.julialang.org/u/YitaoCai)
#### Post date: [April 25, 2022, 12:57pm UTC](https://discourse.julialang.org/t/can-we-use-openslide-or-do-we-have-a-tool-to-open-mrxs-files-from-microscope/79936/16 "2022-04-25T12:57:32Z")

</div>

I was wondering do you know if is there some package that can anonymize the mrxs slide?

---

<div class="post-metadata">

### Author: ![jd-foster](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jd-foster/32/35824_2.png) [@jd-foster](https://discourse.julialang.org/u/jd-foster)
#### Post date: [April 25, 2022, 1:01pm UTC](https://discourse.julialang.org/t/can-we-use-openslide-or-do-we-have-a-tool-to-open-mrxs-files-from-microscope/79936/17 "2022-04-25T13:01:08Z")

</div>

Sorry, I really know nothing about mrxs data.

---

<div class="post-metadata">

### Author: ![logankilpatrick](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/logankilpatrick/32/38123_2.png) [@logankilpatrick](https://discourse.julialang.org/u/logankilpatrick)
#### Post date: [August 12, 2022, 2:16pm UTC](https://discourse.julialang.org/t/can-we-use-openslide-or-do-we-have-a-tool-to-open-mrxs-files-from-microscope/79936/18 "2022-08-12T14:16:23Z")

</div>

There is also [Path to supporting Julia 1.X · Issue #4 · ihnorton/OpenSlide.jl · GitHub](https://github.com/ihnorton/OpenSlide.jl/issues/4) which might be worth bringing back to life if there’s enough interest. I am working in a limited capacity with the open slide folks right now.
