# Bioformats in Julia?

**URL:** <https://discourse.julialang.org/t/bioformats-in-julia/2440>\
**Category:** Data\
**Created:** [March 4, 2017, 1:59pm UTC](https://discourse.julialang.org/t/bioformats-in-julia/2440 "2017-03-04T13:59:49Z")\
**Posts on this page:** 7\
**Page:** 4

<div class="post-metadata">

**Author:** ![tim.holy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tim.holy/32/52_2.png) [@tim.holy](https://discourse.julialang.org/u/tim.holy)\
**Post date:** [March 17, 2017, 6:11pm UTC](https://discourse.julialang.org/t/bioformats-in-julia/2440/63 "2017-03-17T18:11:07Z")

</div>

> BTW by some reason I wasn’t able to apply “imwrite” function, got “not defined” error.

Not quite sure what you mean exactly, but FYI other readers like ImageMagick use `load` and `save` for image I/O, as defined by the FileIO.jl package. I’m not aware of a definition for `imwrite`.

---

<div class="post-metadata">

**Author:** ![yalexand](https://avatars.discourse-cdn.com/v4/letter/y/5daacb/32.png) [@yalexand](https://discourse.julialang.org/u/yalexand)\
**Post date:** [March 17, 2017, 11:25pm UTC](https://discourse.julialang.org/t/bioformats-in-julia/2440/64 "2017-03-17T23:25:10Z")

</div>

one can found several places where it was mentioned, e.g.

> <https://stackoverflow.com/questions/25706309/export-an-image-using-images-in-julia>

the last post there, it looks like, yours.

I tried “save” but got errors as well, likely some package wrongly installed. I’ll check it in Monday.  
…

---

<div class="post-metadata">

**Author:** ![tim.holy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tim.holy/32/52_2.png) [@tim.holy](https://discourse.julialang.org/u/tim.holy)\
**Post date:** [March 18, 2017, 12:45am UTC](https://discourse.julialang.org/t/bioformats-in-julia/2440/65 "2017-03-18T00:45:53Z")

</div>

2014 was so last-century. I’d even forgotten we ever had `imwrite`.

---

<div class="post-metadata">

**Author:** ![yalexand](https://avatars.discourse-cdn.com/v4/letter/y/5daacb/32.png) [@yalexand](https://discourse.julialang.org/u/yalexand)\
**Post date:** [March 23, 2017, 11:27am UTC](https://discourse.julialang.org/t/bioformats-in-julia/2440/66 "2017-03-23T11:27:10Z")

</div>

I now have acceptable route for OPT images’ processing, that combines several ideas advised by the community:

1. “load” - from Julia
2. reading angles metadata from Bioformats accessed via JavaCall, using XML for parsing
3. … reconstructing …
4. “save” - also from Julia

(code is below)

There is one mysterious thing that is still unsolved.  
It isn’t likely to be major, but anyway.  
I specify for “save” procedure explicitly that it should interpret the reconstruction (3D stack of images) as XYZ but not XYT.  
When I load the saved tiff image to ImageJ, I can see that it is XYZ.  
However, when I open the same image via another app that uses Bioformats , e.g. Icy, it interprets this image as XYT.  
Maybe someone has an idea how to fix this?

```julia
# get angles
r = bfGetReader(src_img_filename)
angles = bfGetModulo(r,"Z")
jcall(r, "close", Void, ())

# get projections
proj = convert(Array{Float64,3},load(src_img_filename))

# ..do reconstruction using "proj" and "angles"

save(dst_img_filename,
colorview(Gray,AxisArray(normedview(convert(Array{Normed{UInt16,16},3},reconstruction)),:x,:y,:z)))

```

---

<div class="post-metadata">

**Author:** ![tlnagy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tlnagy/32/5815_2.png) [@tlnagy](https://discourse.julialang.org/u/tlnagy)\
**Post date:** [August 22, 2017, 11:06pm UTC](https://discourse.julialang.org/t/bioformats-in-julia/2440/67 "2017-08-22T23:06:22Z")

</div>

In case anyone here is interested, I wrote a package to open OME-TIFF files in Julia: [GitHub - tlnagy/OMETIFF.jl: I/O operations for OME-TIFF files in Julia](https://github.com/tlnagy/OMETIFF.jl)

```julia
using FileIO
load("path/to/file.ome.tiff")

```

It’s new and still has some limitations (as of 17-08-22)\[1\]

- No support for files \>4gb
- TIFFs split across multiple files don’t work either

but it can open all the basic OME-TIFF files from the [openmicroscopy.org](http://openmicroscopy.org) spec page and load them into the `Images.jl` framework.

* * *

1. I hope to implement these eventually.

---

<div class="post-metadata">

**Author:** ![tim.holy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tim.holy/32/52_2.png) [@tim.holy](https://discourse.julialang.org/u/tim.holy)\
**Post date:** [August 26, 2017, 4:28pm UTC](https://discourse.julialang.org/t/bioformats-in-julia/2440/68 "2017-08-26T16:28:40Z")

</div>

Fantastic work! Really happy to see this.

---

<div class="post-metadata">

**Author:** ![jwu](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jwu/32/3775_2.png) [@jwu](https://discourse.julialang.org/u/jwu)\
**Post date:** [October 5, 2018, 3:04pm UTC](https://discourse.julialang.org/t/bioformats-in-julia/2440/69 "2018-10-05T15:04:40Z")

</div>

I see a related package based on JavaCall.jl:  
[https://github.com/ahnlabb/BioformatsLoader.jl](https://github.com/ahnlabb/BioformatsLoader.jl)

[Previous page](https://discourse.julialang.org/t/bioformats-in-julia/2440.md?page=3)
