hwanglab / wsitiler Goto Github PK
View Code? Open in Web Editor NEWTools for dividing pathology whole slide images into tiles and save them as individual files.
License: GNU General Public License v3.0
Tools for dividing pathology whole slide images into tiles and save them as individual files.
License: GNU General Public License v3.0
Allow user to select Resolution/Power of WSI that will be tiled, and the size of the tile (either pixels or microns) instead of only microns per tile at max resolution.
Add .npy file format option for saving tiles
TILES_DIRECTORY
├── tiles
├── image_id_0
├── tile_id_0.npy
├── tile_id_1.npy
└── ...
├── image_id_1
├── tile_id_0.npy
├── tile_id_1.npy
└── ...
└── ...
├── info
├── image_id_0
├── tissue_mask_thumbnail.png
├── tiled_slide_thumbnail.png
├── original_slide_thumbnail.png
└── tile_reference.tsv
└── ...
Normalization tends to have errors and is not stable.
Add an annotator
module to label tiles in the appropriate csv file and export thumbnails.
Implement such that annotations may be imported from:
Implement export of annotations from csv file in the following format
If tiling on a WSI level that is not the maximum magnification, the tiles do not match the expected location.
openslide read region does not cut out the expected region at the expected magnification.
Exporting tiles at maximum magnification works with no issues
Separate the tile images' save location and tile information files' (e.g., tissue thumbnail image, reference .tsv file) save location
TILES_DIRECTORY
├── tiles
├── image_id_0
├── tile_id_0.png
├── tile_id_1.png
└── ...
├── image_id_1
├── tile_id_0.png
├── tile_id_1.png
└── ...
└── ...
├── info
├── image_id_0
├── tissue_mask_thumbnail.png
├── tiled_slide_thumbnail.png
├── original_slide_thumbnail.png
└── tile_reference.tsv
└── ...
When running tiler.py
as a command line script using the deployed WSItiler module through pop installation, there is an error during the tile export multiprocessing step.
command:
python -m wsitiler.tiler -i blca_wsi/ -o test_tiles/ -t -vvvv -c 20 -n None
error output:
Starting tiling run
Run Arguments: {'input': 'blca_wsi/', 'output': 'test_tiles/', 'cores': 20, 'microns_per_tile': 256, 'normalizer': 'None', 'final_tile_size': 224, 'foreground_threshold': 0, 'normalizer_reference': 'None', 'verbose': 4, 'tissue_chunk_id': True}
Found WSI images. Starting Processing
The following WSIs were found:
1: blca_wsi/TCGA-DK-A3IM-01Z-00-DX1.ED1A8B22-566E-4A95-AF6D-7C9E536BE2B7.svs
1 - Processing blca_wsi/TCGA-DK-A3IM-01Z-00-DX1.ED1A8B22-566E-4A95-AF6D-7C9E536BE2B7.svs
1 - Generating tile reference and mask
1 - Tile Reference Time: 8.800365
1 - Initializing normalizer
1 - Normalizer method: None
Normalizer reference: None
1 - Exporting tiles
1 - Pool size: 20 cores
XIO: fatal IO error 22 (Invalid argument) on X server ":1"
after 622 requests (622 known processed) with 4 events remaining.
XIO: fatal IO error 25 (Inappropriate ioctl for device) on X server ":1"
after 627 requests (627 known processed) with 6 events remaining.
Terminated
If you run import wsitiler.normalizer as norm
and try to instantiate an object like:
obj = norm.MacenkoNormalizer.MacenkoNormalizer()
, then MacenkoNormalizer
can't be found:
AttributeError: module 'wsitiler.normalizer' has no attribute 'MacenkoNormalizer'
However, if we import as import wsitiler.normalizer.MacenkoNormalizer as norm
then we CAN call norm.MacenkoNormalizer()
When tiling a slide with large holes in the tissue, the foreground detection steps fills the holes using "binary_fill_holes". This causes some tiles to be empty even though they are marked as being 100% tissue. In turn, the normalization step runs into problems.
/media/clemenj/data/Projects/WSItiler/wsitiler/normalizer/MacenkoNormalizer.py:90: RuntimeWarning: Degrees of freedom <= 0 for slice
eigvals, eigvecs = np.linalg.eigh(np.cov(ODhat.T))
/home/clemenj/miniconda3/envs/WSItiler/lib/python3.9/site-packages/numpy/lib/function_base.py:2493: RuntimeWarning: divide by zero encountered in true_divide
c *= np.true_divide(1, fact)
/home/clemenj/miniconda3/envs/WSItiler/lib/python3.9/site-packages/numpy/lib/function_base.py:2493: RuntimeWarning: invalid value encountered in multiply
c *= np.true_divide(1, fact)
/media/clemenj/data/Projects/WSItiler/wsitiler/normalizer/MacenkoNormalizer.py:117: RuntimeWarning: overflow encountered in exp
Inorm = np.multiply(Io, np.exp(-self.HERef.dot(C2)))
/media/clemenj/data/Projects/WSItiler/wsitiler/normalizer/MacenkoNormalizer.py:122: RuntimeWarning: overflow encountered in exp
H = np.multiply(Io, np.exp(np.expand_dims(-se
lf.HERef[:, 0], axis=1).dot(np.expand_dims(C2[0, :], axis=0))))
/media/clemenj/data/Projects/WSItiler/wsitiler/normalizer/MacenkoNormalizer.py:117: RuntimeWarning: overflow encountered in exp
Inorm = np.multiply(Io, np.exp(-self.HERef.dot(C2)))
/media/clemenj/data/Projects/WSItiler/wsitiler/normalizer/MacenkoNormalizer.py:117: RuntimeWarning: overflow encountered in multiply
Inorm = np.multiply(Io, np.exp(-self.HERef.dot(C2)))
/media/clemenj/data/Projects/WSItiler/wsitiler/normalizer/MacenkoNormalizer.py:122: RuntimeWarning: overflow encountered in exp
H = np.multiply(Io, np.exp(np.expand_dims(-self.HERef[:, 0], axis=1).dot(np.expand_dims(C2[0, :], axis=0))))
/media/clemenj/data/Projects/WSItiler/wsitiler/normalizer/MacenkoNormalizer.py:122: RuntimeWarning: overflow encountered in multiply
H = np.multiply(Io, np.exp(np.expand_dims(-self.HERef[:, 0], axis=1).dot(np.expand_dims(C2[0, :], axis=0))))
Add module to automatically generate heatmap images according to the tile csv map.
/opt/conda/lib/python3.7/site-packages/numpy/lib/function_base.py:380: RuntimeWarning: Mean of empty slice.
avg = a.mean(axis)
/opt/conda/lib/python3.7/site-packages/numpy/core/_methods.py:163: RuntimeWarning: invalid value encountered in true_divide
ret, rcount, out=ret, casting='unsafe', subok=False)
/home/ext_choi_jinhwan_mayo_edu/bucket_data/lab_members/jinhwan/wsitiler/wsitiler/normalizer/MacenkoNormalizer.py:90: RuntimeWarning: Degrees of freedom <= 0 for slice
eigvals, eigvecs = np.linalg.eigh(np.cov(ODhat.T))
/opt/conda/lib/python3.7/site-packages/numpy/lib/function_base.py:2480: RuntimeWarning: divide by zero encountered in true_divide
c *= np.true_divide(1, fact)
/opt/conda/lib/python3.7/site-packages/numpy/lib/function_base.py:2480: RuntimeWarning: invalid value encountered in multiply
c *= np.true_divide(1, fact)
/home/ext_choi_jinhwan_mayo_edu/bucket_data/lab_members/jinhwan/wsitiler/wsitiler/normalizer/MacenkoNormalizer.py:117: RuntimeWarning: overflow encountered in exp
Inorm = np.multiply(Io, np.exp(-self.HERef.dot(C2)))
/home/ext_choi_jinhwan_mayo_edu/bucket_data/lab_members/jinhwan/wsitiler/wsitiler/normalizer/MacenkoNormalizer.py:122: RuntimeWarning: overflow encountered in exp
H = np.multiply(Io, np.exp(np.expand_dims(-self.HERef[:, 0], axis=1).dot(np.expand_dims(C2[0, :], axis=0))))
/home/ext_choi_jinhwan_mayo_edu/bucket_data/lab_members/jinhwan/wsitiler/wsitiler/normalizer/MacenkoNormalizer.py:122: RuntimeWarning: overflow encountered in multiply
H = np.multiply(Io, np.exp(np.expand_dims(-self.HERef[:, 0], axis=1).dot(np.expand_dims(C2[0, :], axis=0))))
/home/ext_choi_jinhwan_mayo_edu/bucket_data/lab_members/jinhwan/wsitiler/wsitiler/normalizer/MacenkoNormalizer.py:117: RuntimeWarning: overflow encountered in exp
Inorm = np.multiply(Io, np.exp(-self.HERef.dot(C2)))
/home/ext_choi_jinhwan_mayo_edu/bucket_data/lab_members/jinhwan/wsitiler/wsitiler/normalizer/MacenkoNormalizer.py:126: RuntimeWarning: overflow encountered in exp
E = np.multiply(Io, np.exp(np.expand_dims(-self.HERef[:, 1], axis=1).dot(np.expand_dims(C2[1, :], axis=0))))
a tiff image might not have the preparties, 'openslide.mpp-x' and 'openslide.objective-power'
float(wsi_object.properties['openslide.mpp-x'])
Traceback (most recent call last):
File "", line 1, in
File "/opt/conda/envs/pytorch_env/lib/python3.7/site-packages/openslide/init.py", line 278, in getitem
raise KeyError()
KeyError
Implement appropriate verbose notices using the logging
module.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.