Skip to content

Commit

Permalink
Merge pull request #54 from camicroscope/develop
Browse files Browse the repository at this point in the history
For 3.9.4
  • Loading branch information
birm authored Jun 17, 2021
2 parents 5c05199 + ac30f8c commit 73fadfa
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
4 changes: 4 additions & 0 deletions SlideServer.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@
# dataset storage location for the workbench tasks
app.config['DATASET_FOLDER'] = "/images/dataset/"

#creating a uploading folder if it doesn't exist
if not os.path.exists('/images/uploading/'):
os.mkdir('/images/uploading')

# where to put and get slides
app.config['UPLOAD_FOLDER'] = "/images/"
app.config['TEMP_FOLDER'] = "/images/uploading/"
Expand Down
33 changes: 33 additions & 0 deletions get_associated_images.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import openslide
import os

dir = "./PDACG/images/"
out_dir = "./PDACG/images/associated/"

for fn in os.listdir(dir):
if fn.endswith(".svs"):
try:
img = openslide.OpenSlide(dir + fn)
except:
print("[ERR]", fn)
continue
img_rgba = img.associated_images;
if "macro" in img_rgba:
macro_rgb = img_rgba["macro"].convert("RGB");
if "label" in img_rgba:
label_rgb = img_rgba["label"].convert("RGB");
if "thumbnail" in img_rgba:
thumb_rgb = img_rgba["thumbnail"].convert("RGB");
else:
thumb_rgb = img.get_thumbnail((img_w,img_h)).convert("RGB");
fname_pre = out_dir + "/" + os.path.splitext(fn)[0];
if macro_rgb is not None:
fname_out = fname_pre + "-macro.jpg";
macro_rgb.save(fname_out);
if label_rgb is not None:
fname_out = fname_pre + "-label.jpg";
label_rgb.save(fname_out);
if thumb_rgb is not None:
fname_out = fname_pre + "-thumb.jpg";
thumb_rgb.save(fname_out);
print("[OK]", fn)

0 comments on commit 73fadfa

Please sign in to comment.