Skip to content

Commit

Permalink
change the tiffslide to openslide
Browse files Browse the repository at this point in the history
  • Loading branch information
benmalef committed Oct 18, 2024
1 parent f2e0d92 commit e01b1bb
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 9 deletions.
3 changes: 3 additions & 0 deletions Dockerfile-CPU
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@ RUN python3.9 -m pip install -e .
# Entrypoint forces all commands given via "docker run" to go through python, CMD forces the default entrypoint script argument to be gandlf run
# If a user calls "docker run gandlf:[tag] anonymize", it will resolve to running "gandlf anonymize" instead.
# CMD is inherently overridden by args to "docker run", entrypoint is constant.
ENV LD_LIBRARY_PATH="/usr/local/lib/python3.9/dist-packages/openslide_bin:$LD_LIBRARY_PATH"

ENTRYPOINT gandlf
CMD run
#CMD /bin/bash

# The below force the container commands to run as a nonroot user with UID > 10000.
# This greatly reduces UID collision probability between container and host, helping prevent privilege escalation attacks.
Expand Down
2 changes: 1 addition & 1 deletion GANDLF/compute/inference_loop.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from skimage.io import imsave
from tqdm import tqdm
from torch.cuda.amp import autocast
import tiffslide as openslide
import openslide
from GANDLF.data import get_testing_loader
from GANDLF.utils import (
best_model_path_end,
Expand Down
2 changes: 1 addition & 1 deletion GANDLF/data/inference_dataloader_histopath.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
from typing import Optional
import numpy as np
import tiffslide
import openslide
from GANDLF.data.patch_miner.opm.utils import get_patch_size_in_microns, tissue_mask
from skimage.transform import resize
from torch.utils.data.dataset import Dataset
Expand Down
7 changes: 3 additions & 4 deletions GANDLF/data/patch_miner/opm/patch_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
from tqdm import tqdm
from pathlib import Path
import pandas as pd
import openslide as tiffslide

import openslide

class PatchManager:
def __init__(self, filename, output_dir):
Expand Down Expand Up @@ -41,7 +40,7 @@ def set_subjectID(self, subjectID):
def set_slide_path(self, filename):
self.img_path = filename
self.img_path = convert_to_tiff(self.img_path, self.output_dir, "img")
self.slide_object = tiffslide.open_slide(self.img_path)
self.slide_object = openslide.open_slide(self.img_path)
self.slide_dims = self.slide_object.dimensions

def set_label_map(self, path):
Expand All @@ -50,7 +49,7 @@ def set_label_map(self, path):
@param path: path to label map.
"""
self.label_map = convert_to_tiff(path, self.output_dir, "mask")
self.label_map_object = tiffslide.open_slide(self.label_map)
self.label_map_object = openslide.open_slide(self.label_map)

assert all(
x == y for x, y in zip(self.label_map_object.dimensions, self.slide_dims)
Expand Down
4 changes: 2 additions & 2 deletions GANDLF/data/patch_miner/opm/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

# import matplotlib.pyplot as plt
import yaml
import openslide as tiffslide
import openslide

# RGB Masking (pen) constants
RGB_RED_CHANNEL = 0
Expand Down Expand Up @@ -428,7 +428,7 @@ def generate_initial_mask(slide_path: str, scale: int) -> Tuple[np.ndarray, tupl
Tuple[np.ndarray, tuple]: The valid mask and the real scale.
"""
# Open slide and get properties
slide = tiffslide.open_slide(slide_path)
slide = openslide.open_slide(slide_path)
slide_dims = slide.dimensions

# Call thumbnail for effiency, calculate scale relative to whole slide
Expand Down
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
"setuptools",
"seaborn",
"pyyaml==6.0.1",
"tiffslide",
"matplotlib",
"gdown==5.1.0",
"pytest",
Expand Down

0 comments on commit e01b1bb

Please sign in to comment.