def createExportDir(self, export_name): """ Creates export directory Parameters ---------- export_name : str Name of folder. i.e. <img directory>/<export_name> Returns ------- current_export_dir : str, path-like Path to export directory <img_directory>/<export_name>/<current_datetime> """ IJ.selectWindow(self.ref_image.ID) # make ref image active window current_datetime = datetime.datetime.now().strftime("%Y%m%d_%H%M") export_dir = os.path.join(IJ.getDir("image"), export_name) if os.path.isdir(export_dir) == False: IJ.log("Created export directory: " + export_dir) os.mkdir(export_dir) current_export_dir = os.path.join(export_dir, current_datetime) os.mkdir(current_export_dir) IJ.log("Currently exporting to: " + current_export_dir) return current_export_dir
def __init__(self, uniqueFileName, outputFolder): self.uniqueID = uniqueFileName[:-4] self.outputFolder = str(outputFolder) elapsedTime = (datetime.now() - datetime.fromtimestamp(0)).total_seconds() elapsedTimeStr = str(elapsedTime) self.downloadsFolder = join(IJ.getDir("downloads"), "SpeckleResults" + self.outputFolder) if not exists(self.downloadsFolder): os.mkdir(self.downloadsFolder)
def openedImagesmain(channel1, channel2, ignoreString, primarySize, primaryImageThresh, secondaryImageThresh): def writeTablesToCSV(id, roiOut, speckleOut): try: #append your labels to them before they're written identifier = id[:-4] speckleOut_ = RTC.appendColToFront(identifier, speckleOut) roiOut_ = RTC.appendColToFront(identifier, roiOut) #save the tables to csvs -- they will append to a currently existing csv #or create a new one Saves.table2CSV("speckleOutput.csv", speckleOut_) Saves.table2CSV("AnalysisOutput.csv", roiOut_) print("finished writing tables to csvs.") except: print("failed to write to csvs.") finally: print("") #Begin try: RTC = ResultsTableToCSV(channel1, channel2, ignoreString) primary, secondary, images = RTC.getOpenImageNames() Binarize(primaryImageThresh, secondaryImageThresh, primary, secondary) speckleInputs = "primary=[{}] secondary=[{}] " \ "redirect=None min_primary_size={} min_secondary_size=0.00000 " \ "show=none exclude speckle statistic secondary_object" IJ.run("Speckle Inspector", speckleInputs.format(primary, secondary, primarySize)) Saves = SaveStuff(primary) Saves.saveLogs() #Saves.saveNewImages(images) Saves.saveAllImages(images) speckleTableName = "Speckle List " + primary roiTableName = "Roi Analysis" roiOut = RTC.roiAnalysisToWrite(roiTableName) speckleOut = RTC.readResultsTablesOfNumbers(speckleTableName) WindowManager.closeAllWindows() fijiDir = IJ.getDir("imagej") fijiScriptsDir = join(fijiDir, "scripts") writeTablesToCSV(primary, roiOut, speckleOut) IJ.open(join(fijiScriptsDir, "SmootherSpeckling.py")) print("script completed successfully.") except: print("sorry, the script broke :/") finally: print("")
IJ.run("Close") c=1 for series in loc2: out_path=filepath1 + "/"+name+"Scene_" + str(c) + ".tif" imp=getImageSeries(imps, series) imp.show() IJ.run("RGB Color") imp.close() IJ.saveAs("tiff", out_path) IJ.run("Close") c+=1 czireader.close() # clear the console automatically when not in headless mode uiService.getDefaultUI().getConsolePane().clear() inputDir = IJ.getDir("Choose input Directory") #only grabs files in case there are any folders in the directory #https://stackoverflow.com/questions/11968976/list-files-in-only-the-current-directory dir_array1 = [f for f in os.listdir(inputDir) if os.path.isfile(os.path.join(inputDir,f))] #does not generate a tiff file or folder for the thumbnail pictures of the preview and label dir_array=[f for f in dir_array1 if "pt" not in f] log.info(dir_array1) log.info(dir_array) dir_length = len(dir_array) #create an output directory inside the folder with all the other ones for i,image in enumerate(dir_array):
from ij import IJ import os path = IJ.getDir("Choose a Directory") c = 0 for f in os.listdir(path): try: ext = f.split('.')[-1] ch = f.split('.')[-2] except: continue if ext == 'tif' and ch == 'UV': print f, " is a UV channel" img = IJ.open(''.join([path, f])) #IJ.setAutoThreshold(img, "Default dark") IJ.run("8-bit") IJ.setThreshold(255, 255) IJ.run("Close") c += 1 if c >= 5: break