Skip to content

Instantly share code, notes, and snippets.

View 3dimaging's full-sized avatar
🎯
Focusing

Weizhe Li 3dimaging

🎯
Focusing
View GitHub Profile
I did this under python3.5, which is the default version for python3 in Ubuntu
sudo apt-get install python3-tk
sudo apt-get install libpython3.6-dev
pip3 install matplotlib numpy
then download ASAP from the website: https://github.com/computationalpathologygroup/ASAP/releases
@3dimaging
3dimaging / gist:c57c85d61eddb0c5b131eb94126551a6
Created June 27, 2018 16:06
get annotation overlay with images by using python
#!/usr/bin/env python3
import multiresolutionimageinterface as mir
import matplotlib.pyplot as plt
import cv2
import numpy as np
reader = mir.MultiResolutionImageReader()
mr_image = reader.open('/home/wli/Downloads/tumor_036.tif')
Ximageorg, Yimageorg = mr_image.getDimensions()
#!/usr/bin/env python3
import multiresolutionimageinterface as mir
import matplotlib.pyplot as plt
reader = mir.MultiResolutionImageReader()
mr_image = reader.open('/home/wli/Downloads/tumor_009.tif')
# dims=mr_image.getLevelDimensions(6)
# tile = mr_image.getUCharPatch(0, 0, dims[0], dims[1], 6)
# plt.imshow(tile)
# plt.show()
#!/usr/bin/env python3
import multiresolutionimageinterface as mir
import matplotlib.pyplot as plt
import os.path as osp
import openslide
import matplotlib.pyplot as plt
from pathlib import Path
import glob
#please make sure the same number of files in the folder of tumor file and folder of annotation files
#please change the slide_path, anno_path, mask_path accordingly, and leave everything else untouched.
@3dimaging
3dimaging / googlenet.py
Created September 10, 2018 19:11 — forked from joelouismarino/googlenet.py
GoogLeNet in Keras
from scipy.misc import imread, imresize
from keras.layers import Input, Dense, Convolution2D, MaxPooling2D, AveragePooling2D, ZeroPadding2D, Dropout, Flatten, merge, Reshape, Activation
from keras.models import Model
from keras.regularizers import l2
from keras.optimizers import SGD
from googlenet_custom_layers import PoolHelper,LRN
def create_googlenet(weights_path=None):
@3dimaging
3dimaging / sgdr.py
Created September 17, 2018 19:10 — forked from jeremyjordan/sgdr.py
Keras Callback for implementing Stochastic Gradient Descent with Restarts
from keras.callbacks import Callback
import keras.backend as K
import numpy as np
class SGDRScheduler(Callback):
'''Cosine annealing learning rate scheduler with periodic restarts.
# Usage
```python
schedule = SGDRScheduler(min_lr=1e-5,
#!/usr/bin/env python3
import multiresolutionimageinterface as mir
import matplotlib.pyplot as plt
import os.path as osp
import openslide
import matplotlib.pyplot as plt
from pathlib import Path
import glob
import re
#please make sure the same number of files in the folder of tumor file and folder of annotation files
#!/usr/bin/env python3
#If you need more information about how ElementTree package handle XML file, please follow the link:
#https://docs.python.org/3/library/xml.etree.elementtree.html
#import multiresolutionimageinterface as mir
import matplotlib.pyplot as plt
import cv2
#!/usr/bin/env python3
#If you need more information about how ElementTree package handle XML file, please follow the link:
#https://docs.python.org/3/library/xml.etree.elementtree.html
#import multiresolutionimageinterface as mir
import matplotlib.pyplot as plt
import cv2
@3dimaging
3dimaging / RF_training.py
Created May 7, 2019 20:40
updated050719
import numpy as np
from sklearn.metrics import roc_curve, precision_recall_curve, auc, average_precision_score
from sklearn.model_selection import train_test_split
from sklearn.ensemble import RandomForestClassifier
from sklearn.metrics import roc_auc_score
import pandas as pd
import pickle
#read in files
X_tumor = pd.read_csv('/home/wzli/Downloads/PF_parameter_MethodII_no_norm/data_sheet_for_random_forest_16_strike_tumor_9_0502_Method_II_no_norm.csv')
X_normal = pd.read_csv('/home/wzli/Downloads/PF_parameter_MethodII_no_norm/data_sheet_for_random_forest_16_strike_normal_9_0502_Method_II_no_norm.csv')