Java Code Examples for ij.gui.GenericDialog#addMessage()

The following examples show how to use ij.gui.GenericDialog#addMessage() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LayerSet.java    From TrakEM2 with GNU General Public License v3.0 6 votes vote down vote up
protected Tag askForNewTag(final int keyCode) {
	GenericDialog gd = new GenericDialog("Define new tag");
	gd.addMessage("Define new tag for key: " + ((char)keyCode));
	TreeSet<Tag> ts = getTags(keyCode);
	gd.addStringField("New tag:", "", 40);
	if (null != ts && ts.size() > 0) {
		String[] names = new String[ts.size()];
		int next = 0;
		for (Tag t : ts) names[next++] = t.toString();
		gd.addChoice("Existing tags for " + ((char)keyCode) + ":", names, names[0]);
	}
	gd.showDialog();
	if (gd.wasCanceled()) return null;
	String tag = gd.getNextString().trim();
	if (0 == tag.length()) {
		Utils.logAll("Invalid tag " + tag);
		return null;
	}
	return putTag(tag, keyCode);
}
 
Example 2
Source File: DifferenceOfMean.java    From SPIM_Registration with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected boolean setAdvancedValues( final Channel channel )
{
	final int channelId = channel.getId();
	
	final GenericDialog gd = new GenericDialog( "Advanced values for channel " + channel.getName() );

	String ch;

	if ( this.channelsToProcess.size() > 1 )
		ch = "_" + channel.getName().replace( ' ', '_' );
	else
		ch = "";

	gd.addMessage( "Advanced values for channel " + channel.getName() );
	gd.addNumericField( "Radius_1" + ch, defaultRadius1[ channelId ], 0 );
	gd.addNumericField( "Radius_2" + ch, defaultRadius2[ channelId ], 0 );
	gd.addNumericField( "Threshold" + ch, defaultThreshold[ channelId ], 4 );
	gd.addCheckbox( "Find_minima" + ch, defaultFindMin[ channelId ] );
	gd.addCheckbox( "Find_maxima" + ch, defaultFindMax[ channelId ] );

	gd.showDialog();
	
	if ( gd.wasCanceled() )
		return false;
	
	this.radius1[ channelId ] = defaultRadius1[ channelId ] = (int)Math.round( gd.getNextNumber() );
	this.radius2[ channelId ] = defaultRadius2[ channelId ] = (int)Math.round( gd.getNextNumber() );
	this.threshold[ channelId ] = defaultThreshold[ channelId ] = gd.getNextNumber();
	this.findMin[ channelId ] = defaultFindMin[ channelId ] = gd.getNextBoolean();
	this.findMax[ channelId ] = defaultFindMax[ channelId ] = gd.getNextBoolean();
	
	return true;
}
 
Example 3
Source File: InteractivePlotter.java    From Scripts with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Displays a message dialog taking into account the position of the main
 * plugin prompt
 */
private void showMessage(final String title, final String msg) {
	final GenericDialog gd = new GenericDialog(title);
	gd.addMessage(msg);
	gd.setLocationRelativeTo(prompt);
	gd.hideCancelButton();
	gd.showDialog();
}
 
Example 4
Source File: DifferenceOf.java    From SPIM_Registration with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Figure out which view to use for the interactive preview
 * 
 * @param dialogHeader
 * @param text
 * @param channel
 * @return
 */
protected ViewId getViewSelection( final String dialogHeader, final String text, final Channel channel )
{
	final ArrayList< ViewDescription > views = SpimData2.getAllViewIdsForChannelSorted( spimData, viewIdsToProcess, channel );
	final String[] viewChoice = new String[ views.size() ];

	for ( int i = 0; i < views.size(); ++i )
	{
		final ViewDescription vd = views.get( i );
		viewChoice[ i ] = "Timepoint " + vd.getTimePointId() + ", Angle " + vd.getViewSetup().getAngle().getName() + ", Illum " + vd.getViewSetup().getIllumination().getName() + ", ViewSetupId " + vd.getViewSetupId();
	}

	if ( defaultViewChoice >= views.size() )
		defaultViewChoice = 0;

	final GenericDialog gd = new GenericDialog( dialogHeader );

	gd.addMessage( text );
	gd.addChoice( "View", viewChoice, viewChoice[ defaultViewChoice ] );
	
	gd.showDialog();
	
	if ( gd.wasCanceled() )
		return null;

	final ViewId viewId = views.get( defaultViewChoice = gd.getNextChoiceIndex() );

	return viewId;
}
 
Example 5
Source File: BoundingBoxGUI.java    From SPIM_Registration with GNU General Public License v2.0 5 votes vote down vote up
protected GenericDialog getSimpleDialog( final boolean compress, final boolean allowModifyDimensions )
{
	final int[] rangeMin = new int[ 3 ];
	final int[] rangeMax = new int[ 3 ];

	setUpDefaultValues( rangeMin, rangeMax );

	final GenericDialog gd = new GenericDialog( "Manually define Bounding Box" );

	gd.addMessage( "Note: Coordinates are in global coordinates as shown " +
			"in Fiji status bar of a fused datasets", GUIHelper.smallStatusFont );

	if ( !compress )
		gd.addMessage( "", GUIHelper.smallStatusFont );

	gd.addSlider( "Minimal_X", rangeMin[ 0 ], rangeMax[ 0 ], this.min[ 0 ] );
	gd.addSlider( "Minimal_Y", rangeMin[ 1 ], rangeMax[ 1 ], this.min[ 1 ] );
	gd.addSlider( "Minimal_Z", rangeMin[ 2 ], rangeMax[ 2 ], this.min[ 2 ] );

	if ( !compress )
		gd.addMessage( "" );

	gd.addSlider( "Maximal_X", rangeMin[ 0 ], rangeMax[ 0 ], this.max[ 0 ] );
	gd.addSlider( "Maximal_Y", rangeMin[ 1 ], rangeMax[ 1 ], this.max[ 1 ] );
	gd.addSlider( "Maximal_Z", rangeMin[ 2 ], rangeMax[ 2 ], this.max[ 2 ] );

	if ( !allowModifyDimensions )
	{
		for ( int i = gd.getSliders().size() - 6; i < gd.getSliders().size(); ++i )
			((Scrollbar)gd.getSliders().get( i )).setEnabled( false );

		for ( int i = gd.getNumericFields().size() - 6; i < gd.getNumericFields().size(); ++i )
			((TextField)gd.getNumericFields().get( i )).setEnabled( false );
	}

	return gd;
}
 
Example 6
Source File: ExportToRenderAsIs_Plugin.java    From render with GNU General Public License v2.0 5 votes vote down vote up
boolean setParametersFromDialog() {

            final GenericDialog dialog = new GenericDialog("Export Parameters");

            final int defaultTextColumns = 100;
            dialog.addStringField("Render Web Services Base URL", baseDataUrl, defaultTextColumns);
            layerRange.addFieldsToDialog(dialog);
            dialog.addCheckbox("Only Export Visible Patches", onlyExportVisiblePatches);
            dialog.addCheckbox("Use Patch Title For Tile ID", usePatchTitleForTileId);
            dialog.addMessage("  note: leave unchecked to use TrakEM2 patch object ID as tile ID");
            dialog.addStringField("Target Render Stack Owner", targetRenderOwner, defaultTextColumns);
            dialog.addStringField("Target Render Stack Project", targetRenderProject, defaultTextColumns);
            dialog.addStringField("Target Render Stack Name", targetRenderStack, defaultTextColumns);
            dialog.addNumericField("Stack Resolution X (nm/pixel)", stackResolutionX, 0);
            dialog.addNumericField("Stack Resolution Y (nm/pixel)", stackResolutionY, 0);
            dialog.addNumericField("Stack Resolution Z (nm/pixel)", stackResolutionZ, 0);
            dialog.addCheckbox("Complete Stack After Export", completeStackAfterExport);

            dialog.showDialog();
            dialog.repaint(); // seems to help with missing dialog elements, but shouldn't be necessary

            final boolean wasCancelled = dialog.wasCanceled();

            if (! wasCancelled) {
                baseDataUrl = dialog.getNextString().trim();
                layerRange.setFieldsFromDialog(dialog);
                onlyExportVisiblePatches = dialog.getNextBoolean();
                usePatchTitleForTileId = dialog.getNextBoolean();
                targetRenderOwner = dialog.getNextString().trim();
                targetRenderProject = dialog.getNextString().trim();
                targetRenderStack =  dialog.getNextString().trim();
                stackResolutionX = dialog.getNextNumber();
                stackResolutionY = dialog.getNextNumber();
                stackResolutionZ = dialog.getNextNumber();
                completeStackAfterExport = dialog.getNextBoolean();
            }

            return wasCancelled;
        }
 
Example 7
Source File: AbstractLayerAlignmentParam.java    From TrakEM2 with GNU General Public License v3.0 5 votes vote down vote up
public boolean setupSIFT( final String title )
{
	/* SIFT */
	final GenericDialog gdSIFT = new GenericDialog( title + "SIFT parameters" );

	SIFT.addFields( gdSIFT, ppm.sift );

	gdSIFT.addMessage( "Local Descriptor Matching:" );
	gdSIFT.addNumericField( "closest/next_closest_ratio :", ppm.rod, 2 );

	gdSIFT.addMessage( "Miscellaneous:" );
	gdSIFT.addCheckbox( "clear_cache", ppm.clearCache );
	gdSIFT.addNumericField( "feature_extraction_threads :", ppm.maxNumThreadsSift, 0 );

	gdSIFT.showDialog();

	if ( gdSIFT.wasCanceled() )
		return false;

	SIFT.readFields( gdSIFT, ppm.sift );

	ppm.rod = ( float )gdSIFT.getNextNumber();
	ppm.clearCache = gdSIFT.getNextBoolean();
	ppm.maxNumThreadsSift = ( int )gdSIFT.getNextNumber();

	return true;
}
 
Example 8
Source File: Specify_Calibration.java    From SPIM_Registration with GNU General Public License v2.0 5 votes vote down vote up
public static boolean queryNewCal( final ArrayList< Cal > calibrations, final Cal maxCal )
{
	final GenericDialog gd = new GenericDialog( "Define new calibration" );
	
	gd.addNumericField( "Calibration_x", maxCal.getCal()[ 0 ], 40, 20, "" );
	// ImageJ cuts of part of the number otherwise
	((TextField)gd.getNumericFields().lastElement()).setText( "" + maxCal.getCal()[ 0 ] );
	gd.addNumericField( "Calibration_y", maxCal.getCal()[ 1 ], 40, 20, "" );
	// ImageJ cuts of part of the number otherwise
	((TextField)gd.getNumericFields().lastElement()).setText( "" + maxCal.getCal()[ 1 ] );
	gd.addNumericField( "Calibration_z", maxCal.getCal()[ 2 ], 40, 20, "" );
	// ImageJ cuts of part of the number otherwise
	((TextField)gd.getNumericFields().lastElement()).setText( "" + maxCal.getCal()[ 2 ] );
	gd.addStringField( "Unit", maxCal.unit() );

	if ( calibrations.size() > 1 )
		gd.addMessage( "WARNING: Calibrations are not the same for all\n" +
					   "view setups! All calibrations will be overwritten\n" +
					   "for all view setups if defined here.",
					   GUIHelper.mediumstatusfont, GUIHelper.warning );

	gd.addMessage( "Note: These values will be applied to selected view\n" +
				   "setups, existing registration are not affected and\n" +
				   "will need to be recomputed if necessary.",
				   GUIHelper.mediumstatusfont );

	gd.showDialog();
	
	if ( gd.wasCanceled() )
		return false;
	
	maxCal.getCal()[ 0 ] = gd.getNextNumber();
	maxCal.getCal()[ 1 ] = gd.getNextNumber();
	maxCal.getCal()[ 2 ] = gd.getNextNumber();
	maxCal.setUnit( gd.getNextString() );

	return true;
}
 
Example 9
Source File: DistanceTransformWatershed.java    From MorphoLibJ with GNU Lesser General Public License v3.0 4 votes vote down vote up
public int showDialog(
		ImagePlus imp,
		String command,
		PlugInFilterRunner pfr )
{
	if( !BinaryImages.isBinaryImage( imp ) )
	{
		IJ.error( "Distance Transform Watershed", "Input image is not"
				+ " binary (8-bit with only 0 or 255 values)" );
		return DONE;
	}
	// Store user data
	this.imagePlus = imp;
	this.baseImage = imp.getProcessor().duplicate();
	this.pfr = pfr;

	// Create a new generic dialog with appropriate options
	GenericDialog gd = new GenericDialog( "Distance Transform Watershed" );
	gd.setInsets( 0, 0, 0 );
	gd.addMessage( "Distance map options:",
			new Font( "SansSerif", Font.BOLD, 12 ) );
	gd.addChoice( "Distances", ChamferWeights.getAllLabels(), weightLabel );
	String[] outputTypes = new String[]{"32 bits", "16 bits"};
	gd.addChoice( "Output Type", outputTypes, outputTypes[ floatProcessing ? 0:1 ]);
	gd.setInsets( 0, 0, 0 );
	gd.addCheckbox( "Normalize weights", normalize );
	gd.setInsets( 20, 0, 0 );
	gd.addMessage( "Watershed options:",
			new Font( "SansSerif", Font.BOLD, 12 ) );
	gd.addNumericField( "Dynamic", dynamic, 2 );
	gd.addChoice( "Connectivity", Conn2D.getAllLabels(), connLabel );
	gd.setInsets( 20, 0, 0 );
	gd.addPreviewCheckbox( pfr );
	gd.addDialogListener(this);
	previewing = true;
	gd.addHelp( "http://imagej.net/MorphoLibJ#Utilities_for_binary_images" );
	gd.showDialog();
	previewing = false;

	// test cancel
	if (gd.wasCanceled())
		return DONE;

	// set up current parameters
	weightLabel = gd.getNextChoice();
	floatProcessing = gd.getNextChoiceIndex() == 0;
	normalize = gd.getNextBoolean();
	dynamic = (int) gd.getNextNumber();
	connLabel = gd.getNextChoice();
	connectivity = Conn2D.fromLabel( connLabel ).getValue();

	// identify which weights should be used
	weights = ChamferWeights.fromLabel( weightLabel );

	return flags;
}
 
Example 10
Source File: GUIHelper.java    From SPIM_Registration with GNU General Public License v2.0 4 votes vote down vote up
public static final void addPreibischLabWebsite( final GenericDialog gd )
{
	gd.addMessage( "This software is developed by the Preibisch Lab in collaboration with the ImgLib2 and Fiji team\nhttp://preibischlab.mdc-berlin.de/", new Font( Font.SANS_SERIF, Font.BOLD, 12 ) );
	MultiLineLabel text =  (MultiLineLabel) gd.getMessage();
	GUIHelper.addHyperLinkListener( text, "http://preibischlab.github.io/preibisch-labsite" );
}
 
Example 11
Source File: DistanceTransformWatershed3D.java    From MorphoLibJ with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * Plugin run method
 */
public void run(String arg) {
	
	ImagePlus image = WindowManager.getCurrentImage();
	if ( image == null ) 
	{
		IJ.error("Distance Transform Watershed 3D",
				"Need at least one image to work");
		return;
	}

	if( !BinaryImages.isBinaryImage( image ) )
	{
		IJ.error( "Distance Transform Watershed 3D", "Input image is not"
				+ " binary (8-bit with only 0 or 255 values)" );
	}

	// Create a new generic dialog with appropriate options
	GenericDialog gd = new GenericDialog( "Distance Transform Watershed 3D" );
	gd.setInsets( 0, 0, 0 );
	gd.addMessage( "Distance map options:",
			new Font( "SansSerif", Font.BOLD, 12 ) );
	gd.addChoice( "Distances", ChamferWeights3D.getAllLabels(), weightLabel );
	String[] outputTypes = new String[]{"32 bits", "16 bits"};
	gd.addChoice( "Output Type", outputTypes, outputTypes[ floatProcessing ? 0:1 ]);
	gd.setInsets( 0, 0, 0 );
	gd.addCheckbox( "Normalize weights", normalize );
	gd.setInsets( 20, 0, 0 );
	gd.addMessage( "Watershed options:",
			new Font( "SansSerif", Font.BOLD, 12 ) );
	gd.addNumericField( "Dynamic", dynamic, 2 );
	gd.addChoice( "Connectivity", Conn3D.getAllLabels(),
			connectivity.label );
	gd.addHelp( "http://imagej.net/MorphoLibJ#Utilities_for_binary_images" );
	gd.showDialog();

	// test cancel
	if ( gd.wasCanceled() )
		return;

	// set up current parameters
	weightLabel = gd.getNextChoice();
	floatProcessing = gd.getNextChoiceIndex() == 0;
	normalize = gd.getNextBoolean();
	dynamic = (int) gd.getNextNumber();
	connectivity = Conn3D.fromLabel( gd.getNextChoice() );

	// identify which weights should be used
	weights = ChamferWeights3D.fromLabel( weightLabel );

	long t0 = System.currentTimeMillis();

	final ImagePlus result;
	if (floatProcessing)
		result = processFloat( image, weights.getFloatWeights(), normalize );
	else
		result = processShort( image, weights.getShortWeights(), normalize );

	Images3D.optimizeDisplayRange( result );

	// Display the result image
	result.show();
	result.setSlice( image.getCurrentSlice() );

	// Display elapsed time
	long t1 = System.currentTimeMillis();
	IJUtils.showElapsedTime( "Distance Transform Watershed 3D",
			t1 - t0, image );
}
 
Example 12
Source File: ParticleAnalysis3DPlugin.java    From MorphoLibJ with GNU Lesser General Public License v3.0 4 votes vote down vote up
public void run(String args) 
  {
      ImagePlus imagePlus = IJ.getImage();
      
if (imagePlus.getStackSize() == 1) 
{
	IJ.error("Requires a Stack");
	return;
}

      // create the dialog, with operator options
      GenericDialog gd = new GenericDialog("Particles Analysis 3D");
      gd.addCheckbox("Volume", true);
      gd.addCheckbox("Surface Area", true);
      gd.addCheckbox("Sphericity", true);
      gd.addCheckbox("Euler Number", true);
      gd.addCheckbox("Equivalent Ellipsoid", true);
      gd.addCheckbox("Ellipsoid Elongation", true);
      gd.addCheckbox("Max. Inscribed Ball", true);
      gd.addMessage("");
      gd.addChoice("Surface area method:", surfaceAreaMethods, surfaceAreaMethods[1]);
      gd.addChoice("Euler Connectivity:", connectivityNames, connectivityNames[1]);
      gd.showDialog();
      
      // If cancel was clicked, do nothing
      if (gd.wasCanceled())
          return;

      // Extract features to extract from image
      computeVolume 		= gd.getNextBoolean();
      computeSurface 		= gd.getNextBoolean();
      computeSphericity 	= gd.getNextBoolean() & computeVolume & computeSurface;
      computeEulerNumber	= gd.getNextBoolean();
      computeEllipsoid 	= gd.getNextBoolean();
      computeElongations 	= gd.getNextBoolean() & computeEllipsoid;
      computeInscribedBall = gd.getNextBoolean();
      
      
      // extract analysis options
      surfaceAreaDirs = dirNumbers[gd.getNextChoiceIndex()];
      connectivity = connectivityValues[gd.getNextChoiceIndex()];
      
      // Execute the plugin
      ResultsTable table = process(imagePlus);
      
	// create string for indexing results
String tableName = imagePlus.getShortTitle() + "-morpho"; 
  
// show result
table.show(tableName);
  }
 
Example 13
Source File: GenericLoadParseQueryXML.java    From SPIM_Registration with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Querys a pattern of element from the list
 * 
 * @param name - type of elements (e.g. "Timepoints")
 * @param list - list of available elements
 * @param defaultSelectionArray - default selection (array of size 1 to be able to return it)
 * @return the selection or null if cancelled
 */
public static boolean[] queryPattern( final String name, final String[] list, final String[] defaultSelectionArray )
{
	String defaultSelection = defaultSelectionArray[ 0 ];

	if ( defaultSelection == null || defaultSelection.length() == 0 )
	{
		defaultSelection = list[ 0 ];
		
		for ( int i = 1; i < Math.min( list.length, 3 ); ++i )
			defaultSelection += "," + list[ i ];
	}
	
	final GenericDialog gd = new GenericDialog( "Select Range of " + name );
	
	gd.addMessage( "" );
	gd.addStringField( "Process_following_" + name, defaultSelection, 30 );
	gd.addMessage( "" );
	gd.addMessage( "Available " + name + ":" );
	
	final String singular = name.substring( 0, name.length() - 1 ) + " ";
	String allTps = singular + list[ 0 ];
	
	for ( int i = 1; i < list.length; ++i )
		allTps += "\n" + singular + list[ i ];
	
	gd.addMessage( allTps, GUIHelper.smallStatusFont );
	
	GUIHelper.addScrollBars( gd );
	gd.showDialog();
	
	if ( gd.wasCanceled() )
		return null;
	
	// the result
	final boolean[] selected = new boolean[ list.length ];
	
	for ( int i = 0; i < list.length; ++i )
		selected[ i ] = false;
	
	try 
	{
		final ArrayList< String > nameList = NamePattern.parseNameString( defaultSelection = gd.getNextString(), true );
		
		for ( final String entry : nameList )
		{
			boolean found = false;
			
			for ( int i = 0; i < list.length && !found; ++i )
			{
				if ( entry.equals( list[ i ] ) )
				{
					selected[ i ] = true;
					found = true;
				}
			}
			
			if ( !found )
				IOFunctions.println( name + " " + entry + " not part of the list of " + name + "s. Ignoring it." );
		}				
	} 
	catch ( final ParseException e ) 
	{
		IOFunctions.println( "Cannot parse pattern '" + defaultSelection + "': " + e );
		return null;
	}
	
	defaultSelectionArray[ 0 ] = defaultSelection;
	
	return selected;
}
 
Example 14
Source File: AnalyzeMicrostructure3D.java    From MorphoLibJ with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public void run(String arg)
{
    ImagePlus imagePlus = IJ.getImage();
    
    if (imagePlus.getStackSize() == 1) 
    {
        IJ.error("Requires a Stack");
        return;
    }
    
    // create the dialog, with operator options
    GenericDialog gd = new GenericDialog("Microstructure Analysis");
    gd.addCheckbox("Volume", true);
    gd.addCheckbox("Surface Area", true);
    gd.addCheckbox("Mean_Breadth", true);
    gd.addCheckbox("Euler Number", true);
    gd.addMessage("");
    gd.addChoice("Surface area method:", dirNumberLabels, dirNumberLabels[1]);
    gd.addChoice("Mean breadth method:", dirNumberLabels, dirNumberLabels[1]);
    gd.addChoice("Mean Breadth Conn.:", connectivity2dNames, connectivity2dNames[1]);
    gd.addChoice("Euler Connectivity:", connectivity3dNames, connectivity3dNames[1]);
    gd.showDialog();
    
    // If cancel was clicked, do nothing
    if (gd.wasCanceled())
        return;

    // Extract features to extract from image
    computeVolume       = gd.getNextBoolean();
    computeSurface      = gd.getNextBoolean();
    computeMeanBreadth  = gd.getNextBoolean();
    computeEulerNumber  = gd.getNextBoolean();
    
    // extract analysis options
    surfaceAreaDirs = dirNumbers[gd.getNextChoiceIndex()];
    meanBreadthDirs = dirNumbers[gd.getNextChoiceIndex()];
    connectivity2d = connectivity2dValues[gd.getNextChoiceIndex()];
    connectivity = connectivity3dValues[gd.getNextChoiceIndex()];
    
    // Execute the plugin
    ResultsTable table = process(imagePlus);
    
    // create string for indexing results
    String tableName = imagePlus.getShortTitle() + "-microstructure"; 

    // show result
    table.show(tableName);
}
 
Example 15
Source File: Segmentation.java    From TrakEM2 with GNU General Public License v3.0 4 votes vote down vote up
public boolean setup() {
	GenericDialog gd = new GenericDialog("Fast Marching Options");
	gd.addMessage("Fast Marching:");
	gd.addNumericField("Grey value threshold", fm_grey, 0);
	gd.addNumericField("Distance threshold", fm_dist, 2);
	gd.addNumericField("Max iterations", max_iterations, 0);
	gd.addNumericField("Iterations inc", iter_inc, 0);
	gd.addCheckbox("Enable grey value erosion filter", apply_grey_value_erosion);
	gd.addMessage("Lasso:");
	gd.addNumericField("ratio space/color:", ratio_space_color, 2);
	gd.addMessage("Preprocessing by bandpass filter:");
	gd.addCheckbox("Enable bandpass filter", apply_bandpass_filter);
               gd.addNumericField("Filter_Large Structures Down to", low_frequency_threshold, 0, 4, "pixels");
               gd.addNumericField("Filter_Small Structures Up to", high_frequency_threshold, 0, 4, "pixels");
               gd.addCheckbox("Autoscale After Filtering", autoscale_after_filtering);
               gd.addCheckbox("Saturate Image when Autoscaling", saturate_when_autoscaling);
	final Component[] c = {
		(Component)gd.getNumericFields().get(gd.getNumericFields().size()-2),
		(Component)gd.getNumericFields().get(gd.getNumericFields().size()-1),
		(Component)gd.getCheckboxes().get(gd.getCheckboxes().size()-2),
		(Component)gd.getCheckboxes().get(gd.getCheckboxes().size()-1)
	};
	Utils.addEnablerListener((Checkbox)gd.getCheckboxes().get(gd.getCheckboxes().size()-3), c, null);
	if (!apply_bandpass_filter) {
		for (Component comp : c) comp.setEnabled(false);
	}
	gd.addMessage("Semiautomatic neurite tracer:");
	gd.addCheckbox("Invert image", SNT_invert_image);
	gd.showDialog();
	if (gd.wasCanceled()) return false;

	// FastMarching:
	fm_grey = (int) gd.getNextNumber();
	fm_dist = gd.getNextNumber();
	max_iterations = (int)gd.getNextNumber();
	iter_inc = (int)gd.getNextNumber();
	// Grey value erosion:
	apply_grey_value_erosion = gd.getNextBoolean();

	// Ratio space/color for lasso:
	ratio_space_color = gd.getNextNumber();

	// Bandpass filter:
	apply_bandpass_filter = gd.getNextBoolean();
	low_frequency_threshold = (int) gd.getNextNumber();
	high_frequency_threshold = (int) gd.getNextNumber();
	autoscale_after_filtering = gd.getNextBoolean();
	saturate_when_autoscaling = gd.getNextBoolean();

	// Semiautomatic neurite tracer:
	SNT_invert_image = gd.getNextBoolean();

	return true;
}
 
Example 16
Source File: InterfaceSurfaceArea3D.java    From MorphoLibJ with GNU Lesser General Public License v3.0 4 votes vote down vote up
public void run(String args) 
  {
      ImagePlus imagePlus = IJ.getImage();
      
if (imagePlus.getStackSize() == 1) 
{
	IJ.error("Requires a Stack");
	return;
}

      // create the dialog, with operator options
      GenericDialog gd = new GenericDialog("Interface Surface Area");
      gd.addNumericField("Label 1", 1, 0);
      gd.addNumericField("Label 2", 2, 0);
      gd.addMessage("");
      gd.addChoice("Surface_area_method:", surfaceAreaMethods, surfaceAreaMethods[1]);
      gd.showDialog();
      
      // If cancel was clicked, do nothing
      if (gd.wasCanceled())
          return;

      // extract analysis options
      int label1 = (int) gd.getNextNumber();
      int label2 = (int) gd.getNextNumber();
      nDirs = dirNumbers[gd.getNextChoiceIndex()];
      
      // Extract Image Stack and its calibration
      ImageStack image = imagePlus.getStack();
      Calibration calib = imagePlus.getCalibration();

      double S12 = IntrinsicVolumes3D.interfaceSurfaceArea(image, label1, label2, calib, nDirs);
      
      // Execute the plugin
      ResultsTable table = new ResultsTable();
      table.incrementCounter();
      table.addValue("Label1", label1);
      table.addValue("Label2", label2);
      table.addValue("Interf.Surf", S12);
      
	// create string for indexing results
String tableName = imagePlus.getShortTitle() + "-Interface"; 
  
// show result
table.show(tableName);
  }
 
Example 17
Source File: ImportFromRender_Plugin.java    From render with GNU General Public License v2.0 4 votes vote down vote up
boolean setParametersFromDialog() {

            final GenericDialog dialog = new GenericDialog("Import Parameters");

            final int defaultTextColumns = 80;
            dialog.addStringField("Render Web Services Base URL", baseDataUrl, defaultTextColumns);
            dialog.addStringField("Render Stack Owner", renderOwner, defaultTextColumns);
            dialog.addStringField("Render Stack Project", renderProject, defaultTextColumns);
            dialog.addStringField("Render Stack Name", renderStack, defaultTextColumns);
            dialog.addStringField("Channel (empty for default)", "", defaultTextColumns);
            dialog.addNumericField("Min Z", minZ, 1);
            dialog.addNumericField("Max Z", maxZ, 1);
            dialog.addNumericField("Image Plus Type (use '-1' to slowly derive dynamically)", imagePlusType, 0);
            dialog.addMessage("  note: image plus type values are: 0:GRAY8, 1:GRAY16, 2:GRAY32, 3:COLOR_256, 4:COLOR_RGB");
            dialog.addCheckbox("Load Masks", loadMasks);
            dialog.addCheckbox("Split Sections", splitSections);
            dialog.addCheckbox("Replace Last Transform With Stage", replaceLastWithStage);
            dialog.addNumericField("Number of threads for mipmaps", numberOfMipmapThreads, 0);

            dialog.showDialog();
            dialog.repaint(); // seems to help with missing dialog elements, but shouldn't be necessary

            final boolean wasCancelled = dialog.wasCanceled();

            if (! wasCancelled) {
                baseDataUrl = dialog.getNextString();
                renderOwner = dialog.getNextString();
                renderProject = dialog.getNextString();
                renderStack =  dialog.getNextString();
                String channelString = dialog.getNextString();
                if (channelString != null && channelString.length() > 0) {
                    channels.add(channelString);
                }
                minZ = dialog.getNextNumber();
                maxZ = dialog.getNextNumber();
                imagePlusType = new Double(dialog.getNextNumber()).intValue();
                loadMasks = dialog.getNextBoolean();
                splitSections = dialog.getNextBoolean();
                replaceLastWithStage = dialog.getNextBoolean();
                numberOfMipmapThreads = (int) dialog.getNextNumber();
            }

            return wasCancelled;
        }
 
Example 18
Source File: EfficientBayesianBased.java    From SPIM_Registration with GNU General Public License v2.0 4 votes vote down vote up
protected boolean getBlending()
{
	if ( adjustBlending )
	{
		final GenericDialog gd = new GenericDialog( "Adjust blending parameters" );
		
		if ( defaultBlendingBorder == null || defaultBlendingBorder.length < 3 )
			defaultBlendingBorder = new int[]{ defaultBlendingBorderNumber, defaultBlendingBorderNumber, Math.round( defaultBlendingBorderNumber/2.5f ) };
		
		if ( defaultBlendingRange == null || defaultBlendingRange.length < 3 )
			defaultBlendingRange =  new int[]{ defaultBlendingRangeNumber, defaultBlendingRangeNumber, defaultBlendingRangeNumber };
		
		gd.addSlider( "Boundary_pixels_X", -50, 50, defaultBlendingBorder[ 0 ] );
		gd.addSlider( "Boundary_pixels_Y", -50, 50, defaultBlendingBorder[ 1 ] );
		gd.addSlider( "Boundary_pixels_Z", -50, 50, defaultBlendingBorder[ 2 ] );
		gd.addSlider( "Blending_range_X", 0, 100, defaultBlendingRange[ 0 ] );
		gd.addSlider( "Blending_range_Y", 0, 100, defaultBlendingRange[ 1 ] );
		gd.addSlider( "Blending_range_Z", 0, 100, defaultBlendingRange[ 2 ] );
		
		gd.addMessage( "" );
		gd.addMessage( "Note: both sizes are in local coordinates of the input views. Increase one or both of those values if stripy artifacts\n" +
					   "are visible in the deconvolution result.\n" +
					   "The boundary pixels describe a range of pixels at the edge of each input view that are discarded because of the PSF size,\n" +
					   "it should typically correspond to half the size of the extracted PSF.\n" +
					   "The blending range defines in which outer part of each view the cosine blending is performed. You can manually inspect\n" +
					   "the results of these operations by choosing 'Illustrate overlap of views per pixel (do not deconvolve)' in the previous\n" +
					   "dialog. Choose just one input view to get an idea of what is cut off for individual stacks.", GUIHelper.mediumstatusfont );
		
		gd.showDialog();
		
		if ( gd.wasCanceled() )
			return false;
		
		blendingBorderX = defaultBlendingBorder[ 0 ] = (int)Math.round( gd.getNextNumber() );
		blendingBorderY = defaultBlendingBorder[ 1 ] = (int)Math.round( gd.getNextNumber() );
		blendingBorderZ = defaultBlendingBorder[ 2 ] = (int)Math.round( gd.getNextNumber() );
		blendingRangeX = defaultBlendingRange[ 0 ] = (int)Math.round( gd.getNextNumber() );
		blendingRangeY = defaultBlendingRange[ 1 ] = (int)Math.round( gd.getNextNumber() );
		blendingRangeZ = defaultBlendingRange[ 2 ] = (int)Math.round( gd.getNextNumber() );
	}
	else
	{
		if ( defaultBlendingBorder != null && defaultBlendingBorder.length >= 3 )
		{
			blendingBorderX = defaultBlendingBorder[ 0 ];
			blendingBorderY = defaultBlendingBorder[ 1 ];
			blendingBorderZ = defaultBlendingBorder[ 2 ];
		}
		else
		{
			blendingBorderX = defaultBlendingBorderNumber;
			blendingBorderY = defaultBlendingBorderNumber;
			blendingBorderZ = Math.round( defaultBlendingBorderNumber/2.5f );
		}
		
		if ( defaultBlendingRange != null && defaultBlendingRange.length >= 3 )
		{
			blendingRangeX = defaultBlendingRange[ 0 ];
			blendingRangeY = defaultBlendingRange[ 1 ];
			blendingRangeZ = defaultBlendingRange[ 2 ];
		}
		else
		{
			blendingRangeX = defaultBlendingRangeNumber;
			blendingRangeY = defaultBlendingRangeNumber;
			blendingRangeZ = defaultBlendingRangeNumber;
		}
	}
	
	return true;
}
 
Example 19
Source File: AnalyzeSkeleton_.java    From AnalyzeSkeleton with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Process the image: tag skeleton and show results.
 * 
 * @see ij.plugin.filter.PlugInFilter#run(ij.process.ImageProcessor)
 */
public void run(ImageProcessor ip) 
{
	loadDialogSettings();
	createSettingsDialog();
	settingsDialog.showDialog();
	if (settingsDialog.wasCanceled()) {
		return;
	}
	setSettingsFromDialog();
	saveDialogSettings();

	// pre-checking if another image is needed and also setting bPruneCycles
	ImagePlus origIP = null;
	switch(pruneIndex)
	{
		// No pruning
		case AnalyzeSkeleton_.NONE:
			this.bPruneCycles = false;
			break;
		// Pruning cycles by shortest branch
		case AnalyzeSkeleton_.SHORTEST_BRANCH:
			this.bPruneCycles = true;
			break;
		// Pruning cycles by lowest pixel intensity
		case AnalyzeSkeleton_.LOWEST_INTENSITY_VOXEL:
		case AnalyzeSkeleton_.LOWEST_INTENSITY_BRANCH:
			// Select original image between the open images
			int[] ids = WindowManager.getIDList();
			if ( ids == null || ids.length < 1 )
			{
				IJ.showMessage( "You should have at least one image open." );
				return;
			}

			String[] titles = new String[ ids.length ];
			for ( int i = 0; i < ids.length; ++i )
			{
				titles[ i ] = ( WindowManager.getImage( ids[ i ] ) ).getTitle();
			}

			final GenericDialog gd2 = new GenericDialog( "Image selection" );

			gd2.addMessage( "Select original grayscale image:" );
			final String current = WindowManager.getCurrentImage().getTitle();
			gd2.addChoice( "original_image", titles, current );

			gd2.showDialog();

			if (gd2.wasCanceled()) 
				return;

			// Get original stack
			origIP = WindowManager.getImage( ids[ gd2.getNextChoiceIndex() ] );

			this.bPruneCycles = true;
			break;
		default:
	}

	// now we have all the information that's needed for running the plugin
	// as if it was called from somewhere else
	run(pruneIndex, pruneEnds, calculateShortestPath, origIP, false,
			verbose, (protectRoi) ? this.imRef.getRoi() : null);

	if(debug)
		IJ.log("num of skeletons = " + this.numOfTrees);

	// Show labeled skeletons
	if( AnalyzeSkeleton_.displaySkeletons )
	{
		ImagePlus labeledSkeletons = 
				new ImagePlus( this.imRef.getShortTitle() 
						+ "-labeled-skeletons", this.labeledSkeletons.duplicate() );
		IJ.run( labeledSkeletons, "Fire", null );
		labeledSkeletons.show();
	}

	// Show results table
	showResults();

}
 
Example 20
Source File: DistortionCorrectionTask.java    From TrakEM2 with GNU General Public License v3.0 4 votes vote down vote up
public boolean setup( final Selection selection )
{
	if ( !setupSIFT( "Distortion Correction: " ) )
		return false;

	/* Geometric filters */

	final GenericDialog gd = new GenericDialog( "Distortion Correction: Geometric filters" );

	gd.addNumericField( "maximal_alignment_error :", maxEpsilon, 2, 6, "px" );
	gd.addNumericField( "minimal_inlier_ratio :", minInlierRatio, 2 );
	gd.addNumericField( "minimal_number_of_inliers :", minNumInliers, 0 );
	gd.addChoice( "expected_transformation :", Param.modelStrings, Param.modelStrings[ expectedModelIndex ] );
	gd.addCheckbox( "test_multiple_hypotheses", multipleHypotheses );
	gd.addCheckbox( "ignore constant background", rejectIdentity );
	gd.addNumericField( "tolerance :", identityTolerance, 2, 6, "px" );
	gd.addCheckbox( "tiles are rougly in place", tilesAreInPlace );

	gd.showDialog();

	if ( gd.wasCanceled() )
		return false;

	maxEpsilon = ( float )gd.getNextNumber();
	minInlierRatio = ( float )gd.getNextNumber();
	minNumInliers = ( int )gd.getNextNumber();
	expectedModelIndex = gd.getNextChoiceIndex();
	multipleHypotheses = gd.getNextBoolean();
	rejectIdentity = gd.getNextBoolean();
	identityTolerance = ( float )gd.getNextNumber();
	tilesAreInPlace = gd.getNextBoolean();

	final GenericDialog gdOptimize = new GenericDialog( "Distortion Correction: Montage Optimization" );
	gdOptimize.addChoice( "desired_transformation :", modelStrings, modelStrings[ desiredModelIndex ] );
	gdOptimize.addCheckbox( "regularize_model", regularize );
	gdOptimize.addMessage( "Optimization:" );
	gdOptimize.addNumericField( "maximal_iterations :", maxIterationsOptimize, 0 );
	gdOptimize.addNumericField( "maximal_plateauwidth :", maxPlateauwidthOptimize, 0 );

	gdOptimize.showDialog();

	if ( gdOptimize.wasCanceled() )
		return false;

	desiredModelIndex = gdOptimize.getNextChoiceIndex();
	regularize = gdOptimize.getNextBoolean();
	maxIterationsOptimize = ( int )gdOptimize.getNextNumber();
	maxPlateauwidthOptimize = ( int )gdOptimize.getNextNumber();

	if ( regularize )
	{
		final GenericDialog gdRegularize = new GenericDialog( "Distortion Correction: Montage Regularization" );

		gdRegularize.addChoice( "regularizer :", modelStrings, modelStrings[ regularizerIndex ] );
		gdRegularize.addNumericField( "lambda :", lambdaRegularize, 2 );

		gdRegularize.showDialog();

		if ( gdRegularize.wasCanceled() )
			return false;

		regularizerIndex = gdRegularize.getNextChoiceIndex();
		lambdaRegularize = gdRegularize.getNextNumber();
	}

	final GenericDialog gdLens = new GenericDialog( "Distortion Correction: Lens Distortion" );

	gdLens.addMessage( "Lens Model :" );
	gdLens.addNumericField( "power_of_polynomial_kernel :", dimension, 0 );
	gdLens.addNumericField( "lambda :", lambda, 6 );

	gdLens.addMessage( "Apply Distortion Correction :" );

	Utils.addLayerRangeChoices( selection.getLayer(), gdLens );
	gdLens.addCheckbox( "clear_present_transforms", clearTransform );
	gdLens.addCheckbox( "visualize_distortion_model", visualize );

	gdLens.showDialog();
	if ( gdLens.wasCanceled() )
		return false;

	dimension = ( int )gdLens.getNextNumber();
	lambda = ( double )gdLens.getNextNumber();
	firstLayerIndex = gdLens.getNextChoiceIndex();
	lastLayerIndex = gdLens.getNextChoiceIndex();
	clearTransform = gdLens.getNextBoolean();
	visualize = gdLens.getNextBoolean();

	return true;
}