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

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…)

1 Like

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 might be useful, particularly (4.).

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

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

ERROR: Python: ModuleNotFoundError: No module named 'openslide'
Python stacktrace: none
 [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
conda status
  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?

This is the C package. You probably want openslide-python:

For example:

using CondaPkg
using PythonCall

pkg> conda add openslide-python

ops = pyimport("openslide")
1 Like

Yeah, this works, thank you so much!!! :grinning:

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

1 Like

Conda : Conda — conda documentation

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

Thank you for your information! :+1:

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

For future reference, minimal working example for test data:

mkdir("test_data")"", "./test_data/")
run(`unzip ./test_data/ -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}(

# Save image data:
im = PyDict{String, Py}(s.associated_images)
1 Like

You are so kind!!! I appreciate your help :smiley:

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


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.

1 Like

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!

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

using Pkg
using OpenSlide_jll
function openslide_get_version()
    return unsafe_string(ccall((:openslide_get_version, libopenslide), Cstring, ()))

you should be able to run

julia> openslide_get_version()

It sounds great :+1:
I got the following error:

ERROR: UndefVarError: libopenslide not defined

Should I install other things except openslide_jll(already installed)?

libopenslide is exported by OpenSlide_jll so if

using OpenSlide_jll

gives an error, something is badly broken.

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

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

Sorry, I really know nothing about mrxs data.

1 Like

There is also Path to supporting Julia 1.X · Issue #4 · ihnorton/OpenSlide.jl · GitHub 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.