Code Monkey home page Code Monkey logo

wsitiler's People

Contributors

jeanrclemenceau avatar

Stargazers

 avatar

wsitiler's Issues

Improve tile resolution and size selection

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

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

	            └── ... 

Improve Normalization

Normalization tends to have errors and is not stable.

  • Improve implementation of normalizer
  • add other normalization options.

Add "annotator" module

Add an annotator module to label tiles in the appropriate csv file and export thumbnails.

Implement such that annotations may be imported from:

  • xml files
  • geojson files (Qupath compatibility)
  • heatmap images (continuous values; requires threshold)
  • heatmap mask images (binary values)

Implement export of annotations from csv file in the following format

  • geojson
  • mask image

Fix export when not using highest magnification

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 and save location

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

	            └── ... 

Fatal IO Error

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

MacenkoNormalizer not recognized when importing wsitiler.normalizer

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

Normalization on tissue with large gaps may cause errors

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.
sample_hole_tissue

/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 "heatmapper" module

Add module to automatically generate heatmap images according to the tile csv map.

  • Allow assigning a feature to each of the R,G,and B channels
  • Allow assigning a color pallate for continous variables

get rid of RuntimeWarning

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

error when handling .tiff extension images.

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 Logging appropriately

Implement appropriate verbose notices using the logging module.

  • Save running parameters in debug mode
  • track memory usage in debug mode

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.