Skip to content

Commit

Permalink
change unsigned int to float
Browse files Browse the repository at this point in the history
  • Loading branch information
kapoorlab committed Feb 9, 2024
1 parent dea8bfa commit 7dca1cd
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import ij.ImagePlus;
import net.imagej.ImgPlus;
import net.imglib2.type.numeric.integer.UnsignedShortType;
import net.imglib2.type.numeric.real.FloatType;
import net.imglib2.util.Pair;

public class OneatCorrector implements TrackCorrector {
Expand All @@ -69,7 +70,7 @@ public class OneatCorrector implements TrackCorrector {

private HashMap<Integer, Pair<Spot, Spot>> Apoptosisspots;

private final ImgPlus<UnsignedShortType> img;
private final ImgPlus<FloatType> img;

private final Map<String, Object> settings;

Expand All @@ -89,7 +90,7 @@ public class OneatCorrector implements TrackCorrector {

private static final String BASE_ERROR_MESSAGE = "[OneatTrackCorrector] ";

public OneatCorrector(final File oneatdivision, final File oneatapoptosis, final ImgPlus<UnsignedShortType> intimg,
public OneatCorrector(final File oneatdivision, final File oneatapoptosis, final ImgPlus<FloatType> intimg,
final Model model, final TrackMate trackmate, final Settings modelsettings,
final DisplaySettings displaySettings, double[] calibration, Map<String, Object> settings,
final Logger logger, final Boolean addDisplay) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
import fiji.plugin.trackmate.gui.displaysettings.DisplaySettings;
import net.imagej.ImgPlus;
import net.imglib2.type.numeric.integer.UnsignedShortType;
import net.imglib2.type.numeric.real.FloatType;

import static fiji.plugin.trackmate.tracking.TrackerKeys.KEY_SPLITTING_MAX_DISTANCE;
import static fiji.plugin.trackmate.detection.DetectorKeys.KEY_TARGET_CHANNEL;
@Plugin( type = TrackCorrectorFactory.class, visible = true )
Expand Down Expand Up @@ -93,7 +95,7 @@ public ImageIcon getIcon() {


@Override
public OneatCorrector create( ImgPlus<UnsignedShortType> img, Model model, TrackMate trackmate, Settings modelsettings, DisplaySettings displaysettings,
public OneatCorrector create( ImgPlus<FloatType> img, Model model, TrackMate trackmate, Settings modelsettings, DisplaySettings displaysettings,
Map<String, Object> settings, final Logger logger, double[] calibration, boolean addDisplay) {


Expand Down Expand Up @@ -239,4 +241,6 @@ public OneatCorrectorFactory copy() {
}




}
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
import net.imglib2.type.numeric.NumericType;
import net.imglib2.type.numeric.RealType;
import net.imglib2.type.numeric.integer.UnsignedShortType;
import net.imglib2.type.numeric.real.FloatType;

public class OneatExporterAction < T extends NativeType< T > & NumericType< T > > extends AbstractTMAction {

Expand Down Expand Up @@ -167,7 +168,7 @@ else if (img.numDimensions() == 5) {
}

@SuppressWarnings({ "rawtypes", "unchecked" })
final ImgPlus< UnsignedShortType > intimg = (ImgPlus) detectionimg;
final ImgPlus< FloatType > intimg = (ImgPlus) detectionimg;


OneatCorrector oneatcorrector = corrector.create(intimg, model, trackmate, settings, displaySettings, mapsettings, logger, calibration, false );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
import fiji.plugin.trackmate.tracking.SpotTracker;
import fiji.plugin.trackmate.tracking.TrackerKeys;
import net.imagej.ImgPlus;
import net.imglib2.type.numeric.integer.UnsignedShortType;
import net.imglib2.type.numeric.real.FloatType;


/**
* Interface for track corrector factories that need to process all the tracks at
Expand All @@ -44,7 +45,7 @@
public interface TrackCorrectorFactory extends TrackMateModule
{

public TrackCorrector create( ImgPlus< UnsignedShortType > img, Model model, TrackMate trackmate, Settings modelsettings, DisplaySettings displaysettings,
public TrackCorrector create( ImgPlus< FloatType > img, Model model, TrackMate trackmate, Settings modelsettings, DisplaySettings displaysettings,
final Map< String, Object > settings, final Logger logger, final double[] calibration, final boolean addDisplay );

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
import net.imglib2.img.display.imagej.ImgPlusViews;
import net.imglib2.type.NativeType;
import net.imglib2.type.numeric.RealType;
import net.imglib2.type.numeric.integer.UnsignedShortType;
import net.imglib2.type.numeric.real.FloatType;
import net.imglib2.util.LinAlgHelpers;
import net.imglib2.util.Pair;
import net.imglib2.util.ValuePair;
Expand Down Expand Up @@ -235,7 +235,7 @@ public static List<Future<Graphobject>> LinkCreator(final Model model, final Tra
HashMap<Pair<Integer, Integer>, Pair<Spot, Integer>> uniquelabelID,
Pair<HashMap<Integer, Spot>, HashMap<Integer, ArrayList<Spot>>> DividingStartspots,
HashMap<Integer, Pair<Spot, ArrayList<Spot>>> Mitosisspots, Map<String, Object> settings, final int ndim,
final Logger logger, final ImgPlus<UnsignedShortType> img, HashMap<Integer, ArrayList<Spot>> framespots,
final Logger logger, final ImgPlus<FloatType> img, HashMap<Integer, ArrayList<Spot>> framespots,
int numThreads, double[] calibration, boolean addDisplay) {

// Get the trackmodel and spots in the default tracking result and start to
Expand Down Expand Up @@ -563,7 +563,7 @@ public static SimpleWeightedGraph<Spot, DefaultWeightedEdge> getCorrectedTracks(
Pair<HashMap<Integer, Spot>, HashMap<Integer, ArrayList<Spot>>> DividingStartspots,
HashMap<Integer, Pair<Spot, ArrayList<Spot>>> Mitosisspots,
HashMap<Integer, Pair<Spot, Spot>> Apoptosisspots, Map<String, Object> settings, final int ndim,
final Logger logger, final ImgPlus<UnsignedShortType> img, HashMap<Integer, ArrayList<Spot>> framespots,
final Logger logger, final ImgPlus<FloatType> img, HashMap<Integer, ArrayList<Spot>> framespots,
int numThreads, double[] calibration, boolean addDisplay) throws InterruptedException, ExecutionException {

// Get the trackmodel and spots in the default tracking result and start to
Expand Down Expand Up @@ -717,7 +717,7 @@ private static void addOverlay(final Roi overlay, final ImagePlus imp, final Spo

}

private static SpotCollection regionspot(final ImgPlus<UnsignedShortType> img, final SpotCollection allspots,
private static SpotCollection regionspot(final ImgPlus<FloatType> img, final SpotCollection allspots,
final Spot motherspot, final Logger logger, final double[] calibration, final int frame,
final double region, final double[] motherslope, final double mariangle, final boolean mariprinciple) {

Expand Down Expand Up @@ -800,7 +800,7 @@ private static Pair<double[], double[]> getEigen(final Ellipsoid ellipsoid, int

}

private static Ellipsoid getEllipsoid(Spot currentspot, ImgPlus<UnsignedShortType> img, double[] calibration) {
private static Ellipsoid getEllipsoid(Spot currentspot, ImgPlus<FloatType> img, double[] calibration) {

int ndim = img.numDimensions();
Ellipsoid currentellipsoid = null;
Expand All @@ -809,19 +809,19 @@ private static Ellipsoid getEllipsoid(Spot currentspot, ImgPlus<UnsignedShortTyp
center[d] = Math.round(currentspot.getFeature(Spot.POSITION_FEATURES[d]).doubleValue() / calibration[d]);
}

ImgPlus<UnsignedShortType> frameimg = ImgPlusViews.hyperSlice(img, ndim - 1,
ImgPlus<FloatType> frameimg = ImgPlusViews.hyperSlice(img, ndim - 1,
(int) currentspot.getFeature(Spot.FRAME).intValue());

long[] location = new long[ndim - 1];
RandomAccess<UnsignedShortType> ranac = frameimg.randomAccess();
RandomAccess<FloatType> ranac = frameimg.randomAccess();
for (int d = 0; d < ndim - 1; ++d) {
location[d] = (long) (currentspot.getDoublePosition(d) / calibration[d]);
ranac.setPosition(location[d], d);
}

int label = ranac.get().get();
int label = (int) ranac.get().get();

Cursor<UnsignedShortType> cur = frameimg.localizingCursor();
Cursor<FloatType> cur = frameimg.localizingCursor();
ArrayList<Localizable> points = new ArrayList<Localizable>();
while (cur.hasNext()) {

Expand Down Expand Up @@ -935,11 +935,11 @@ private static double[] computeAxisAndRadiiFromCovariance(double[][] covariance,
* list of dividing spots for that track
*/
public static Pair<HashMap<Pair<Integer, Integer>, Pair<Spot, Integer>>, Pair<HashMap<Integer, Spot>, HashMap<Integer, ArrayList<Spot>>>> getFirstTrackMateobject(
final Model model, final ImgPlus<UnsignedShortType> img, final Logger logger, double[] calibration) {
final Model model, final ImgPlus<FloatType> img, final Logger logger, double[] calibration) {

Pair<HashMap<Integer, Spot>, HashMap<Integer, ArrayList<Spot>>> DividingStartspots = getTMStartSplit(model);
int ndim = img.numDimensions() - 1;
RandomAccess<UnsignedShortType> ranac = img.randomAccess();
RandomAccess<FloatType> ranac = img.randomAccess();
Set<Integer> AllTrackIds = model.getTrackModel().trackIDs(true);
HashMap<Pair<Integer, Integer>, Pair<Spot, Integer>> uniquelabelID = new HashMap<Pair<Integer, Integer>, Pair<Spot, Integer>>();

Expand All @@ -964,7 +964,7 @@ public static Pair<HashMap<Pair<Integer, Integer>, Pair<Spot, Integer>>, Pair<Ha
}

ranac.setPosition(frame, ndim);
int label = ranac.get().get();
int label = (int) ranac.get().get();

uniquelabelID.put(new ValuePair<Integer, Integer>(label, frame),
new ValuePair<Spot, Integer>(spot, trackID));
Expand All @@ -981,15 +981,15 @@ public static Pair<HashMap<Pair<Integer, Integer>, Pair<Spot, Integer>>, Pair<Ha
public static <T extends RealType<T> & NativeType<T>> HashMap<Integer, Pair<Spot, Spot>> getapoptosisTrackID(
HashMap<Pair<Integer, Integer>, Pair<Spot, Integer>> uniquelabelID,
Pair<HashMap<Integer, Spot>, HashMap<Integer, ArrayList<Spot>>> DividingStartspots, final Model model,
final ImgPlus<UnsignedShortType> img, HashMap<Integer, ArrayList<Spot>> framespots,
final ImgPlus<FloatType> img, HashMap<Integer, ArrayList<Spot>> framespots,
final Map<String, Object> mapsettings, final Logger logger, final int numThreads, double[] calibration) {

// Starting point of the tree + apoptotic spot in the trackID
HashMap<Integer, Pair<Spot, Spot>> Trackapoptosis = new HashMap<Integer, Pair<Spot, Spot>>();
// Spots from trackmate

int ndim = img.numDimensions() - 1;
RandomAccess<UnsignedShortType> ranac = img.randomAccess();
RandomAccess<FloatType> ranac = img.randomAccess();

logger.log("Matching with oneat apoptosis spots.\n");
logger.setProgress(1.);
Expand All @@ -1013,7 +1013,7 @@ public static <T extends RealType<T> & NativeType<T>> HashMap<Integer, Pair<Spot
}
ranac.setPosition(frame, ndim);
ArrayList<Integer> Alllabels = new ArrayList<Integer>();
int labelID = ranac.get().get();
int labelID = (int) ranac.get().get();
if (labelID != 0)
Alllabels.add(labelID);

Expand Down Expand Up @@ -1053,7 +1053,7 @@ public static <T extends RealType<T> & NativeType<T>> HashMap<Integer, Pair<Spot
public static <T extends RealType<T> & NativeType<T>> HashMap<Integer, Pair<Spot, ArrayList<Spot>>> getmitosisTrackID(
HashMap<Pair<Integer, Integer>, Pair<Spot, Integer>> uniquelabelID,
Pair<HashMap<Integer, Spot>, HashMap<Integer, ArrayList<Spot>>> DividingStartspots, final Model model,
final ImgPlus<UnsignedShortType> img, HashMap<Integer, ArrayList<Spot>> framespots,
final ImgPlus<FloatType> img, HashMap<Integer, ArrayList<Spot>> framespots,
final Map<String, Object> mapsettings, final Logger logger, final int numThreads, double[] calibration) {

// Starting point of the tree + list of mitosis spots in the trackID
Expand All @@ -1062,7 +1062,7 @@ public static <T extends RealType<T> & NativeType<T>> HashMap<Integer, Pair<Spot

int ndim = img.numDimensions() - 1;
int tmoneatdeltat = (int) mapsettings.get(KEY_GAP_CLOSING_MAX_FRAME_GAP);
RandomAccess<UnsignedShortType> ranac = img.randomAccess();
RandomAccess<FloatType> ranac = img.randomAccess();

logger.log("Matching with oneat mitosis spots.\n");
logger.setProgress(1.);
Expand All @@ -1087,7 +1087,7 @@ public static <T extends RealType<T> & NativeType<T>> HashMap<Integer, Pair<Spot
ranac.setPosition(frame, ndim);

ArrayList<Integer> Alllabels = new ArrayList<Integer>();
int labelID = ranac.get().get();
int labelID = (int) ranac.get().get();
if (labelID != 0)
Alllabels.add(labelID);

Expand Down Expand Up @@ -1152,7 +1152,7 @@ public static <T extends RealType<T> & NativeType<T>> HashMap<Integer, Pair<Spot
private static SimpleWeightedGraph<Spot, DefaultWeightedEdge> BreakLinksTrack(final Model model,
HashMap<Pair<Integer, Integer>, Pair<Spot, Integer>> uniquelabelID,
Pair<HashMap<Integer, Spot>, HashMap<Integer, ArrayList<Spot>>> DividingStartspots,
HashMap<Integer, ArrayList<Spot>> framespots, final ImgPlus<UnsignedShortType> img, final Logger logger,
HashMap<Integer, ArrayList<Spot>> framespots, final ImgPlus<FloatType> img, final Logger logger,
final SimpleWeightedGraph<Spot, DefaultWeightedEdge> graph, double[] calibration, int N) {

int count = 0;
Expand All @@ -1163,7 +1163,7 @@ private static SimpleWeightedGraph<Spot, DefaultWeightedEdge> BreakLinksTrack(fi

Set<Integer> AllTrackIds = model.getTrackModel().trackIDs(true);

RandomAccess<UnsignedShortType> ranac = img.randomAccess();
RandomAccess<FloatType> ranac = img.randomAccess();
ArrayList<Integer> DividingTrackids = new ArrayList<Integer>();
for (Map.Entry<Integer, ArrayList<Spot>> framemap : framespots.entrySet()) {

Expand All @@ -1184,7 +1184,7 @@ private static SimpleWeightedGraph<Spot, DefaultWeightedEdge> BreakLinksTrack(fi
}
ranac.setPosition(frame, ndim);
// Get the label ID of the current interesting spot
int labelID = ranac.get().get();
int labelID = (int) ranac.get().get();

if (uniquelabelID.containsKey(new ValuePair<Integer, Integer>(labelID, frame))) {
Pair<Spot, Integer> spotandtrackID = uniquelabelID
Expand Down

0 comments on commit 7dca1cd

Please sign in to comment.