Example #1
0
def preprocess(filePath, fileName, fileID):
    global radius
    global circularity
    global size
    global lowerThreshold
    global upperThreshold
    global bytesInMB

    curr = IJ.openImage(filePath + '/' + fileName)
    c1, c2, c3 = ChannelSplitter.split(curr) # type:
    c1.show()
    c2.show()
    IJ.log("before blur: " +  str(IJ.currentMemory()/bytesInMB) + " MB")
    IJ.run(c1,"Gaussian Blur...","sigma=%i" %radius)
    IJ.log("after blur: " +  str(IJ.currentMemory()/bytesInMB) + " MB" + "\n")
    IJ.setThreshold(c1, lowerThreshold, upperThreshold)
 
    #IJ.run("Set Measurements...", "mean center redirect=C2-GT_%s-Stitch.tif decimal=1" %fileID)
    #IJ.run("Set Measurements...", "mean center redirect=C2-GT_A4-Stitch.tif decimal=1")
    IJ.run("Set Measurements...", "mean center redirect=C2-GT_%s-Stitch.tif decimal=1" %fileID) # there is a space after "redirect ="
    # produces 1980 cells but totally wrong measurements, record them next time when continued manually
    IJ.run(c1, "Analyze Particles...", "size=50.00-Infinity circularity=0.70-1.00 show=Nothing display exclude include")
    # I suspect that IJ.run(c1, "Analyze Particles...", "size=%s-Infinity circularity=%s-1.00 show=Nothing display exclude include" %(size, circularity)) works
    c1.changes = False
    c1.close()
    c2.close()
    return c3
Example #2
0
def main():
    global bytesInMB
    x = 3
    for file in os.listdir(tiff_path): # goes through each tiff file 
        fileID = file[3:5] # ex: A3
        channel = preprocess(tiff_path, file, fileID)
        IJ.log("after preprocess: " +  str(IJ.currentMemory()/bytesInMB) + " MB")
        IJ.run("Collect Garbage")
        IJ.log("after garbage collect/before csvPreprocess: " +  str(IJ.currentMemory()/bytesInMB) + " MB" + "\n")
        data = csvPreprocess(fileID)
        IJ.log("after csvPreprocess: " +  str(IJ.currentMemory()/bytesInMB) + " MB")
        IJ.run("Collect Garbage")
        IJ.log("after garbage collect: " +  str(IJ.currentMemory()/bytesInMB) + " MB")
        sys.exit(0)
        """
Example #3
0
def get_free_memory():
    """gets the free memory thats available to ImageJ

    Returns
    -------
    free_memory : integer
        the free memory in bytes
    """
    max_memory = int(IJ.maxMemory())
    used_memory = int(IJ.currentMemory())
    free_memory = max_memory - used_memory

    return free_memory
Example #4
0
def get_image(info, default_path, used_files):
	"""handle getting image from file"""
	check_for_file_overlap_OK = False;
	while not check_for_file_overlap_OK:
		info.set_input_file_path(file_location_chooser(default_path));
		if info.get_input_file_path() in used_files:
			dlg = GenericDialog("Image already used...");
			dlg.addMessage("This image has already been used in this analysis run.  \n " + 
					"Continue with this image, or choose a new one?");
			dlg.setOKLabel("Continue");
			dlg.setCancelLabel("Choose again...");
			dlg.showDialog();
			check_for_file_overlap_OK = False if dlg.wasCanceled() else True;
		else:
			check_for_file_overlap_OK = True;
	import_opts, info = choose_series(info.get_input_file_path(), info)

	imps = bf.openImagePlus(import_opts);
	imp = imps[0];
	
	try:
		memory_usage = IJ.currentMemory()/IJ.maxMemory();
		print("memory usage = " +str(memory_usage));
		# arbitrary limit...
		if memory_usage > 0.95: 
			IJ.run(imp, "8-bit", "");
			print("WARNING - IMAGE CONVERTED TO 8 BIT TO CONSERVE MEMORY!");
		info.set_metadata_file_path(os.path.splitext(info.get_input_file_path())[0] + ".txt");
		metadata = import_iq3_metadata(info.get_metadata_file_path());
		IJ.run(imp, "Properties...", "channels=" + str(int(metadata['n_channels'])) + 
										" slices=" + str(int(metadata['z_pixels'])) + 
										" frames=1 unit=" + str(metadata['x_unit']) + 
										" pixel_width=" + str(metadata['x_physical_size']) + 
										" pixel_height=" + str(metadata['y_physical_size']) + 
										" voxel_depth=" + str(metadata['z_extent']/metadata['z_pixels']));
		info.set_xy_pixel_size_um(metadata['x_physical_size']);
		info.set_z_plane_spacing_um(metadata['z_extent']/metadata['z_pixels']);
		info = parse_info_from_filename(info);
	except e as Exception:
		print(e.message);
	finally:
		if imp is not None:
			imp.close();
	return imp, info;