#@File (label = "Source folder", style="directory") sourcePath_File #@String (label = "Image folder name", value="STITCHED") rawImg_suffix #@String (label = "Results folder name", value="MAXDISTRIB") results_suffix #@int (label = "Transcripts radius (in pixel)", value=2)tx_MaxRadius #@string (label = "transcripts channel(s)" ) transcripts_channels_str # balabla #@string (label = "test", style = "message", value = "value") test # Author: Benoit Lombardot, Scientific computing facility @ MPI-CBG # date: 2015-11-26 ################################################## # import ######################################### from ij import IJ from mpicbg_scicomp.transcript_analysis import cell_transcript_analysis_v3; # needs Dev version for now import os from os import path #from os import listdir, sep, path, sys; #from os import makedirs; ################################################## # get parameters independant of the file ######### IJ.log("===============================\nscript started") #tx_MaxRadius transcripts_channels = transcripts_channels_str.split(",") for i in range(len(transcripts_channels)): transcripts_channels[i] = int(transcripts_channels[i]) main_folder= sourcePath_File.getPath(); # base directory containing the raw data and masks folders. #rawImg_suffix: name of the folder containing the raw image #results_suffix: name of the folder that will contain the results rawImgFolder = path.join(main_folder, rawImg_suffix); resultFolder = path.join(main_folder, results_suffix) ; if not path.exists(resultFolder ): os.makedirs(resultFolder); ################################################## # process function ############################### def process_file(filePath, resultsFolder, filePrefix): tx_analyzer = cell_transcript_analysis_v3(); tx_analyzer.setTranscriptMaxRadius(tx_MaxRadius); tx_analyzer.setTranscriptChannel(transcripts_channels); tx_analyzer.setImagePath(filePath); tx_analyzer.setSavePath(resultFolder); tx_analyzer.setFilePrefix(filePrefix); # processing imp_aux = IJ.openImage( filePath ); imp_rawImg = tx_analyzer.convert_input(imp_aux); tx_analyzer.save_transcripts_maxima_distribution(imp_rawImg); ############################################################ # main script ############################################## # select file to analyze if path.exists(rawImgFolder) : rawImg_files_list = [ f for f in os.listdir(rawImgFolder) if ( path.isfile(path.join(rawImgFolder,f)) & (rawImg_suffix in f) )]; # loop on file to analyze count= 0; max_count = len(rawImg_files_list); for fName in rawImg_files_list : count = count +1; IJ.log("processing file "+fName+" ("+str(count)+"/"+str(max_count)+")") fPath = path.join(rawImgFolder , fName); fNamePrefix = fName.split("_"+rawImg_suffix)[0]; fPathPrefix = path.join(resultFolder,fNamePrefix); processed = process_file(fPath, resultFolder, fPathPrefix) IJ.log("script finished\n===============================")