This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 2 functions to create big pickle files (>2 gb) and read them back into python | |
def write_big_pkl(obj, path): | |
"""Pickle obj, where obj is a >2 gb object. | |
Args: | |
obj: The object to be pickled. | |
path: The absolute path to save the pickle to. | |
""" | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# c_foci = an array with numbers indicating where foci are (e.g. all voxels corresponding to focus #1 = 1, all vx corresp to foci #2 = 2, etc.) | |
# segmented_cells = an array with #s indicating where cells are, same format as c_foci | |
# x = focus ID that is being checked for parent cells | |
if verbose: | |
print('current ID: ' + str(x)) | |
parent_cell, cell_cts = np.unique( | |
self.segmented_cells[i][c_foci == x], | |
return_counts=True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
foci_cts_dict = {} | |
for i in np.unique(cells): # gets the unique IDs of the cells | |
if i == 0: # if it's bgrd | |
continue | |
else | |
overlapping_foci = np.unique(seg_foci[cells == i]) # gets the unique IDs for each focus in the cell, as well as the bgrd | |
num_foci = overlapping_foci.shape[0]-1 # shape[0] is the length of the overlapping_foci array; subtract bgrd | |
foci_cts_dict[i] = num_foci # add a key:value pair to foci_cts_dict where key is cell # and val is num of foci | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
os.chdir(img_dir) | |
flist = os.listdir() | |
imgs = [f for f in flist if '.tif' in f.lower()] | |
pex_imgs = [im for im in imgs if '594' in im] | |
mito_imgs = [im for im in imgs if '447' in im] | |
pex_imgs.sort() | |
mito_imgs.sort() | |
if len(pex_imgs) != len(mito_imgs): | |
raise ValueError('Length of pex and mito img sets do not match.') | |
ims_per_job = int(len(pex_imgs)/array_l) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# imports | |
import pandas as pd | |
import os | |
import ftplib as FTP | |
import urllib | |
from xml.etree import ElementTree as ET | |
import subprocess | |
# next line is the request url that I was using; everything after the first ? is the query terms. | |
# there's a place somewhere on pubmed (can't remember where) where you can get the string to use there. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data = {'x': ["0-7 days", "7-30 days", "31-90 days", ">90 days"], | |
'All dogs': [41.4391, 34.8107, 15.6709, 4.4533], | |
'Filtered': [0, 0, 0, 0]} | |
source = ColumnDataSource(data=data) | |
callback = CustomJS(args=dict(source=source), code=""" | |
$.ajax({ | |
url: '/_ajax', | |
data: $("#filter_form").serialize(), | |
type: 'GET', | |
success: function(response) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import spacenetutilities.labeltools.coreLabelTools as cLT | |
import os | |
import argparse | |
import re | |
argparser = argparse.ArgumentParser() | |
argparser.add_argument('--geojson_src_dir', '-j', type=str, required=True, | |
help='Path to the directory containing geojsons. If ' + | |
'the referenced directory contains subdirectories ' + | |
'that must be searched, the `--recursive` argument ' + |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import rasterio | |
import geopandas as gpd | |
def transform_gdf(gdf, geotiff): | |
"""Transform the coordinates of a GeoDataFrame. | |
Arguments | |
--------- | |
gdf : gpd.GeoDataFrame | |
A geodataframe with an identity affine xform. |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.