Skip to content

Instantly share code, notes, and snippets.

@prerakmody
Last active November 29, 2022 16:26
Show Gist options
  • Save prerakmody/9bdaae226c3ad6b731ae0911ce3a29df to your computer and use it in GitHub Desktop.
Save prerakmody/9bdaae226c3ad6b731ae0911ce3a29df to your computer and use it in GitHub Desktop.
Using the timeit command
"""
Data: https://drive.google.com/drive/folders/1zPK--rbdnqK2T0NnTrfvujeSg4PkN_bH?usp=sharing (contains normal_001.tif)
Alternatively: https://aws.amazon.com/marketplace/pp/prodview-exkvqrznup6vc?sr=0-1&ref_=beagle&applicationId=AWSMPContessa#resources
"""
import os
import sys
import timeit
import numpy as np
sys.path.append('C:\\Program Files\\ASAP 2.1\\bin') # https://github.com/computationalpathologygroup/ASAP/releases/tag/ASAP-2.1
import multiresolutionimageinterface as mir
reader = mir.MultiResolutionImageReader()
setup = '''
import os
import sys
import timeit
import numpy as np
sys.path.append('C:\\Program Files\\ASAP 2.1\\bin') # https://github.com/computationalpathologygroup/ASAP/releases/tag/ASAP-2.1
import multiresolutionimageinterface as mir
reader = mir.MultiResolutionImageReader()
'''
statement1 = '''
reader.open('normal_001.tif')
'''
timeit.repeat(statement1, setup, repeat=5, number = 10) # ~0.3 sec
setup = '''
import os
import sys
import timeit
import numpy as np
sys.path.append('C:\\Program Files\\ASAP 2.1\\bin') # https://github.com/computationalpathologygroup/ASAP/releases/tag/ASAP-2.1
import multiresolutionimageinterface as mir
reader = mir.MultiResolutionImageReader()
wsi_img = reader.open('normal_001.tif')
'''
statement1 = '''
np.array(wsi_img.getUCharPatch(10000, 10000, 512, 512, 2))
'''
timeit.repeat(statement1, setup, repeat=5, number = 10) # ~0.07 sec
setup = '''
import os
import sys
import timeit
import numpy as np
sys.path.append('C:\\Program Files\\ASAP 2.1\\bin') # https://github.com/computationalpathologygroup/ASAP/releases/tag/ASAP-2.1
import multiresolutionimageinterface as mir
reader = mir.MultiResolutionImageReader()
wsi_img = reader.open('normal_001.tif')
'''
statement1 = '''
np.array(wsi_img.getUCharPatch(np.random.randint(0,10000), np.random.randint(0,10000), 512, 512, 2))
'''
timeit.repeat(statement1, setup, repeat=5, number = 10) #~ 0.12sec
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment