def tile_lims(stack, num_std, bar=True, size=20): from showit import tile if type(stack) is list: stack = np.array(stack) stats = stack_describe(stack) lims = [s['mean'] + num_std * s['std'] for s in stats] tile(stack, bar=bar, clim=list(zip([0] * len(lims), lims)), size=size)
def show(args, print_help=False): import matplotlib.pyplot as plt from showit import tile from .io import Stack s = Stack() s.read(args.in_json) tile(s.image.squeeze(), size=args.sz, bar=True) plt.show()
def show(args, print_help=False): import matplotlib.pyplot as plt from showit import tile from .experiment import Experiment s = Experiment() s.read(args.in_json) tile(s.image.squeeze(), size=args.sz, bar=True) plt.show()
def show(in_json, sz): import matplotlib.pyplot as plt from showit import tile from .experiment import Experiment s = Experiment() s.read(in_json) tile(s.image.squeeze(), size=sz, bar=True) plt.show()
def main(): # these samples will be automatically downloaded if they are not found locally dataset = loader.load(samples=[ '4bad52d5ef5f68e87523ba40aa870494a63c318da7ec7609e486e62f7f7a25e8', 'a7e37600a431fa6d6023514df87cfc8bb5ec028fb6346a10c2ececc563cc5423', '70a6300a00dbac92be9238252ee2a75c86faf4729f3ef267688ab859eed1cc60' ]) # this transform will cause the dataset to find the mean image of a movie # anytime an item is requested from the dataset transform = preprocess.Mean() dataset.set_transform(transform) mean_images = list() for i in range(len(dataset)): sample = dataset[i] # mean transform has already been applied! mean_images.append(sample) tile(mean_images) plt.show()
def test_tile(): im = random.randn(5, 25, 25) tile(im)
# EPY: START markdown # ## Raw Data # # The raw data can be downloaded and formatted for analysis by running: ```python examples/get_iss_data.py ><raw data directory> <output directory> --d 1``` from the Starfish directory # EPY: END markdown # EPY: START code from starfish.io import Stack # replace <output directory> with where you saved the formatted data to with the above script in_json = '<output directory>/org.json' s = Stack() s.read(in_json) tile(s.squeeze(), size=10) # EPY: END code # EPY: START code image(s.aux_dict['dots'], size=10) # EPY: END code # EPY: START markdown # ## Register # EPY: END markdown # EPY: START code from starfish.registration._fourier_shift import compute_shift, shift_im upsample = 1000
import numpy as np import pandas as pd import matplotlib.pyplot as plt from showit import image, tile import pprint # EPY: ESCAPE %matplotlib inline from starfish.io import Stack from starfish.constants import Indices s = Stack() s.read( 'https://dmf0bdeheu4zf.cloudfront.net/20180611/ISS/fov_001/experiment.json' ) # s.image.squeeze() simply converts the 4D tensor H*C*X*Y into a list of len(H*C) image planes for rendering by 'tile' tile(s.image.squeeze()) # EPY: END code # EPY: START markdown # ## Show input file format that specifies how the tiff stack is organized # # The stack contains multiple single plane images, one for each color channel, 'ch', (columns in above image) and hybridization round, 'hyb', (rows in above image). This protocol assumes that genes are encoded with a length 4 quatenary barcode that can be read out from the images. Each hybridization encodes a position in the codeword. The maximum signal in each color channel (columns in the above image) corresponds to a letter in the codeword. The channels, in order, correspond to the letters: 'T', 'G', 'C', 'A'. The goal is now to process these image data into spatially organized barcodes, e.g., ACTG, which can then be mapped back to a codebook that specifies what gene this codeword corresponds to. # EPY: END markdown # EPY: START code pp = pprint.PrettyPrinter(indent=2) pp.pprint(s.org) # EPY: END code # EPY: START markdown # The flat TIFF files are loaded into a 4-d tensor with dimensions corresponding to hybridization round, channel, x, and y. For other volumetric approaches that image the z-plane, this would be a 5-d tensor.
import numpy as np import matplotlib.pyplot as plt import pickle from pathlib import Path from showit import tile #%% Import training data training_data = pd.read_pickle( '/home/alex/Documents/DataProjects/Data/MBI/ProstateX/generated/train/dataframes/training.pkl' ) #%% Plot grid of t2 significant findings t2_train = training_data[(training_data['sequence_type'] == 't2') & (training_data['ClinSig'] == True)] t2_patches = t2_train['patch'].values tile(t2_patches, grid=(50, 8), size=60) #%% Plot grid of adc significant findings adc_train = training_data[(training_data['sequence_type'] == 'adc') & (training_data['ClinSig'] == True)] adc_patches = adc_train['patch'].values tile(adc_patches, grid=(50, 8), size=60) #%% Plot grid of bval significant findings bval_train = training_data[(training_data['sequence_type'] == 'bval') & (training_data['ClinSig'] == True)] bval_patches = bval_train['patch'].values tile(bval_patches, grid=(50, 8), size=60) #%% Plot grid of ktrans significant findings ktrans_train = training_data[(training_data['sequence_type'] == 'ktrans')
# EPY: START markdown # ## Raw Data # # The raw data can be downloaded and formatted for analysis by running: ```python examples/get_iss_data.py ><raw data directory> <output directory> --d 1``` from the Starfish directory # EPY: END markdown # EPY: START code from starfish.io import Stack # replace <output directory> with where you saved the formatted data to with the above script in_json = '<output directory>/org.json' s = Stack() s.read(in_json) tile(s.image.squeeze(), size=10); # EPY: END code # EPY: START code image(s.auxiliary_images['dots'], size=10) # EPY: END code # EPY: START markdown # ## Register # EPY: END markdown # EPY: START code from starfish.pipeline.registration import Registration registration = Registration.fourier_shift(upsampling=1000) registration.register(s)
""" Author: Alex Hamilton - https://github.com/alexhamiltonRN Created: 2018-11-17 Description: A script to plot significant findings in numpy arrays. """ #%% import pandas as pd import numpy as np import matplotlib.pyplot as plt import pickle from pathlib import Path from showit import tile #%% T2 Train t2_train = np.load('/home/alex/Documents/DataProjects/Data/MBI/ProstateX/generated/train/numpy/t2/X_train.npy') tile(t2_train, grid=(70,8), size = 60) #%% ADC Train adc_train = np.load('/home/alex/Documents/DataProjects/Data/MBI/ProstateX/generated/train/numpy/adc/X_train.npy') tile(adc_train, grid=(70,8), size = 60) #%% BVAL Train bval_train = np.load('/home/alex/Documents/DataProjects/Data/MBI/ProstateX/generated/train/numpy/bval/X_train.npy') tile(bval_train, grid=(70,8), size = 60) #%% KTRANS Train ktrans_train = np.load('/home/alex/Documents/DataProjects/Data/MBI/ProstateX/generated/train/numpy/ktrans/X_train.npy') tile(ktrans_train, grid=(70,8), size = 60)