Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/main/java/fiji/plugin/trackmate/LoadTrackMatePlugIn.java
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,8 @@ public void run( final String filePath )
ImagePlus imp = reader.readImage();
if ( null == imp )
imp = ViewUtils.makeEmpytImagePlus( model );



/*
* Read settings.
*/
Expand All @@ -151,6 +152,11 @@ public void run( final String filePath )
+ "The file did not contain a settings element. Using default values." );
settings = new Settings( imp );
}

/**
* Check if settings and image dimensions don't match in Z and T dimensions
*/
GuiUtils.checkDimensionsImpAndSettings( imp, settings );

/*
* Declare the analyzers that are in the settings to the model. This is
Expand Down
40 changes: 40 additions & 0 deletions src/main/java/fiji/plugin/trackmate/gui/GuiUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
*/
package fiji.plugin.trackmate.gui;


import java.awt.Color;
import java.awt.Component;
import java.awt.Desktop;
Expand Down Expand Up @@ -62,6 +63,7 @@
import org.scijava.prefs.PrefService;

import fiji.plugin.trackmate.util.TMUtils;
import fiji.plugin.trackmate.Settings;
import ij.IJ;
import ij.ImagePlus;
import ij.measure.Calibration;
Expand Down Expand Up @@ -255,6 +257,44 @@ public static final void userCheckImpDimensions( final ImagePlus imp )
}
}
}

/**
* Check if the image dimensions and the dimensions in the settings match
* @param imp movie to check Z and T dimensions
* @param settings settings loaded from TrackMate file
*/
public static final void checkDimensionsImpAndSettings( final ImagePlus imp, final Settings settings )
{
final int[] dims = imp.getDimensions();
// dimension of image and .xml metadata match, don't do anything
if ( ( settings.nslices == dims[3] ) && ( settings.nframes == dims[4] ) )
return;

if ( dims[ 4 ] == 1 && dims[ 3 ] > 1 )
{
switch ( JOptionPane.showConfirmDialog( null,
"It appears this image has 1 timepoint but "
+ dims[ 3 ]
+ " slices, while the TrackMate file has "+settings.nframes+" timepoint and "+settings.nslices+" slices.\n"
+ "Do you want to swap Z and T?",
"Z/T swapped?", JOptionPane.YES_NO_CANCEL_OPTION ) )
{
case JOptionPane.YES_OPTION:
imp.setDimensions( dims[ 2 ], dims[ 4 ], dims[ 3 ] );
final Calibration calibration = imp.getCalibration();
if ( 0. == calibration.frameInterval )
{
calibration.frameInterval = 1;
calibration.setTimeUnit( "frame" );
}
break;

case JOptionPane.CANCEL_OPTION:
return;
}
}
}


public static void setSystemLookAndFeel()
{
Expand Down