########################################################################################
# name: Move CV7000 images to subfolders, (deprecated)
# author: Marc Bickle, Martin Stoeter
# category: utilities
# preview:
This script moves all images of one CV7000 measurement into separate folders
for wells (e.g. C04) or well-fields (e.g. C04_F002).
- select folder with CV7000 measurement or folder containing many measurements
- measurement folder is recognized as folder containing correction images ("DC_sCMOS...", "OTF_sCMOS", "back_DC_sCMOS..." or "back_OTF_sCMOS...")
- script runs recursively and goes through all subfolders
######
$$$TEMPLATE_DESC$$$
path =
folderStructure =
.*)_(?P[A-P][0-9]{2})_(?PT[0-9]{4})(?PF[0-9]{3}).*(?PA[0-9]{2})(?PZ[0-9]{0,2})(?PC[0-9]{2}).tif$')
for file in os.listdir("."):
if file.startswith(subDir) and file.endswith("tif"):
#find only the files starting with platename, i.e. the images of interest
res = re.search(pattern, file)
barcode, well, field = res.group("Plate"), res.group("Well"), res.group("Field")
if folderStructure == "wells":
if not os.path.exists(well):
os.makedirs(well)
os.rename(file, well+"/"+file)
if folderStructure == "well-fields":
if not os.path.exists(well+"_"+field):
os.makedirs(well+"_"+field)
os.rename(file, well+"_"+field+"/"+file)
def doSubDir(subDir):
folderWithCV7000images = False #this variable stores the information if this directory is actually the one containing CV7000 images (.tif)
os.chdir(subDir) #go into directory
os.listdir(".") #get all files incl. directories
for file in os.listdir("."):
if os.path.isdir(file): #if it is a directory, go into this function again (as new interation with this subdirectory)
doSubDir(file)
else:
if file.startswith("DC_sCMOS") | file.startswith("back_DC_sCMOS") | file.startswith("OTF_sCMOS") | file.startswith("back_OTF_sCMOS"): #if such a file is found (a correction file), the this folder contains CV7000 images (.tif)
folderWithCV7000images = True
if folderWithCV7000images:
moveImagesToSubDirs(subDir)
os.chdir("..") #go out of subdirectory again
#start of code
os.chdir(path) #change to the directory containing images and then one folder up for recursive folder search
os.chdir("..")
patternDir = re.compile("(.*/)(.*)") #get first folder name and call recursive function
resDir = re.search(patternDir, path)
doSubDir(resDir.group(2))
pyOut = kIn #in is equal to out
]]>
########################################################################################
# name: Move CV7000 images to subfolders, (uses folder name)
# author: Marc Bickle, Martin Stoeter
# category: utilities
# preview:
This script moves all images of one CV7000 measurement into separate folders
for wells (e.g. C04) or well-fields (e.g. C04_F002).
- select folder with CV7000 measurement or folder containing many measurements
- CV7000 image name containing barcode, well, etc. is checked if .tif file starts with barcode name
- script runs recursively and goes through all subfolders
######
$$$TEMPLATE_DESC$$$
path =
folderStructure =
.*)_(?P[A-P][0-9]{2})_(?PT[0-9]{4})(?PF[0-9]{3}).*(?PA[0-9]{2})(?PZ[0-9]{0,2})(?PC[0-9]{2}).tif$')
patternDir = re.compile("(.*/)(.*)") #get first folder name and call recursive function
folderWithCV7000images = False #this variable stores the information if this directory is actually the one containing CV7000 images (.tif)
os.chdir(subDir) #go into directory
os.listdir(".") #get all files incl. directories
for file in os.listdir("."):
if os.path.isdir(file): #if it is a directory, go into this function again (as new interation with this subdirectory)
doSubDir(file)
else:
if file.endswith(".tif"): #if file is an images
res = re.search(pattern, file)
if res != None:
barcode, well, field = res.group("Plate"), res.group("Well"), res.group("Field")
if barcode == subDir: #if file starts with with name of the folder name above
if folderStructure == "wells":
if not os.path.exists(well):
os.makedirs(well)
os.rename(file, well+"/"+file)
if folderStructure == "well-fields":
if not os.path.exists(well+"_"+field):
os.makedirs(well+"_"+field)
os.rename(file, well+"_"+field+"/"+file)
os.chdir("..") #go out of subdirectory again
#start of code
os.chdir(path) #change to the directory containing images and then one folder up for recursive folder search
os.chdir("..")
patternDir = re.compile("(.*/)(.*)") #get first folder name and call recursive function
resDir = re.search(patternDir, path)
doSubDir(resDir.group(2))
pyOut = kIn #in is equal to out
]]>
########################################################################################
# name: Move CV7000 images from subfolders one folder up
# author: Martin Stoeter, Marc Bickle
# category: utilities
# preview:
This script moves all images of a CV7000 measurement from separate folders
one folder up (reverse function of snippet: Move CV7000 images to subfolders)
- select folder with CV7000 measurement or folder containing many measurements
- CV7000 image name containing barcode, well, etc. is checked if .tif file starts with barcode name
- script runs recursively and goes through all subfolders, but doest delete subfolders
######
$$$TEMPLATE_DESC$$$
path =
.*)_(?P[A-P][0-9]{2})_(?PT[0-9]{4})(?PF[0-9]{3}).*(?PA[0-9]{2})(?PZ[0-9]{0,2})(?PC[0-9]{2}).tif$')
folderWithCV7000images = False #this variable stores the information if this directory is actually the one containing CV7000 images (.tif)
os.chdir(subDir) #go into directory
os.listdir(".") #get all files incl. directories
for file in os.listdir("."):
if os.path.isdir(file): #if it is a directory, go into this function again (as new interation with this subdirectory)
doSubDir(file)
else:
if file.endswith(".tif"): #if file is an images
#find only the files starting with platename, i.e. the images of interest
res = re.search(pattern, file)
if res != None:
barcode, well, field = res.group("Plate"), res.group("Well"), res.group("Field")
if well == subDir or well+"_"+field == subDir:
os.rename(file, "../"+file)
os.chdir("..") #go out of subdirectory again
#start of code
os.chdir(path) #change to the directory containing images and then one folder up for recursive folder search
os.chdir("..")
patternDir = re.compile("(.*/)(.*)") #get first folder name and call recursive function
resDir = re.search(patternDir, path)
doSubDir(resDir.group(2))
pyOut = kIn #in is equal to out
]]>
########################################################################################
# name: Compute the intersection of lists
# author: Marc Bickle
# category: relations
# preview:
Computes the intersection of lists (for a Venn diagram use the corresponding Python plot). Accepts 2 or 3 columns of data and returns all possible intersections and the unique values.
######
$$$TEMPLATE_DESC$$$
# b) Define what values to use
features = []
########################################################################################
# name: estimate gaussion intersection
# author: Felix Meyenhofer
# category: statistics
# preview: gaussian-intersection.png
compute the histograms of random variables, fit a gaussian and compute the intersection points.
(use the python figure template with the same name to produce the control plots)
######
$$$TEMPLATE_DESC$$$
# a) Define your treatments of interest
strColName =
# b) Define what numerical values to use
numColName =
# c) number of bins.
nBins = int()
intersection[0]:
o1 = integrate.quad(g1, mue1-sig15, intersection[0])
else:
o1 = integrate.quad(g1, intersection[0], mue1+sig15)
sig25 = sig2*5
i2 = integrate.quad(g2, mue1-sig25, mue1+sig25)
if mue2 > intersection[0]:
o2 = integrate.quad(g2, mue2-sig25, intersection[0])
else:
o2 = integrate.quad(g2, intersection[0], mue2+sig15)
overlap = (o1[0] + o2[0]) / (i1[0] + i2[0])
return (intersection[0], intersection[1], overlap, mue1, sig1, p1[1], p1[2], mue2, sig2, p2[1], p2[2])
# # Control plot.
# sigm = np.max([sig1, sig2])*4
# muemi = np.min([mue1, mue2])
# muema = np.max([mue1, mue2])
# x = np.linspace(muemi-sigm, muema+sigm, 100)
# plot(x, g1(x), 'b', x, g2(x), 'g', intersection[0], intersection[1], 'rx')
# pyOut = {'x coord.':[], 'y coord.':[], 'group a':[], 'mean(a) estimate':[], 'sd(a) estimate':[], 'mean(a) fit':[], 'sd(a) fit':[],
# 'group b':[], 'mean(b) estimate':[], 'sd(b) estimate':[], 'mean(b) fit':[], 'sd(b) fit':[]}
pyOut = OrderedDict()
for key in ['x coord.', 'y coord.', '% overlap', 'group a', 'mean(a) estimate', 'sd(a) estimate', 'mean(a) fit', 'sd(a) fit','group b', 'mean(b) estimate', 'sd(b) estimate', 'mean(b) fit', 'sd(b) fit']:
pyOut[key] = []
vec = kIn[numColName]
cat = kIn[strColName]
sets = {}
for index in range(0,len(vec)-1):
if sets.has_key(cat[index]):
sets[cat[index]].append(vec[index])
else:
sets[cat[index]] = [vec[index]]
keys = sets.keys()
numSets = len(keys)
for a in range(0, numSets-1):
seta = sets[keys[a]]
for b in range(a+1,numSets):
setb = sets[keys[b]]
data = findIntersection(seta, setb)
pyOut['x coord.'].append(data[0])
pyOut['y coord.'].append(data[1])
pyOut['% overlap'].append(data[2])
pyOut['group a'].append(keys[a])
pyOut['mean(a) estimate'].append(data[3])
pyOut['sd(a) estimate'].append(data[4])
pyOut['mean(a) fit'].append(data[5])
pyOut['sd(a) fit'].append(data[6])
pyOut['group b'].append(keys[b])
pyOut['mean(b) estimate'].append(data[7])
pyOut['sd(b) estimate'].append(data[8])
pyOut['mean(b) fit'].append(data[9])
pyOut['sd(b) fit'].append(data[10])
]]>