Start this notebook with DEBUG=matrixscreener ipython notebook for debug output.


In [2]:
import matrixscreener as ms
e = ms.experiment.Experiment('../tests/experiment--test/')

In [3]:
from PIL import Image
i = Image.open(e.images[0])
i.info


Out[3]:
{'compression': 'raw', 'dpi': (105716.63707131297, 105716.63707131297)}

In [4]:
from IPython.display import Math
# pixel size in microns
Math(str(0.254 / _3['dpi'][0] * 1e6) + '\mu m')


Out[4]:
$$2.402649261616787\mu m$$

In [5]:
!du -h -d 1 ../tests/experiment--test/


4.4M	../tests/experiment--test//slide--S00
4.4M	../tests/experiment--test/

In [6]:
filename = e.images[0]
!ls -l $filename


-rw-r--r--  1 arve  staff  1055760 Feb  3 23:09 ../tests/experiment--test/slide--S00/chamber--U00--V00/field--X00--Y00/image--L00--S00--U00--V00--J20--E00--O00--X00--Y00--T00--Z00--C00.ome.tif

In [8]:
import numpy as np
orig = np.array(i)

In [9]:
ms.experiment.compress(e.images, delete_tif=True)
!du -h -d 1 ../tests/experiment--test/


1.6M	../tests/experiment--test//slide--S00
1.6M	../tests/experiment--test/

In [10]:
filename = e.images[0]
!ls -l $filename


-rw-r--r--  1 arve  staff  280843 Feb  3 23:33 ../tests/experiment--test/slide--S00/chamber--U00--V00/field--X00--Y00/image--L00--S00--U00--V00--J20--E00--O00--X00--Y00--T00--Z00--C00.png

In [11]:
i = Image.open(filename)
compressed = np.array(i)

In [12]:
ms.experiment.decompress(e.images, delete_png=True, delete_json=True)
!du -h -d 1 ../tests/experiment--test/


4.4M	../tests/experiment--test//slide--S00
4.4M	../tests/experiment--test/

In [13]:
filename = e.images[0]
!ls -l $filename


-rw-r--r--  1 arve  staff  1055760 Feb  3 23:34 ../tests/experiment--test/slide--S00/chamber--U00--V00/field--X00--Y00/image--L00--S00--U00--V00--J20--E00--O00--X00--Y00--T00--Z00--C00.ome.tif

In [14]:
i = Image.open(filename)
decompressed = np.array(i)

In [15]:
# compare data
np.all(orig == compressed)


Out[15]:
True

In [16]:
np.all(orig == decompressed)


Out[16]:
True