示例#1
1
def main():
    # Open a .ome.tif image from the Flexoscope.
    impath = IJ.getFilePath("Choose .ome.tiff file")
    channels = Opener.openUsingBioFormats(impath)

    # Show image
    # imp.show() # straight to channels object sames memory.

    # Split channels.
    channels = ChannelSplitter().split(channels)

    # Process channel 1.
    # subtractzproject(imp, projectionMethod="Median")
    channels[1] = ImagePlus()
    channels.append(ImagePlus())
    channels[1] = subtractzproject(channels[0])
    IJ.run(channels[0], "Enhance Contrast...", "saturated=0.3 normalize process_all use")
    IJ.run(channels[0], "8-bit", "") 
    IJ.run(channels[1], "Square", "stack")
    IJ.run(channels[1], "Enhance Contrast...", "saturated=0.3 normalize process_all use")
    IJ.run(channels[1], "8-bit", "") 

    # Merge channels.
    merge = RGBStackMerge().mergeChannels(channels, True) # boolean keep
    merge.show()
示例#2
0
def main():
    # Open a .ome.tif image from the Flexoscope.
    impath = IJ.getFilePath("Choose .ome.tiff file")
    channels = Opener.openUsingBioFormats(impath)
    cal = channels.getCalibration()

    # Show image
    # imp.show() # straight to channels object sames memory.

    # Split channels.
    channels = ChannelSplitter().split(channels)

    # Process channel 1.
    # subtractzproject(imp, projectionMethod="Median")
    channels[0] = subtractzproject(channels[0])
    IJ.run(channels[0], "8-bit", "") 

    # Process channel 2.
    # glidingprojection(imp, startframe=1, stopframe=None, glidingFlag=True, no_frames_per_integral=3, projectionmethod="Median")
    channels[1] = glidingprojection(channels[1]) 
    IJ.run(channels[1], "8-bit", "") 

    # [Optional] Process channel 3, 4, etc.
    # subtractzproject(channels[3], projectionMethod="Median")
    # glidingprojection(channels[3], startframe=1, stopframe=None, glidingFlag=True, no_frames_per_integral=3, projectionmethod="Median")
    # IJ.run(channels[3], "8-bit", "") 

    # Merge channels.
    merge = RGBStackMerge().mergeChannels(channels, True) # boolean keep
    merge.setCalibration(cal)
    merge.show()
def iter_rois_fwhm(roi_path, img_path):
    roi = readRois(roi_path)
    img = Opener.openUsingBioFormats(img_path)
    title = str(img.getShortTitle())
    all_out = []
    for i in roi.getIndexes():
        roi.select(img, i)
        x, y = getXY(img)
        fwhm, r2, params = fit_curve(x, y)
        all_out.append({
            "fwhm": fwhm,
            "r2": r2,
            "roi_id": i,
            "ch_n": 2,
            "img_name": title,
            "ch_name": "NaV1.6",
        })
    roi.close()
    img.close()
    return all_out
示例#4
0
	for filename in filenames:
		match = re.search(pattern, filename)
		if match is not None:
			#print filename, match.group(3)
			GRlist.append(match.group(3))

print srcDir
print 'files: ', len(GRlist)

GRlist = sorted(GRlist)
timeseries = []

for timepoint in GRlist:
	thisfile = basename + '_R' + repetition + '_GR' + timepoint + '_B' + block + '_L' + location + '.lsm'
	print thisfile
	imp = Opener.openUsingBioFormats(os.path.join(srcDir, thisfile))
	imp.setOpenAsHyperStack(False)
	timeseries.append(imp)

newname = basename + '_R' + repetition + '_B' + block + '_L' + location + '.lsm'
calib = timeseries[0].getCalibration()
dimA = timeseries[0].getDimensions()
jaimp = array(timeseries, ImagePlus)
ccc = Concatenator()
#allimp = ccc.concatenateHyperstacks(jaimp, newname, False)
allimp = ccc.concatenate(jaimp, False)
allimp.setDimensions(dimA[2], dimA[3], len(GRlist))
allimp.setCalibration(calib)
allimp.setOpenAsHyperStack(True)
allimp.show()
IJ.run("Collect Garbage");
#inputDir1 = IJ.getDirectory("Choose image directory! ")
inputDir1 = "/home/mt/Downloads/1/"
fileList1 = os.listdir(inputDir1); 
###tilestring=getString("Which Tilescan", "1")
RGB=os.path.join(inputDir1,'RGB.png')
	
FileList=sorted(os.listdir(inputDir1))
print(FileList)
stitchedFiles=[x for x in FileList if "stitched.TIF" in x]
stitchedNames=[x.split('_')[0] for x in stitchedFiles]

mergedFiles=[x for x in FileList if "merged.TIF" in x]

imp = Opener.openUsingBioFormats(os.path.join(inputDir1,mergedFiles[0]))
xsize=imp.getWidth()
ysize=imp.getHeight()
imp.close()

print(xsize,ysize)

for im in stitchedFiles:
    if not "hoechst" in im.lower():
        IJ.open(inputDir1+im)
        imp = IJ.getImage()
        imp.setTitle(im.split('_')[0])
IJ.run("Images to Stack", "name=Stack title=[] use")
imp = IJ.getImage()
#IJ.run("Multiply...", "value=2.2")
IJ.beep()
image_basenames = list(set(image_basenames))
print(image_basenames)
ImageJ()
for i in image_basenames:
    print(i)
    cur_images = []
    for j in image_list:
        m = re.search(i, j)
        if m:
            cur_images.append(j)

#    imp_c1 = IJ.openImage(cur_images[0])
#    imp_c2 = IJ.openImage(cur_images[1])
    image_path = image_directory + cur_images[2]
    imp_c3 = Opener.openUsingBioFormats(image_path)
    imp_c3.show()
    save_name = image_directory + '/Stacks/' + i + 'merged.tif'
    IJ.saveAsTiff(imp_c3, save_name)
    #    merge_string = "c1=" + cur_images[0] + " c2=" + cur_images[1] + " create";
    #    IJ.run("Merge Channels...", merge_string)
    IJ.run('Z Project...', 'projection=[Max Intensity] all')
    IJ.run('Enhance Contrast...', 'saturated=0.05')
    max_im = IJ.getImage()
    save_name = image_directory + '/MaxZProj/' + i + 'MaxZProj.tif'
    IJ.saveAsTiff(max_im, save_name)
    IJ.run('Close All')
    gc.collect()

IJ.run('Close All')