def scaleImageUI():  
	gd = GenericDialog("Scale")  
	gd.addSlider("Scale", 1, 200, 100)  
	gd.addCheckbox("Preview", True)  
	# The UI elements for the above two inputs  
	slider = gd.getSliders().get(0) # the only one  
	checkbox = gd.getCheckboxes().get(0) # the only one  
	
	imp = WM.getCurrentImage()  
	if not imp:  
		print "Open an image first!"  
		return  
	
	previewer = ScalingPreviewer(imp, slider, checkbox)  
	slider.addAdjustmentListener(previewer)  
	checkbox.addItemListener(previewer)  
		
	gd.showDialog()  
	
	if gd.wasCanceled():  
		previewer.reset()  
		print "User canceled dialog!"  
	else:  
		previewer.scale()  
	
	previewer.destroy()  
def getOptions():

    pixels = zeros('f', 4)  # 4 elements

    # First Dialog Box
    item = [
        "coralline", "tunicate", "red", "macro", "background", "more than one"
    ]
    gd = GenericDialog("Options")
    gd.addRadioButtonGroup("options", item, 3, 2, "coralline")
    gd.showDialog()
    button = gd.getNextRadioButton()

    # Second Dialog Box
    gd2 = GenericDialog("Multiple Options")
    items = ["coralline", "tunicate", "red", "macro", "garbage"]
    defaultVal = [False] * 5
    gd2.addCheckboxGroup(2, 3, items, defaultVal)
    gd2.addNumericField("coralline %", 0, 0)
    gd2.addNumericField("tunicate %", 0, 0)
    gd2.addNumericField("red %", 0, 0)
    gd2.addNumericField("macro %", 0, 0)
    gd2.addNumericField("background %", 0, 0)

    if gd.wasCanceled():
        return 0

    if button == "coralline":
        pixels[0] = 1
    elif button == "tunicate":
        pixels[1] = 1
    elif button == "red":
        pixels[2] = 1
    elif button == "macro":
        pixels[3] = 1
    elif button == "more than one":
        gd2.showDialog()
        checklist = gd2.getCheckboxes()
        pixels[0] = int(
            checklist[0].state) * (float(gd2.getNextNumber()) / 100)
        pixels[1] = int(
            checklist[1].state) * (float(gd2.getNextNumber()) / 100)
        pixels[2] = int(
            checklist[2].state) * (float(gd2.getNextNumber()) / 100)
        pixels[3] = int(
            checklist[3].state) * (float(gd2.getNextNumber()) / 100)

    return pixels
Example #3
0
def Options(sourceFolder):
    #globals
    global gGetNumChanFromScanImage
    global gNumChannels

    global gDoAlign
    global gAlignThisChannel

    global gDoCrop
    global gCropLeft
    global gCropTop
    global gCropWidth
    global gCropHeight

    global gAlignOnMiddleSlice
    global gAlignOnThisSlice
    global gRemoveCalibration
    global gLinearShift
    global gSave8bit

    tifNames = [file.name for file in File(sourceFolder).listFiles(Filter())]
    numTifs = len(tifNames)

    gd = GenericDialog('Align Batch 6 Options')
    #gd.addStringField('Command: ', '')

    gd.addMessage('Source Folder: ' + sourceFolder)
    gd.addMessage('Number of .tif files: ' + str(numTifs))

    #gd.setInsets(5,0,3)
    #0
    gd.addCheckboxGroup(
        1, 1, ['Get Number Of Channels From ScanImage 3.x or 4.x header'],
        [gGetNumChanFromScanImage], ['Channels'])
    gd.addNumericField(
        'Otherwise, Assume All Stacks Have This Number Of Channels: ',
        gNumChannels, 0)

    print gLinearShift

    #1
    gd.addCheckboxGroup(1, 1, ['Remove Linear Calibration From ScanImage 4.x'],
                        [gRemoveCalibration], ['ScanImage4'])
    gd.addNumericField('And offset (subtract) by this amount: ', gLinearShift,
                       0)

    #2
    gd.addCheckboxGroup(1, 1, ['Crop All Images (pixels)'], [gDoCrop],
                        ['Crop'])
    gd.addNumericField('Left', gCropLeft, 0)
    gd.addNumericField('Top', gCropTop, 0)
    gd.addNumericField('Width', gCropWidth, 0)
    gd.addNumericField('Height', gCropHeight, 0)

    #gd.setInsets(5,0,3)
    #3
    gd.addCheckboxGroup(1, 1, ['Run MultiStackReg'], [gDoAlign],
                        ['MultStackReg'])
    gd.addNumericField('If 2 Channels Then Align On This Channel',
                       gAlignThisChannel, 0)

    #4
    gd.addCheckboxGroup(1, 1, ['Start Alignment On Middle Slice'],
                        [gAlignOnMiddleSlice], ['Align On Middle Slice'])
    gd.addNumericField('Otherwise, Start Alignment On This Slice',
                       gAlignOnThisSlice, 0)

    #5
    gd.addCheckboxGroup(1, 1, ['Save 8-bit'], [gSave8bit],
                        ['Save 8-bit (at end)'])
    #gd.addCheckbox('Save 8-bit', gSave8bit)

    gd.showDialog()

    if gd.wasCanceled():
        print 'Options Was Cancelled by user'
        return 0
    else:
        print 'Reading values'
        gNumChannels = int(gd.getNextNumber())

        gLinearShift = int(gd.getNextNumber())

        gCropLeft = int(gd.getNextNumber())
        gCropTop = int(gd.getNextNumber())
        gCropWidth = int(gd.getNextNumber())
        gCropHeight = int(gd.getNextNumber())

        gAlignThisChannel = int(gd.getNextNumber())
        gAlignOnThisSlice = int(gd.getNextNumber())

        checks = gd.getCheckboxes()
        checkIdx = 0
        for check in checks:
            #print check.getState()
            if checkIdx == 0:
                gGetNumChanFromScanImage = check.getState()
            if checkIdx == 1:
                gRemoveCalibration = check.getState()
            if checkIdx == 2:
                gDoCrop = check.getState()
            if checkIdx == 3:
                gDoAlign = check.getState()
            if checkIdx == 4:
                gAlignOnMiddleSlice = check.getState()

            if checkIdx == 5:
                gSave8bit = check.getState()
            checkIdx += 1

        # print to fiji console
        bPrintLog('These are your global options:', 0)
        bPrintLog('gGetNumChanFromScanImage=' + str(gGetNumChanFromScanImage),
                  1)
        bPrintLog('gNumChannels=' + str(gNumChannels), 1)
        bPrintLog('gRemoveCalibration=' + str(gRemoveCalibration), 1)
        bPrintLog('gLinearShift=' + str(gLinearShift), 1)
        bPrintLog('gDoCrop=' + str(gDoCrop), 1)
        bPrintLog('gDoAlign=' + str(gDoAlign), 1)
        bPrintLog('gAlignThisChannel=' + str(gAlignThisChannel), 1)
        bPrintLog('gSave8bit=' + str(gSave8bit), 1)

        return 1
def Options(sourceFolder):
	#globals
	global gFileType
	global gGetNumChanFromScanImage
	global gNumChannels
		
	global gDoAlign
	global gAlignThisChannel
	
	global gDoCrop
	global gCropLeft
	global gCropTop
	global gCropWidth
	global gCropHeight
	
	global gAlignOnMiddleSlice
	global gAlignOnThisSlice
	global gRemoveCalibration
	global gLinearShift
	global gSave8bit

	tifNames = [file.name for file in File(sourceFolder).listFiles(Filter())]
	lsmNames = [file.name for file in File(sourceFolder).listFiles(Filter_LSM())]
	
	numTifs = len(tifNames)
	numLSM = len(lsmNames)

	gd = GenericDialog('Align Batch 7 Options')
	#gd.addStringField('Command: ', '')

	gd.addMessage('Source Folder: ' + sourceFolder)
	gd.addMessage('Number of .tif files: ' + str(numTifs))
	gd.addMessage('Number of .lsm files: ' + str(numLSM))
	
	gd.addChoice('File Type', ['tif','lsm'], gFileType)
	
	#gd.setInsets(5,0,3)
	#0
	gd.addCheckboxGroup(1, 1, ['Get Number Of Channels From ScanImage 3.x or 4.x header'], [gGetNumChanFromScanImage], ['Channels'])
	gd.addNumericField('Otherwise, Assume All Stacks Have This Number Of Channels: ', gNumChannels, 0)

	print gLinearShift
	
	#1
	gd.addCheckboxGroup(1, 1, ['Remove Linear Calibration From ScanImage 4.x'], [gRemoveCalibration], ['ScanImage4'])
	gd.addNumericField('And offset (subtract) by this amount: ', gLinearShift, 0)
	gd.addMessage('20151110, this number = 2^15-512 = 32768-512 = 32256')
	
	#2
	gd.addCheckboxGroup(1, 1, ['Crop All Images (pixels)'], [gDoCrop], ['Crop'])
	gd.addNumericField('Left', gCropLeft, 0)
	gd.addNumericField('Top', gCropTop, 0)
	gd.addNumericField('Width', gCropWidth, 0)
	gd.addNumericField('Height', gCropHeight, 0)

	#gd.setInsets(5,0,3)
	#3
	gd.addCheckboxGroup(1, 1, ['Run MultiStackReg'], [gDoAlign], ['MultStackReg'])
	gd.addNumericField('If 2 Channels Then Align On This Channel', gAlignThisChannel, 0)
	
	#4
	gd.addCheckboxGroup(1, 1, ['Start Alignment On Middle Slice'], [gAlignOnMiddleSlice], ['Align On Middle Slice'])
	gd.addNumericField('Otherwise, Start Alignment On This Slice', gAlignOnThisSlice, 0)

	#5
	gd.addCheckboxGroup(1, 1, ['Save 8-bit'], [gSave8bit], ['Save 8-bit (at end)'])
	#gd.addCheckbox('Save 8-bit', gSave8bit)
	
	gd.showDialog()

	if gd.wasCanceled():
		print 'Options Was Cancelled by user'
		return 0
	else:
		print 'Reading values'
		gFileType = gd.getNextChoice()
		
		gNumChannels = int(gd.getNextNumber())

		gLinearShift = int(gd.getNextNumber())

		gCropLeft = int(gd.getNextNumber())
		gCropTop = int(gd.getNextNumber())
		gCropWidth = int(gd.getNextNumber())
		gCropHeight = int(gd.getNextNumber())

		gAlignThisChannel = int(gd.getNextNumber())
		gAlignOnThisSlice = int(gd.getNextNumber())

		checks = gd.getCheckboxes()
		checkIdx = 0
		for check in checks:
			#print check.getState()
			if checkIdx==0:
				gGetNumChanFromScanImage = check.getState()
			if checkIdx==1:
				gRemoveCalibration = check.getState()
			if checkIdx==2:
				gDoCrop = check.getState()
			if checkIdx==3:
				gDoAlign = check.getState()
			if checkIdx==4:
				gAlignOnMiddleSlice = check.getState()

			if checkIdx==5:
				gSave8bit = check.getState()
			checkIdx += 1

		# print to fiji console
		bPrintLog('These are your global options:', 0)
		bPrintLog('gFileType=' + gFileType, 1)
		bPrintLog('gGetNumChanFromScanImage=' + str(gGetNumChanFromScanImage), 1)
		bPrintLog('gNumChannels=' + str(gNumChannels), 1)
		bPrintLog('gRemoveCalibration=' + str(gRemoveCalibration), 1)
		bPrintLog('gLinearShift=' + str(gLinearShift), 1)
		bPrintLog('gDoCrop=' + str(gDoCrop), 1)
		bPrintLog('gDoAlign=' + str(gDoAlign), 1)
		bPrintLog('gAlignThisChannel=' + str(gAlignThisChannel), 1)
		bPrintLog('gSave8bit=' + str(gSave8bit), 1)
		
		return 1
Example #5
0
def run():
    ### Default arguments
    two_sarcomere_size = 25  # determined by filter used.
    rotation_angle = 0.0

    ### Get the image we'd like to work with.
    # Don't need to ask where to save the intermediate image since it'll just be saved in the matchedmyo folder anyway
    #   may change this though. In case they want to keep that image around.
    this_img = WindowManager.getCurrentImage()
    if this_img == None:
        ud = WaitForUserDialog(
            "Please select the image you would like to analyze.")
        ud.show()
        this_img = WindowManager.getCurrentImage()
    img_name = this_img.getTitle()

    matchedmyo_path = "/home/AD/dfco222/scratchMarx/matchedmyo/"  # this would be grabbed from the prompt
    gd = GenericDialog("Preprocessing Options")
    gd.addCheckbox("Automatic Resizing/Rotation", True)
    gd.addCheckbox("CLAHE", True)
    gd.addCheckbox("Normalization to Transverse Tubules", True)
    gd.showDialog()
    if gd.wasCanceled():
        return
    auto_resize_rotate = gd.getNextBoolean()
    clahe = gd.getNextBoolean()
    normalize = gd.getNextBoolean()

    if auto_resize_rotate:
        # Clear selection so it takes FFT of full image

        rotation_angle = auto_resize_angle_measure(this_img,
                                                   two_sarcomere_size)

    if clahe:
        clahe_args = "blocksize={} histogram=256 maximum=3 mask=*None* fast_(less_accurate)".format(
            two_sarcomere_size)
        IJ.run(this_img, "Enhance Local Contrast (CLAHE)", clahe_args)

    if normalize:
        # Ask the user to select a subsection of the image that looks healthy-ish.
        ud = WaitForUserDialog(
            "Please select a subsection exhibiting a measure of healthy TT structure using the Rectangle tool.\n"
            + " Only a single cell or several are needed.\n\n" +
            " Press 'OK' when finished.")
        ud.show()
        IJ.setTool("rectangle")

        # Duplicate the selected subsection.
        selection = this_img.crop()
        IJ.run(selection, "Duplicate...", "title=subsection.tif")

        # Grab the subsection image and rotate it.
        selection = WindowManager.getImage("subsection.tif")
        IJ.run(
            selection, "Rotate...",
            "angle={} grid=1 interpolation=Bicubic enlarge".format(
                rotation_angle))

        # Ask the user to select a bounding box that contains only tubules
        # NOTE: Need to get rid of initial selection since it's the entire image and it's annoying to click out of
        IJ.setTool("rectangle")
        IJ.run(selection, "Select None", "")
        ud = WaitForUserDialog(
            "Select a subsection of the image that contains only tubules and no membrane."
        )
        ud.show()

        # Grab the subsection ImagePlus
        selection = WindowManager.getCurrentImage()
        this_window = WindowManager.getActiveWindow()
        selection_small = selection.crop()
        IJ.run(selection, "Close", "")

        # NOTE: May not actually display this depending on how the macros work
        IJ.run(selection_small, "Duplicate...", "title=subsection_small.tif")

        # Smooth the selection using the single TT filter.
        # NOTE: It won't read in so we're just going to hard code it in since it's simple
        tt_filt_row = "0 0 0 1 1 1 1 1 1 0 0 0 0\n"
        tt_filt = ""
        for i in range(21):
            tt_filt += tt_filt_row
        IJ.run("Convolve...", "text1=[" + tt_filt + "] normalize")

        # Segment out the TTs from the 'gaps' using Gaussian Adaptive Thresholding.
        selection_small = WindowManager.getImage("subsection_small.tif")
        IJ.run(selection_small, "Duplicate...", "title=thresholded.tif")
        threshed = WindowManager.getImage("thresholded.tif")
        IJ.run(threshed, "Auto Local Threshold",
               "method=Bernsen radius=7 parameter_1=1 parameter_2=0 white")

        # Select the TTs from the thresholded image.
        IJ.run(threshed, "Create Selection", "")
        tt_selection = WindowManager.getImage("subsection_small.tif")
        IJ.selectWindow("thresholded.tif")
        IJ.selectWindow("subsection_small.tif")
        IJ.run(tt_selection, "Restore Selection", "")

        # Get TT intensity statistics.
        stat_options = IS.MEAN | IS.MIN_MAX | IS.STD_DEV
        stats = IS.getStatistics(tt_selection.getProcessor(), stat_options,
                                 selection_small.getCalibration())
        # Calculate pixel ceiling intensity value based on heuristic.
        # TODO: Add a catch for data type overflow.
        pixel_ceiling = stats.mean + 3 * stats.stdDev
        print "px ceil:", pixel_ceiling

        # Invert selection to get inter-sarcomeric gap intensity statistics.
        IJ.run(tt_selection, "Make Inverse", "")
        stat_options = IS.MEAN | IS.MIN_MAX | IS.STD_DEV
        stats = IS.getStatistics(tt_selection.getProcessor(), stat_options,
                                 selection_small.getCalibration())
        # Calculate pixel floor intensity value based on heuristic.
        pixel_floor = stats.mean - stats.stdDev
        # TODO: Add a catch for data type underflow.
        print "px floor:", pixel_floor

        # Threshold original image based on these values.
        IJ.selectWindow(this_img.getTitle())
        IJ.run(this_img, "Select All", "")
        IJ.setMinAndMax(pixel_floor, pixel_ceiling)
        IJ.run(this_img, "Apply LUT", "")

    ## Ask if it is acceptable.
    gd = GenericDialog("Acceptable?")
    gd.addMessage(
        "If the preprocessed image is acceptable for analysis, hit 'OK' to being analysis.\n"
        + " If the image is unacceptable or an error occurred, hit 'Cancel'")
    gd.showDialog()
    if gd.wasCanceled():
        return

    ## Save the preprocessed image.
    imp = IJ.getImage()
    fs = FileSaver(imp)
    img_save_dir = matchedmyo_path + "myoimages/"  # actually get from user at some point
    img_file_path = img_save_dir + img_name[:-4] + "_preprocessed.tif"
    if os.path.exists(img_save_dir) and os.path.isdir(img_save_dir):
        print "Saving image as:", img_file_path
        if os.path.exists(img_file_path):
            # use dialog box to ask if they want to overwrite
            gd = GenericDialog("Overwrite?")
            gd.addMessage(
                "A file exists with the specified path, \"{}\". Would you like to overwrite it?"
                .format(img_file_path))
            gd.enableYesNoCancel()
            gd.showDialog()
            if gd.wasCanceled():
                return
        elif fs.saveAsTiff(img_file_path):
            print "Preprocessed image saved successfully at:", '"' + img_file_path + '"'
    else:
        print "Folder does not exist or is not a folder!"

    ### Create the YAML file containing the parameters for classification
    ## Ask user for YAML input
    gd = GenericDialog("YAML Input")
    gd.addStringField("imageName", img_file_path, 50)
    #gd.addStringField("maskName", "None")
    gd.addStringField("outputParams_fileRoot", img_file_path[:-4], 50)
    gd.addStringField("outputParams_fileType", "tif")
    gd.addNumericField("outputParams_dpi", 300, 0)
    gd.addCheckbox("outputParams_saveHitsArray", False)
    gd.addStringField("outputParams_csvFile", matchedmyo_path + "results/")
    gd.addCheckbox("TT Filtering", True)
    gd.addToSameRow()
    gd.addCheckbox("LT Filtering", True)
    gd.addToSameRow()
    gd.addCheckbox("TA Filtering", True)
    gd.addNumericField("scopeResolutions_x", 5.0, 3)
    gd.addToSameRow()
    gd.addNumericField("scopeResolutions_y", 5.0, 3)
    gd.addMessage("Enter in filter rotation angles separated by commas.")
    gd.addStringField("", "-25, -20, -15, -10, -5, 0, 5, 10, 15, 20, 25", 50)
    gd.addCheckbox("returnAngles", False)
    gd.addCheckbox("returnPastedFilter", True)
    gd.showDialog()
    if gd.wasCanceled():
        return

    strings = [st.text for st in gd.getStringFields()]
    #if strings[1] == "None" or "":
    #	strings[1] = None
    nums = [float(num.text) for num in gd.getNumericFields()]
    nums[0] = int(nums[0])  # Have to make sure the dpi variable is an integer
    checks = [str(bool(boo.state)) for boo in gd.getCheckboxes()]
    iter_argument = ','.join(
        [str(float(it) - rotation_angle) for it in strings[4].split(',')])
    string_block = """imageName: {0[0]}
outputParams:
  fileRoot: {0[1]}
  fileType: {0[2]}
  dpi: {1[0]}
  saveHitsArray: {2[0]}
  csvFile: {0[3]}
preprocess: False
filterTypes:
  TT: {2[1]}
  LT: {2[2]}
  TA: {2[3]}
scopeResolutions:
  x: {1[1]}
  y: {1[2]}
iters: [{3}]
returnAngles: {2[4]}
returnPastedFilter: {2[5]}""".format(strings, nums, checks, iter_argument)
    im_title = this_img.getTitle()
    with cd(matchedmyo_path):
        yaml_file_path = "./YAML_files/" + im_title[:-4] + ".yml"
        with open("./YAML_files/" + im_title[:-4] + ".yml", "w") as ym:
            ym.write(string_block)
        print "Wrote YAML file to:", matchedmyo_path + yaml_file_path[2:]

    ### Run the matchedmyo code on the preprocessed image
    with cd(matchedmyo_path):
        #os.chdir(matchedmyo_path)
        #subprocess.call(["python3", matchedmyo_path+"matchedmyo.py", "fullValidation"])
        subprocess.call(
            ["python3", "matchedmyo.py", "run", "--yamlFile", yaml_file_path])
def analysis_parameters_gui(rerun_analysis=False, params=None):
	"""GUI for setting analysis parameters at the start of a run. TODO: more effectively separate model and view"""
	if params is None:
		params = Parameters(load_last_params = True);
	dialog = GenericDialog("Analysis parameters");
	controls = [];
	if rerun_analysis:
		params.setUseSingleChannel(False);
		params.togglePerformUserQC(False);
		params.setDoInnerOuterComparison(False);

	controls.append(MyControlDefinition(u'Curvature length parameter (\u00b5m): ', 
									 MyControlDefinition.Numeric, 
									 round(params.curvature_length_um, 2), 
									 params.setCurvatureLengthUm));
	controls.append(MyControlDefinition(u'Width of region for intensity analysis (\u00b5m): ', 
									MyControlDefinition.Numeric, 
									round(params.intensity_profile_width_um, 2), 
									params.setIntensityProfileWidthUm))
	controls.append(MyControlDefinition("Threshold method: ",
									 MyControlDefinition.Choice, 
									 params.threshold_method, 
									 params.setThresholdMethod, 
									 choices=params.listThresholdMethods(), 
									 enabled=(not rerun_analysis)));
	controls.append(MyControlDefinition("Curvature overlay LUT: ", 
									 MyControlDefinition.Choice, 
									 params.curvature_overlay_lut_string, 
									 params.setCurvatureOverlayLUT, 
									 choices=IJ.getLuts()));
	controls.append(MyControlDefinition("Curvature kymograph LUT: ",
									 MyControlDefinition.Choice, 
									 params.curvature_kymograph_lut_string, 
									 params.setCurvatureKymographLUT, 
									 choices=IJ.getLuts()));
	controls.append(MyControlDefinition("Labelled species kymograph LUT: ", 
									 MyControlDefinition.Choice, 
									 params.actin_kymograph_lut_string, 
									 params.setActinKymographLUT, 
									 choices=IJ.getLuts()));
	controls.append(MyControlDefinition("Labelled species for intensity analysis: ", 
									 MyControlDefinition.String, 
									 params.labeled_species, 
									 params.setLabeledSpecies));
	controls.append(MyControlDefinition("Use intensity channel for segmentation too?", 
									 MyControlDefinition.Checkbox, 
									 params.use_single_channel, 
									 params.setUseSingleChannel, 
									 enabled=(not rerun_analysis)));
	controls.append(MyControlDefinition("Metadata source: ", 
									 MyControlDefinition.RadioButtonGroup, 
									 params.metadata_source, 
									 params.setMetadataSource, 
									 choices=["Image metadata", "Acquisition metadata"]));
	controls.append(MyControlDefinition("Constrain anchors close to manual selections?", 
									 MyControlDefinition.Checkbox, 
									 params.constrain_anchors, 
									 params.toggleConstrainAnchors, 
									 enabled=(not rerun_analysis)));
	controls.append(MyControlDefinition("Filter out negative curvatures", 
									 MyControlDefinition.Checkbox, 
									 params.filter_negative_curvatures, 
									 params.setFilterNegativeCurvatures));
	controls.append(MyControlDefinition("Account for photobleaching?", 
									 MyControlDefinition.Checkbox, 
									 params.photobleaching_correction, 
									 params.togglePhotobleachingCorrection));
	controls.append(MyControlDefinition("Perform quality control of membrane edges?", 
									 MyControlDefinition.Checkbox, 
									 params.perform_user_qc, 
									 params.togglePerformUserQC, 
									 enabled=(not rerun_analysis)));
	controls.append(MyControlDefinition("Perform quality control of background regions?", 
									 MyControlDefinition.Checkbox, 
									 params.qc_background_rois, 
									 params.toggleBackgroundQc));
	controls.append(MyControlDefinition("Perform spatial cropping?", 
									 MyControlDefinition.Checkbox, 
									 params.perform_spatial_crop, 
									 params.toggleSpatialCrop, 
									 enabled=(not rerun_analysis)));
	controls.append(MyControlDefinition("Perform time cropping?",
									 MyControlDefinition.Checkbox, 
									 params.perform_time_crop, 
									 params.toggleTimeCrop, 
									 enabled=(not rerun_analysis)));
	controls.append(MyControlDefinition("Close images on completion?", 
									 MyControlDefinition.Checkbox, 
									 params.close_on_completion, 
									 params.toggleCloseOnCompletion));
	controls.append(MyControlDefinition("Compare inner and outer curvature regions?", 
									 MyControlDefinition.Checkbox, 
									 params.inner_outer_comparison, 
									 params.setDoInnerOuterComparison, 
									 enabled=(not rerun_analysis)));
	for control in controls:
		control.addControl(dialog);
	dialog.showDialog();
	if dialog.wasCanceled():
		raise KeyboardInterrupt("Run canceled");

	numeric_controls = [c for c in controls if c.control_type==MyControlDefinition.Numeric];
	for nc, nf in zip(numeric_controls, dialog.getNumericFields()):
		nc.setter(float(nf.getText()));
	string_controls = [c for c in controls if c.control_type==MyControlDefinition.String];
	for sc, sf in zip(string_controls, dialog.getStringFields()):
		sc.setter(sf.getText());
	choice_controls = [c for c in controls if c.control_type==MyControlDefinition.Choice];
	for cc, cf in zip(choice_controls, dialog.getChoices()):
		cc.setter(cf.getSelectedItem());
	checkbox_controls = [c for c in controls if c.control_type==MyControlDefinition.Checkbox];
	for cbc, cbf in zip(checkbox_controls, dialog.getCheckboxes()):
		cbc.setter(cbf.getState());
	radiobuttongroup_controls = [c for c in controls if c.control_type==MyControlDefinition.RadioButtonGroup];
	for rbc in radiobuttongroup_controls:
		rbc.setter(rbc.checkboxes[[cb.getState() for cb in rbc.checkboxes].index(True)].getLabel());

	params.persistParameters();
	return params;
Example #7
0
        else:
            eventOutL = frames + slider3_feedback + 1 + slider2_feedback * (
                ch * frames) + evt * (zplanes * ch * frames)
            imp2.setPosition(1, eventOutL, 1)


# Define the pre-conditions for loading the data, default values represent my normal acquisition parameters only the loop has to be set, the rest is read from metadata

psgd = GenericDialog("Pre-Set")
psgd.addCheckbox(
    "Images open?", False
)  # if your images  are already open as a virtual stack, you can avoid to load again
psgd.showDialog()

if psgd.wasOKed():
    choiceIm = psgd.getCheckboxes().get(0).getState()

    # load data as virtual stack, simple image stack
    if choiceIm == False:
        IJ.run("Close All", "")
        impDir = OpenDialog("Select the 6D dataset").getPath()
        impDir = impDir.replace("\\", "/")

        IJ.run(
            "Bio-Formats", "open=" + impDir +
            " color_mode=Default display_metadata rois_import=[ROI manager] view=[Standard ImageJ] stack_order=Default use_virtual_stack"
        )

        #define ImagePlus to variable and remove path from title
        imp = WM.getCurrentImage()
        directoryTitle = IJ.getDirectory("current")